def makeCryptor(privkey): privkey_bin = '\x02\xca\x00 ' + a.changebase(privkey, 16, 256, minlen=32) pubkey = a.changebase(a.privtopub(privkey), 16, 256, minlen=65)[1:] pubkey_bin = '\x02\xca\x00 ' + pubkey[:32] + '\x00 ' + pubkey[32:] cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin) return cryptor
def makePrivCryptor(privkey): privkey_bin = '\x02\xca\x00 ' + arithmetic.changebase(privkey, 16, 256, minlen=32) pubkey = arithmetic.changebase(arithmetic.privtopub(privkey), 16, 256, minlen=65)[1:] pubkey_bin = '\x02\xca\x00 ' + pubkey[:32] + '\x00 ' + pubkey[32:] cryptor = ec.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin) return cryptor
def privToPub(privkey): return a.privtopub(privkey)
def makeCryptor(privkey): privkey_bin = "\x02\xca\x00 " + a.changebase(privkey, 16, 256, minlen=32) pubkey = a.changebase(a.privtopub(privkey), 16, 256, minlen=65)[1:] pubkey_bin = "\x02\xca\x00 " + pubkey[:32] + "\x00 " + pubkey[32:] cryptor = pyelliptic.ECC(curve="secp256k1", privkey=privkey_bin, pubkey=pubkey_bin) return cryptor
' random 32 byte values and call the first one the signing key' ' and the second one the encryption key:' ) privateSigningKey = \ '93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665' privateEncryptionKey = \ '4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a' print( '\nprivateSigningKey = %s\nprivateEncryptionKey = %s' % (privateSigningKey, privateEncryptionKey) ) print( '\nNow let us convert them to public keys by doing' ' an elliptic curve point multiplication.' ) publicSigningKey = arithmetic.privtopub(privateSigningKey) publicEncryptionKey = arithmetic.privtopub(privateEncryptionKey) print( '\npublicSigningKey = %s\npublicEncryptionKey = %s' % (publicSigningKey, publicEncryptionKey) ) print( '\nNotice that they both begin with the \\x04 which specifies' ' the encoding type. This prefix is not send over the wire.' ' You must strip if off before you send your public key across' ' the wire, and you must add it back when you receive a public key.' ) publicSigningKeyBinary = \ arithmetic.changebase(publicSigningKey, 16, 256, minlen=64)