mirror of
https://github.com/bitcoin/bips.git
synced 2026-05-18 16:59:30 +00:00
Squashed 'bip-0352/secp256k1lab/' content from commit 44dc4bd
git-subtree-dir: bip-0352/secp256k1lab git-subtree-split: 44dc4bd893b8f03e621585e3bf255253e0e0fbfb
This commit is contained in:
15
src/secp256k1lab/keys.py
Normal file
15
src/secp256k1lab/keys.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from .secp256k1 import GE, G
|
||||
from .util import int_from_bytes
|
||||
|
||||
# The following function is based on the BIP 327 reference implementation
|
||||
# https://github.com/bitcoin/bips/blob/master/bip-0327/reference.py
|
||||
|
||||
|
||||
# Return the plain public key corresponding to a given secret key
|
||||
def pubkey_gen_plain(seckey: bytes) -> bytes:
|
||||
d0 = int_from_bytes(seckey)
|
||||
if not (1 <= d0 <= GE.ORDER - 1):
|
||||
raise ValueError("The secret key must be an integer in the range 1..n-1.")
|
||||
P = d0 * G
|
||||
assert not P.infinity
|
||||
return P.to_bytes_compressed()
|
||||
Reference in New Issue
Block a user