Error on eddsa.sign()
calvbore opened this issue · 0 comments
calvbore commented
Would keep getting this error when trying to use the sign
function: TypeError: "list" argument must be an Array of Buffers
Quick fix for the error by modifying lines 57 & 58 of eddsa.js
function now looks like:
function sign(prv, msg) {
const h1 = createBlakeHash("blake512").update(prv).digest();
const sBuff = pruneBuffer(h1.slice(0,32));
const s = utils.leBuff2int(sBuff);
const A = babyJub.mulPointEscalar(babyJub.Base8, Scalar.shr(s, 3));
const rBuff = createBlakeHash("blake512").update(Buffer.concat([h1.slice(32,64), msg])).digest();
let r = utils.leBuff2int(rBuff);
const Fr = new F1Field(babyJub.subOrder);
r = Fr.e(r);
const R8 = babyJub.mulPointEscalar(babyJub.Base8, r);
const R8p = Buffer.from(babyJub.packPoint(R8)); //CHANGED from: const R8p = babyJub.packPoint(R8);
const Ap = Buffer.from(babyJub.packPoint(A)); //CHANGED from: const Ap = babyJub.packPoint(A);
const hmBuff = pedersenHash(Buffer.concat([R8p, Ap, msg]));
const hm = utils.leBuff2int(hmBuff);
const S = Fr.add(r , Fr.mul(hm, s));
return {
R8: R8,
S: S
};
}
Not sure if this is a suitable fix to merge but it has worked for my needs so far.