Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added experimental FROST support #154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions buidl/cecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(self, csec=None, usec=None):
def __eq__(self, other):
return self.sec() == other.sec()

def __hash__(self):
return hash(self.sec())

def __repr__(self):
return f"S256Point({self.sec().hex()})"

Expand Down Expand Up @@ -399,9 +402,11 @@ def sign(self, z):
raise RuntimeError("generated signature doesn't verify")
return sig

def sign_schnorr(self, msg, aux):
def sign_schnorr(self, msg, aux=None):
if len(msg) != 32:
raise ValueError("msg needs to be 32 bytes")
if aux is None:
aux = b"\x00" * 32
if len(aux) != 32:
raise ValueError("aux needs to be 32 bytes")
# per libsecp256k1 documentation, this helps against side-channel attacks
Expand All @@ -418,7 +423,10 @@ def sign_schnorr(self, msg, aux):
raw_sig = ffi.new("unsigned char [64]")
if not lib.secp256k1_schnorrsig_sign(GLOBAL_CTX, raw_sig, msg, keypair, aux):
raise RuntimeError("libsecp256k1 schnorr signing problem")
return SchnorrSignature(bytes(ffi.buffer(raw_sig, 64)))
schnorr = SchnorrSignature(bytes(ffi.buffer(raw_sig, 64)))
if not self.point.verify_schnorr(msg, schnorr):
raise RuntimeError("Bad Signature")
return schnorr

def deterministic_k(self, z):
k = b"\x00" * 32
Expand Down
Loading