- Notifications
You must be signed in to change notification settings - Fork 155
Closed
Description
Related to issue: indutny/elliptic#191 (comment)
@fanatid said he saw the same issue as the one below where strip() is missing. I'm posting it here in hopes for a minor patch with a workaround.
FAIL tests/apis/ava/keychain.test.ts (5.154s) AssetsKeyPair ✕ Creation Empty (403ms) ● AssetsKeyPair › Creation Empty TypeError: r.strip is not a function at K256.ireduce (node_modules/elliptic/node_modules/bn.js/lib/bn.js:2975:9) at Red.imod (node_modules/elliptic/node_modules/bn.js/lib/bn.js:3147:39) at Red.mul (node_modules/elliptic/node_modules/bn.js/lib/bn.js:3211:17) at BN.redMul (node_modules/bn.js/lib/bn.js:2984:21) at JPoint.eqXToP (node_modules/elliptic/lib/elliptic/curve/short.js:909:36) at EC.verify (node_modules/elliptic/lib/elliptic/ec/index.js:191:12) at AssetsKeyPair.verify (src/apis/ava/keychain.ts:2440:17) at Object.<anonymous> (tests/apis/ava/keychain.test.ts:15:19)
from code:
/** * Verifies that the private key associated with the provided public key produces the signature associated with the given message. * * @param msg The message associated with the signature * @param sig The signature of the signed message * * @returns True on success, false on failure */ verify = (msg:Buffer, sig:Buffer):boolean => { let sigObj:elliptic.ec.SignatureOptions = this._sigFromSigBuffer(sig); return ec.verify(msg, sigObj, this.keypair); } /** * @ignore */ protected _sigFromSigBuffer = (sig:Buffer):elliptic.ec.SignatureOptions => { let r:BN = new BN(bintools.copyFrom(sig, 0, 32)); let s:BN = new BN(bintools.copyFrom(sig, 32, 64)); let recoveryParam:number = bintools.copyFrom(sig, 64, 65).readUIntBE(0, 1); let sigOpt = { r:r, s:s, recoveryParam:recoveryParam }; return sigOpt; }
Metadata
Metadata
Assignees
Labels
No labels