graphenebase.memo module

graphenebase.memo.decode_memo(priv, pub, nonce, message)

Decode a message with a shared secret between Alice and Bob

Parameters:
  • priv (PrivateKey) – Private Key (of Bob)
  • pub (PublicKey) – Public Key (of Alice)
  • nonce (int) – Nonce used for Encryption
  • message (bytes) – Encrypted Memo message
Returns:

Decrypted message

Return type:

str

Raises:

ValueError – if message cannot be decoded as valid UTF-8 string

graphenebase.memo.encode_memo(priv, pub, nonce, message)

Encode a message with a shared secret between Alice and Bob

Parameters:
  • priv (PrivateKey) – Private Key (of Alice)
  • pub (PublicKey) – Public Key (of Bob)
  • nonce (int) – Random nonce
  • message (str) – Memo message
Returns:

Encrypted message

Return type:

hex

graphenebase.memo.get_shared_secret(priv, pub)

Derive the share secret between priv and pub

Parameters:
Returns:

Shared secret

Return type:

hex

The shared secret is generated such that:

Pub(Alice) * Priv(Bob) = Pub(Bob) * Priv(Alice)
graphenebase.memo.init_aes(shared_secret, nonce)

Initialize AES instance

Parameters:
  • shared_secret (hex) – Shared Secret to use as encryption key
  • nonce (int) – Random nonce
Returns:

AES instance

Return type:

AES