src/crypto/scrypt.js
function derive(passwd, salt, N, r, p, len) {
  if (r * p >= (1 << 30))
    throw new Error('EFBIG');

  if ((N & (N - 1)) !== 0 || N === 0)
    throw new Error('EINVAL');

  if (N > 0xffffffff)
    throw new Error('EINVAL');

  const XY = Buffer.allocUnsafe(256 * r);
  const V = Buffer.allocUnsafe(128 * r * N);

  const B = pbkdf2.derive(passwd, salt, 1, p * 128 * r, 'sha256');

  for (let i = 0; i < p; i++)
    smix(B, i * 128 * r, r, N, V, XY);

  return pbkdf2.derive(passwd, B, 1, len, 'sha256');
}
function derive(passwd, salt, N, r, p, len) {
  if (r * p >= (1 << 30))
    throw new Error('EFBIG');

  if ((N & (N - 1)) !== 0 || N === 0)
    throw new Error('EINVAL');

  if (N > 0xffffffff)
    throw new Error('EINVAL');

  const XY = Buffer.allocUnsafe(256 * r);
  const V = Buffer.allocUnsafe(128 * r * N);

  const B = pbkdf2.derive(passwd, salt, 1, p * 128 * r, 'sha256');

  for (let i = 0; i < p; i++)
    smix(B, i * 128 * r, r, N, V, XY);

  return pbkdf2.derive(passwd, B, 1, len, 'sha256');
}
function derive ( passwd , salt , N , r , p , len ) { if ( r * p >= ( 1 << 30 ) ) throw new Error ( 'EFBIG' ) ; if ( ( N & ( N - 1 ) ) !== 0 || N === 0 ) throw new Error ( 'EINVAL' ) ; if ( N > 0xffffffff ) throw new Error ( 'EINVAL' ) ; const XY = Buffer . allocUnsafe ( 256 * r ) ; const V = Buffer . allocUnsafe ( 128 * r * N ) ; const B = pbkdf2 . derive ( passwd , salt , 1 , p * 128 * r , 'sha256' ) ; for ( let i = 0 ; i < p ; i ++ ) smix ( B , i * 128 * r , r , N , V , XY ) ; return pbkdf2 . derive ( passwd , B , 1 , len , 'sha256' ) ; }
Javascript scrypt implementation. Scrypt is
used in bip38. WMCC_Core doesn't support bip38
yet, but here it is, just in case.
@alias module:crypto/scrypt.derive
@param {Buffer} passwd
@param {Buffer} salt
@param {Number} N
@param {Number} r
@param {Number} p
@param {Number} len
@returns {Buffer}
Javascript scrypt implementation . Scrypt is used in bip38 . WMCC_Core doesn t support bip38 yet but here it is just in case .