We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from bit import Key from bit.format import verify_sig import base64 from hashlib import sha256
wif_private_key = 'Kxb19KFrrqrmT79bvG4tnKibVcgppavcvjkP1iBGGjnH787H39QG' key = Key(wif_private_key)
message = '''ok 666''' message_bytes = message.encode('utf-8')
message_hash = sha256(message_bytes).digest()
signature_bytes = key.sign(message_hash)
signature_base64 = base64.b64encode(signature_bytes).decode('utf-8') print(f'Signature (Base64): {signature_base64}')
signature_bytes = base64.b64decode(signature_base64) is_valid = verify_sig(signature_bytes, message_hash, key.public_key) print(f'Is the signature valid? {is_valid}')
python result is MEUCIQDGOkOlG2DMAcZ4/nvsUNi4ZxbTKGJFIx0h76QkBLVmqgIgd2McFwd+/ZHxCcktZffZS762gA5o8oRM5u4tqORp6HA=
The electrum result is IDVIF+7m9nKMvxAKo88PNwLJeg8H2MA9WoDZgjDCs0boKyuFdqWnTSCuAobVmzJr+NzqlCg180yvc5vsfsVeBjA=
After multiple verifications, electrum is correct.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
from bit import Key
from bit.format import verify_sig
import base64
from hashlib import sha256
Use WIF format private key
wif_private_key = 'Kxb19KFrrqrmT79bvG4tnKibVcgppavcvjkP1iBGGjnH787H39QG'
key = Key(wif_private_key)
Message to be signed
message = '''ok 666'''
message_bytes = message.encode('utf-8')
Compute SHA-256 hash of the message
message_hash = sha256(message_bytes).digest()
Sign the hash of the message
signature_bytes = key.sign(message_hash)
Convert the signature to Base64 encoding
signature_base64 = base64.b64encode(signature_bytes).decode('utf-8')
print(f'Signature (Base64): {signature_base64}')
Verify the signature
Decode the actual Base64 encoded signature
signature_bytes = base64.b64decode(signature_base64)
is_valid = verify_sig(signature_bytes, message_hash, key.public_key)
print(f'Is the signature valid? {is_valid}')
python result is MEUCIQDGOkOlG2DMAcZ4/nvsUNi4ZxbTKGJFIx0h76QkBLVmqgIgd2McFwd+/ZHxCcktZffZS762gA5o8oRM5u4tqORp6HA=
The electrum result is IDVIF+7m9nKMvxAKo88PNwLJeg8H2MA9WoDZgjDCs0boKyuFdqWnTSCuAobVmzJr+NzqlCg180yvc5vsfsVeBjA=
After multiple verifications, electrum is correct.
The text was updated successfully, but these errors were encountered: