bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.18k stars 986 forks source link

powermod produces incorrect result #419

Open guidovranken opened 3 years ago

guidovranken commented 3 years ago
var sjcl = require('sjcl');

var bn0 = new sjcl.bn('c794');
var bn1 = new sjcl.bn('33');
var bn2 = new sjcl.bn('b');

console.log(bn0.powermod(bn1, bn2).toString());

prints:

0x1a5bd6f3654947df9b7939b126da9f94047e49aa7cbcc2707d02eac675ad742625826d8670c61fdc198291ad991bc0be5803e0b0e

which is evidently incorrect (result is larger than modulo).