From ac8a48029292a08699e96f386e2e33bd06942564 Mon Sep 17 00:00:00 2001 From: wwared Date: Sat, 17 Feb 2024 11:28:35 -0300 Subject: [PATCH] Ensure the result is 0 if a == b --- crates/emulated/src/field_ops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/emulated/src/field_ops.rs b/crates/emulated/src/field_ops.rs index 7844b39..c58da7c 100644 --- a/crates/emulated/src/field_ops.rs +++ b/crates/emulated/src/field_ops.rs @@ -435,7 +435,7 @@ where if a.is_constant() && b.is_constant() { let a_int = BigInt::from(a); let b_int = BigInt::from(b); - let res_int = if a_int > b_int { + let res_int = if a_int >= b_int { (a_int - b_int).rem(P::modulus()) } else { P::modulus() - (b_int - a_int).rem(P::modulus())