From 927463f76a0c019c08590ab1dd25948ebe3449e3 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 8 Dec 2021 03:34:57 +0000 Subject: [PATCH] Add `Assigned::is_zero_vartime` method --- halo2_proofs/src/plonk/assigned.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/halo2_proofs/src/plonk/assigned.rs b/halo2_proofs/src/plonk/assigned.rs index d958fce8..3c1795c1 100644 --- a/halo2_proofs/src/plonk/assigned.rs +++ b/halo2_proofs/src/plonk/assigned.rs @@ -152,6 +152,18 @@ impl Assigned { } } + /// Returns true iff this element is zero. + pub fn is_zero_vartime(&self) -> bool { + match self { + Self::Zero => true, + Self::Trivial(x) => x.is_zero_vartime(), + // Assigned maps x/0 -> 0. + Self::Rational(numerator, denominator) => { + numerator.is_zero_vartime() || denominator.is_zero_vartime() + } + } + } + /// Inverts this assigned value (taking the inverse of zero to be zero). pub fn invert(&self) -> Self { match self {