diff --git a/std/math/emulated/composition.go b/std/math/emulated/composition.go index bce35e744..c76f9da7a 100644 --- a/std/math/emulated/composition.go +++ b/std/math/emulated/composition.go @@ -67,7 +67,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 .