Beta on SKALE Base Sepolia — Re-encryption precompiles are available on SKALE Base Sepolia for testing and development.
Why Re-encryption?
Smart contracts often need to store private data onchain — balances, game state, personal records — but public blockchains expose everything. Re-encryption solves this by letting contracts encrypt data onchain using either the network’s threshold key (for validator-driven processing) and/or a specific viewer’s public key (for private off-chain access). No single validator can decrypt data. Plaintext is only materialized during authorized threshold-decryption execution and delivered to the designated contract callback. Contracts should avoid emitting, storing, or returning plaintext unless disclosure is intended.What Is Re-encryption?
Re-encryption provides two precompiled contracts that allow Solidity code to encrypt data onchain:- EncryptTE (
0x1D) — encrypt with the network’s BLS threshold key, decryptable only by the consensus committee via CTX - EncryptECIES (
0x1C) — encrypt for a specific viewer’s secp256k1 public key, decryptable only by that viewer’s private key off-chain
Quick Example
Precompiles
EncryptTE — Network Threshold Key
EncryptTE encrypts data using the network’s BLS threshold key. Only the consensus committee (2t+1 of 3t+1 validators) can decrypt via a Conditional Transaction callback. Use this for private onchain state that needs validator-driven processing.EncryptECIES — Viewer Key
EncryptECIES encrypts data for a specific viewer’s secp256k1 public key. Only the holder of the corresponding private key can decrypt offline. Use this for data sharing where a specific party needs access.PublicKey Struct
0x04 prefix). The viewer generates a keypair off-chain and submits the public key onchain.
Encryption Patterns
Pattern 1: Private Onchain State (TE)
Store values TE-encrypted. Validators can decrypt via CTX for processing. Data can be updated over time.Pattern 2: Viewer-Key Storage (ECIES)
Store values ECIES-encrypted for a specific viewer key. Cannot be decrypted or manipulated by validators.Pattern 3: Both (TE + ECIES)
Use TE for validator processing and ECIES for viewer access. Best for scenarios needing both consensus-driven state transitions and private viewing.Client-Side ECIES Decryption
ECIES ciphertext format:IV(16 bytes) || ephemeralPubKey(33 bytes) || ciphertext
Error Codes
Use Cases
- Private onchain state — Store encrypted values that only consensus can process
- Data sharing — Encrypt data for specific parties without trusted intermediaries
- Confidential tokens — Dual encryption for both balance processing and viewing
- Encrypted storage — Off-chain readable data with on-chain verification
Learn More
- Encrypted Transactions — Hide transaction payloads during mempool and consensus
- Conditional Transactions — Request decryption from within smart contracts
- Confidential Tokens — ERC20 tokens with encrypted balances
