MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / _sign_with_libsecp256k1

Method _sign_with_libsecp256k1

bitcoin/core/key.py:317–330  ·  view source on GitHub ↗
(self, hash)

Source from the content-addressed store, hash-verified

315 return mb.raw.rjust(32, b'\x00')
316
317 def _sign_with_libsecp256k1(self, hash):
318 raw_sig = ctypes.create_string_buffer(64)
319 result = _libsecp256k1.secp256k1_ecdsa_sign(
320 _libsecp256k1_context, raw_sig, hash, self.get_raw_privkey(), None, None)
321 assert 1 == result
322 sig_size0 = ctypes.c_size_t()
323 sig_size0.value = 75
324 mb_sig = ctypes.create_string_buffer(sig_size0.value)
325 result = _libsecp256k1.secp256k1_ecdsa_signature_serialize_der(
326 _libsecp256k1_context, mb_sig, ctypes.byref(sig_size0), raw_sig)
327 assert 1 == result
328 # libsecp256k1 creates signatures already in lower-S form, no further
329 # conversion needed.
330 return mb_sig.raw[:sig_size0.value]
331
332
333 def sign(self, hash): # pylint: disable=redefined-builtin

Callers 1

signMethod · 0.95

Calls 1

get_raw_privkeyMethod · 0.95

Tested by

no test coverage detected