From 211a543513713a884885812f55118c1ce4ade106 Mon Sep 17 00:00:00 2001 From: David Rusu Date: Fri, 17 May 2024 18:36:30 +0400 Subject: [PATCH] rewrite Bigger constraint as a dataclass --- coordination-layer/constraints/bigger.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/coordination-layer/constraints/bigger.py b/coordination-layer/constraints/bigger.py index 98f02d2..1f4f81d 100644 --- a/coordination-layer/constraints/bigger.py +++ b/coordination-layer/constraints/bigger.py @@ -1,13 +1,21 @@ +from dataclasses import dataclass + from noir_constraint import NoirConstraint, NoirProof +@dataclass class Bigger: - def __init__(self, y: int): - self.y = y - self.noir = NoirConstraint("bigger") + """ + The statement "I know an `x` that is bigger than `y`". + - `y` is a public parameter provided when the constraint is initialized + - `x` is a secret parameter provided at proving time + """ + + y: int + _noir = NoirConstraint("bigger") def prove(self, x: int) -> NoirProof: - return self.noir.prove({"x": str(x), "y": str(self.y)}) + return self._noir.prove({"x": str(x), "y": str(self.y)}) - def verify(self, proof): - return self.noir.verify({"y": str(self.y)}, proof) + def verify(self, proof: NoirProof): + return self._noir.verify({"y": str(self.y)}, proof)