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

allow use of custom nonce in ecdsa_sign #11

Merged
merged 1 commit into from
Jul 30, 2016
Merged
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
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