From 47ace2f565c72dfc10b031fe9b719a23c1ae310c Mon Sep 17 00:00:00 2001 From: conduition Date: Fri, 23 Aug 2024 05:22:55 +0000 Subject: [PATCH] fix funding proof signature to match spec --- cashu/core/crypto/dlc.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cashu/core/crypto/dlc.py b/cashu/core/crypto/dlc.py index 77616023..78bd7113 100644 --- a/cashu/core/crypto/dlc.py +++ b/cashu/core/crypto/dlc.py @@ -70,10 +70,9 @@ def sign_dlc( ) -> bytes: message = ( bytes.fromhex(dlc_root) - +str(funding_amount).encode("utf-8") + +funding_amount.to_bytes(8, "big") ) - message_hash = sha256(message).digest() - return privkey.schnorr_sign(message_hash, None, raw=True) + return privkey.schnorr_sign(message, None, raw=True) def verify_dlc_signature( dlc_root: str, @@ -83,7 +82,6 @@ def verify_dlc_signature( ) -> bool: message = ( bytes.fromhex(dlc_root) - +str(funding_amount).encode("utf-8") + +funding_amount.to_bytes(8, "big") ) - message_hash = sha256(message).digest() - return pubkey.schnorr_verify(message_hash, signature, None, raw=True) + return pubkey.schnorr_verify(message, signature, None, raw=True)