From 0e0403d0e2edac7c4e992f7979d5296a9b8788c4 Mon Sep 17 00:00:00 2001 From: George Kadianakis Date: Thu, 16 Mar 2023 15:49:40 +0200 Subject: [PATCH] Reject zero inputs in bls_modular_inverse() --- specs/deneb/polynomial-commitments.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/specs/deneb/polynomial-commitments.md b/specs/deneb/polynomial-commitments.md index c48857d9e..e23c31fab 100644 --- a/specs/deneb/polynomial-commitments.md +++ b/specs/deneb/polynomial-commitments.md @@ -252,10 +252,11 @@ def compute_challenge(blob: Blob, ```python def bls_modular_inverse(x: BLSFieldElement) -> BLSFieldElement: """ - Compute the modular inverse of x - i.e. return y such that x * y % BLS_MODULUS == 1 and return 0 for x == 0 + Compute the modular inverse of x (for x != 0) + i.e. return y such that x * y % BLS_MODULUS == 1 """ - return BLSFieldElement(pow(x, -1, BLS_MODULUS)) if x != 0 else BLSFieldElement(0) + assert (int(x) % BLS_MODULUS) != 0 + return BLSFieldElement(pow(x, -1, BLS_MODULUS)) ``` #### `div`