Skip to content

Commit

Permalink
refactor: optimize pedersen function (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nir11 committed Nov 14, 2023
1 parent d2eb73b commit c73ee56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/signature.ts
Expand Up @@ -86,15 +86,15 @@ function hasHexPrefix(str: string) {
function pedersen(input: Array<string>) {
let point = shiftPoint;
for (let i = 0; i < input.length; i++) {
let x = new BN(input[i], 16);
const x = new BN(input[i], 16);
assert(x.gte(zeroBn) && x.lt(prime), 'Invalid input: ' + input[i]);
for (let j = 0; j < 252; j++) {
const pt = constantPoints[2 + i * 252 + j];
assert(!point.getX().eq(pt.getX()));
if (x.and(oneBn).toNumber() !== 0) {
point = point.add(pt);
}
x = x.shrn(1);
x.iushrn(1);
}
}
return point.getX().toString(16);
Expand Down

0 comments on commit c73ee56

Please sign in to comment.