The confidential transfer system uses a dual-key encryption scheme based on ElGamal and AES encryption. The keys are derived from wallet signatures using specific seed messages.
-
ElGamal Key Derivation
- Seed Message:
"ElGamalSecretKey" - Purpose: Used for ElGamal encryption of confidential balances
- Source: Agave zk-sdk
- Seed Message:
-
AES Key Derivation
- Seed Message:
"AeKey" - Purpose: Used for AES encryption of confidential data
- Source: Agave zk-sdk
- Seed Message:
The key derivation process follows these steps:
- The wallet signs a specific seed message concatenated with an empty public seed
- The signature is used to derive the encryption keys
- The empty public seed ensures compatibility with the SPL Token CLI implementation
// Example of signature generation
const messageToSign = Buffer.concat([
seedMessage, // Either "ElGamalSecretKey" or "AeKey"
emptyPublicSeed // Empty byte array for CLI compatibility
]);sequenceDiagram
participant Wallet
participant SolanaSDK
participant ZkSDK as Zk SDK
Note over Wallet: Initialize confidential account
Note over Wallet: ElGamal Key Setup
Wallet->>Wallet: Create "ElGamalSecretKey" buffer
Wallet->>Wallet: Create seed buffer
Wallet->>Wallet: Concatenate buffers
Wallet->>SolanaSDK: signMessage(concatenatedBuffer)
SolanaSDK-->>Wallet: Return signature
Wallet->>ZkSDK: deriveElGamalKey(signature)
ZkSDK-->>Wallet: Return ElGamal encryption key
Note over Wallet: AES Key Setup
Wallet->>Wallet: Create "AeKey" buffer
Wallet->>Wallet: Create seed buffer
Wallet->>Wallet: Concatenate buffers
Wallet->>SolanaSDK: signMessage(concatenatedBuffer)
SolanaSDK-->>Wallet: Return signature
Wallet->>ZkSDK: deriveAESKey(signature)
ZkSDK-->>Wallet: Return AES encryption key
Note over Wallet: Account Ready
Note over Wallet: Keys available for confidential operations
-
Hard-coded Seeds
- The seed messages are hard-coded to ensure consistent key derivation across all implementations
- This matches the implementation in the Solana Token-2022 program
- Reference: Token-2022 CLI Implementation
-
Compatibility Requirements
- While custom key derivation (using alternative seeds or custom seed buffers) is technically feasible, the current implementation strictly adheres to the hardcoded conventions of
ElGamalSecretKeyandAeKeyas seeds. This ensures compatibility with the Token-2022 program and SPL Token CLI. Future versions may introduce support for customizable key derivation schemes. - This ensures that keys derived in the frontend match those used in backend operations
- While custom key derivation (using alternative seeds or custom seed buffers) is technically feasible, the current implementation strictly adheres to the hardcoded conventions of
-
Implementation Notes
- The wallet must support message signing
- The signature process is deterministic, ensuring consistent key derivation
- The derived keys must always either be securely stored or derived on-the-fly and never transmitted. They are only used for encryption/decryption operations
The encryption scheme is used in various operations:
-
Confidential Transfers
- ElGamal encryption for balance encryption
- AES encryption for additional data protection
-
Balance Decryption
- Uses AES key for decrypting confidential balances
- Requires wallet signature for key derivation
-
Account Initialization
- Both ElGamal and AES keys are derived during account setup
- For securely cached encryption keys, this should be the only event/instance where encryption keys are generated.
- Ensures proper encryption of initial confidential data
- Both ElGamal and AES keys are derived during account setup