diff --git a/README.md b/README.md index 83d7ca47..6fcd3653 100644 --- a/README.md +++ b/README.md @@ -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") diff --git a/src/frontend/python/README.md b/src/frontend/python/README.md index adf6b24d..caa4fe15 100644 --- a/src/frontend/python/README.md +++ b/src/frontend/python/README.md @@ -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 @@ -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 ``` diff --git a/tutorials/tutorial_pt2.ipynb b/tutorials/tutorial_pt2.ipynb index 3b8323c4..da969fe7 100644 --- a/tutorials/tutorial_pt2.ipynb +++ b/tutorials/tutorial_pt2.ipynb @@ -10,7 +10,7 @@ "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", @@ -18,12 +18,12 @@ "```\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", diff --git a/tutorials/tutorial_pt3_ch2.ipynb b/tutorials/tutorial_pt3_ch2.ipynb index 1783ae8d..cefb3443 100644 --- a/tutorials/tutorial_pt3_ch2.ipynb +++ b/tutorials/tutorial_pt3_ch2.ipynb @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/tutorials/tutorial_pt3_ch4.ipynb b/tutorials/tutorial_pt3_ch4.ipynb index d22c5875..14996ecb 100644 --- a/tutorials/tutorial_pt3_ch4.ipynb +++ b/tutorials/tutorial_pt3_ch4.ipynb @@ -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", @@ -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", @@ -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", diff --git a/tutorials/tutorial_pt3_ch5.ipynb b/tutorials/tutorial_pt3_ch5.ipynb index e20a0939..e01f227e 100644 --- a/tutorials/tutorial_pt3_ch5.ipynb +++ b/tutorials/tutorial_pt3_ch5.ipynb @@ -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", @@ -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", @@ -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", @@ -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",