mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-11-22 08:08:11 +00:00
Merge pull request #431 from cjjojoba/cjjojoba-patch-1
Update ec-math.py
This commit is contained in:
commit
cbc23caf8a
@ -21,13 +21,13 @@ generator = generator_secp256k1
|
|||||||
def random_secret():
|
def random_secret():
|
||||||
convert_to_int = lambda array: int("".join(array).encode("hex"), 16)
|
convert_to_int = lambda array: int("".join(array).encode("hex"), 16)
|
||||||
|
|
||||||
# Collect 256 bits of random data from the OS's cryptographically secure random generator
|
# Collect 256 bits of random data from the OS's cryptographically secure random number generator
|
||||||
byte_array = os.urandom(32)
|
byte_array = os.urandom(32)
|
||||||
|
|
||||||
return convert_to_int(byte_array)
|
return convert_to_int(byte_array)
|
||||||
|
|
||||||
def get_point_pubkey(point):
|
def get_point_pubkey(point):
|
||||||
if point.y() & 1:
|
if (point.y() % 2) == 1:
|
||||||
key = '03' + '%064x' % point.x()
|
key = '03' + '%064x' % point.x()
|
||||||
else:
|
else:
|
||||||
key = '02' + '%064x' % point.x()
|
key = '02' + '%064x' % point.x()
|
||||||
|
Loading…
Reference in New Issue
Block a user