MCPcopy Create free account
hub / github.com/petertodd/python-bitcoinlib / use_libsecp256k1_for_signing

Function use_libsecp256k1_for_signing

bitcoin/core/key.py:210–236  ·  view source on GitHub ↗
(do_use)

Source from the content-addressed store, hash-verified

208
209
210def use_libsecp256k1_for_signing(do_use):
211 global _libsecp256k1
212 global _libsecp256k1_context
213 global _libsecp256k1_enable_signing
214
215 if not do_use:
216 _libsecp256k1_enable_signing = False
217 return
218
219 if not is_libsec256k1_available():
220 raise ImportError("unable to locate libsecp256k1")
221
222 if _libsecp256k1_context is None:
223 _libsecp256k1 = ctypes.cdll.LoadLibrary(_libsecp256k1_path)
224 _libsecp256k1.secp256k1_context_create.restype = ctypes.c_void_p
225 _libsecp256k1.secp256k1_context_create.errcheck = _check_res_void_p
226 _libsecp256k1.secp256k1_context_randomize.restype = ctypes.c_int
227 _libsecp256k1.secp256k1_context_randomize.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
228 _libsecp256k1_context = _libsecp256k1.secp256k1_context_create(SECP256K1_CONTEXT_SIGN)
229 assert(_libsecp256k1_context is not None)
230 seed = urandom(32)
231 result = _libsecp256k1.secp256k1_context_randomize(_libsecp256k1_context, seed)
232 assert 1 == result
233
234
235
236 _libsecp256k1_enable_signing = True
237
238
239

Callers 1

testMethod · 0.90

Calls 1

is_libsec256k1_availableFunction · 0.85

Tested by 1

testMethod · 0.72