You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am by no means a crypto expert, but on a recent project we were having issues tracing down problems verifying signatures. In the end we reduced it to the difference between the way the secp256k1 c library verified signatures vs the way elliptic.js verified signatures. I can't tell you what is going wrong on the maths side but hopefully the following test case can help:
msg = Buffer("7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069", 'hex');
sig = Buffer("3046022100c74b47f51776096053d01dea04bc67f77f1145df46a5b4c5c817aa2acdfad7ff022100efbbe32d7d7b2109365290427cf19bdbdc14304608441aaf19781216da53d6da", 'hex')
publicKey = Buffer("040db450c7aca2a501d6e8f04338f7e93f4fef29fa5881fcc180ec8324f3b40a1fa22bccd174898e2bcb5247f2d648ea899a95dae8bf84ba8a13e7dcc9cb7f08bd", 'hex')
var secp256k1 = require('secp256k1');
//this one fails
sigImport = secp256k1.signatureImport(sig);
if(secp256k1.verifySync(msg, sigImport, publicKey)) {
console.log("sig ok");
} else {
console.log("is not ok")
}
var EC = require("elliptic").ec;
//this one succeeds
var ec = new EC("secp256k1");
if (ec.verify(msg, sig, publicKey)) {
console.log("sig ok");
} else {
console.log("is not ok");
}
The text was updated successfully, but these errors were encountered:
@carnun it's happened because secp256k1 return false for non lower-s signatures,
so, working example:
varmsg=Buffer('7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069','hex')varsig=Buffer('3046022100c74b47f51776096053d01dea04bc67f77f1145df46a5b4c5c817aa2acdfad7ff022100efbbe32d7d7b2109365290427cf19bdbdc14304608441aaf19781216da53d6da','hex')varpublicKey=Buffer('040db450c7aca2a501d6e8f04338f7e93f4fef29fa5881fcc180ec8324f3b40a1fa22bccd174898e2bcb5247f2d648ea899a95dae8bf84ba8a13e7dcc9cb7f08bd','hex')varsecp256k1=require('secp256k1')// this one failsvarsigImport=secp256k1.signatureImport(sig)varnormalizedSig=secp256k1.signatureNormalize(sigImport)if(secp256k1.verify(msg,normalizedSig,publicKey)){console.log('sig ok')}else{console.log('is not ok')}
I am by no means a crypto expert, but on a recent project we were having issues tracing down problems verifying signatures. In the end we reduced it to the difference between the way the secp256k1 c library verified signatures vs the way elliptic.js verified signatures. I can't tell you what is going wrong on the maths side but hopefully the following test case can help:
The text was updated successfully, but these errors were encountered: