bn.js icon indicating copy to clipboard operation
bn.js copied to clipboard

Incorrect mod result with mont reduction

Open SurienDG opened this issue 5 years ago • 1 comments

I did

let red10 = BN.mont(new BN(10, 10));
let red_1 = new BN(104, 10).toRed(red10);
red_1 = red_1.fromRed();
console.log("red_1: " + red_1.toString());

This outputs

red_1: 2

Which is incorrect. It should output red_1: 4 (since 104 mod 10 = 4). I do get the correct if I use BN.red instead if BN.mont

SurienDG avatar Dec 03 '20 23:12 SurienDG

Nevermind I read #193 but perhaps we could get some better documentation about this?

SurienDG avatar Dec 03 '20 23:12 SurienDG