From 5c74bd75e1ff464676b408d41842049b6dd7d0c2 Mon Sep 17 00:00:00 2001 From: Ivo Kubjas Date: Tue, 14 May 2024 06:42:47 +0200 Subject: [PATCH] fix: more descriptive error message (#1104) --- std/math/emulated/composition.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/std/math/emulated/composition.go b/std/math/emulated/composition.go index d1dad61d41..d94d4f5cca 100644 --- a/std/math/emulated/composition.go +++ b/std/math/emulated/composition.go @@ -68,7 +68,9 @@ func decompose(input *big.Int, nbBits uint, res []*big.Int) error { // then no such underflow happens and s = a-b (mod p) as the padding is multiple // of p. func subPadding(modulus *big.Int, bitsPerLimbs uint, overflow uint, nbLimbs uint) []*big.Int { - + if modulus.Cmp(big.NewInt(0)) == 0 { + panic("modulus is zero") + } // first, we build a number nLimbs, such that nLimbs > b; // here b is defined by its bounds, that is b is an element with nbLimbs of (bitsPerLimbs+overflow) // so a number nLimbs > b, is simply taking the next power of 2 over this bound .