Last active
May 24, 2022 04:26
-
-
Save sungkhum/53b5b3cd050d46387c1f555f4dad18a5 to your computer and use it in GitHub Desktop.
Generate JWT from SEEDHEX for BitClout DeSo in Python
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 jwt | |
import binascii | |
from ecdsa import SigningKey, SECP256k1 | |
''' SEEDHEX should always be kept private. It has access to your complete wallet. It's kinda like | |
seed phrase. This is why writing methods in backend isn't a good practice until we have derived keys. | |
You can only automate your own account and can't have user authorisation. It is recommended to use test account while using write methods. | |
You can find the seedHex of your account in your browser storage. Just open https://bitclout.com/ > Dev tools > Application > Storage > Local Storage > https://identity.bitclout.com > users > Select the public key with which you want to post > seedHex''' | |
SEEDHEX = "" | |
private_key = bytes(SEEDHEX, 'utf-8') | |
private_key = binascii.unhexlify(private_key) | |
key = SigningKey.from_string(private_key, curve=SECP256k1) | |
key = key.to_pem() | |
encoded_jwt = jwt.encode({}, key, algorithm="ES256") | |
print(encoded_jwt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment