From 8e9144e1af27158927b7e622af1b0c86c53365c1 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 28 Apr 2021 20:21:22 +0900 Subject: [PATCH] finalExp checks zero for safety --- include/mcl/bn.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index c8255aa..43deecd 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -1456,6 +1456,7 @@ inline void mapToCyclotomic(Fp12& y, const Fp12& x) Fp12 z; Fp12::Frobenius2(z, x); // z = x^(p^2) z *= x; // x^(p^2 + 1) + assert(z.isZero()); Fp12::inv(y, z); Fp6::neg(z.b, z.b); // z^(p^6) = conjugate of z y *= z; @@ -1617,6 +1618,10 @@ inline void makeAdjP(G1& adjP, const G1& P) inline void finalExp(Fp12& y, const Fp12& x) { #if 1 + if (x.isZero()) { + y.clear(); + return; + } mapToCyclotomic(y, x); #else const mpz_class& p = param.p;