mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-06 07:03:11 +00:00
Add the Bigger wrapper
This commit is contained in:
parent
65e40caea0
commit
8b2cf83bed
0
coordination-layer/constraints/__init__.py
Normal file
0
coordination-layer/constraints/__init__.py
Normal file
13
coordination-layer/constraints/bigger.py
Normal file
13
coordination-layer/constraints/bigger.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from noir_constraint import NoirConstraint, NoirProof
|
||||||
|
|
||||||
|
|
||||||
|
class Bigger:
|
||||||
|
def __init__(self, y: int):
|
||||||
|
self.y = y
|
||||||
|
self.noir = NoirConstraint("bigger")
|
||||||
|
|
||||||
|
def prove(self, x: int) -> NoirProof:
|
||||||
|
return self.noir.prove({"x": str(x), "y": str(self.y)})
|
||||||
|
|
||||||
|
def verify(self, proof):
|
||||||
|
return self.noir.verify({"y": str(self.y)}, proof)
|
||||||
14
coordination-layer/constraints/test_bigger.py
Normal file
14
coordination-layer/constraints/test_bigger.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from .bigger import Bigger
|
||||||
|
|
||||||
|
|
||||||
|
class TestBigger(TestCase):
|
||||||
|
def test_bigger(self):
|
||||||
|
bigger = Bigger(3)
|
||||||
|
proof = bigger.prove(5)
|
||||||
|
bigger.verify(proof)
|
||||||
|
|
||||||
|
# If we try to reuse the proof for a different Bigger instance, it fails
|
||||||
|
bigger_4 = Bigger(4)
|
||||||
|
assert not bigger_4.verify(proof)
|
||||||
Loading…
x
Reference in New Issue
Block a user