> For the complete documentation index, see [llms.txt](https://docs.seismic.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seismic.systems/reference/precompiles/hkdf.md).

# HKDF

[HMAC-based Key Derivation Function](https://en.wikipedia.org/wiki/HKDF) ([RFC 5869](https://datatracker.ietf.org/doc/html/rfc5869)). Derives a 32-byte cryptographic key from input key material. Commonly used to turn a shared secret (from ECDH) into an encryption key suitable for AES-GCM.

{% hint style="info" %}
The Seismic HKDF precompile uses hardcoded parameters: salt is `None`, info is a fixed internal string, and the output is always 32 bytes. The only user-supplied input is the raw key material.
{% endhint %}

## Input

| Field              | Type  | Description                                       |
| ------------------ | ----- | ------------------------------------------------- |
| input key material | bytes | Source key material (e.g., raw ECDH shared point) |

## Output

| Bytes       | Type     | Description          |
| ----------- | -------- | -------------------- |
| derived key | 32 bytes | Derived key material |

## Use cases

* Deriving AES encryption keys from shared secrets
* Key derivation with domain separation

## Examples

### Built-in helper

```solidity
function hkdf(bytes memory input) view returns (bytes32);
```

```solidity
bytes32 derivedKey = hkdf(inputKeyMaterial);
```

### Manual usage

```solidity
function deriveKey(bytes memory ikm) internal view returns (bytes32) {
    (bool success, bytes memory result) = address(0x68).staticcall(ikm);
    require(success, "HKDF precompile failed");
    require(result.length == 32, "Invalid HKDF output length");
    return bytes32(result);
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.seismic.systems/reference/precompiles/hkdf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
