nectarbase.memo module
- class nectarbase.memo.CryptographyAESWrapper(key: bytes, iv: bytes)
Bases:
object- decrypt(data: bytes) bytes
- encrypt(data: bytes) bytes
- nectarbase.memo.decode_memo(priv: Any, message: str) str
Decode a message with a shared secret between Alice and Bob
- Parameters:
priv (PrivateKey) – Private Key (of Bob)
message (base58encoded) – Encrypted Memo message
- Returns:
Decrypted message
- Return type:
str
- Raises:
ValueError – if message cannot be decoded as valid UTF-8 string
- nectarbase.memo.decode_memo_bts(priv: Any, pub: PublicKey, nonce: int, message: str) str
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
- nectarbase.memo.encode_memo(priv: Any, pub: PublicKey, nonce: int, message: str, **kwargs: Any) str
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
- nectarbase.memo.encode_memo_bts(priv: Any, pub: PublicKey, nonce: int, message: str) str
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
- nectarbase.memo.extract_memo_data(message: str) Tuple[PublicKey, PublicKey, str, int, bytes]
Returns the stored pubkey keys, nonce, checksum and encrypted message of a memo
Derive the share secret between
privandpub:param Base58 priv: Private Key :param Base58 pub: Public Key :return: Shared secret :rtype: hex The shared secret is generated such that:Pub(Alice) * Priv(Bob) = Pub(Bob) * Priv(Alice)
- nectarbase.memo.init_aes(shared_secret: str, nonce: int) Any
Initialize AES instance :param hex shared_secret: Shared Secret to use as encryption key :param int nonce: Random nonce :return: AES instance :rtype: AES
- nectarbase.memo.init_aes2(shared_secret: str, nonce: int) Tuple[Any, int]
Initialize AES instance :param hex shared_secret: Shared Secret to use as encryption key :param int nonce: Random nonce
- nectarbase.memo.init_aes_bts(shared_secret: str, nonce: int) Any
Initialize AES instance :param hex shared_secret: Shared Secret to use as encryption key :param int nonce: Random nonce :return: AES instance :rtype: AES