Function derive_symmetric_key
pub fn derive_symmetric_key(
input: &Bytes,
gas_limit: u64,
) -> Result<PrecompileOutput, PrecompileErrors>
Expand description
§Derive Symmetric Key (ECDH + HKDF-AES)
Accepts 65 bytes of input:
0..32
:sk_bytes
(secp256k1 secret key)32..65
:pk_bytes
(compressed public key)
Steps:
- Compute ECDH shared secret using
pk * sk
. - Derive a 32-byte AES key from the shared secret via
seismic_enclave::derive_aes_key
, which internally runs HKDF-SHA256 (see separate doc for gas breakdown).
Returns the 32-byte AES key if successful, or an error otherwise.
§Gas:
We apply a constant DERIVE_SYM_KEY_COST
(3,800), ensuring we
overestimate in comparison to ECRecover
and simpler HKDF ops.
If gas_limit < DERIVE_SYM_KEY_COST
, we revert with OutOfGas
.