2024-05-17 18:36:30 +04:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
2024-05-17 14:39:21 +04:00
|
|
|
from noir_constraint import NoirConstraint, NoirProof
|
|
|
|
|
|
|
|
|
|
|
2024-05-17 18:36:30 +04:00
|
|
|
@dataclass
|
2024-05-17 14:39:21 +04:00
|
|
|
class Bigger:
|
2024-05-17 18:36:30 +04:00
|
|
|
"""
|
|
|
|
|
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")
|
2024-05-17 14:39:21 +04:00
|
|
|
|
|
|
|
|
def prove(self, x: int) -> NoirProof:
|
2024-05-17 18:36:30 +04:00
|
|
|
return self._noir.prove({"x": str(x), "y": str(self.y)})
|
2024-05-17 14:39:21 +04:00
|
|
|
|
2024-05-17 18:36:30 +04:00
|
|
|
def verify(self, proof: NoirProof):
|
|
|
|
|
return self._noir.verify({"y": str(self.y)}, proof)
|