Skip to content

Keystore.toKey

Extracts a Key from a JSON Keystore to use for decryption.

Imports

Named
import { Keystore } from 'ox'

Examples

import { Keystore } from 'ox'
 
// JSON keystore.
const keystore = { crypto: { ... }, id: '...', version: 3 }
 
const key = Keystore.toKey(keystore, { password: 'hunter2' })
 
const decrypted = Keystore.decrypt(keystore, key)

Definition

function toKey(
  keystore: Keystore.Keystore,
  options: toKey.Options,
): Key

Source: src/core/Keystore.ts

Parameters

keystore

JSON Keystore

keystore.cipher

  • Type: "aes-128-ctr"

keystore.cipherparams

  • Type: { iv: string; }

keystore.ciphertext

  • Type: string

keystore.crypto

  • Type: { cipher: "aes-128-ctr"; ciphertext: string; cipherparams: { iv: string; }; mac: string; } & Pick

keystore.id

  • Type: string

keystore.iv

  • Type: string

keystore.mac

  • Type: string

keystore.version

  • Type: 3

options

  • Type: toKey.Options

Options

options.password

  • Type: string

Password to derive key from.

Return Type

Key

Key