Skip to content

Commit

Permalink
Merge pull request #11 from AdamISZ/customnonce
Browse files Browse the repository at this point in the history
allow use of custom nonce in ecdsa_sign
  • Loading branch information
ludbb authored Jul 30, 2016
2 parents fe2443a + 3caf31d commit 5a817ea
Show file tree
Hide file tree
Showing 3 changed files with 1,266 additions and 3 deletions.
9 changes: 6 additions & 3 deletions secp256k1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,15 @@ def tweak_mul(self, scalar):
"""
return _tweak_private(self, lib.secp256k1_ec_privkey_tweak_mul, scalar)

def ecdsa_sign(self, msg, raw=False, digest=hashlib.sha256):
def ecdsa_sign(self, msg, raw=False, digest=hashlib.sha256, custom_nonce=None):
msg32 = _hash32(msg, raw, digest)
raw_sig = ffi.new('secp256k1_ecdsa_signature *')

nonce_fn = ffi.NULL
nonce_data = ffi.NULL
if custom_nonce:
nonce_fn, nonce_data = custom_nonce
signed = lib.secp256k1_ecdsa_sign(
self.ctx, raw_sig, msg32, self.private_key, ffi.NULL, ffi.NULL)
self.ctx, raw_sig, msg32, self.private_key, nonce_fn, nonce_data)
assert signed == 1

return raw_sig
Expand Down
Loading

0 comments on commit 5a817ea

Please sign in to comment.