Skip to content

P256.fromSeed

Derives a valid P256 private key from a seed.

The seed must contain at least 32 bytes of cryptographically strong key material. Do not pass a password directly; use a password KDF first.

The permanent derivation contract uses the seed as the HMAC-SHA256 key. The HMAC message uses the ox.p256.fromSeed.v1 domain followed by a 32-bit big-endian counter starting at zero. Invalid scalars are skipped.

Imports

Named
import { P256 } from 'ox'

Examples

import { P256 } from 'ox'
 
const privateKey = P256.fromSeed(
  '0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'
)

Definition

function fromSeed<as>(
  seed: Hex.Hex | Bytes.Bytes,
  options?: fromSeed.Options<as>,
): fromSeed.ReturnType<as>

Source: src/core/P256.ts

Parameters

seed

  • Type: Hex.Hex | Bytes.Bytes

Seed containing at least 32 bytes of cryptographically strong key material.

options

  • Type: fromSeed.Options<as>
  • Optional

Options.

options.as

  • Type: "Bytes" | "Hex" | as
  • Optional

Format of the returned private key.

Return Type

A valid P256 private key.

fromSeed.ReturnType<as>