Precompiles
Seismic adds six precompiled contracts to the EVM, giving smart contracts access to cryptographic primitives that would be prohibitively expensive to implement in Solidity. All standard Ethereum precompiles (e.g. ecrecover, sha256) remain available at their usual addresses.
Precompiles are called like regular contracts using staticcall or call to their fixed addresses. They execute native code rather than EVM bytecode, making them significantly cheaper and faster than equivalent Solidity implementations.
These are the precompiles Seismic adds:
Common pattern: Encrypted events
A frequent use of the precompiles is encrypting event data so that only the intended recipient can read it. The typical flow chains ECDH and AES-GCM Encrypt together:
// 1. Derive an AES key via ECDH
sbytes32 aesKey = sbytes32(ecdh(contractPrivKey, recipientCompressedPubKey));
// 2. Generate a random nonce
uint96 nonce = uint96(unsafe_rng_u96());
// 3. Encrypt the sensitive data
bytes memory encrypted = aes_gcm_encrypt(aesKey, nonce, plaintext);
// 4. Emit a regular event with the encrypted bytes
emit EncryptedData(msg.sender, recipient, nonce, encrypted);For a complete walkthrough of this pattern, see Events.
Last updated

