bn.js
bn.js copied to clipboard
Incorrect mod result with mont reduction
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
Nevermind I read #193 but perhaps we could get some better documentation about this?