ecdh
On-chain elliptic-curve Diffie-Hellman key exchange
Compute a shared key with the ECDH precompile at 0x65.
Overview
ecdh() and async_ecdh() take a PrivateKey and a CompressedPublicKey and return a Bytes32 shared key.
The on-chain precompile performs ECDH and an HKDF derivation step, so the returned Bytes32 is ready to use as an AES key.
Signature
def ecdh(
w3: Web3,
*,
sk: PrivateKey,
pk: CompressedPublicKey,
) -> Bytes32
async def async_ecdh(
w3: AsyncWeb3,
*,
sk: PrivateKey,
pk: CompressedPublicKey,
) -> Bytes32Parameters
Parameter
Type
Required
Description
w3
Web3 / AsyncWeb3
Yes
Connected Seismic client
Returns
Type
Description
Derived shared key
Examples
Two-Party Key Exchange
Use Shared Key for AES-GCM
Async Usage
Gas Cost
Fixed cost: 3120.
Notes
Input layout is
sk(32) || pk(33).Invalid keys cause the call to fail.
Keep private keys out of logs and telemetry.
See Also
Last updated

