Skip to content

Commit 391f0ba

Browse files
committed
specify supported moduli
1 parent 8acdef2 commit 391f0ba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ff-macros/src/small_fp/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ pub(crate) fn small_fp_config_helper(
2222

2323
let backend_impl = match backend.as_str() {
2424
"standard" => standard_backend::backend_impl(&ty, modulus, generator),
25-
"montgomery" => montgomery_backend::backend_impl(&ty, modulus, generator),
25+
"montgomery" => {
26+
if modulus >= 1u128 << 127 {
27+
panic!(
28+
"SmallFpConfig montgomery backend supports only moduli < 2^127. Use MontConfig with BigInt instead of SmallFp."
29+
)
30+
}
31+
montgomery_backend::backend_impl(&ty, modulus, generator)
32+
},
33+
2634
_ => panic!("Unknown backend type: {}", backend),
2735
};
2836

0 commit comments

Comments
 (0)