-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b1109b
commit 59dc56f
Showing
9 changed files
with
78 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from hashlib import sha256 | ||
from typing import List | ||
|
||
from secp import PrivateKey, PublicKey | ||
|
||
from ..base import BlindedMessage | ||
|
||
|
||
def construct_message(quote_id: str, outputs: List[BlindedMessage]) -> bytes: | ||
serialized_outputs = bytes.fromhex("".join([o.B_ for o in outputs])) | ||
msgbytes = sha256( | ||
quote_id.encode("utf-8") | ||
+ serialized_outputs | ||
).digest() | ||
return msgbytes | ||
|
||
def sign_mint_quote( | ||
quote_id: str, | ||
outputs: List[BlindedMessage], | ||
privkey: PrivateKey, | ||
) -> str: | ||
msgbytes = construct_message(quote_id, outputs) | ||
sig = privkey.schnorr_sign(msgbytes) | ||
return sig.hex() | ||
|
||
def verify_mint_quote( | ||
quote_id: str, | ||
outputs: List[BlindedMessage], | ||
pubkey: PublicKey, | ||
signature: str, | ||
) -> bool: | ||
msgbytes = construct_message(quote_id, outputs) | ||
sig = bytes.fromhex(signature) | ||
return pubkey.schnorr_verify(msgbytes, sig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters