@helium/crypto-react-native
Advanced tools
Comparing version 3.9.0 to 3.43.1
@@ -31,3 +31,3 @@ "use strict"; | ||
const entropy = mnenomic.toEntropy(); | ||
const seed = Buffer.concat([entropy, entropy]); | ||
const seed = entropy.length === 16 ? Buffer.concat([entropy, entropy]) : entropy; | ||
return Keypair.fromEntropy(seed); | ||
@@ -37,4 +37,5 @@ } | ||
const entropyBuffer = Buffer.from(entropy); | ||
if (Buffer.byteLength(entropyBuffer) !== 32) | ||
if (Buffer.byteLength(entropyBuffer) !== 32) { | ||
throw new Error('Invalid entropy, must be 32 bytes'); | ||
} | ||
const keypair = await react_native_sodium_1.default.crypto_sign_seed_keypair(entropyBuffer.toString('base64')); | ||
@@ -41,0 +42,0 @@ return new Keypair(keypair); |
@@ -21,4 +21,5 @@ "use strict"; | ||
throw new Error('invalid entropy, greater than 32'); | ||
if (entropy.length % 4 !== 0) | ||
if (entropy.length % 4 !== 0) { | ||
throw new Error('invalid entropy, not divisble by 4'); | ||
} | ||
const entropyBits = utils_1.bytesToBinary([].slice.call(entropy)); | ||
@@ -53,3 +54,3 @@ const checksumBits = utils_1.deriveChecksumBits(entropy); | ||
const newChecksum = utils_1.deriveChecksumBits(entropy); | ||
if (newChecksum !== checksumBits) | ||
if (checksumBits !== '0000' && newChecksum !== checksumBits) | ||
throw new Error('invalid checksum'); | ||
@@ -56,0 +57,0 @@ return entropy; |
{ | ||
"name": "@helium/crypto-react-native", | ||
"version": "3.9.0", | ||
"version": "3.43.1", | ||
"description": "Cryptography utilities including mnemonics, keypairs and base58-check encoding for React Native", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "299f2c790fbca9461265b94695c7ab816abc7f9d" | ||
"gitHead": "795bf010b6f233703ef9eab1df45f24fb3253553" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65700
2383