Skip to content

Commit

Permalink
Merge pull request #61 from NillionNetwork/feat/testnet-config
Browse files Browse the repository at this point in the history
add testnet config and blind app guide for hackathon
  • Loading branch information
oceans404 authored Jul 10, 2024
2 parents df2e765 + 39a4d1c commit fd62a5e
Show file tree
Hide file tree
Showing 18 changed files with 780 additions and 277 deletions.
52 changes: 52 additions & 0 deletions docs/_js-headers-proxy.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

The JavaScript Client makes use of browser web-workers. To make your app cross-origin isolated, you'll need to set COOP and COEP headers, completed for you in [the cra-nillion webpack.config.js](https://github.com/NillionNetwork/cra-nillion/blob/main/webpack.config.js)

```
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
```

<Tabs>

<TabItem value="React" label="ReactJS" default>

Add headers and create a nilchain proxy in your [webpack.config.js](https://github.com/NillionNetwork/cra-nillion/blob/main/webpack.config.js)

```js
module.exports = {
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
},
hot: true,
client: {
overlay: false,
},
historyApiFallback: true,
proxy: [
{
context: ['/nilchain-proxy'],
target: process.env.REACT_APP_NILLION_NILCHAIN_JSON_RPC,
pathRewrite: { '^/nilchain-proxy': '' },
changeOrigin: true,
secure: false,
},
],
},
};
```

</TabItem>
</Tabs>

For more information, check out

- https://developer.chrome.com/blog/enabling-shared-array-buffer/
- https://web.dev/articles/coop-coep
- https://webpack.js.org/configuration/dev-server/
20 changes: 10 additions & 10 deletions docs/_nada-venv-setup.mdx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

1. Create a python [virtual environment](https://docs.python.org/3/library/venv.html)

```
python3 -m venv .venv
```
```
python3 -m venv .venv
```

2. Activate the python virtual environment

```
source .venv/bin/activate
```
```
source .venv/bin/activate
```

3. Install [nada-dsl](https://pypi.org/project/nada-dsl/)
3. Install [nada-dsl](https://pypi.org/project/nada-dsl/) from pypi

```
pip install nada-dsl
```
```
pip install nada-dsl
```
59 changes: 59 additions & 0 deletions docs/_quickstart-compile-run-test.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Use the <strong>[`nada`](/nada)</strong> tool to compile, run and test the program we have just written. More information about the nada tool can be found [here](https://docs.nillion.com/nada).

1. Add your program to `nada-project.toml` config file

For the nada tool to know about our program, we need to add the following to the to the `nada-project.toml` config file.
```bash
[[programs]]
path = "src/secret_addition.py"
name = "secret_addition"
prime_size = 128
```

2. Run the `nada build` command to compile programs.
```bash
nada build
```

This will compile all programs listed in the nada-project.toml file. You will see the binary files (.nada.bin) outputted to the `target/` directory.

3. Generate test
```bash
nada generate-test --test-name secret_addition_test secret_addition
```

This uses the nada tool to generate a set of test values, that will be stored in `tests/`. Here secret_addition_test is the name of the test, and secret_addition is the name of the program we want to test. You will notice that the test file (`tests/secret_addition_test.yaml`) is automatically populated with `3`s everywhere by default. Later, for the test to pass, we will have to change the output from `3` to the correct output.

4. Run the program with test values
```bash
nada run secret_addition_test
```

Now we run the program. This uses the inputs defined in the test file (tests/secret_addition_test.yaml) and runs the program and prints the result. Make note of the result, we will need it next.

5. Test the program
```bash
nada test secret_addition_test
```

Finally, we test the program. If you run the above command without altering the default values (`3`s) in the test file (`tests/secret_addition_test.yaml`), the test will fail because the expected test output doesn't match the resulting output. Modify the value of `my_output` in the test file and re-test the program.
<strong>Modify test values in `secret_addition_test.yaml`</strong>
```bash
---
program: secret_addition
inputs:
my_int1:
SecretInteger: "3"
my_int2:
SecretInteger: "3"
expected_outputs:
my_output:
SecretInteger: "6"
```
<strong>Re-run test</strong>
```bash
nada test secret_addition_test
```
2 changes: 1 addition & 1 deletion docs/_sdk-installation.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1. Install [nilup](/nilup) the [Nillion SDK tool](/nillion-sdk-and-tools#nillion-sdk-tools) installer and version manager. Binaries are available for [Linux and macOS platforms](/limitations#platforms)
1. Install [nilup](/nilup), the [Nillion SDK tool](/nillion-sdk-and-tools#nillion-sdk-tools) installer and version manager. Binaries are available for [Linux and macOS platforms](/limitations#platforms)

_For the security-conscious, please download the `install.sh` script, so that you can inspect how
it works, before piping it to `bash`._
Expand Down
70 changes: 70 additions & 0 deletions docs/_understanding-first-nada-program.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Let's go through the program line by line to understand what is each part is doing.

1. First we import all from nada_dsl, the Nada language
```python
from nada_dsl import *
```
2. Next we create `function nada_main()` - this is the main function that contains our Nada program's code.
```python
from nada_dsl import *

def nada_main():
```
3. Create a party with a name: `Party1`
```python
from nada_dsl import *

def nada_main():

party1 = Party(name="Party1")
```

This is a single party program, but you could add more than one party; for example we could define `party2 = Party(name="Party2")`.
4. Create program inputs
```python
from nada_dsl import *

def nada_main():

party1 = Party(name="Party1")

my_int1 = SecretInteger(Input(name="my_int1", party=party1))

my_int2 = SecretInteger(Input(name="my_int2", party=party1))
```

This program has two inputs, both secret integers. Each input must have a `name` and a `party` associated to it. Currently in nada you can only compute on secret or public integers (and rationals by using the `nada-algebra` library).

5. Compute on the inputs
```python
from nada_dsl import *

def nada_main():

party1 = Party(name="Party1")

my_int1 = SecretInteger(Input(name="my_int1", party=party1))

my_int2 = SecretInteger(Input(name="my_int2", party=party1))

new_int = my_int1 + my_int2
```
This performs addition to sum the inputs. Check out all the [built in operations available in nada here](/nada-lang-operators).

6. Return the output of the program
```python
from nada_dsl import *

def nada_main():

party1 = Party(name="Party1")

my_int1 = SecretInteger(Input(name="my_int1", party=party1))

my_int2 = SecretInteger(Input(name="my_int2", party=party1))

new_int = my_int1 + my_int2

return [Output(new_int, "my_output", party1)]
```
To output the result of a program, we must provide a name - in this case `my_output` - and a party to whom the output is provided - in this case `party1`.
26 changes: 14 additions & 12 deletions docs/first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
This page will help you take your first steps (~30 mins) as a Nillion developer. Once you have completed them, fill out the form for your chance to claim your $20 prize - each week we will review the submissions and pick the best to recieve a prize 🎉

1. Star & fork either the [Python](https://github.com/NillionNetwork/nillion-python-starter) or [JavaScript](https://github.com/NillionNetwork/cra-nillion) quickstart repos (bonus points for both)
🚨 Add the topic `nillion-nada` to this repo so we can find it easily
2. Follow at least one path (Python or JavaScript) in the [Developer Quickstart](/quickstart)
🚨 Make sure you [enable telemetry](/nillion-sdk-and-tools#installation) as you install the Nillion SDK

🚨 Add the topic `nillion-nada` to this repo so we can find it easily

2. Follow at least one of the quickstarts: [Python Quickstart](/python-quickstart) or [JavaScript Blind App Quickstart](/quickstart)

🚨 Make sure you [enable telemetry](/nillion-sdk-and-tools#installation) as you install the Nillion SDK

3. Once you have completed the quickstart, add at least one new [nada program](/nada-lang-programs) to your repo (bonus points for creativity, but make sure it compiles and runs)
- Python quickstart: add your nada program in your repo's [programs](https://github.com/NillionNetwork/nillion-python-starter/tree/main/programs) folder
- JavaScript quickstart: add your program in your repo's [public/programs](https://github.com/NillionNetwork/cra-nillion/tree/main/public/programs) folder

- Python quickstart: add your nada program in your repo's [programs](https://github.com/NillionNetwork/nillion-python-starter/tree/main/programs) folder
- JavaScript quickstart: add your program in your repo's [public/programs](https://github.com/NillionNetwork/cra-nillion/tree/main/public/programs) folder

4. Join our community:
- [Join our Discord server](https://discord.com/invite/nillionnetwork)
- [Follow us on Twitter](https://x.com/nillionnetwork)

5. Fill out [this form](https://forms.gle/TXhKmEjjrRhFYtf48) to claim your prize 🎉
- [Join our Discord server](https://discord.com/invite/nillionnetwork)
- [Follow us on Twitter](https://x.com/nillionnetwork)

5. Fill out [this form](https://forms.gle/TXhKmEjjrRhFYtf48) to claim your prize 🎉
32 changes: 17 additions & 15 deletions docs/hacker-house-goa-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ The 50 best tasks that are submitted will be awarded a $20 prize 🎉 Good luck!
Follow the steps below to complete the task:

1. Join our community:
- [Join our Discord server](https://discord.gg/nillionnetwork)
- Make sure you join the `developers-sdk` channel
- Once you fill out the form at the end of this task, we will add you to a dedicated `hacker-house-goa` Discord channel too.
- [Follow us on Twitter](https://x.com/nillionnetwork)

- [Join our Discord server](https://discord.gg/nillionnetwork)
- Make sure you join the `developers-sdk` channel
- Once you fill out the form at the end of this task, we will add you to a dedicated `hacker-house-goa` Discord channel too.
- [Follow us on Twitter](https://x.com/nillionnetwork)

2. Star & fork either the [Python](https://github.com/NillionNetwork/nillion-python-starter) or [JavaScript](https://github.com/NillionNetwork/cra-nillion) quickstart repos (bonus points for both)
🚨 Add the topic `nillion-nada` to this repo so we can find it easily
3. Follow at least one of the quickstarts (Python or JavaScript) in the [Developer Quickstart](/quickstart)
🚨 Make sure you [enable telemetry](/nillion-sdk-and-tools#installation) as you install the Nillion SDK. Start your telemetry identifier with `hacker-house-goa` so we can identify you

🚨 Add the topic `nillion-nada` to this repo so we can find it easily

3. Follow at least one of the quickstarts: [Python Quickstart](/python-quickstart) or [JavaScript Blind App Quickstart](/quickstart)

🚨 Make sure you [enable telemetry](/nillion-sdk-and-tools#installation) as you install the Nillion SDK. Start your telemetry identifier with `hacker-house-goa` so we can identify you

4. Once you have completed the quickstart, add at least one new [nada program](/nada-lang-programs) to your repo (bonus points for creativity, but make sure it compiles and runs)
- Python quickstart: add your nada program in your repo's programs folder.
- JavaScript quickstart: add your program in your repo's [public/programs](https://github.com/NillionNetwork/cra-nillion/tree/main/public/programs) folder
- The Nillion team will review all your new nada programs and award $20 prizes to the best 50.

5. Fill out [this form](https://forms.gle/8mWZyvdirzc66B679) to complete the initial Nillion task for Hacker House Goa.
- Python quickstart: add your nada program in your repo's programs folder.
- JavaScript quickstart: add your program in your repo's [public/programs](https://github.com/NillionNetwork/cra-nillion/tree/main/public/programs) folder
- The Nillion team will review all your new nada programs and award $20 prizes to the best 50.

5. Fill out [this form](https://forms.gle/8mWZyvdirzc66B679) to complete the initial Nillion task for Hacker House Goa.
34 changes: 18 additions & 16 deletions docs/hacker-house-goa.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

👋 Hey, welcome to [Nillion](https://docs.nillion.com/). We are really pleased to have you start your journey with us.

This page describes the initial Nillion task for Hacker House Goa for MacOS and Linux users. If you are on Windows, head over to [this page](https://docs.nillion.com/hacker-house-goa-windows).
This page describes the initial Nillion task for Hacker House Goa for MacOS and Linux users. If you are on Windows, head over to [this page](https://docs.nillion.com/hacker-house-goa-windows).

The initial task should take 30-45 minutes and will help you get started with Nillion; join our social channels, and start working with our SDK. If you have any questions, feel free to ask them on the discord channel.

Expand All @@ -11,22 +11,24 @@ The 50 best tasks that are submitted will be awarded a $20 prize 🎉 Good luck!
Follow the steps below to complete the task:

1. Join our community:
- [Join our Discord server](https://discord.gg/nillionnetwork)
- Make sure you join the `developers-sdk` channel
- Once you fill out the form at the end of this task, we will add you to a dedicated `hacker-house-goa` Discord channel too.
- [Follow us on Twitter](https://x.com/nillionnetwork)

- [Join our Discord server](https://discord.gg/nillionnetwork)
- Make sure you join the `developers-sdk` channel
- Once you fill out the form at the end of this task, we will add you to a dedicated `hacker-house-goa` Discord channel too.
- [Follow us on Twitter](https://x.com/nillionnetwork)

2. Star & fork either the [Python](https://github.com/NillionNetwork/nillion-python-starter) or [JavaScript](https://github.com/NillionNetwork/cra-nillion) quickstart repos (bonus points for both)
🚨 Add the topic `nillion-nada` to this repo so we can find it easily
3. Follow at least one of the quickstarts (Python or JavaScript) in the [Developer Quickstart](/quickstart)
🚨 Make sure you [enable telemetry](/nillion-sdk-and-tools#installation) as you install the Nillion SDK. Start your telemetry identifier with `hacker-house-goa` so we can identify you

🚨 Add the topic `nillion-nada` to this repo so we can find it easily

3. Follow at least one of the quickstarts: [Python Quickstart](/python-quickstart) or [JavaScript Blind App Quickstart](/quickstart)

🚨 Make sure you [enable telemetry](/nillion-sdk-and-tools#installation) as you install the Nillion SDK. Start your telemetry identifier with `hacker-house-goa` so we can identify you

4. Once you have completed the quickstart, add at least one new [nada program](/nada-lang-programs) to your repo (bonus points for creativity, but make sure it compiles and runs)
- Python quickstart: add your nada program in your repo's programs folder.
- JavaScript quickstart: add your program in your repo's [public/programs](https://github.com/NillionNetwork/cra-nillion/tree/main/public/programs) folder
- The Nillion team will review all your new nada programs and award $20 prizes to the best 50.

5. Fill out [this form](https://forms.gle/8mWZyvdirzc66B679) to complete the initial Nillion task for Hacker House Goa.
- Python quickstart: add your nada program in your repo's programs folder.
- JavaScript quickstart: add your program in your repo's [public/programs](https://github.com/NillionNetwork/cra-nillion/tree/main/public/programs) folder
- The Nillion team will review all your new nada programs and award $20 prizes to the best 50.

5. Fill out [this form](https://forms.gle/8mWZyvdirzc66B679) to complete the initial Nillion task for Hacker House Goa.
Loading

0 comments on commit fd62a5e

Please sign in to comment.