es/utils/keystore.js
async function deriveKey (password, nonce, options = {
  kdf_params: DEFAULTS.crypto.kdf_params,
  kdf: DEFAULTS.crypto.kdf
}) {
  if (typeof password === 'undefined' || password === null || !nonce) {
    throw new Error('Must provide password and nonce to derive a key')
  }

  if (!DERIVED_KEY_FUNCTIONS.hasOwnProperty(options.kdf)) throw new Error('Unsupported kdf type')

  return DERIVED_KEY_FUNCTIONS[options.kdf](password, nonce, options)
}
async function deriveKey (password, nonce, options = {
  kdf_params: DEFAULTS.crypto.kdf_params,
  kdf: DEFAULTS.crypto.kdf
}) {
  if (typeof password === 'undefined' || password === null || !nonce) {
    throw new Error('Must provide password and nonce to derive a key')
  }

  if (!DERIVED_KEY_FUNCTIONS.hasOwnProperty(options.kdf)) throw new Error('Unsupported kdf type')

  return DERIVED_KEY_FUNCTIONS[options.kdf](password, nonce, options)
}
async function deriveKey ( password , nonce , options = { kdf_params : DEFAULTS . crypto . kdf_params , kdf : DEFAULTS . crypto . kdf } ) { if ( typeof password === 'undefined' || password === null || ! nonce ) { throw new Error ( 'Must provide password and nonce to derive a key' ) } if ( ! DERIVED_KEY_FUNCTIONS . hasOwnProperty ( options . kdf ) ) throw new Error ( 'Unsupported kdf type' ) return DERIVED_KEY_FUNCTIONS [ options . kdf ] ( password , nonce , options ) }
Derive secret key from password with key derivation function.
@param {string} password User-supplied password.
@param {buffer|Uint8Array} nonce Randomly generated nonce.
@param {Object=} options Encryption parameters.
@param {string=} options.kdf Key derivation function (default: DEFAULTS.crypto.kdf).
@param {Object=} options.kdf_params KDF parameters (default: DEFAULTS.crypto.kdf_params).
@return {buffer} Secret key derived from password.
Derive secret key from password with key derivation function .