SHARE
TWEET

Untitled

a guest Oct 5th, 2018 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import nacl.encoding
  2. import nacl.signing
  3. import os
  4.  
  5. # Generate a new random signing key
  6. signing_key = nacl.signing.SigningKey.generate()
  7. sk_bytes = bytes.fromhex(signing_key.encode(encoder=nacl.encoding.HexEncoder).decode("utf-8"))
  8. print('priv: {}'.format(signing_key.encode(encoder=nacl.encoding.HexEncoder).decode("utf-8")))
  9.  
  10. # Obtain the verify key for a given signing key
  11. verify_key = signing_key.verify_key
  12. verify_key_hex = verify_key.encode(encoder=nacl.encoding.HexEncoder).decode("utf-8")
  13. print("ed pub: {}".format(verify_key_hex))
  14. ver_bytes = bytes.fromhex(verify_key_hex)
  15. print('ed signbit: {}'.format(ver_bytes[31] & 0x7F))
  16.  
  17. # Serialize the verify key
  18. verify_key_curve_hex = verify_key.to_curve25519_public_key().encode(encoder=nacl.encoding.HexEncoder)
  19. print('curve pub: {}'.format(verify_key_curve_hex.decode("utf-8")))
  20. print('curve lsb: {}'.format(bytes.fromhex(verify_key_curve_hex.decode("utf-8"))[31] & 0x7F))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top