Created
December 4, 2017 17:28
-
-
Save nonsense/8d8bdf08d4d50baac65dde70df1f7509 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ecdsa | |
import sha3 | |
from bitcoin import encode_pubkey, decode_pubkey | |
def decompress_secp256k1_pubkey(data): | |
x, y = decode_pubkey(data, 'bin_compressed') | |
p = ecdsa.ellipticcurve.Point(ecdsa.SECP256k1.curve, x, y) | |
return ecdsa.VerifyingKey.from_public_point(p, ecdsa.SECP256k1) | |
sig = "638A54215D80A6713C8D523A6ADC4E6E73652D859103A36B700851CB0E61B66B8EBFC1A610C57D732EC6E0A8F06A9A7A28DF5051ECE514702FF9CDFF0B11F454" | |
content = "f854018664697363763582765f82696490736563703235366b312d6b656363616b83697034847f00000189736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138" | |
key = "03ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138" | |
bsig = bytes.fromhex(sig) | |
bcontent = bytes.fromhex(content) | |
bkey = bytes.fromhex(key) | |
pub = decompress_secp256k1_pubkey(bkey) | |
print(pub.verify(bsig, bcontent, hashfunc=sha3.keccak_256)) | |
#digest = "d301ce462d3e639518f482c7f03821fec1e602018630ce621e1e7851c12343a6" | |
#bdigest = bytes.fromhex(digest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment