hkdf
On-chain HKDF-SHA256 key derivation
Last updated
from seismic_web3 import create_public_client
from seismic_web3 import precompiles as sp
w3 = create_public_client("https://testnet-1.seismictest.net/rpc")
key = sp.hkdf(w3, b"input key material")
print(key.to_0x_hex())master = b"shared-secret"
encryption_key = sp.hkdf(w3, master + b"\x01encryption")
auth_key = sp.hkdf(w3, master + b"\x02auth")
assert encryption_key != auth_keyfrom seismic_web3 import create_async_public_client
from seismic_web3 import precompiles as sp
async def main():
w3 = create_async_public_client("https://testnet-1.seismictest.net/rpc")
key = await sp.async_hkdf(w3, b"async input")
print(key.to_0x_hex())from math import ceil
linear = 3000 + ceil(len(ikm) / 32) * 12
total_gas = 2 * linear + 120