aes_gcm_encrypt
On-chain AES-256-GCM encryption
Encrypt bytes with the AES-GCM precompile at 0x66.
Overview
aes_gcm_encrypt() and async_aes_gcm_encrypt() accept a 32-byte key, a 12-byte nonce (or nonce integer), and plaintext bytes.
The returned ciphertext includes the 16-byte authentication tag.
Signature
def aes_gcm_encrypt(
w3: Web3,
*,
aes_key: Bytes32,
nonce: int | EncryptionNonce,
plaintext: bytes,
) -> HexBytes
async def async_aes_gcm_encrypt(
w3: AsyncWeb3,
*,
aes_key: Bytes32,
nonce: int | EncryptionNonce,
plaintext: bytes,
) -> HexBytesParameters
Parameter
Type
Required
Description
w3
Web3 / AsyncWeb3
Yes
Connected Seismic client
plaintext
bytes
Yes
Data to encrypt
Returns
Type
Description
HexBytes
Ciphertext with authentication tag appended
Examples
Basic Usage
With EncryptionNonce
Async Usage
Encrypt/Decrypt Round Trip
Gas Cost
The SDK uses:
Examples:
len(plaintext)=0:1000len(plaintext)=16:1030len(plaintext)=17:1060
Notes
Never reuse a nonce with the same key.
intnonces are encoded to 12-byte big-endian values.Returned bytes are
ciphertext || tag.
See Also
Last updated

