Skip to content

Commit 62892e0

Browse files
committed
WIP
1 parent a6b9d50 commit 62892e0

File tree

3 files changed

+565
-178
lines changed

3 files changed

+565
-178
lines changed

buidl/cecc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,11 @@ def sign(self, z):
402402
raise RuntimeError("generated signature doesn't verify")
403403
return sig
404404

405-
def sign_schnorr(self, msg, aux):
405+
def sign_schnorr(self, msg, aux=None):
406406
if len(msg) != 32:
407407
raise ValueError("msg needs to be 32 bytes")
408+
if aux is None:
409+
aux = b"\x00" * 32
408410
if len(aux) != 32:
409411
raise ValueError("aux needs to be 32 bytes")
410412
# per libsecp256k1 documentation, this helps against side-channel attacks
@@ -421,7 +423,10 @@ def sign_schnorr(self, msg, aux):
421423
raw_sig = ffi.new("unsigned char [64]")
422424
if not lib.secp256k1_schnorrsig_sign(GLOBAL_CTX, raw_sig, msg, keypair, aux):
423425
raise RuntimeError("libsecp256k1 schnorr signing problem")
424-
return SchnorrSignature(bytes(ffi.buffer(raw_sig, 64)))
426+
schnorr = SchnorrSignature(bytes(ffi.buffer(raw_sig, 64)))
427+
if not self.point.verify_schnorr(msg, schnorr):
428+
raise RuntimeError("Bad Signature")
429+
return schnorr
425430

426431
def deterministic_k(self, z):
427432
k = b"\x00" * 32

0 commit comments

Comments
 (0)