From f74f9500271e1332d828c7ca4fcc65cdf1f6fd2d Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 24 Jul 2024 18:11:21 -0700 Subject: [PATCH 01/19] add starter examples --- docs/nada-by-example.md | 9 +++ docs/nada-by-example/addition.md | 22 ++++++ docs/nada-by-example/comparison.md | 75 +++++++++++++++++++ docs/nada-by-example/debugging.md | 19 +++++ docs/nada-by-example/division.md | 22 ++++++ docs/nada-by-example/equality.md | 38 ++++++++++ docs/nada-by-example/for-loop.md | 22 ++++++ docs/nada-by-example/hello-world.md | 19 +++++ docs/nada-by-example/helper-function.md | 22 ++++++ docs/nada-by-example/if-else.md | 38 ++++++++++ docs/nada-by-example/list-comprehensions.md | 22 ++++++ docs/nada-by-example/modulo.md | 22 ++++++ docs/nada-by-example/multiplication.md | 22 ++++++ docs/nada-by-example/power.md | 22 ++++++ .../probabilistic-truncation.md | 22 ++++++ docs/nada-by-example/reveal.md | 22 ++++++ docs/nada-by-example/shift-left.md | 22 ++++++ docs/nada-by-example/shift-right.md | 22 ++++++ docs/nada-by-example/subtraction.md | 22 ++++++ sidebars.js | 50 +++++++++++++ 20 files changed, 534 insertions(+) create mode 100644 docs/nada-by-example.md create mode 100644 docs/nada-by-example/addition.md create mode 100644 docs/nada-by-example/comparison.md create mode 100644 docs/nada-by-example/debugging.md create mode 100644 docs/nada-by-example/division.md create mode 100644 docs/nada-by-example/equality.md create mode 100644 docs/nada-by-example/for-loop.md create mode 100644 docs/nada-by-example/hello-world.md create mode 100644 docs/nada-by-example/helper-function.md create mode 100644 docs/nada-by-example/if-else.md create mode 100644 docs/nada-by-example/list-comprehensions.md create mode 100644 docs/nada-by-example/modulo.md create mode 100644 docs/nada-by-example/multiplication.md create mode 100644 docs/nada-by-example/power.md create mode 100644 docs/nada-by-example/probabilistic-truncation.md create mode 100644 docs/nada-by-example/reveal.md create mode 100644 docs/nada-by-example/shift-left.md create mode 100644 docs/nada-by-example/shift-right.md create mode 100644 docs/nada-by-example/subtraction.md diff --git a/docs/nada-by-example.md b/docs/nada-by-example.md new file mode 100644 index 0000000..65817f9 --- /dev/null +++ b/docs/nada-by-example.md @@ -0,0 +1,9 @@ +--- +displayed_sidebar: nadaByExampleSidebar +--- + +# Introduction + +This is an introduction to the [Nada language](/nada-lang) with examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. + +Version: [nada-dsl 0.4.0](https://pypi.org/project/nada-dsl/0.4.0/) diff --git a/docs/nada-by-example/addition.md b/docs/nada-by-example/addition.md new file mode 100644 index 0000000..1333c4a --- /dev/null +++ b/docs/nada-by-example/addition.md @@ -0,0 +1,22 @@ +# Addition + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml +``` + + + + diff --git a/docs/nada-by-example/comparison.md b/docs/nada-by-example/comparison.md new file mode 100644 index 0000000..d32c74b --- /dev/null +++ b/docs/nada-by-example/comparison.md @@ -0,0 +1,75 @@ +# Comparison + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Less than `<` + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_lt.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_lt_test.yaml +``` + + + +## Less than or equal to `<=` + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_lte.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_lte_test.yaml +``` + + + +## Greater than `>` + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_gt.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_gt_test.yaml +``` + + + +## Greater than or equal to `>=` + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_gte.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_gte_test.yaml +``` + + + + + diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md new file mode 100644 index 0000000..6821322 --- /dev/null +++ b/docs/nada-by-example/debugging.md @@ -0,0 +1,19 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Debugging + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/debug.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/debug_test.yaml +``` + + diff --git a/docs/nada-by-example/division.md b/docs/nada-by-example/division.md new file mode 100644 index 0000000..63054ef --- /dev/null +++ b/docs/nada-by-example/division.md @@ -0,0 +1,22 @@ +# Division + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/division.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/division_test.yaml +``` + + + + diff --git a/docs/nada-by-example/equality.md b/docs/nada-by-example/equality.md new file mode 100644 index 0000000..bebecf1 --- /dev/null +++ b/docs/nada-by-example/equality.md @@ -0,0 +1,38 @@ +# Equality (Equals) + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Private equality `==` + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/equality.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/equality_test.yaml +``` + + + +## Public output equality `==` + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/equality_public.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/equality_public_test.yaml +``` + + \ No newline at end of file diff --git a/docs/nada-by-example/for-loop.md b/docs/nada-by-example/for-loop.md new file mode 100644 index 0000000..972d148 --- /dev/null +++ b/docs/nada-by-example/for-loop.md @@ -0,0 +1,22 @@ +# For Loop + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/for_loop.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/for_loop_test.yaml +``` + + + + diff --git a/docs/nada-by-example/hello-world.md b/docs/nada-by-example/hello-world.md new file mode 100644 index 0000000..a059b74 --- /dev/null +++ b/docs/nada-by-example/hello-world.md @@ -0,0 +1,19 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Hello, World + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/hello_world.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/hello_world_test.yaml +``` + + diff --git a/docs/nada-by-example/helper-function.md b/docs/nada-by-example/helper-function.md new file mode 100644 index 0000000..e9fe74f --- /dev/null +++ b/docs/nada-by-example/helper-function.md @@ -0,0 +1,22 @@ +# Helper Functions + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/list_comprehensions_with_helper.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/list_comprehensions_with_helper_test.yaml +``` + + + + diff --git a/docs/nada-by-example/if-else.md b/docs/nada-by-example/if-else.md new file mode 100644 index 0000000..995a34e --- /dev/null +++ b/docs/nada-by-example/if-else.md @@ -0,0 +1,38 @@ +# If / Else (Ternary) + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## If / Else with a public condition + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/if_else_public.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/if_else_public_test.yaml +``` + + + +## If / Else with a private condition + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/if_else_private.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/if_else_private_test.yaml +``` + + \ No newline at end of file diff --git a/docs/nada-by-example/list-comprehensions.md b/docs/nada-by-example/list-comprehensions.md new file mode 100644 index 0000000..067e2ce --- /dev/null +++ b/docs/nada-by-example/list-comprehensions.md @@ -0,0 +1,22 @@ +# List Comprehensions + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/list_comprehensions.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/list_comprehensions_test.yaml +``` + + + + diff --git a/docs/nada-by-example/modulo.md b/docs/nada-by-example/modulo.md new file mode 100644 index 0000000..e6d25c7 --- /dev/null +++ b/docs/nada-by-example/modulo.md @@ -0,0 +1,22 @@ +# Modulo + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/modulo.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/modulo_test.yaml +``` + + + + diff --git a/docs/nada-by-example/multiplication.md b/docs/nada-by-example/multiplication.md new file mode 100644 index 0000000..c450015 --- /dev/null +++ b/docs/nada-by-example/multiplication.md @@ -0,0 +1,22 @@ +# Multiplication + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/multiplication.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/multiplication_test.yaml +``` + + + + diff --git a/docs/nada-by-example/power.md b/docs/nada-by-example/power.md new file mode 100644 index 0000000..496796d --- /dev/null +++ b/docs/nada-by-example/power.md @@ -0,0 +1,22 @@ +# Power + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/power.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/power_test.yaml +``` + + + + diff --git a/docs/nada-by-example/probabilistic-truncation.md b/docs/nada-by-example/probabilistic-truncation.md new file mode 100644 index 0000000..7bb2e5f --- /dev/null +++ b/docs/nada-by-example/probabilistic-truncation.md @@ -0,0 +1,22 @@ +# Probabilistic Truncation + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/probabilistic_truncation.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/probabilistic_truncation_test.yaml +``` + + + + diff --git a/docs/nada-by-example/reveal.md b/docs/nada-by-example/reveal.md new file mode 100644 index 0000000..7df8ccc --- /dev/null +++ b/docs/nada-by-example/reveal.md @@ -0,0 +1,22 @@ +# Reveal + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/reveal.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/reveal_test.yaml +``` + + + + diff --git a/docs/nada-by-example/shift-left.md b/docs/nada-by-example/shift-left.md new file mode 100644 index 0000000..f9c9f32 --- /dev/null +++ b/docs/nada-by-example/shift-left.md @@ -0,0 +1,22 @@ +# Left Shift + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/shift_left.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/shift_left_test.yaml +``` + + + + diff --git a/docs/nada-by-example/shift-right.md b/docs/nada-by-example/shift-right.md new file mode 100644 index 0000000..5097524 --- /dev/null +++ b/docs/nada-by-example/shift-right.md @@ -0,0 +1,22 @@ +# Right Shift + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/shift_right.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/shift_right_test.yaml +``` + + + + diff --git a/docs/nada-by-example/subtraction.md b/docs/nada-by-example/subtraction.md new file mode 100644 index 0000000..e6129bb --- /dev/null +++ b/docs/nada-by-example/subtraction.md @@ -0,0 +1,22 @@ +# Subtraction + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/subtraction.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/subtraction_test.yaml +``` + + + + diff --git a/sidebars.js b/sidebars.js index 5f97670..16beac2 100644 --- a/sidebars.js +++ b/sidebars.js @@ -333,6 +333,11 @@ const sidebars = { }, ], }, + { + type: 'link', + label: 'Nada by Example', + href: '/nada-by-example', + }, ], }, 'limitations', @@ -408,6 +413,51 @@ const sidebars = { href: 'https://nillion.com/news', }, ], + nadaByExampleSidebar: [ + { + type: 'html', + className: 'sidebar-title', + value: 'Nada by Example', + defaultStyle: true, + }, + 'nada-by-example', + 'nada-by-example/hello-world', + 'nada-by-example/debugging', + { + type: 'link', + label: 'Nada Language Docs', + href: 'https://docs.nillion.com/nada-lang', + }, + { + type: 'html', + className: 'sidebar-title', + value: 'Nada Operations', + defaultStyle: true, + }, + 'nada-by-example/addition', + 'nada-by-example/subtraction', + 'nada-by-example/multiplication', + 'nada-by-example/division', + 'nada-by-example/power', + 'nada-by-example/modulo', + 'nada-by-example/shift-left', + 'nada-by-example/shift-right', + 'nada-by-example/probabilistic-truncation', + 'nada-by-example/comparison', + 'nada-by-example/equality', + 'nada-by-example/if-else', + 'nada-by-example/reveal', + { + type: 'html', + className: 'sidebar-title', + value: 'Programming with Nada', + defaultStyle: true, + }, + 'nada-by-example/list-comprehensions', + 'nada-by-example/helper-function', + 'nada-by-example/for-loop', + + ] }; export default sidebars; From 783875a950568ae9b10ab404c0beecb93a53df99 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 24 Jul 2024 18:11:21 -0700 Subject: [PATCH 02/19] add nada-by-example repo quickstart --- docs/_python-version-info.mdx | 10 ++ docs/multi-party-computation.md | 2 +- docs/nada-by-example-quickstart.md | 177 +++++++++++++++++++++++++++++ docs/nada-by-example.md | 8 +- docs/python-client-reference.md | 4 +- docs/quickstart-nada.md | 12 +- docs/quickstart-testnet.md | 2 +- sidebars.js | 12 +- 8 files changed, 207 insertions(+), 20 deletions(-) create mode 100644 docs/_python-version-info.mdx create mode 100644 docs/nada-by-example-quickstart.md diff --git a/docs/_python-version-info.mdx b/docs/_python-version-info.mdx new file mode 100644 index 0000000..5e6bd9b --- /dev/null +++ b/docs/_python-version-info.mdx @@ -0,0 +1,10 @@ +:::info + +You'll need [python3](https://www.python.org/downloads/) version 3.11 or higher with a working [pip](https://pip.pypa.io/en/stable/getting-started/) installed to import the nada_dsl dependency. Before setting up your Python virtual environment, confirm that you have python3 (version >=3.11) and pip installed + +``` +python3 --version +python3 -m pip --version +``` + +::: \ No newline at end of file diff --git a/docs/multi-party-computation.md b/docs/multi-party-computation.md index 64f86c5..a83cbc4 100644 --- a/docs/multi-party-computation.md +++ b/docs/multi-party-computation.md @@ -15,7 +15,7 @@ MPC enables computation over inputs from multiple parties while keeping the actu ### Classic Scenario: The Millionaire Problem -The "Millionaires Problem" is a classic MPC scenario, first introduced by Andrew Yao in 1982. In the "Millionaires Problem" problem, two millionaires want to find out who is richer without disclosing their actual net worth. Using MPC, the millionaires can jointly compute who has more money without revealing their individual net worths to each other or anyone else. This is achieved through a series of cryptographic operations that allow each party to input their net worth into a shared computation. The computation is structured in a way that it only outputs the comparison result (i.e., which millionaire is richer) without leaking any specifics about their respective net worths. This problem showcases the power of MPC - it can preserve privacy while enabling collaborative computation. +The "millionaires Problem" is a classic MPC scenario, first introduced by Andrew Yao in 1982. In the "millionaires Problem" problem, two millionaires want to find out who is richer without disclosing their actual net worth. Using MPC, the millionaires can jointly compute who has more money without revealing their individual net worths to each other or anyone else. This is achieved through a series of cryptographic operations that allow each party to input their net worth into a shared computation. The computation is structured in a way that it only outputs the comparison result (i.e., which millionaire is richer) without leaking any specifics about their respective net worths. This problem showcases the power of MPC - it can preserve privacy while enabling collaborative computation. ### Real World Application: The 2008 Danish Sugar Beet Auction diff --git a/docs/nada-by-example-quickstart.md b/docs/nada-by-example-quickstart.md new file mode 100644 index 0000000..0d5226d --- /dev/null +++ b/docs/nada-by-example-quickstart.md @@ -0,0 +1,177 @@ +--- +displayed_sidebar: nadaByExampleSidebar +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import PythonVersionInfo from './\_python-version-info.mdx'; + +# Nada by Example Local Setup Quickstart + +All examples for "Nada by Example" live in the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) Github repo. Nada programs are in [`nada-by-example/src/`](https://github.com/NillionNetwork/nada-by-example/tree/main/src) and tests are in [`nada-by-example/tests`](https://github.com/NillionNetwork/nada-by-example/tree/main/tests). After you complete local repo setup following the instructions below, you can run an example from the repo locally. + +:::tip + +The [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo is a Nada project created with Nillion's [nada](/nada) tool. You can run all existing `nada` commands found in the [nada tool docs](/nada) to compile programs, get program requirements, run a program, and test a program. +::: + + +## Repo setup instructions + +Install Nillion, clone the nada-by-example repo, and set up a developer environment for your local nada-by-example repo. + +#### 1. Install Nillion globally + +Check to see if you have `nilup`, the Nillion installer installed + +``` +nilup -V +``` + +If you don't have nilup, install nilup + +``` +curl https://nilup.nilogy.xyz/install.sh | bash +``` + +#### 2. Use the latest version of the Nillion SDK + +Install and use the `latest` version of the Nillion SDK and tools. + +``` +nilup install latest +nilup use latest +``` + +#### 3. Optionally enable nilup telemetry, providing your Ethereum wallet address + +``` +nilup instrumentation enable --wallet +``` + +#### 4. Clone the nada-by-example repo + +Star [nada-by-example](https://github.com/NillionNetwork/nada-by-example) on Github so you have it for future reference. Then clone the repo + +``` +git clone https://github.com/NillionNetwork/nada-by-example.git +``` + +#### 5. Create a Python virtual environment and install Nada in nada-by-example + + + +``` +cd nada-by-example +python3 -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +``` + +#### 6. Build (compile) all Nada programs in the repo + +``` +nada build +``` + +`nada build` is a [nada tool command](/nada#build-compile-a-program) that compiles programs to create one compiled binary (.nada.bin) file per program listed in the [nada-project.toml file](https://github.com/NillionNetwork/nada-by-example/blob/main/nada-project.toml) in the target/ directory. + + +✅ Great work! Now that you've set up the nada-by-example repo, you can run any example. + +## How to run and test an example program + +Every Nada program example has a corresponding test file. Programs are in [`nada-by-example/src/`](https://github.com/NillionNetwork/nada-by-example/tree/main/src) and test files are in [`nada-by-example/tests`](https://github.com/NillionNetwork/nada-by-example/tree/main/tests). Running a program uses the inputs specified in the test file. Testing a program uses the inputs specified in the test file and also checks the outputs against the `expected_outputs` specified in the test file. + + +Run any program with the inputs specified in the test file with [`nada run`](/nada#run-a-program) + +``` +nada run +``` + +Test any program with the inputs and outputs specified in the test file with [`nada test`](/nada#test-a-program) + +``` +nada test +``` + + +### Run the addition example + +Here is the Nada program and test file for the addition example. The program is [src/addition.py](https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py) and the test file is [tests/addition_test.yaml](https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml) + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml +``` + + + +Run the addition program with `addition_test` test inputs: + +``` +nada run addition_test +``` + +The result of running this program is + +``` +(.venv) ➜ nada-by-example git:(main) nada run addition_test +Running program 'addition' with inputs from test file addition_test +Building ... +Running ... +Program ran! +Outputs: { + "sum": SecretInteger( + NadaInt( + 40, + ), + ), +} +``` + +### Test the addition example + +Here is the Nada program and test file for the addition example. The program is [src/addition.py](https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py) and the test file is [tests/addition_test.yaml](https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml) + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml +``` + + + +Test the addition program with `addition_test` test inputs and expected outputs: + +``` +nada test addition_test +``` + +The result of testing this program is + +``` +(.venv) ➜ nada-by-example git:(main) nada test addition_test +Running test: addition_test +Building ... +Running ... +addition_test: PASS +``` + +Testing the addition program with `addition_test` results in a PASS because the expected_outputs `sum` output matches the run result. \ No newline at end of file diff --git a/docs/nada-by-example.md b/docs/nada-by-example.md index 65817f9..6d379f7 100644 --- a/docs/nada-by-example.md +++ b/docs/nada-by-example.md @@ -2,8 +2,12 @@ displayed_sidebar: nadaByExampleSidebar --- -# Introduction +# Intro to Nada by Example -This is an introduction to the [Nada language](/nada-lang) with examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. +Welcome to **Nada by Example**, an introduction to the Nada language with reference examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. Nada is a Python language for defining MPC (multi party compute) programs on the [Nillion Network](/network). + +Developers can use Nada to write programs that handle secret inputs from multiple parties (aka multiple users). These programs compute in a way that ensures they are “blind” to the underlying data, meaning they cannot access or view the secret inputs. This concept is known as “blind computation.” + +To learn more about Nada, check out the full [Nada language docs here](/nada-lang). Version: [nada-dsl 0.4.0](https://pypi.org/project/nada-dsl/0.4.0/) diff --git a/docs/python-client-reference.md b/docs/python-client-reference.md index d0db75d..091d564 100644 --- a/docs/python-client-reference.md +++ b/docs/python-client-reference.md @@ -1116,7 +1116,7 @@ Returns the SDK client’s instance party ID, which can be used by the client to create program bindings (`ProgramBindings`, check examples). -Effectively, the party ID is equivalent to the the Peer ID +Effectively, the party ID is equivalent to the Peer ID used within libp2p for inter-node communication. It is a hash generated from the public key of the node’s key-pair (`NodeKey`). Not to be confused with the `user_id()` which is generated from the @@ -1362,7 +1362,7 @@ Store values in the Nillion Network. str * **Raises:** **TypeError** – When using bindings, the input party name provided (e.g. “InputPartyName”) must - match the input party name in the Nada program. Otherwise, we get a TypeError. + match the input party name in the Nada program. Otherwise, we get a TypeError. ### Example diff --git a/docs/quickstart-nada.md b/docs/quickstart-nada.md index 736600d..85a520d 100644 --- a/docs/quickstart-nada.md +++ b/docs/quickstart-nada.md @@ -1,6 +1,7 @@ import VenvSetup from './\_nada-venv-setup.mdx'; import UnderstandingProgram from './\_understanding-first-nada-program.mdx'; import CompileRunTest from './\_quickstart-compile-run-test.mdx'; +import PythonVersionInfo from './\_python-version-info.mdx'; # Create a Nada project and write your first Nada program @@ -20,16 +21,7 @@ nada init nada_quickstart_programs The Nillion Network leverages Nada, our MPC language, for defining MPC programs. Our initial implementation of Nada comes in the form of Nada, a Python DSL (Domain Specific Language). -:::info - -You'll need [python3](https://www.python.org/downloads/) version 3.11 or higher with a working [pip](https://pip.pypa.io/en/stable/getting-started/) installed to import the nada_dsl dependency. Before setting up your Python virtual environment, confirm that you have python3 (version >=3.11) and pip installed - -``` -python3 --version -python3 -m pip --version -``` - -::: + 0. Change directories into your new nada project directory diff --git a/docs/quickstart-testnet.md b/docs/quickstart-testnet.md index 071d1c8..d981848 100644 --- a/docs/quickstart-testnet.md +++ b/docs/quickstart-testnet.md @@ -56,4 +56,4 @@ https://github.com/NillionNetwork/cra-nillion/blob/main/vercel.json - reading about [Nillion concepts](/concepts) and the [Nada Language](nada-lang) - learning how to interact with and manage programs, secrets, and permissions on the Nillion Network with [Nillion Client](/js-client) -- challenging yourself to create a page that solves the [Millionaires Problem](/multi-party-computation#classic-scenario-the-millionaires-problem) +- challenging yourself to create a page that solves the [millionaires Problem](/multi-party-computation#classic-scenario-the-millionaires-problem) diff --git a/sidebars.js b/sidebars.js index 0be870d..69201e7 100644 --- a/sidebars.js +++ b/sidebars.js @@ -421,13 +421,17 @@ const sidebars = { value: 'Nada by Example', defaultStyle: true, }, - 'nada-by-example', + { + type: 'doc', + label: 'Introduction', + id: 'nada-by-example', + }, 'nada-by-example/hello-world', 'nada-by-example/debugging', { - type: 'link', - label: 'Nada Language Docs', - href: 'https://docs.nillion.com/nada-lang', + type: 'doc', + label: 'Local Setup Quickstart', + id: 'nada-by-example-quickstart', }, { type: 'html', From 780b77b81d258b5dbbba59f0d2a37919f4cd72e4 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 30 Jul 2024 15:42:26 -0700 Subject: [PATCH 03/19] add debugging and first program pages --- docs/_operations-table.mdx | 17 +++++ docs/nada-by-example-quickstart.md | 6 +- docs/nada-by-example.md | 4 +- docs/nada-by-example/debugging.md | 76 +++++++++++++++++++++ docs/nada-by-example/first-program.md | 90 +++++++++++++++++++++++++ docs/nada-by-example/hello-world.md | 19 ------ docs/nada-by-example/nada-operations.md | 7 ++ docs/nada-lang-operators.md | 19 +----- sidebars.js | 41 ++++++----- 9 files changed, 226 insertions(+), 53 deletions(-) create mode 100644 docs/_operations-table.mdx create mode 100644 docs/nada-by-example/first-program.md delete mode 100644 docs/nada-by-example/hello-world.md create mode 100644 docs/nada-by-example/nada-operations.md diff --git a/docs/_operations-table.mdx b/docs/_operations-table.mdx new file mode 100644 index 0000000..31bf079 --- /dev/null +++ b/docs/_operations-table.mdx @@ -0,0 +1,17 @@ + +| Operation with linked example | Syntax | Supported Types
(`P: Public`, `S: Secret`) | +| ----------------------------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| [Addition](/nada-by-example/addition) | `x + y` | `P ← P + P`,
`S ← P + S`,
`S ← S + P`,
`S ← S + S` | +| [Subtraction](/nada-by-example/subtraction) | `x - y` | `P ← P - P`,
`S ← P - S`,
`S ← S - P`,
`S ← S - S` | +| [Multiplication](/nada-by-example/multiplication) | `x * y` | `P ← P * P`,
`S ← P * S`,
`S ← S * P`,
`S ← S * S` | +| [Power](/nada-by-example/power) | `x ** y` | `P ← P ** P` | +| [Division](/nada-by-example/division) | `x / y` | `P ← P / P`,
`S ← P / S`,
`S ← S / P`,
`S ← S / S` | +| [Modulo](/nada-by-example/modulo) | `x % y` | `P ← P % P`,
`S ← P % S`,
`S ← S % P`,
`S ← S % S` | +| [Left shift](/nada-by-example/shift-left) and [Right shift](/nada-by-example/shift-right) | `x << y`,
`x >> y` | `P ← P << P`,
`S ← S << P` | +| [Probabilistic truncation](/nada-by-example/probabilistic-truncation) | `x.trunc_pr(y)` | `S ← S.trunc_pr(P)` | +| [Comparisons](/nada-by-example/comparison) | `x < y`,
`x <= y`,
`x > y`,
`x >= y` | `P ← P < P`,
`S ← P < S`,
`S ← S < P`,
`S ← S < S` | +| [Ternary](/nada-by-example/if-else) _"if else"_
(public condition) | `cond.if_else(x, y)` | `P ← P.if_else(P, P)`,
`S ← P.if_else(P, S)`,
`S ← P.if_else(S, P)`,
`S ← P.if_else(S, S)` | +| [Ternary](/nada-by-example/if-else) _"if else"_
(secret condition) | `cond.if_else(x, y)` | `S ← S.if_else(P, P)`,
`S ← S.if_else(P, S)`,
`S ← S.if_else(S, P)`,
`S ← S.if_else(S, S)` | +| [Reveal](/nada-by-example/reveal)
(convert a private
value into a public value) | `x.reveal()` | `P ← S.reveal()` | +| [Equality](/nada-by-example/equality) | `x == y` | `S ← S == S`,
`S ← S == P`,
`S ← P == S`,
`P ← P == P` | +| [Public Output Equality](/nada-by-example/equality)
(publicly output if two secrets are equal) | `x.public_equals(y)` | `P ← S.public_equals(S)` | diff --git a/docs/nada-by-example-quickstart.md b/docs/nada-by-example-quickstart.md index 0d5226d..b2eb520 100644 --- a/docs/nada-by-example-quickstart.md +++ b/docs/nada-by-example-quickstart.md @@ -174,4 +174,8 @@ Running ... addition_test: PASS ``` -Testing the addition program with `addition_test` results in a PASS because the expected_outputs `sum` output matches the run result. \ No newline at end of file +Testing the addition program with `addition_test` results in a PASS because the expected_outputs `sum` output matches the run result. + +## Keep exploring examples + +🥳 You're all set up to run and test any example in [nada-by-example](https://github.com/NillionNetwork/nada-by-example). Keep exploring what's possible with Nada by running the rest of the programs in the repo. \ No newline at end of file diff --git a/docs/nada-by-example.md b/docs/nada-by-example.md index 6d379f7..d82910c 100644 --- a/docs/nada-by-example.md +++ b/docs/nada-by-example.md @@ -4,9 +4,9 @@ displayed_sidebar: nadaByExampleSidebar # Intro to Nada by Example -Welcome to **Nada by Example**, an introduction to the Nada language with reference examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. Nada is a Python language for defining MPC (multi party compute) programs on the [Nillion Network](/network). +Welcome to **Nada by Example**, an introduction to the Nada language with reference examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. Nada is a Python-based language for defining MPC (Multi-Party Compute) programs on the [Nillion Network](/network). -Developers can use Nada to write programs that handle secret inputs from multiple parties (aka multiple users). These programs compute in a way that ensures they are “blind” to the underlying data, meaning they cannot access or view the secret inputs. This concept is known as “blind computation.” +Developers can use Nada to write programs that handle secret inputs from multiple parties (i.e., multiple users). These programs compute in a way that ensures they are “blind” to the underlying data, meaning they cannot access or view the secret inputs. This concept is known as “blind computation.” To learn more about Nada, check out the full [Nada language docs here](/nada-lang). diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index 6821322..e548940 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -3,9 +3,16 @@ import TabItem from '@theme/TabItem'; # Debugging +If you come from a Python background, you might be used to using print statements to debug your code. Today, Nada programs do not support print statements, and compilation will fail if any are included. The best way to debug a Nada program is to raise a Python exception. + +## Debugging by raising exceptions + + +Uncomment any one of the raise Exception() lines, then re-build this program with `nada build debug` to print the inside of the exception to the terminal + ```python reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/src/debug.py ``` @@ -17,3 +24,72 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/debug_test.yam ``` + +### Type exception + +This exception prints the data type of `sum` to your terminal. When debugging with `type()`, double check that your Nada operation supports the type raised in the exception by looking at the [Nada Operations](/nada-by-example/nada-operations) Supported Types column. + +``` +raise Exception(type(sum)) +``` + +``` +nada run debug_test +Running program 'debug' with inputs from test file debug_test +Building ... +Error: + 0: Traceback (most recent call last): + File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 97, in + output = compile(sys.argv[1]) + ^^^^^^^^^^^^^^^^^^^^ + File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/timer.py", line 116, in wrapper + value = func(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^ + File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 48, in compile + outputs = main() + ^^^^^^ + File "/Users/steph/Desktop/nillion/nada-by-example/src/debug.py", line 15, in nada_main + raise Exception(type(sum)) + Exception: + 0: + +Location: + tools/nada/src/build.rs:15 +``` + +### Operation exception + +This exception prints the operation type of `sum` to your terminal. When debugging with operation types, check that the Nada operation type and syntax are correct by looking at the [Nada Operations](/nada-by-example/nada-operations) Syntax and Supported Types columns. + + +``` +raise Exception(sum) +``` + +``` +nada run debug_test +Running program 'debug' with inputs from test file debug_test +Building ... +Error: + 0: Traceback (most recent call last): + File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 97, in + output = compile(sys.argv[1]) + ^^^^^^^^^^^^^^^^^^^^ + File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/timer.py", line 116, in wrapper + value = func(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^ + File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 48, in compile + outputs = main() + ^^^^^^ + File "/Users/steph/Desktop/nillion/nada-by-example/src/debug.py", line 16, in nada_main + raise Exception(sum) + Exception: SecretInteger(inner=) + 0: + +Location: + tools/nada/src/build.rs:15 +``` + +## Next steps + +🐛 Now that you've learned to debug, you're ready play with Nada programs. Move on to the next section where you will set up a local environment and run and test Nada programs locally following the [Nada by Example Local Setup Quickstart](/nada-by-example-quickstart). \ No newline at end of file diff --git a/docs/nada-by-example/first-program.md b/docs/nada-by-example/first-program.md new file mode 100644 index 0000000..ac18af0 --- /dev/null +++ b/docs/nada-by-example/first-program.md @@ -0,0 +1,90 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Your First Nada Program + +Welcome to your first Nada program example! This example is an addition program that will help you understand the basics of writing a Nada program and introduce key concepts such as a `Party`, `Input`, `SecretInteger`, `Operation`, and `Output`. + +This addition program in Nada demonstrates how to handle secret inputs from multiple parties, perform a computation (addition), and produce an output for another party. + +## Nada program and test file + + + + + +The `addition` Nada program takes in a secret input from Alice and a secret input from Bob. It runs an addition operation to get the sum of the two secret inputs. The Nada program returns an output, the sum, to Charlie who never sees the values of Alice or Bob's secret inputs. + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py +``` + + + + +You can auto-generate a test file like this one for any nada program with the [nada tool](/nada#generate-a-test-file). A test file verifies that the program works as expected. It provides test inputs and defines the expected outputs given the inputs. You'll learn how to run programs and test programs as part of the [Local Setup Quickstart](/nada-by-example-quickstart) + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml +``` + + + + + + +## Nada Program Key Concepts + +### Parties + +A `Party` represents a user or entity participating in the computation. A party can provide inputs and/or receive outputs. The addition program has 3 parties named Alice, Bob, and Charlie. Alice and Bob provide inputs to the program. Charlie receives the output of the program. + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py#L4-L6 +``` + +### Inputs + +An `Input` is a value provided to a Nada program by a specific party. Inputs are wrapped with one of the following `Public` or `Secret` data types: + +| `Public` | `Secret` | +| ----------------------- | ----------------------- | +| `PublicInteger` | `SecretInteger` | +| `PublicUnsignedInteger` | `SecretUnsignedInteger` | + +The addition program has two `SecretInteger` typed `Input`: + +1. `num_1` provided by Alice +2. `num_2` provided by Bob. + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py#L7-L8 +``` + +### Operations + +An operation is a computation performed on inputs to produce a result. In Nada, operations can be performed on both public and secret data types. Check out the full list of available [Nada operations here](/nada-by-example/nada-operations). + +The addition program involves one operation, addition, to sum the 2 secret inputs. + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py#L9 +``` + +### Outputs + +An `Output` defines how the result of the computation is shared with the parties. It ensures that the result of blind computation is properly revealed only to the intended party or parties. + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py#L10 +``` + +The addition program returns one output, the sum to Charlie. Charlie can see the resulting sum, but never sees the values of Alice or Bob's secret inputs that were added together to get the sum. This shows the power of blind computation! + +## Wrap up + +In this example, you learned how to use Nada to create a multiplication program that performs blind computation. By defining Party, Input, SecretInteger, performing an Operation, and specifying Output, you can compute on secret inputs from multiple users. This ensures that sensitive data remains confidential throughout the computation process. + +The power of Nada lies in its ability to compute on secret inputs without revealing the underlying data to any party involved. This makes Nada programs perfect for applications requiring high levels of privacy and security. + +Continue learning and experimenting with Nada by **learning how to debug a Nada program** in the next section. \ No newline at end of file diff --git a/docs/nada-by-example/hello-world.md b/docs/nada-by-example/hello-world.md deleted file mode 100644 index a059b74..0000000 --- a/docs/nada-by-example/hello-world.md +++ /dev/null @@ -1,19 +0,0 @@ -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -# Hello, World - - - - -```python reference showGithubLink -https://github.com/NillionNetwork/nada-by-example/blob/main/src/hello_world.py -``` - - - -```python reference showGithubLink -https://github.com/NillionNetwork/nada-by-example/blob/main/tests/hello_world_test.yaml -``` - - diff --git a/docs/nada-by-example/nada-operations.md b/docs/nada-by-example/nada-operations.md new file mode 100644 index 0000000..330f256 --- /dev/null +++ b/docs/nada-by-example/nada-operations.md @@ -0,0 +1,7 @@ +import NadaOperationsTable from '../\_operations-table.mdx'; + +# Nada Operations + +This chart shows all supported Nada operations, their syntax, and supported data types. Each operation has a linked example Nada program. + + \ No newline at end of file diff --git a/docs/nada-lang-operators.md b/docs/nada-lang-operators.md index d9c9b1e..5c9fcc7 100644 --- a/docs/nada-lang-operators.md +++ b/docs/nada-lang-operators.md @@ -1,22 +1,9 @@ +import NadaOperationsTable from './\_operations-table.mdx'; + # Built-In Operations Overview of the primitive and the array Nada operations. ## Primitive Operations -| Name | Syntax | Supported Types
(`P: Public`, `S: Secret`) | -| ----------------------------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | -| Addition | `x + y` | `P ← P + P`,
`S ← P + S`,
`S ← S + P`,
`S ← S + S` | -| Subtraction | `x - y` | `P ← P - P`,
`S ← P - S`,
`S ← S - P`,
`S ← S - S` | -| Multiplication | `x * y` | `P ← P * P`,
`S ← P * S`,
`S ← S * P`,
`S ← S * S` | -| Power | `x ** y` | `P ← P ** P` | -| Division | `x / y` | `P ← P / P`,
`S ← P / S`,
`S ← S / P`,
`S ← S / S` | -| Modulo | `x % y` | `P ← P % P`,
`S ← P % S`,
`S ← S % P`,
`S ← S % S` | -| Shifts | `x << y`,
`x >> y` | `P ← P << P`,
`S ← S << P` | -| Probabilistic truncation | `x.trunc_pr(y)` | `S ← S.trunc_pr(P)` | -| Comparisons | `x < y`,
`x <= y`,
`x > y`,
`x >= y` | `P ← P < P`,
`S ← P < S`,
`S ← S < P`,
`S ← S < S` | -| Ternary _"if else"_
(public condition) | `cond.if_else(x, y)` | `P ← P.if_else(P, P)`,
`S ← P.if_else(P, S)`,
`S ← P.if_else(S, P)`,
`S ← P.if_else(S, S)` | -| Ternary _"if else"_
(secret condition) | `cond.if_else(x, y)` | `S ← S.if_else(P, P)`,
`S ← S.if_else(P, S)`,
`S ← S.if_else(S, P)`,
`S ← S.if_else(S, S)` | -| Reveal
(convert a private
value into a public value) | `x.reveal()` | `P ← S.reveal()` | -| Equality | `x == y` | `S ← S == S`,
`S ← S == P`,
`S ← P == S`,
`P ← P == P` | -| Public Output Equality
(publicly output if two secrets are equal) | `x.public_equals(y)` | `P ← S.public_equals(S)` | + \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 69201e7..e7cf52c 100644 --- a/sidebars.js +++ b/sidebars.js @@ -426,7 +426,7 @@ const sidebars = { label: 'Introduction', id: 'nada-by-example', }, - 'nada-by-example/hello-world', + 'nada-by-example/first-program', 'nada-by-example/debugging', { type: 'doc', @@ -436,22 +436,33 @@ const sidebars = { { type: 'html', className: 'sidebar-title', - value: 'Nada Operations', + value: 'Nada Program Examples', defaultStyle: true, }, - 'nada-by-example/addition', - 'nada-by-example/subtraction', - 'nada-by-example/multiplication', - 'nada-by-example/division', - 'nada-by-example/power', - 'nada-by-example/modulo', - 'nada-by-example/shift-left', - 'nada-by-example/shift-right', - 'nada-by-example/probabilistic-truncation', - 'nada-by-example/comparison', - 'nada-by-example/equality', - 'nada-by-example/if-else', - 'nada-by-example/reveal', + { + type: 'category', + label: 'Nada Operations', + link: { + type: 'doc', + id: 'nada-by-example/nada-operations', + }, + collapsed: false, + items: [ + 'nada-by-example/addition', + 'nada-by-example/subtraction', + 'nada-by-example/multiplication', + 'nada-by-example/division', + 'nada-by-example/power', + 'nada-by-example/modulo', + 'nada-by-example/shift-left', + 'nada-by-example/shift-right', + 'nada-by-example/probabilistic-truncation', + 'nada-by-example/comparison', + 'nada-by-example/equality', + 'nada-by-example/if-else', + 'nada-by-example/reveal', + ] + }, { type: 'html', className: 'sidebar-title', From b434d9344b96336444fb6f71922c8c8893ec9e20 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 30 Jul 2024 16:01:53 -0700 Subject: [PATCH 04/19] add nada ai and nada numpy examples --- sidebars.js | 91 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 11 deletions(-) diff --git a/sidebars.js b/sidebars.js index e7cf52c..25f3985 100644 --- a/sidebars.js +++ b/sidebars.js @@ -232,11 +232,6 @@ const sidebars = { label: 'Lists and Iteration', id: 'nada-lang-tutorial-lists-and-iteration', }, - { - type: 'link', - label: 'More Example Programs', - href: 'https://github.com/NillionNetwork/nillion-python-starter/tree/main/programs', - }, { type: 'doc', label: 'Debugging', @@ -433,6 +428,16 @@ const sidebars = { label: 'Local Setup Quickstart', id: 'nada-by-example-quickstart', }, + { + type: 'link', + label: 'Ask a Nada Question', + href: 'https://github.com/orgs/NillionNetwork/discussions/categories/q-a', + }, + { + type: 'link', + label: 'Report a Bug', + href: 'https://github.com/orgs/NillionNetwork/discussions/categories/bugs', + }, { type: 'html', className: 'sidebar-title', @@ -446,7 +451,6 @@ const sidebars = { type: 'doc', id: 'nada-by-example/nada-operations', }, - collapsed: false, items: [ 'nada-by-example/addition', 'nada-by-example/subtraction', @@ -463,16 +467,81 @@ const sidebars = { 'nada-by-example/reveal', ] }, + 'nada-by-example/list-comprehensions', + 'nada-by-example/helper-function', + 'nada-by-example/for-loop', { type: 'html', className: 'sidebar-title', - value: 'Programming with Nada', + value: 'Examples with Nada Libraries', defaultStyle: true, }, - 'nada-by-example/list-comprehensions', - 'nada-by-example/helper-function', - 'nada-by-example/for-loop', - + { + type: 'category', + label: 'Nada Numpy', + collapsible: true, + collapsed: false, + items: [ + { + type: 'link', + label: 'Dot product', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/dot_product', + }, + { + type: 'link', + label: 'Matrix multiplication', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/matrix_multiplication', + }, + { + type: 'link', + label: 'Broadcasting', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/broadcasting', + }, + { + type: 'link', + label: 'Rational numbers', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/rational_numbers', + }, + ], + }, + { + type: 'category', + label: 'Nada AI', + collapsible: true, + collapsed: false, + items: [ + { + type: 'link', + label: 'Linear regression', + href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/linear_regression', + }, + { + type: 'link', + label: 'Neural network', + href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/neural_net', + }, + { + type: 'link', + label: 'Complex model', + href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/complex_model', + }, + { + type: 'link', + label: 'Time series', + href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/time_series', + }, + { + type: 'link', + label: 'Spam detection', + href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/spam_detection', + }, + { + type: 'link', + label: 'Convolutional Neural Network', + href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/conv_net', + } + ], + }, ] }; From eb3b4b104a3646a18742b75009bb9b74bd3d748e Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 30 Jul 2024 16:09:06 -0700 Subject: [PATCH 05/19] link to more debugging techniques --- docs/nada-by-example.md | 2 +- docs/nada-by-example/debugging.md | 2 +- sidebars.js | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/nada-by-example.md b/docs/nada-by-example.md index d82910c..5ebfc7e 100644 --- a/docs/nada-by-example.md +++ b/docs/nada-by-example.md @@ -2,7 +2,7 @@ displayed_sidebar: nadaByExampleSidebar --- -# Intro to Nada by Example +# Nada by Example Welcome to **Nada by Example**, an introduction to the Nada language with reference examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. Nada is a Python-based language for defining MPC (Multi-Party Compute) programs on the [Nillion Network](/network). diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index e548940..3440439 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -3,7 +3,7 @@ import TabItem from '@theme/TabItem'; # Debugging -If you come from a Python background, you might be used to using print statements to debug your code. Today, Nada programs do not support print statements, and compilation will fail if any are included. The best way to debug a Nada program is to raise a Python exception. +If you come from a Python background, you might be used to using print statements to debug your code. Today, Nada programs do not support print statements, and compilation will fail if any are included. The best way to debug a Nada program is to raise a Python exception. Check out other [best practices and Nada debugging techniques, documented here](/nada-debugging). ## Debugging by raising exceptions diff --git a/sidebars.js b/sidebars.js index 25f3985..bb781cc 100644 --- a/sidebars.js +++ b/sidebars.js @@ -484,7 +484,7 @@ const sidebars = { items: [ { type: 'link', - label: 'Dot product', + label: 'Dot Product', href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/dot_product', }, { @@ -499,7 +499,7 @@ const sidebars = { }, { type: 'link', - label: 'Rational numbers', + label: 'Rational Numbers', href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/rational_numbers', }, ], @@ -512,27 +512,27 @@ const sidebars = { items: [ { type: 'link', - label: 'Linear regression', + label: 'Linear Regression', href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/linear_regression', }, { type: 'link', - label: 'Neural network', + label: 'Neural Network', href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/neural_net', }, { type: 'link', - label: 'Complex model', + label: 'Complex Model', href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/complex_model', }, { type: 'link', - label: 'Time series', + label: 'Time Series', href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/time_series', }, { type: 'link', - label: 'Spam detection', + label: 'Spam Detection', href: 'https://github.com/NillionNetwork/nada-ai/tree/main/examples/spam_detection', }, { From 83185fb589e0ab28b118a6cd199d28ed8ab1e420 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 30 Jul 2024 16:42:59 -0700 Subject: [PATCH 06/19] add nada by example docs header --- docusaurus.config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docusaurus.config.js b/docusaurus.config.js index ff899b4..55de9ac 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -78,6 +78,18 @@ const config = { src: 'img/logo.svg', }, items: [ + { + type: 'doc', + position: 'left', + docId: 'welcome', + label: 'Docs', + }, + { + type: 'doc', + position: 'left', + docId: 'nada-by-example', + label: 'Nada by Example', + }, { href: 'https://github.com/NillionNetwork', label: 'GitHub', From 45474267343480e26a31fbcf031593d619d7dd96 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 11:48:27 -0700 Subject: [PATCH 07/19] update debugging page to explain how to use print() --- docs/nada-by-example/debugging.md | 94 ++++++++++++++----------------- 1 file changed, 42 insertions(+), 52 deletions(-) diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index 3440439..0533c33 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -3,16 +3,44 @@ import TabItem from '@theme/TabItem'; # Debugging -If you come from a Python background, you might be used to using print statements to debug your code. Today, Nada programs do not support print statements, and compilation will fail if any are included. The best way to debug a Nada program is to raise a Python exception. Check out other [best practices and Nada debugging techniques, documented here](/nada-debugging). +When developing and debugging Nada programs, it can be helpful to inspect the values and types of variables at various points in your code. You can do this by adding Python `print()` statements, then running the file directly. -## Debugging by raising exceptions +## Debugging with print() + + +### 1. Include a Python main block + +To use print statements for debugging in a Nada program, you can add the following Python main block to the end of your Nada program file. This block ensures that the `nada_main()` function runs standalone as the main program when the script is executed directly. + +```python +if __name__ == "__main__": + nada_main() +``` + +### 2. Add print() statements + +Add print() statements within the Nada program to print variables or types of variables. + +### 3. Run the program with Python + +Run the program with Python to print any print() statements to the terminal. + +``` +python3 src/[program_name].py +``` + +### 4. Remove print() statments before compiling a Nada program + +Make sure to comment out or remove all print statements before compiling Nada programs, as Nada compilation will fail if any print statements are included. + +The Python main block can be left in for Nada program compilation. + +## Debugging example -Uncomment any one of the raise Exception() lines, then re-build this program with `nada build debug` to print the inside of the exception to the terminal - ```python reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/src/debug.py ``` @@ -25,69 +53,31 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/debug_test.yam -### Type exception +### Print type of variable -This exception prints the data type of `sum` to your terminal. When debugging with `type()`, double check that your Nada operation supports the type raised in the exception by looking at the [Nada Operations](/nada-by-example/nada-operations) Supported Types column. +Printing the type of a variable prints the Nada data type to your terminal as a class. When debugging with `type()`, double check that your Nada operation supports the type printed by looking at the [Nada Operations](/nada-by-example/nada-operations) Supported Types column. ``` -raise Exception(type(sum)) +print(type(sum)) ``` ``` -nada run debug_test -Running program 'debug' with inputs from test file debug_test -Building ... -Error: - 0: Traceback (most recent call last): - File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 97, in - output = compile(sys.argv[1]) - ^^^^^^^^^^^^^^^^^^^^ - File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/timer.py", line 116, in wrapper - value = func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^ - File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 48, in compile - outputs = main() - ^^^^^^ - File "/Users/steph/Desktop/nillion/nada-by-example/src/debug.py", line 15, in nada_main - raise Exception(type(sum)) - Exception: - 0: - -Location: - tools/nada/src/build.rs:15 +(.venv) ➜ nada-by-example git:(main) ✗ python3 src/debug.py + ``` -### Operation exception +### Print variable -This exception prints the operation type of `sum` to your terminal. When debugging with operation types, check that the Nada operation type and syntax are correct by looking at the [Nada Operations](/nada-by-example/nada-operations) Syntax and Supported Types columns. +Printing a variable prints the Nada data type of the variable and any applicable operation types to your terminal. When debugging with operation types, check that the Nada operation type and syntax are correct by looking at the [Nada Operations](/nada-by-example/nada-operations) Syntax and Supported Types columns. ``` -raise Exception(sum) +print(sum) ``` ``` -nada run debug_test -Running program 'debug' with inputs from test file debug_test -Building ... -Error: - 0: Traceback (most recent call last): - File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 97, in - output = compile(sys.argv[1]) - ^^^^^^^^^^^^^^^^^^^^ - File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/timer.py", line 116, in wrapper - value = func(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^ - File "/Users/steph/Desktop/nillion/nada-by-example/.venv/lib/python3.12/site-packages/nada_dsl/compile.py", line 48, in compile - outputs = main() - ^^^^^^ - File "/Users/steph/Desktop/nillion/nada-by-example/src/debug.py", line 16, in nada_main - raise Exception(sum) - Exception: SecretInteger(inner=) - 0: - -Location: - tools/nada/src/build.rs:15 +(.venv) ➜ nada-by-example git:(main) ✗ python3 src/debug.py +SecretInteger(inner=) ``` ## Next steps From 2e312517f278e20cd47badbf74586a212623e469 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 13:25:58 -0700 Subject: [PATCH 08/19] add primitive data types --- docs/_data-types-table.mdx | 4 +++ docs/nada-by-example/addition.md | 4 +-- docs/nada-by-example/first-program.md | 6 ++-- docs/nada-by-example/literal-data-type.md | 44 +++++++++++++++++++++++ docs/nada-by-example/nada-data-types.md | 11 ++++++ docs/nada-by-example/public-data-type.md | 44 +++++++++++++++++++++++ docs/nada-by-example/secret-data-type.md | 44 +++++++++++++++++++++++ docs/nada-lang-types.md | 9 +++-- sidebars.js | 13 +++++++ 9 files changed, 168 insertions(+), 11 deletions(-) create mode 100644 docs/_data-types-table.mdx create mode 100644 docs/nada-by-example/literal-data-type.md create mode 100644 docs/nada-by-example/nada-data-types.md create mode 100644 docs/nada-by-example/public-data-type.md create mode 100644 docs/nada-by-example/secret-data-type.md diff --git a/docs/_data-types-table.mdx b/docs/_data-types-table.mdx new file mode 100644 index 0000000..e65e331 --- /dev/null +++ b/docs/_data-types-table.mdx @@ -0,0 +1,4 @@ +| [Secret](/nada-by-example/secret-data-type) | [Public](/nada-by-example/public-data-type) | [Literals](/nada-by-example/literal-data-type) | +| ----------------------- | ----------------------- | ----------------- | +| `SecretInteger` | `PublicInteger` | `Integer` | +| `SecretUnsignedInteger` | `PublicUnsignedInteger` | `UnsignedInteger` | \ No newline at end of file diff --git a/docs/nada-by-example/addition.md b/docs/nada-by-example/addition.md index 1333c4a..6db4c1e 100644 --- a/docs/nada-by-example/addition.md +++ b/docs/nada-by-example/addition.md @@ -17,6 +17,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml ``` - - - + \ No newline at end of file diff --git a/docs/nada-by-example/first-program.md b/docs/nada-by-example/first-program.md index ac18af0..0df0a52 100644 --- a/docs/nada-by-example/first-program.md +++ b/docs/nada-by-example/first-program.md @@ -3,7 +3,7 @@ import TabItem from '@theme/TabItem'; # Your First Nada Program -Welcome to your first Nada program example! This example is an addition program that will help you understand the basics of writing a Nada program and introduce key concepts such as a `Party`, `Input`, `SecretInteger`, `Operation`, and `Output`. +Welcome to your first Nada program example! This example is an addition program that is meant to help you understand the basics of writing a Nada program and introduce key concepts such as a `Party`, `Input`, `SecretInteger`, `Operation`, and `Output`. This addition program in Nada demonstrates how to handle secret inputs from multiple parties, perform a computation (addition), and produce an output for another party. @@ -54,8 +54,8 @@ An `Input` is a value provided to a Nada program by a specific party. Inputs are The addition program has two `SecretInteger` typed `Input`: -1. `num_1` provided by Alice -2. `num_2` provided by Bob. +1. `num_1` input by Alice +2. `num_2` input by Bob. ```python reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py#L7-L8 diff --git a/docs/nada-by-example/literal-data-type.md b/docs/nada-by-example/literal-data-type.md new file mode 100644 index 0000000..57cf463 --- /dev/null +++ b/docs/nada-by-example/literal-data-type.md @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Literals + +Literals are constant values defined within the program rather than provided by a party. + +## Integer + +`Integer` represents a literal integer value. This value can be a negative integer, a positive integer, or zero. + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_literal.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_literal_test.yaml +``` + + + +## UnsignedInteger + +`UnsignedInteger` represents a literal unsigned integer value. This value can be zero or a positive integer. + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_literal_unsigned.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_literal_unsigned_test.yaml +``` + + \ No newline at end of file diff --git a/docs/nada-by-example/nada-data-types.md b/docs/nada-by-example/nada-data-types.md new file mode 100644 index 0000000..69ba5ca --- /dev/null +++ b/docs/nada-by-example/nada-data-types.md @@ -0,0 +1,11 @@ +import NadaDataTypesTable from '../\_data-types-table.mdx'; + +# Primitive Data Types + +This chart shows the primitive data types available in Nada. Each data type links to example Nada programs. + + + +[Secret](/nada-by-example/secret-data-type) and [Public](/nada-by-example/public-data-type) data types are used to specify user inputs to a Nada program. + +[Literals](/nada-by-example/literal-data-type) can only be used within a Nada program. \ No newline at end of file diff --git a/docs/nada-by-example/public-data-type.md b/docs/nada-by-example/public-data-type.md new file mode 100644 index 0000000..6f4f9be --- /dev/null +++ b/docs/nada-by-example/public-data-type.md @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Public + +The Public data type is used for inputs that are not sensitive and can be shown in the clear during computation. These input values are visible to the program. + +## PublicInteger + +`PublicInteger` represents a user input public integer value. This value can be a negative integer, a positive integer, or zero. + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_public.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_public_test.yaml +``` + + + +## PublicUnsignedInteger + +`PublicUnsignedInteger` represents a user input public unsigned integer value. This value can be zero or a positive integer. + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_public_unsigned.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_public_unsigned_test.yaml +``` + + \ No newline at end of file diff --git a/docs/nada-by-example/secret-data-type.md b/docs/nada-by-example/secret-data-type.md new file mode 100644 index 0000000..4de75ca --- /dev/null +++ b/docs/nada-by-example/secret-data-type.md @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Secret + +The Secret data type is used for inputs that need to be kept confidential during computation. These input values are not visible to the program. + +## SecretInteger + +`SecretInteger` represents a user input secret integer value. This value can be a negative integer, a positive integer, or zero. + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/multiplication.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/multiplication_test.yaml +``` + + + +## SecretUnsignedInteger + +`SecretUnsignedInteger` represents a user input secret unsigned integer value. This value can be zero or a positive integer. + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_unsigned.py +``` + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_unsigned_test.yaml +``` + + \ No newline at end of file diff --git a/docs/nada-lang-types.md b/docs/nada-lang-types.md index f0e3425..e9bb0dd 100644 --- a/docs/nada-lang-types.md +++ b/docs/nada-lang-types.md @@ -1,15 +1,14 @@ +import NadaDataTypesTable from './\_data-types-table.mdx'; + # Data Types Overview of the primitive and the compound Nada data types. ## Primitive Data Types -| `Public` | `Secret` | `Literals` | -| ----------------------- | ----------------------- | ----------------- | -| `PublicInteger` | `SecretInteger` | `Integer` | -| `PublicUnsignedInteger` | `SecretUnsignedInteger` | `UnsignedInteger` | + -`Public` and `Secret` data types can be used to specify user inputs as: +`Secret` and `Public` data types can be used to specify user inputs as: ```python a = SecretInteger(Input(name="a", party=party1)) diff --git a/sidebars.js b/sidebars.js index bb781cc..6ed2094 100644 --- a/sidebars.js +++ b/sidebars.js @@ -444,6 +444,19 @@ const sidebars = { value: 'Nada Program Examples', defaultStyle: true, }, + { + type: 'category', + label: 'Primitive Data Types', + link: { + type: 'doc', + id: 'nada-by-example/nada-data-types', + }, + items: [ + 'nada-by-example/secret-data-type', + 'nada-by-example/public-data-type', + 'nada-by-example/literal-data-type', + ] + }, { type: 'category', label: 'Nada Operations', From 71bfef65dbc38641818d6cb1fd4d2c8fb3ef084a Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 13:40:28 -0700 Subject: [PATCH 09/19] add instructions for generating a new test file --- docs/nada-by-example-quickstart.md | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docs/nada-by-example-quickstart.md b/docs/nada-by-example-quickstart.md index b2eb520..6f0b349 100644 --- a/docs/nada-by-example-quickstart.md +++ b/docs/nada-by-example-quickstart.md @@ -176,6 +176,52 @@ addition_test: PASS Testing the addition program with `addition_test` results in a PASS because the expected_outputs `sum` output matches the run result. +### Add a new test for the addition example + +Use the [nada tool](/nada#generate-a-test-file) to add a new test file named "addition_test_2" for the addition example. + +``` +nada generate-test --test-name addition_test_2 addition +``` + +This results in a new test file: `/tests/addition_test_2.yaml` + +``` +(.venv) ➜ nada-by-example git:(main) nada generate-test --test-name addition_test_2 addition +Generating test 'addition_test_2' for +Building ... +Generating test file ... +Test generated! +``` + +Update the values in the test file to anything you want, for example: + +```yaml +--- +program: addition +inputs: + num_1: + SecretInteger: "100" + num_2: + SecretInteger: "10" +expected_outputs: + sum: + SecretInteger: "110" + +``` + +#### Run addition with your new test + +``` +nada run addition_test_2 +``` + +#### Test addition with your new test + +``` +nada test addition_test_2 +``` + ## Keep exploring examples 🥳 You're all set up to run and test any example in [nada-by-example](https://github.com/NillionNetwork/nada-by-example). Keep exploring what's possible with Nada by running the rest of the programs in the repo. \ No newline at end of file From ca91f2f5ced3fe905aa32e708ef269419e1a12c7 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 13:58:49 -0700 Subject: [PATCH 10/19] update type to yaml, remove version --- docs/multi-party-computation.md | 2 +- docs/nada-by-example-quickstart.md | 4 ++-- docs/nada-by-example.md | 6 ++---- docs/nada-by-example/addition.md | 2 +- docs/nada-by-example/comparison.md | 8 ++++---- docs/nada-by-example/debugging.md | 8 +++++--- docs/nada-by-example/division.md | 2 +- docs/nada-by-example/equality.md | 4 ++-- docs/nada-by-example/for-loop.md | 2 +- docs/nada-by-example/helper-function.md | 2 +- docs/nada-by-example/if-else.md | 4 ++-- docs/nada-by-example/list-comprehensions.md | 2 +- docs/nada-by-example/literal-data-type.md | 4 ++-- docs/nada-by-example/modulo.md | 2 +- docs/nada-by-example/multiplication.md | 2 +- docs/nada-by-example/power.md | 2 +- docs/nada-by-example/probabilistic-truncation.md | 2 +- docs/nada-by-example/public-data-type.md | 4 ++-- docs/nada-by-example/reveal.md | 2 +- docs/nada-by-example/secret-data-type.md | 4 ++-- docs/nada-by-example/shift-left.md | 2 +- docs/nada-by-example/shift-right.md | 2 +- docs/nada-by-example/subtraction.md | 2 +- docs/quickstart-testnet.md | 2 +- 24 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/multi-party-computation.md b/docs/multi-party-computation.md index a83cbc4..64f86c5 100644 --- a/docs/multi-party-computation.md +++ b/docs/multi-party-computation.md @@ -15,7 +15,7 @@ MPC enables computation over inputs from multiple parties while keeping the actu ### Classic Scenario: The Millionaire Problem -The "millionaires Problem" is a classic MPC scenario, first introduced by Andrew Yao in 1982. In the "millionaires Problem" problem, two millionaires want to find out who is richer without disclosing their actual net worth. Using MPC, the millionaires can jointly compute who has more money without revealing their individual net worths to each other or anyone else. This is achieved through a series of cryptographic operations that allow each party to input their net worth into a shared computation. The computation is structured in a way that it only outputs the comparison result (i.e., which millionaire is richer) without leaking any specifics about their respective net worths. This problem showcases the power of MPC - it can preserve privacy while enabling collaborative computation. +The "Millionaires Problem" is a classic MPC scenario, first introduced by Andrew Yao in 1982. In the "Millionaires Problem" problem, two millionaires want to find out who is richer without disclosing their actual net worth. Using MPC, the millionaires can jointly compute who has more money without revealing their individual net worths to each other or anyone else. This is achieved through a series of cryptographic operations that allow each party to input their net worth into a shared computation. The computation is structured in a way that it only outputs the comparison result (i.e., which millionaire is richer) without leaking any specifics about their respective net worths. This problem showcases the power of MPC - it can preserve privacy while enabling collaborative computation. ### Real World Application: The 2008 Danish Sugar Beet Auction diff --git a/docs/nada-by-example-quickstart.md b/docs/nada-by-example-quickstart.md index 6f0b349..9e30596 100644 --- a/docs/nada-by-example-quickstart.md +++ b/docs/nada-by-example-quickstart.md @@ -110,7 +110,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml ``` @@ -152,7 +152,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml ``` diff --git a/docs/nada-by-example.md b/docs/nada-by-example.md index 5ebfc7e..bc887f2 100644 --- a/docs/nada-by-example.md +++ b/docs/nada-by-example.md @@ -4,10 +4,8 @@ displayed_sidebar: nadaByExampleSidebar # Nada by Example -Welcome to **Nada by Example**, an introduction to the Nada language with reference examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. Nada is a Python-based language for defining MPC (Multi-Party Compute) programs on the [Nillion Network](/network). +Welcome to **Nada by Example**, an introduction to the Nada language with reference examples from the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo. [Nada DSL](https://pypi.org/project/nada-dsl) is a Python-based language for defining MPC (Multi-Party Compute) programs on the [Nillion Network](/network). Developers can use Nada to write programs that handle secret inputs from multiple parties (i.e., multiple users). These programs compute in a way that ensures they are “blind” to the underlying data, meaning they cannot access or view the secret inputs. This concept is known as “blind computation.” -To learn more about Nada, check out the full [Nada language docs here](/nada-lang). - -Version: [nada-dsl 0.4.0](https://pypi.org/project/nada-dsl/0.4.0/) +To learn more about Nada, check out the full [Nada language docs here](/nada-lang). \ No newline at end of file diff --git a/docs/nada-by-example/addition.md b/docs/nada-by-example/addition.md index 6db4c1e..c2e0797 100644 --- a/docs/nada-by-example/addition.md +++ b/docs/nada-by-example/addition.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml ``` diff --git a/docs/nada-by-example/comparison.md b/docs/nada-by-example/comparison.md index d32c74b..ec8b25c 100644 --- a/docs/nada-by-example/comparison.md +++ b/docs/nada-by-example/comparison.md @@ -14,7 +14,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_lt.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_lt_test.yaml ``` @@ -31,7 +31,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_lte.p -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_lte_test.yaml ``` @@ -48,7 +48,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_gt.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_gt_test.yaml ``` @@ -65,7 +65,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/comparison_gte.p -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_gte_test.yaml ``` diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index 0533c33..1fd2563 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -3,9 +3,11 @@ import TabItem from '@theme/TabItem'; # Debugging -When developing and debugging Nada programs, it can be helpful to inspect the values and types of variables at various points in your code. You can do this by adding Python `print()` statements, then running the file directly. +When programming in Nada, keep this phrase in mind: Think Big, Code Small. Read about the "Think Big, Code Small" philosphy with [Nada best practices and more debugging tips here](/nada-debugging). + +# Debugging with print() -## Debugging with print() +When developing and debugging Nada programs, it can be helpful to inspect the values and types of variables at various points in your code. You can do this by adding Python `print()` statements, then running the file directly. ### 1. Include a Python main block @@ -47,7 +49,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/debug.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/debug_test.yaml ``` diff --git a/docs/nada-by-example/division.md b/docs/nada-by-example/division.md index 63054ef..98a1d2e 100644 --- a/docs/nada-by-example/division.md +++ b/docs/nada-by-example/division.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/division.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/division_test.yaml ``` diff --git a/docs/nada-by-example/equality.md b/docs/nada-by-example/equality.md index bebecf1..a946e03 100644 --- a/docs/nada-by-example/equality.md +++ b/docs/nada-by-example/equality.md @@ -14,7 +14,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/equality.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/equality_test.yaml ``` @@ -31,7 +31,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/equality_public. -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/equality_public_test.yaml ``` diff --git a/docs/nada-by-example/for-loop.md b/docs/nada-by-example/for-loop.md index 972d148..4459ff0 100644 --- a/docs/nada-by-example/for-loop.md +++ b/docs/nada-by-example/for-loop.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/for_loop.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/for_loop_test.yaml ``` diff --git a/docs/nada-by-example/helper-function.md b/docs/nada-by-example/helper-function.md index e9fe74f..a530412 100644 --- a/docs/nada-by-example/helper-function.md +++ b/docs/nada-by-example/helper-function.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/list_comprehensi -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/list_comprehensions_with_helper_test.yaml ``` diff --git a/docs/nada-by-example/if-else.md b/docs/nada-by-example/if-else.md index 995a34e..773797b 100644 --- a/docs/nada-by-example/if-else.md +++ b/docs/nada-by-example/if-else.md @@ -14,7 +14,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/if_else_public.p -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/if_else_public_test.yaml ``` @@ -31,7 +31,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/if_else_private. -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/if_else_private_test.yaml ``` diff --git a/docs/nada-by-example/list-comprehensions.md b/docs/nada-by-example/list-comprehensions.md index 067e2ce..801556f 100644 --- a/docs/nada-by-example/list-comprehensions.md +++ b/docs/nada-by-example/list-comprehensions.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/list_comprehensi -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/list_comprehensions_test.yaml ``` diff --git a/docs/nada-by-example/literal-data-type.md b/docs/nada-by-example/literal-data-type.md index 57cf463..d738b51 100644 --- a/docs/nada-by-example/literal-data-type.md +++ b/docs/nada-by-example/literal-data-type.md @@ -18,7 +18,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_literal -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_literal_test.yaml ``` @@ -37,7 +37,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_literal -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_literal_unsigned_test.yaml ``` diff --git a/docs/nada-by-example/modulo.md b/docs/nada-by-example/modulo.md index e6d25c7..cf994c9 100644 --- a/docs/nada-by-example/modulo.md +++ b/docs/nada-by-example/modulo.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/modulo.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/modulo_test.yaml ``` diff --git a/docs/nada-by-example/multiplication.md b/docs/nada-by-example/multiplication.md index c450015..a47f3bb 100644 --- a/docs/nada-by-example/multiplication.md +++ b/docs/nada-by-example/multiplication.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/multiplication.p -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/multiplication_test.yaml ``` diff --git a/docs/nada-by-example/power.md b/docs/nada-by-example/power.md index 496796d..274cad9 100644 --- a/docs/nada-by-example/power.md +++ b/docs/nada-by-example/power.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/power.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/power_test.yaml ``` diff --git a/docs/nada-by-example/probabilistic-truncation.md b/docs/nada-by-example/probabilistic-truncation.md index 7bb2e5f..07017d5 100644 --- a/docs/nada-by-example/probabilistic-truncation.md +++ b/docs/nada-by-example/probabilistic-truncation.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/probabilistic_tr -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/probabilistic_truncation_test.yaml ``` diff --git a/docs/nada-by-example/public-data-type.md b/docs/nada-by-example/public-data-type.md index 6f4f9be..57d4a1b 100644 --- a/docs/nada-by-example/public-data-type.md +++ b/docs/nada-by-example/public-data-type.md @@ -18,7 +18,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_public. -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_public_test.yaml ``` @@ -37,7 +37,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_public_ -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_public_unsigned_test.yaml ``` diff --git a/docs/nada-by-example/reveal.md b/docs/nada-by-example/reveal.md index 7df8ccc..fec2cec 100644 --- a/docs/nada-by-example/reveal.md +++ b/docs/nada-by-example/reveal.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/reveal.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/reveal_test.yaml ``` diff --git a/docs/nada-by-example/secret-data-type.md b/docs/nada-by-example/secret-data-type.md index 4de75ca..7d0377d 100644 --- a/docs/nada-by-example/secret-data-type.md +++ b/docs/nada-by-example/secret-data-type.md @@ -18,7 +18,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/multiplication.p -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/multiplication_test.yaml ``` @@ -37,7 +37,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_unsigne -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_unsigned_test.yaml ``` diff --git a/docs/nada-by-example/shift-left.md b/docs/nada-by-example/shift-left.md index f9c9f32..33c9c85 100644 --- a/docs/nada-by-example/shift-left.md +++ b/docs/nada-by-example/shift-left.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/shift_left.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/shift_left_test.yaml ``` diff --git a/docs/nada-by-example/shift-right.md b/docs/nada-by-example/shift-right.md index 5097524..60dd772 100644 --- a/docs/nada-by-example/shift-right.md +++ b/docs/nada-by-example/shift-right.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/shift_right.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/shift_right_test.yaml ``` diff --git a/docs/nada-by-example/subtraction.md b/docs/nada-by-example/subtraction.md index e6129bb..73c2577 100644 --- a/docs/nada-by-example/subtraction.md +++ b/docs/nada-by-example/subtraction.md @@ -13,7 +13,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/subtraction.py -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/subtraction_test.yaml ``` diff --git a/docs/quickstart-testnet.md b/docs/quickstart-testnet.md index d981848..071d1c8 100644 --- a/docs/quickstart-testnet.md +++ b/docs/quickstart-testnet.md @@ -56,4 +56,4 @@ https://github.com/NillionNetwork/cra-nillion/blob/main/vercel.json - reading about [Nillion concepts](/concepts) and the [Nada Language](nada-lang) - learning how to interact with and manage programs, secrets, and permissions on the Nillion Network with [Nillion Client](/js-client) -- challenging yourself to create a page that solves the [millionaires Problem](/multi-party-computation#classic-scenario-the-millionaires-problem) +- challenging yourself to create a page that solves the [Millionaires Problem](/multi-party-computation#classic-scenario-the-millionaires-problem) From 684f874ed346b2c92f62b6f2609f29e8923b937f Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 14:01:29 -0700 Subject: [PATCH 11/19] correct yaml file type --- docs/nada-by-example/first-program.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/nada-by-example/first-program.md b/docs/nada-by-example/first-program.md index 0df0a52..c9920ba 100644 --- a/docs/nada-by-example/first-program.md +++ b/docs/nada-by-example/first-program.md @@ -24,11 +24,10 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py You can auto-generate a test file like this one for any nada program with the [nada tool](/nada#generate-a-test-file). A test file verifies that the program works as expected. It provides test inputs and defines the expected outputs given the inputs. You'll learn how to run programs and test programs as part of the [Local Setup Quickstart](/nada-by-example-quickstart) -```python reference showGithubLink +```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml ``` - From 3ba834965998505d2e3123c98308af6924ee0244 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 14:33:28 -0700 Subject: [PATCH 12/19] naming the local setup guide --- docs/nada-by-example-quickstart.md | 2 +- docs/nada-by-example/debugging.md | 2 +- docs/nada-by-example/first-program.md | 2 +- sidebars.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/nada-by-example-quickstart.md b/docs/nada-by-example-quickstart.md index 9e30596..98d0470 100644 --- a/docs/nada-by-example-quickstart.md +++ b/docs/nada-by-example-quickstart.md @@ -6,7 +6,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import PythonVersionInfo from './\_python-version-info.mdx'; -# Nada by Example Local Setup Quickstart +# Nada by Example Local Setup Guide All examples for "Nada by Example" live in the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) Github repo. Nada programs are in [`nada-by-example/src/`](https://github.com/NillionNetwork/nada-by-example/tree/main/src) and tests are in [`nada-by-example/tests`](https://github.com/NillionNetwork/nada-by-example/tree/main/tests). After you complete local repo setup following the instructions below, you can run an example from the repo locally. diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index 1fd2563..e2b3402 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -84,4 +84,4 @@ SecretInteger(inner=) ## Next steps -🐛 Now that you've learned to debug, you're ready play with Nada programs. Move on to the next section where you will set up a local environment and run and test Nada programs locally following the [Nada by Example Local Setup Quickstart](/nada-by-example-quickstart). \ No newline at end of file +🐛 Now that you've learned to debug, you're ready play with Nada programs. Move on to the next section where you will set up a local environment and run and test Nada programs locally following the [Nada by Example Local Setup Guide](/nada-by-example-quickstart). \ No newline at end of file diff --git a/docs/nada-by-example/first-program.md b/docs/nada-by-example/first-program.md index c9920ba..44716c0 100644 --- a/docs/nada-by-example/first-program.md +++ b/docs/nada-by-example/first-program.md @@ -22,7 +22,7 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py -You can auto-generate a test file like this one for any nada program with the [nada tool](/nada#generate-a-test-file). A test file verifies that the program works as expected. It provides test inputs and defines the expected outputs given the inputs. You'll learn how to run programs and test programs as part of the [Local Setup Quickstart](/nada-by-example-quickstart) +You can auto-generate a test file like this one for any nada program with the [nada tool](/nada#generate-a-test-file). A test file verifies that the program works as expected. It provides test inputs and defines the expected outputs given the inputs. You'll learn how to run programs and test programs as part of the [Local Setup Guide](/nada-by-example-quickstart) ```yaml reference showGithubLink https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml diff --git a/sidebars.js b/sidebars.js index 6ed2094..4884f49 100644 --- a/sidebars.js +++ b/sidebars.js @@ -425,7 +425,7 @@ const sidebars = { 'nada-by-example/debugging', { type: 'doc', - label: 'Local Setup Quickstart', + label: 'Local Setup Guide', id: 'nada-by-example-quickstart', }, { From fa66eb89625b24707b4a237dca98af817e71d678 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 15:15:21 -0700 Subject: [PATCH 13/19] correct spelling --- docs/nada-by-example/debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index e2b3402..72b97eb 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -3,7 +3,7 @@ import TabItem from '@theme/TabItem'; # Debugging -When programming in Nada, keep this phrase in mind: Think Big, Code Small. Read about the "Think Big, Code Small" philosphy with [Nada best practices and more debugging tips here](/nada-debugging). +When programming in Nada, keep this phrase in mind: Think Big, Code Small. Read about the "Think Big, Code Small" philosophy with [Nada best practices and more debugging tips here](/nada-debugging). # Debugging with print() From 52cf97b7b2c856675b85a0dfa51c2b1be324eb3d Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 31 Jul 2024 15:19:35 -0700 Subject: [PATCH 14/19] correct title --- docs/nada-by-example/debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nada-by-example/debugging.md b/docs/nada-by-example/debugging.md index 72b97eb..43494c1 100644 --- a/docs/nada-by-example/debugging.md +++ b/docs/nada-by-example/debugging.md @@ -5,7 +5,7 @@ import TabItem from '@theme/TabItem'; When programming in Nada, keep this phrase in mind: Think Big, Code Small. Read about the "Think Big, Code Small" philosophy with [Nada best practices and more debugging tips here](/nada-debugging). -# Debugging with print() +## Debugging with print() When developing and debugging Nada programs, it can be helpful to inspect the values and types of variables at various points in your code. You can do this by adding Python `print()` statements, then running the file directly. From 2a5963667a3167d1b5408b039612ab26267671ce Mon Sep 17 00:00:00 2001 From: oceans404 Date: Thu, 1 Aug 2024 11:46:38 -0700 Subject: [PATCH 15/19] add reduce and voting examples --- docs/nada-by-example/reduce.md | 20 ++++++++++++++++++++ docs/nada-by-example/voting.md | 19 +++++++++++++++++++ sidebars.js | 2 ++ 3 files changed, 41 insertions(+) create mode 100644 docs/nada-by-example/reduce.md create mode 100644 docs/nada-by-example/voting.md diff --git a/docs/nada-by-example/reduce.md b/docs/nada-by-example/reduce.md new file mode 100644 index 0000000..2f14d7b --- /dev/null +++ b/docs/nada-by-example/reduce.md @@ -0,0 +1,20 @@ +# Reduce + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/reduce.py +``` + + + +```yaml reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/reduce_test.yaml +``` + + \ No newline at end of file diff --git a/docs/nada-by-example/voting.md b/docs/nada-by-example/voting.md new file mode 100644 index 0000000..967548c --- /dev/null +++ b/docs/nada-by-example/voting.md @@ -0,0 +1,19 @@ +# Voting + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/voting.py +``` + + + +```yaml reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/voting_test.yaml +``` + + \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 4884f49..73a2ead 100644 --- a/sidebars.js +++ b/sidebars.js @@ -483,6 +483,8 @@ const sidebars = { 'nada-by-example/list-comprehensions', 'nada-by-example/helper-function', 'nada-by-example/for-loop', + 'nada-by-example/reduce', + 'nada-by-example/voting', { type: 'html', className: 'sidebar-title', From 223174d349f384af0e95698028bdabea786025b0 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Thu, 1 Aug 2024 12:38:50 -0700 Subject: [PATCH 16/19] add nada ai and nada numpy pages --- docs/nada-by-example/nada-ai.md | 21 +++++++++ docs/nada-by-example/nada-numpy.md | 11 +++++ sidebars.js | 74 +++++++++++++++++------------- 3 files changed, 73 insertions(+), 33 deletions(-) create mode 100644 docs/nada-by-example/nada-ai.md create mode 100644 docs/nada-by-example/nada-numpy.md diff --git a/docs/nada-by-example/nada-ai.md b/docs/nada-by-example/nada-ai.md new file mode 100644 index 0000000..9061c4d --- /dev/null +++ b/docs/nada-by-example/nada-ai.md @@ -0,0 +1,21 @@ +import DocCardList from '@theme/DocCardList'; + +# Nada AI + +Nada-AI is a Python library designed for AI/ML on top of Nada DSL and Nillion Network. + +To learn more about the library, check out the full [Nada-AI docs here](/nada-ai-introduction). + +:::info +## Nada AI Limitations + +The choice for blind computing implies certain trade-offs in comparison to conventional computing. What you gain in privacy, you pay in extra computational overhead & capacity constraints. + +Therefore, you will notice that large-scale computational workloads may lead to long compilation and/or execution times or hitting network capacity guardrails. Each example lists model limitations or the number of input elements it has been tested with. + +That said, the Nillion team is working around the clock to push the boundaries of this technology and bring the potential of blind computing to reality. 🚀 +::: + +## Nada AI Examples with Google Colab Links + + \ No newline at end of file diff --git a/docs/nada-by-example/nada-numpy.md b/docs/nada-by-example/nada-numpy.md new file mode 100644 index 0000000..314772e --- /dev/null +++ b/docs/nada-by-example/nada-numpy.md @@ -0,0 +1,11 @@ +import DocCardList from '@theme/DocCardList'; + +# Nada Numpy + +Nada Numpy is a Python library designed for algebraic operations on NumPy-like array objects on top of Nada DSL and Nillion Network. + +To learn more about the library, check out the full [Nada-Numpy docs here](/nada-numpy-introduction). + +## Nada Numpy Examples with Google Colab Links + + \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 73a2ead..e9e4b7c 100644 --- a/sidebars.js +++ b/sidebars.js @@ -433,11 +433,6 @@ const sidebars = { label: 'Ask a Nada Question', href: 'https://github.com/orgs/NillionNetwork/discussions/categories/q-a', }, - { - type: 'link', - label: 'Report a Bug', - href: 'https://github.com/orgs/NillionNetwork/discussions/categories/bugs', - }, { type: 'html', className: 'sidebar-title', @@ -485,45 +480,26 @@ const sidebars = { 'nada-by-example/for-loop', 'nada-by-example/reduce', 'nada-by-example/voting', + { + type: 'link', + label: 'Request an Example', + href: 'https://github.com/NillionNetwork/nada-by-example/issues/new/choose', + }, { type: 'html', className: 'sidebar-title', value: 'Examples with Nada Libraries', defaultStyle: true, }, - { - type: 'category', - label: 'Nada Numpy', - collapsible: true, - collapsed: false, - items: [ - { - type: 'link', - label: 'Dot Product', - href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/dot_product', - }, - { - type: 'link', - label: 'Matrix multiplication', - href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/matrix_multiplication', - }, - { - type: 'link', - label: 'Broadcasting', - href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/broadcasting', - }, - { - type: 'link', - label: 'Rational Numbers', - href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/rational_numbers', - }, - ], - }, { type: 'category', label: 'Nada AI', collapsible: true, collapsed: false, + link: { + type: 'doc', + id: 'nada-by-example/nada-ai', + }, items: [ { type: 'link', @@ -557,6 +533,38 @@ const sidebars = { } ], }, + { + type: 'category', + label: 'Nada Numpy', + collapsible: true, + collapsed: false, + link: { + type: 'doc', + id: 'nada-by-example/nada-numpy', + }, + items: [ + { + type: 'link', + label: 'Dot Product', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/dot_product', + }, + { + type: 'link', + label: 'Matrix Multiplication', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/matrix_multiplication', + }, + { + type: 'link', + label: 'Broadcasting', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/broadcasting', + }, + { + type: 'link', + label: 'Rational Numbers', + href: 'https://github.com/NillionNetwork/nada-numpy/tree/main/examples/rational_numbers', + }, + ], + }, ] }; From 55a42000ec08774b6bd061583374890608682277 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Thu, 1 Aug 2024 13:05:18 -0700 Subject: [PATCH 17/19] add rock paper scissors example --- docs/nada-by-example/r-p-s.md | 35 +++++++++++++++++++++++++++++++++++ sidebars.js | 1 + 2 files changed, 36 insertions(+) create mode 100644 docs/nada-by-example/r-p-s.md diff --git a/docs/nada-by-example/r-p-s.md b/docs/nada-by-example/r-p-s.md new file mode 100644 index 0000000..4fda7ca --- /dev/null +++ b/docs/nada-by-example/r-p-s.md @@ -0,0 +1,35 @@ +# Rock Paper Scissors + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +```python reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/src/rock_paper_scissors.py +``` + + + +```yaml reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/rock_paper_scissors_tie.yaml +``` + + +```yaml reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/rock_paper_scissors_rock.yaml +``` + + +```yaml reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/rock_paper_scissors_paper.yaml +``` + + +```yaml reference showGithubLink +https://github.com/NillionNetwork/nada-by-example/blob/main/tests/rock_paper_scissors_scissors.yaml +``` + + \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index e9e4b7c..30bc437 100644 --- a/sidebars.js +++ b/sidebars.js @@ -480,6 +480,7 @@ const sidebars = { 'nada-by-example/for-loop', 'nada-by-example/reduce', 'nada-by-example/voting', + 'nada-by-example/r-p-s', { type: 'link', label: 'Request an Example', From e3cb1f5ea6e98c17aa42cd7b08233f412dc5083a Mon Sep 17 00:00:00 2001 From: oceans404 Date: Thu, 1 Aug 2024 13:48:12 -0700 Subject: [PATCH 18/19] start building page --- docs/start-building.md | 20 ++++++++++++++++++++ sidebars.js | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 docs/start-building.md diff --git a/docs/start-building.md b/docs/start-building.md new file mode 100644 index 0000000..1c29a49 --- /dev/null +++ b/docs/start-building.md @@ -0,0 +1,20 @@ +# Start Building + +Start building on Nillion with one of our developer quickstart guides. + +## Write a Nada Program + +The [Nada Quickstart](/quickstart-nada) will teach you how to create a Nada project and write your first privacy-preserving Nada program. The [Nada by Example Portal](/nada-by-example) is an introduction to Nada with lots of example programs for your reference. + +## Build a Blind App + +This [Blind App Quickstart](/quickstart) is ideal for developers interested in **building frontends or fullstack web apps** on Nillion. This quickstart will guide you through writing a Nada program, storing the program on the Nillion Netowrk, and creating a blind web app lets you store secrets and run your Nada program in the browser. + +## Connect a backend to Nillion + +If you want to **connect a backend** to Nillion, check out the Nillion [Python Quickstart](/python-quickstart). + + +## Write a privacy-preserving Blind AI Nada program + +To write privacy-preserving AI programs, check out our [Nada AI](/nada-by-example/nada-ai) examples, tutorials, and Google Colab links. \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 30bc437..2ac808a 100644 --- a/sidebars.js +++ b/sidebars.js @@ -54,7 +54,7 @@ const sidebars = { { type: 'html', className: 'sidebar-title', - value: 'About', + value: 'Learn', defaultStyle: true, }, 'what-is-nillion', @@ -62,13 +62,14 @@ const sidebars = { 'multi-party-computation', 'nillions-mpc-protocol', 'network', + 'concepts', { type: 'html', className: 'sidebar-title', value: 'Build', defaultStyle: true, }, - 'concepts', + 'start-building', 'network-configuration', { type: 'category', From 35d9dad2344bbcf1d9aa3b275c6a7bc4c9f155c3 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Thu, 1 Aug 2024 13:52:11 -0700 Subject: [PATCH 19/19] add install note to nada guide --- docs/quickstart-nada.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/quickstart-nada.md b/docs/quickstart-nada.md index 85a520d..2abccba 100644 --- a/docs/quickstart-nada.md +++ b/docs/quickstart-nada.md @@ -7,6 +7,19 @@ import PythonVersionInfo from './\_python-version-info.mdx'; The [`nada`](/nada) tool is used to create a new Nada project, compile all programs in the project, run Nada programs, and generate tests for Nada programs. +:::info + +Before starting this guide, [Install the Nillion SDK](/installation) + +Confirm installation: + +``` +nillion -V +``` + +::: + + ## Create a new Nada project Create a `quickstart` directory. Inside of `quickstart`, use the [`nada`](/nada) tool to create a new nada project named "nada_quickstart_programs" by running