Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into 22/move-use-to-circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
leolara authored Sep 13, 2023
2 parents 6447719 + f8a96db commit 4926928
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ In research:
+ Signal typing system, which allows statically checking for soundness issues.
+ Folding backend with ProtoStar, HyperNova, and/or others.

## Fibonnaci circtuit in Chiquito's Python frontend.
## Fibonnaci circuit in Chiquito's Python frontend.

But better see for yourself:

```
```python
class FiboStep(StepType):
def setup(self: FiboStep):
self.c = self.internal("c")
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Setup
Chiquito's Python frontend uses PyO3 and Maturin to expose Rust APIs to Python. Maturin requires the user to locally build a Python virtual environment. Run the following script to create a Python virtual environment, install required packages, and build the project.

```
```bash
# Clone this repo
git clone https://github.com/privacy-scaling-explorations/chiquito/
# Navigate to the repository root directory
Expand All @@ -22,13 +22,13 @@ If the above doesn't work, follow the guide here: https://pyo3.rs/main/getting_s
## Testing with examples
Run fibonacci.py example file using the following script in the virtual environment:

```
```bash
python3 example/fibonacci.py
```

Run mimc7.py example:

```
```bash
python example/mimc7.py
```

Expand Down
6 changes: 3 additions & 3 deletions tutorials/tutorial_pt2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"Chiquito's Python frontend requires using a Python virtual environment for its dependencies, which you should have setup following the [Python README](https://github.com/privacy-scaling-explorations/chiquito/tree/main/src/frontend/python/README.md).\n",
"\n",
"Specifically, after cloning Chiquito, you need to run the following commands in your local machine (NOT in Jupyter):\n",
"```\n",
"```bash\n",
"python3 -m venv .env # create virtual environment\n",
"source .env/bin/activate # activate virtual environment\n",
"pip install -r requirements.txt # install required python dependencies from requirements.txt\n",
"maturin develop # build the project with rust bindings\n",
"```\n",
"\n",
"Then install your local Python virtual environment as a Jupyter Lab Kernel called `chiquito_kernel`. \n",
"```\n",
"```bash\n",
"python -m ipykernel install --user --name=chiquito_kernel\n",
"```\n",
"\n",
"After that, run the following: \n",
"```\n",
"```bash\n",
"cd tutorials # navigate to the tutorials subfolder\n",
"jupyter lab # launch jupyter notebook in browser\n",
"```\n",
Expand Down
10 changes: 5 additions & 5 deletions tutorials/tutorial_pt3_ch2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"\n",
"## FiboStep Setup\n",
"We now define the only step type, `FiboStep`:\n",
"```\n",
"```python\n",
"class FiboStep(StepType):\n",
" def setup(self):\n",
" self.c = self.internal(\"c\")\n",
Expand All @@ -81,7 +81,7 @@
"In the code snippet above, forward signals \"a\" and \"b\" are expressed as `self.circuit.a` and `self.circuit.b`, whereas internal signal \"c\" is expressed as `self.c`, because \"a\" and \"b\" are at the circuit-level. `self.circuit.a.next()` queries the value of circuit-level signal \"a\" at the next step instance. `eq` is a constraint builder that enforces equality between the two arguments passed in. It builds the three constraints of `FiboStep`: `a + b == c`, `b == a.next`, and `c == b.next`.\n",
"\n",
"## FiboStep Witness Generation\n",
"```\n",
"```python\n",
"class FiboStep(StepType):\n",
" def setup(self):\n",
" # ...\n",
Expand All @@ -97,7 +97,7 @@
"Note that in `self.assign`, `a_value` and `b_value` are both wrapped in `F`, which converts them from int to field elements. All witness assignments in PyChiquito are field elements.\n",
"\n",
"Putting everything for `FiboStep` together, we have:\n",
"```\n",
"```python\n",
"class FiboStep(StepType):\n",
" def setup(self):\n",
" self.c = self.internal(\"c\")\n",
Expand All @@ -119,7 +119,7 @@
"\n",
"## Circuit Setup\n",
"We first define the circuit `setup`:\n",
"```\n",
"```python\n",
"class Fibonacci(Circuit):\n",
" def setup(self):\n",
" self.a = self.forward(\"a\")\n",
Expand All @@ -139,7 +139,7 @@
"\n",
"## Circuit Trace\n",
"Now we instantiate step types and assign witness values using `trace`:\n",
"```\n",
"```python\n",
"class Fibonacci(Circuit):\n",
" def setup(self):\n",
" # ...\n",
Expand Down
6 changes: 3 additions & 3 deletions tutorials/tutorial_pt3_ch4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"\n",
"The following shows the incremental code of `FiboFirstStep` compared to `FiboStep`:\n",
"\n",
"```\n",
"```python\n",
"class FiboFirstStep(StepType):\n",
" def setup(self):\n",
" # ...\n",
Expand All @@ -40,7 +40,7 @@
"\n",
"Next, in circuit `setup`, we need to append this step type and constrain that the first step instance is `FiboFirstStep`. Otherwise `setup` is identical to that in Chapter 3:\n",
"\n",
"```\n",
"```python\n",
"class Fibonacci(Circuit):\n",
" def setup(self):\n",
" # ...\n",
Expand All @@ -53,7 +53,7 @@
"\n",
"Finally, in circuit `trace`, we need to instantiate `FiboFirstStep` for the first step instance. Otherwise `trace` is identical to that in Chapter 3:\n",
"\n",
"```\n",
"```python\n",
"class Fibonacci(Circuit):\n",
" def setup(self):\n",
" # ...\n",
Expand Down
8 changes: 4 additions & 4 deletions tutorials/tutorial_pt3_ch5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"\n",
"First, let's add the padding step type: \n",
"\n",
"```\n",
"```python\n",
"class Padding(StepType):\n",
" def setup(self):\n",
" self.transition(eq(self.circuit.b, self.circuit.b.next()))\n",
Expand All @@ -96,7 +96,7 @@
"\n",
"Second, let's modify all existing step types to account for the new signal `n`, basically adding a new constraint `n == n.next` in `setup` and assigning `n_value` in `wg`:\n",
"\n",
"```\n",
"```python\n",
"class FiboFirstStep(StepType):\n",
" def setup(self):\n",
" # ...\n",
Expand All @@ -120,7 +120,7 @@
"\n",
"Third, let's modify the circuit `setup`:\n",
"\n",
"```\n",
"```python\n",
"class Fibonacci(Circuit):\n",
" def setup(self):\n",
" self.a = self.forward(\"a\")\n",
Expand Down Expand Up @@ -153,7 +153,7 @@
"- `FiboStep` for the 2nd through n-th step instance\n",
"- `Padding` for the rest step instances such that there are 10 step instances in total, as specified by `self.pragma_num_steps(10)`\n",
"\n",
"```\n",
"```python\n",
"class Fibonacci(Circuit):\n",
" def setup(self):\n",
" # ...\n",
Expand Down

0 comments on commit 4926928

Please sign in to comment.