unlockaes_gcm_decrypt

On-chain AES-256-GCM decryption

Decrypt bytes with the AES-GCM precompile at 0x67.

Overview

aes_gcm_decrypt() and async_aes_gcm_decrypt() accept a 32-byte key, a nonce, and ciphertext bytes that include the 16-byte authentication tag.

If tag verification fails, the RPC call fails.

Signature

def aes_gcm_decrypt(
    w3: Web3,
    *,
    aes_key: Bytes32,
    nonce: int | EncryptionNonce,
    ciphertext: bytes,
) -> HexBytes

async def async_aes_gcm_decrypt(
    w3: AsyncWeb3,
    *,
    aes_key: Bytes32,
    nonce: int | EncryptionNonce,
    ciphertext: bytes,
) -> HexBytes

Parameters

Parameter
Type
Required
Description

w3

Web3 / AsyncWeb3

Yes

Connected Seismic client

aes_key

Yes

32-byte AES key

nonce

Yes

Must match encryption nonce

ciphertext

bytes

Yes

Ciphertext including authentication tag

Returns

Type
Description

HexBytes

Decrypted plaintext bytes

Examples

Basic Usage

Handle Authentication Failure

Async Usage

Gas Cost

The SDK uses:

len(ciphertext) includes the 16-byte authentication tag.

Notes

  • Use the same key and nonce used for encryption.

  • The decrypt wrapper returns HexBytes; cast with bytes(...) if needed.

  • Failed authentication/tag validation is surfaced as an RPC error.

See Also

Last updated