Revery isWasmOnly helper (#1229)

* Revery isWasmOnly helper

* Adjust
This commit is contained in:
Jaco
2021-11-22 08:51:03 +02:00
committed by GitHub
parent 28f0040080
commit 277c80eb96
15 changed files with 32 additions and 50 deletions
+2 -3
View File
@@ -7,9 +7,8 @@ import type { Params } from './types';
import scryptsy from 'scryptsy';
import { bufferToU8a, u8aToBuffer, u8aToU8a } from '@polkadot/util';
import { scrypt } from '@polkadot/wasm-crypto';
import { isReady, scrypt } from '@polkadot/wasm-crypto';
import { isWasmOnly } from '../helpers';
import { randomAsU8a } from '../random/asU8a';
import { DEFAULT_PARAMS } from './defaults';
@@ -22,7 +21,7 @@ interface Result {
export function scryptEncode (passphrase?: HexString | Uint8Array | string, salt = randomAsU8a(), params = DEFAULT_PARAMS, onlyJs?: boolean): Result {
const u8a = u8aToU8a(passphrase);
const password = isWasmOnly(onlyJs)
const password = !onlyJs && isReady()
? scrypt(u8a, salt, Math.log2(params.N), params.r, params.p)
: bufferToU8a(
scryptsy(u8aToBuffer(u8a), u8aToBuffer(salt), params.N, params.r, params.p, 64)