mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 19:34:18 +01:00
@@ -2,23 +2,28 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
Implementation of https://gist.github.com/RubenSomsen/be7a4760dd4596d06963d67baf140406
|
Implementation of https://gist.github.com/RubenSomsen/be7a4760dd4596d06963d67baf140406
|
||||||
Alice:
|
|
||||||
|
Alice (Client):
|
||||||
A = a*G
|
A = a*G
|
||||||
return A
|
return A
|
||||||
Bob:
|
|
||||||
|
Bob (Mint):
|
||||||
Y = hash_to_curve(secret_message)
|
Y = hash_to_curve(secret_message)
|
||||||
r = random blinding factor
|
r = random blinding factor
|
||||||
B'= Y + r*G
|
B'= Y + r*G
|
||||||
return B'
|
return B'
|
||||||
|
|
||||||
Alice:
|
Alice:
|
||||||
C' = a*B'
|
C' = a*B'
|
||||||
(= a*Y + a*r*G)
|
(= a*Y + a*r*G)
|
||||||
return C'
|
return C'
|
||||||
|
|
||||||
Bob:
|
Bob:
|
||||||
C = C' - r*A
|
C = C' - r*A
|
||||||
(= C' - a*r*G)
|
(= C' - a*r*G)
|
||||||
(= a*Y)
|
(= a*Y)
|
||||||
return C, secret_message
|
return C, secret_message
|
||||||
|
|
||||||
Alice:
|
Alice:
|
||||||
Y = hash_to_curve(secret_message)
|
Y = hash_to_curve(secret_message)
|
||||||
C == a*Y
|
C == a*Y
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ class P2SHScript(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class Proof(BaseModel):
|
class Proof(BaseModel):
|
||||||
id: Union[None, str] = ""
|
id: Union[
|
||||||
|
None, str
|
||||||
|
] = "" # NOTE: None for backwards compatibility of old clients < 0.3
|
||||||
amount: int = 0
|
amount: int = 0
|
||||||
secret: str = ""
|
secret: str = ""
|
||||||
C: str = ""
|
C: str = ""
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ from secp256k1 import PublicKey
|
|||||||
|
|
||||||
|
|
||||||
def hash_to_point_pre_0_3_3(secret_msg):
|
def hash_to_point_pre_0_3_3(secret_msg):
|
||||||
"""Generates x coordinate from the message hash and checks if the point lies on the curve.
|
"""
|
||||||
If it does not, it tries computing again a new x coordinate from the hash of the coordinate."""
|
NOTE: Clients pre 0.3.3 used a different hash_to_curve
|
||||||
|
|
||||||
|
Generates x coordinate from the message hash and checks if the point lies on the curve.
|
||||||
|
If it does not, it tries computing again a new x coordinate from the hash of the coordinate.
|
||||||
|
"""
|
||||||
point = None
|
point = None
|
||||||
msg = secret_msg
|
msg = secret_msg
|
||||||
while point is None:
|
while point is None:
|
||||||
|
|||||||
@@ -104,8 +104,10 @@ async def split(
|
|||||||
"""
|
"""
|
||||||
proofs = payload.proofs
|
proofs = payload.proofs
|
||||||
amount = payload.amount
|
amount = payload.amount
|
||||||
|
|
||||||
|
# NOTE: backwards compatibility with clients < v0.2.2
|
||||||
outputs = payload.outputs.blinded_messages if payload.outputs else None
|
outputs = payload.outputs.blinded_messages if payload.outputs else None
|
||||||
# backwards compatibility with clients < v0.2.2
|
|
||||||
assert outputs, Exception("no outputs provided.")
|
assert outputs, Exception("no outputs provided.")
|
||||||
try:
|
try:
|
||||||
split_return = await ledger.split(proofs, amount, outputs)
|
split_return = await ledger.split(proofs, amount, outputs)
|
||||||
|
|||||||
Reference in New Issue
Block a user