mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-05 14:43:11 +00:00
Add a python wrapper over the bigger constraint
This commit is contained in:
parent
99d8f1a4a7
commit
65e40caea0
@ -21,5 +21,5 @@ noirup
|
||||
From the repository root run:
|
||||
|
||||
```bash
|
||||
python -m unittest -v coordination-layer/test_*
|
||||
python -m unittest discover -v coordination-layer
|
||||
```
|
||||
|
||||
2
coordination-layer/noir/.gitignore
vendored
2
coordination-layer/noir/.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
crates/*/Prover.toml
|
||||
crates/*/Verifier.toml
|
||||
proofs/*.proof
|
||||
target/*
|
||||
target/*
|
||||
|
||||
@ -4,4 +4,4 @@ type = "bin"
|
||||
authors = [""]
|
||||
compiler_version = ">=0.22.0"
|
||||
|
||||
[dependencies]
|
||||
[dependencies]
|
||||
|
||||
@ -4,7 +4,6 @@ This module provides the interface for loading, proving and verifying constraint
|
||||
The assumptions of this module:
|
||||
- noir constraints are defined as a noir package in `./noir/crates/<constraint>/`
|
||||
- ./noir is relative to this file
|
||||
- noir constraints have already been compiled.
|
||||
|
||||
For ergonomics, one should provide python wrappers that understands the API of
|
||||
the corresponding constraint.
|
||||
@ -26,7 +25,7 @@ NARGO = sh.Command("nargo")
|
||||
|
||||
|
||||
@dataclass
|
||||
class Proof:
|
||||
class NoirProof:
|
||||
proof: str
|
||||
|
||||
|
||||
@ -40,7 +39,7 @@ class NoirConstraint:
|
||||
def noir_package_dir(self):
|
||||
return CONSTRAINTS_DIR / self.name
|
||||
|
||||
def prove(self, params: dict):
|
||||
def prove(self, params: dict) -> NoirProof:
|
||||
with portalocker.TemporaryFileLock(LOCK_FILE):
|
||||
with open(self.noir_package_dir / "Prover.toml", "w") as prover_f:
|
||||
toml.dump(params, prover_f)
|
||||
@ -49,9 +48,9 @@ class NoirConstraint:
|
||||
assert prove_res.exit_code == 0
|
||||
|
||||
with open(NOIR_DIR / "proofs" / f"{self.name}.proof", "r") as proof:
|
||||
return Proof(proof.read())
|
||||
return NoirProof(proof.read())
|
||||
|
||||
def verify(self, params: dict, proof: Proof):
|
||||
def verify(self, params: dict, proof: NoirProof):
|
||||
with portalocker.TemporaryFileLock(LOCK_FILE):
|
||||
with open(self.noir_package_dir / "Verifier.toml", "w") as verifier_f:
|
||||
toml.dump(params, verifier_f)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from .noir_constraint import NoirConstraint
|
||||
from noir_constraint import NoirConstraint
|
||||
|
||||
|
||||
class TestNoirCoinstraint(TestCase):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user