diff --git a/src/crypto.mjs b/src/crypto.mjs index 428ced0d44efa2f66008dcf0571d46c93741e407..afae94205836192c267c258af63deef11328eef6 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;