This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #82 - Add `scr/python.rs` contains Python Module - `frontend/python/chiquito` is home for python-source - dependencies = ["py_ecc"] included in `pyproject.toml` so users don't have to `pip install py_ecc` - add `fibonacci.py` to examples
- Loading branch information
Showing
21 changed files
with
2,294 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/target | ||
/Cargo.lock | ||
.vscode | ||
.env | ||
__pycache__ | ||
*.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,13 @@ authors = ["Leo Lara <[email protected]>"] | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
pyo3 = { version = "0.19.1", features = ["extension-module"] } | ||
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", features = [ | ||
"circuit-params", | ||
"circuit-params", | ||
], tag = "v2023_04_20" } | ||
halo2curves = { git = 'https://github.com/privacy-scaling-explorations/halo2curves', tag = "0.3.2", features = [ "derive_serde" ] } | ||
halo2curves = { git = 'https://github.com/privacy-scaling-explorations/halo2curves', tag = "0.3.2", features = [ | ||
"derive_serde", | ||
] } | ||
polyexen = { git = "https://github.com/Dhole/polyexen.git", rev = "67148a8aabb000a61a169b2533b2526c5b76c42f" } | ||
num-bigint = { version = "0.4", features = ["rand"] } | ||
uuid = { version = "1.4.0", features = ["v1", "rng"] } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from __future__ import annotations | ||
from typing import Tuple | ||
|
||
from chiquito.dsl import Circuit, StepType | ||
from chiquito.cb import eq | ||
from chiquito.query import Queriable | ||
from chiquito.util import F | ||
|
||
|
||
class Fibonacci(Circuit): | ||
def setup(self: Fibonacci): | ||
self.a: Queriable = self.forward("a") | ||
self.b: Queriable = self.forward("b") | ||
|
||
self.fibo_step = self.step_type(FiboStep(self, "fibo_step")) | ||
self.fibo_last_step = self.step_type(FiboLastStep(self, "fibo_last_step")) | ||
|
||
self.pragma_first_step(self.fibo_step) | ||
self.pragma_last_step(self.fibo_last_step) | ||
self.pragma_num_steps(11) | ||
|
||
def trace(self: Fibonacci, args: Any): | ||
self.add(self.fibo_step, (1, 1)) | ||
a = 1 | ||
b = 2 | ||
for i in range(1, 10): | ||
self.add(self.fibo_step, (a, b)) | ||
prev_a = a | ||
a = b | ||
b += prev_a | ||
self.add(self.fibo_last_step, (a, b)) | ||
|
||
|
||
class FiboStep(StepType): | ||
def setup(self: FiboStep): | ||
self.c = self.internal("c") | ||
self.constr(eq(self.circuit.a + self.circuit.b, self.c)) | ||
self.transition(eq(self.circuit.b, self.circuit.a.next())) | ||
self.transition(eq(self.c, self.circuit.b.next())) | ||
|
||
def wg(self: FiboStep, args: Tuple[int, int]): | ||
a_value, b_value = args | ||
self.assign(self.circuit.a, F(a_value)) | ||
self.assign(self.circuit.b, F(b_value)) | ||
self.assign(self.c, F(a_value + b_value)) | ||
|
||
|
||
class FiboLastStep(StepType): | ||
def setup(self: FiboLastStep): | ||
self.c = self.internal("c") | ||
self.constr(eq(self.circuit.a + self.circuit.b, self.c)) | ||
|
||
def wg(self: FiboLastStep, values=Tuple[int, int]): | ||
a_value, b_value = values | ||
self.assign(self.circuit.a, F(a_value)) | ||
self.assign(self.circuit.b, F(b_value)) | ||
self.assign(self.c, F(a_value + b_value)) | ||
|
||
|
||
fibo = Fibonacci() | ||
fibo_witness = fibo.gen_witness(None) | ||
fibo.halo2_mock_prover(fibo_witness) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
[build-system] | ||
requires = ["maturin>=1.1,<2.0"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "chiquito" | ||
dependencies = ["py_ecc"] | ||
requires-python = ">=3.7" | ||
classifiers = [ | ||
"Programming Language :: Rust", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
|
||
|
||
[tool.maturin] | ||
bindings = 'pyo3' | ||
features = ["pyo3/extension-module"] | ||
python-source = "src/frontend/python" | ||
module-name = "chiquito.rust_chiquito" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
pub mod dsl; | ||
pub mod pychiquito; | ||
pub mod python; |
Empty file.
Oops, something went wrong.