Polkadot Apps
    Preparing search index...

    Hierarchical key manager.

    Holds a 32-byte master key in memory and derives child keys via HKDF-SHA256. Does not persist anything — persistence is the consumer's responsibility.

    Index

    Methods

    • Derive a Substrate sr25519 account for a given context string.

      HKDF(masterKey, "", "account:" + context) → 32-byte seed → sr25519 keypair

      Parameters

      • context: string
      • ss58Prefix: number = 42

      Returns DerivedAccount

    • Derive NaCl encryption and signing keypairs from the master key.

      • Encryption: HKDF(masterKey, "", "encryption-keypair") → nacl.box.keyPair.fromSecretKey
      • Signing: HKDF(masterKey, "", "signing-keypair") → nacl.sign.keyPair.fromSeed

      Returns DerivedKeypairs

    • Derive a 32-byte symmetric key for a given context string.

      Uses HKDF-SHA256: IKM=masterKey, salt="", info=context

      Parameters

      • context: string

      Returns Uint8Array

    • Export the raw master key bytes for consumer-managed persistence.

      Returns Uint8Array

    • Create a KeyManager from raw 32-byte key material. For restoring from storage, testing, etc.

      Parameters

      • masterKey: Uint8Array

      Returns KeyManager

    • Create a KeyManager from a cryptographic signature.

      Derives master key via HKDF-SHA256: IKM = signatureBytes, salt = options.salt (default "polkadot-apps-keys-v1"), info = signerAddress

      Parameters

      • signature: string | Uint8Array<ArrayBufferLike>

        Hex string (with/without 0x prefix) or raw bytes

      • signerAddress: string

        SS58 address of the signer

      • Optionaloptions: { salt?: string }
        • Optionalsalt?: string

          HKDF salt, defaults to "polkadot-apps-keys-v1"

      Returns KeyManager