Skip to content

Commit

Permalink
allow use of custom nonce in ecdsa_sign
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamISZ committed Mar 29, 2016
1 parent b4475d9 commit 0adbf67
Showing 1 changed file with 6 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

0 comments on commit 0adbf67

Please sign in to comment.