From 25061b56819e6bc6e69e3e99c639dfe8b9369f5b Mon Sep 17 00:00:00 2001 From: "[1000i100] Millicent Billette" <git@1000i100.fr> Date: Sun, 20 Nov 2022 20:12:32 +0100 Subject: [PATCH] v3.4.2 FIX: checkKey throw too_long error on binary RangeError (>32bit) --- src/crypto.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/crypto.mjs b/src/crypto.mjs index 428ced0..afae942 100644 --- a/src/crypto.mjs +++ b/src/crypto.mjs @@ -4,7 +4,6 @@ import scrypt from '../generated/vendors/scrypt.mjs'; import sha256 from '../node_modules/js-sha256/src/sha256.mjs'; import nacl from '../generated/vendors/nacl.mjs'; import {convertPublicKey, convertSecretKey} from '../node_modules/ed2curve/src/index.mjs'; -//import {convertPublicKey} from '../node_modules/ed2curve-esm/dist-src/index.mjs'; import {b16, b58, b64} from './basex.mjs'; import {random, ed25519} from './context-dependant/generics.mjs'; nacl.setPRNG(random); @@ -156,7 +155,7 @@ export function checkKey(pubKey, checkRawPubKey= true) { b58pubKey = typeof pubKey === 'string' ? pubKey : b58.encode(binPubKey); } catch (err){ if(err.message.match(/base58/)) throw new CustomError('not_b58', 'Character out of base 58, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.'); - if(err.message.match(/out of bounds/)) throw new CustomError('too_long','Binary key too long, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.'); + if(err.name === "RangeError") throw new CustomError('too_long','Binary key too long, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.'); throw err; } if(!checkRawPubKey) return true; -- GitLab