Skip to content
Snippets Groups Projects
Commit 25061b56 authored by Millicent Billette's avatar Millicent Billette
Browse files

v3.4.2

FIX: checkKey throw too_long error on binary RangeError (>32bit)
parent 87b38c45
No related branches found
No related tags found
No related merge requests found
Pipeline #17793 failed
...@@ -4,7 +4,6 @@ import scrypt from '../generated/vendors/scrypt.mjs'; ...@@ -4,7 +4,6 @@ import scrypt from '../generated/vendors/scrypt.mjs';
import sha256 from '../node_modules/js-sha256/src/sha256.mjs'; import sha256 from '../node_modules/js-sha256/src/sha256.mjs';
import nacl from '../generated/vendors/nacl.mjs'; import nacl from '../generated/vendors/nacl.mjs';
import {convertPublicKey, convertSecretKey} from '../node_modules/ed2curve/src/index.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 {b16, b58, b64} from './basex.mjs';
import {random, ed25519} from './context-dependant/generics.mjs'; import {random, ed25519} from './context-dependant/generics.mjs';
nacl.setPRNG(random); nacl.setPRNG(random);
...@@ -156,7 +155,7 @@ export function checkKey(pubKey, checkRawPubKey= true) { ...@@ -156,7 +155,7 @@ export function checkKey(pubKey, checkRawPubKey= true) {
b58pubKey = typeof pubKey === 'string' ? pubKey : b58.encode(binPubKey); b58pubKey = typeof pubKey === 'string' ? pubKey : b58.encode(binPubKey);
} catch (err){ } 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(/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; throw err;
} }
if(!checkRawPubKey) return true; if(!checkRawPubKey) return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment