From d503ec4199ca436f29d2d2d27b2558f394a703c8 Mon Sep 17 00:00:00 2001 From: David Butler Date: Wed, 1 May 2024 16:18:40 +0100 Subject: [PATCH 1/3] Restructure directories and manually test everything works --- README.md | 6 +- compile_programs.sh | 8 +-- .../01_store_secret_party1.py | 4 +- .../02_store_secret_party_n.py | 8 +-- .../03_multi_party_compute.py | 4 +- .../README.md | 0 .../config.py | 0 .../01_fetch_reader_userid.py | 4 +- .../02_store_permissioned_secret.py | 8 +-- .../03_retrieve_secret.py | 6 +- .../04_revoke_read_permissions.py | 14 ++-- .../05_test_revoked_permissions.py | 8 +-- .../core_concept_permissions}/README.md | 2 +- .../README.md | 0 .../addition_simple.py | 4 +- .../circuit_simple.py | 4 +- .../circuit_simple_2.py | 4 +- .../complex.py | 4 +- .../correlation_coefficient.py | 6 +- .../division_simple.py | 4 +- .../input_integer.py | 4 +- .../input_single.py | 4 +- .../modulo_simple.py | 4 +- .../multiplication_simple.py | 4 +- .../nada_fn_composition.py | 4 +- .../nada_fn_simple.py | 4 +- .../reduce_simple.py | 4 +- .../reuse.py | 4 +- .../reuse_flipped1.py | 4 +- .../reuse_flipped2.py | 4 +- .../reuse_simple_1.py | 4 +- .../reuse_simple_2.py | 4 +- .../reuse_simple_sub.py | 4 +- .../simple.py | 4 +- .../simple_literals.py | 4 +- .../simple_public_variables.py | 4 +- .../simple_public_variables_only.py | 4 +- .../simple_sub.py | 4 +- .../single_addition.py | 4 +- .../subtraction_simple.py | 4 +- .../subtraction_simple_neg.py | 4 +- .../tiny_secret_addition.py | 4 +- .../tiny_secret_addition_complete.py | 4 +- .../store_and_retrieve_blob.py | 4 +- .../store_and_retrieve_integer.py | 4 +- .../01_store_secret_party1.py | 4 +- .../02_store_secret_party_n.py | 10 +-- .../03_multi_party_compute.py | 4 +- .../millionaires_problem_example}/README.md | 0 .../millionaires_problem_example}/config.py | 0 .../millionaires.nada.bin | Bin .../01_store_program_party1.py | 4 +- .../02_store_secret_party_n.py | 12 ++-- .../03_multi_party_compute.py | 4 +- .../voting_tutorial}/README.md | 8 +-- .../voting_tutorial}/client_voting.py | 8 +-- .../voting_tutorial}/config.py | 0 .../voting_tutorial}/digest_result.py | 0 .../voting_tutorial}/image/architecture.png | Bin .../voting_tutorial}/inputs/v0_input.txt | 0 .../voting_tutorial}/inputs/v1_input.txt | 0 .../voting_tutorial}/inputs/v2_input.txt | 0 .../voting_tutorial}/tutorial.md | 8 +-- .../store_and_retrieve_array.py | 68 ------------------ 64 files changed, 130 insertions(+), 198 deletions(-) rename {client_multi_party_compute => examples_and_tutorials/core_concept_multi_party_compute}/01_store_secret_party1.py (95%) rename {client_multi_party_compute => examples_and_tutorials/core_concept_multi_party_compute}/02_store_secret_party_n.py (94%) rename {client_multi_party_compute => examples_and_tutorials/core_concept_multi_party_compute}/03_multi_party_compute.py (98%) rename {client_multi_party_compute => examples_and_tutorials/core_concept_multi_party_compute}/README.md (100%) rename {client_multi_party_compute => examples_and_tutorials/core_concept_multi_party_compute}/config.py (100%) rename {permissions => examples_and_tutorials/core_concept_permissions}/01_fetch_reader_userid.py (92%) rename {permissions => examples_and_tutorials/core_concept_permissions}/02_store_permissioned_secret.py (92%) rename {permissions => examples_and_tutorials/core_concept_permissions}/03_retrieve_secret.py (89%) rename {permissions => examples_and_tutorials/core_concept_permissions}/04_revoke_read_permissions.py (71%) rename {permissions => examples_and_tutorials/core_concept_permissions}/05_test_revoked_permissions.py (85%) rename {permissions => examples_and_tutorials/core_concept_permissions}/README.md (97%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/README.md (100%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/addition_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/circuit_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/circuit_simple_2.py (97%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/complex.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/correlation_coefficient.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/division_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/input_integer.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/input_single.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/modulo_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/multiplication_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/nada_fn_composition.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/nada_fn_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reduce_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reuse.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reuse_flipped1.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reuse_flipped2.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reuse_simple_1.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reuse_simple_2.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/reuse_simple_sub.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/simple_literals.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/simple_public_variables.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/simple_public_variables_only.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/simple_sub.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/single_addition.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/subtraction_simple.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/subtraction_simple_neg.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/tiny_secret_addition.py (96%) rename {client_single_party_compute => examples_and_tutorials/core_concept_single_party_compute}/tiny_secret_addition_complete.py (97%) rename {store_and_retrieve_secrets => examples_and_tutorials/core_concept_store_and_retrieve_secrets}/store_and_retrieve_blob.py (94%) rename {store_and_retrieve_secrets => examples_and_tutorials/core_concept_store_and_retrieve_secrets}/store_and_retrieve_integer.py (94%) rename {millionaires_problem_example => examples_and_tutorials/millionaires_problem_example}/01_store_secret_party1.py (96%) rename {millionaires_problem_example => examples_and_tutorials/millionaires_problem_example}/02_store_secret_party_n.py (88%) rename {millionaires_problem_example => examples_and_tutorials/millionaires_problem_example}/03_multi_party_compute.py (98%) rename {millionaires_problem_example => examples_and_tutorials/millionaires_problem_example}/README.md (100%) rename {millionaires_problem_example => examples_and_tutorials/millionaires_problem_example}/config.py (100%) rename {millionaires_problem_example => examples_and_tutorials/millionaires_problem_example}/millionaires.nada.bin (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/01_store_program_party1.py (98%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/02_store_secret_party_n.py (89%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/03_multi_party_compute.py (99%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/README.md (81%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/client_voting.py (98%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/config.py (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/digest_result.py (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/image/architecture.png (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/inputs/v0_input.txt (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/inputs/v1_input.txt (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/inputs/v2_input.txt (100%) rename {voting_tutorial => examples_and_tutorials/voting_tutorial}/tutorial.md (99%) delete mode 100644 store_and_retrieve_secrets/store_and_retrieve_array.py diff --git a/README.md b/README.md index 57835275..bafe59a2 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This is a python starter repo for building on the Nillion Network. Complete environment setup, then run the examples: -- To run multi party examples, go to the [client_multi_party_compute](./client_multi_party_compute) folder. +- To run multi party examples, go to the [client_multi_party_compute](examples_and_tutorials/core_concept_multi_party_compute) folder. -- To run single party examples, go to the [client_single_party_compute](./client_single_party_compute) folder. +- To run single party examples, go to the [client_single_party_compute](examples_and_tutorials/core_concept_single_party_compute) folder. -- To run permissions examples (storing and retrieving permissioned secrets, revoking permissions, etc.), go to the [permissions](./permissions) folder. +- To run permissions examples (storing and retrieving permissioned secrets, revoking permissions, etc.), go to the [permissions](examples_and_tutorials/core_concept_permissions) folder. ### Prerequisites: Install the CLI Dependencies diff --git a/compile_programs.sh b/compile_programs.sh index a03a289e..5c7d647e 100755 --- a/compile_programs.sh +++ b/compile_programs.sh @@ -26,10 +26,10 @@ echo "Now try running an example:" echo "----------single party compute --------------" -echo "Code for single party compute lives in the client_single_party_compute folder" -echo "šŸ“‹ to run single party compute - addition_simple program: 'cd client_single_party_compute && python3 addition_simple.py'" +echo "Code for single party compute lives in the examples_and_tutorials/core_concept_client_single_party_compute folder" +echo "šŸ“‹ to run single party compute - addition_simple program: 'cd examples_and_tutorials/core_concept_client_single_party_compute && python3 addition_simple.py'" echo "----------multi party compute --------------" -echo "Code for single party compute lives in the client_multi_party_compute folder" -echo "šŸ“‹ to run multi party compute in 3 steps - addition_simple_multi_party_3: 'cd client_multi_party_compute && python3 01_store_secret_party1.py'" \ No newline at end of file +echo "Code for multi party compute lives in the examples_and_tutorials/core_concept_multi_party_compute folder" +echo "šŸ“‹ to run multi party compute in 3 steps - addition_simple_multi_party_3: 'cd examples_and_tutorials/core_concept_multi_party_compute && python3 01_store_secret_party1.py'" \ No newline at end of file diff --git a/client_multi_party_compute/01_store_secret_party1.py b/examples_and_tutorials/core_concept_multi_party_compute/01_store_secret_party1.py similarity index 95% rename from client_multi_party_compute/01_store_secret_party1.py rename to examples_and_tutorials/core_concept_multi_party_compute/01_store_secret_party1.py index 1b450153..68c4475e 100644 --- a/client_multi_party_compute/01_store_secret_party1.py +++ b/examples_and_tutorials/core_concept_multi_party_compute/01_store_secret_party1.py @@ -10,7 +10,7 @@ CONFIG_PARTY_1 ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -26,7 +26,7 @@ async def main(): user_id_1 = client_1.user_id() - program_mir_path=f"../programs-compiled/{CONFIG_PROGRAM_NAME}.nada.bin" + program_mir_path=f"../../programs-compiled/{CONFIG_PROGRAM_NAME}.nada.bin" # 1st Party stores program action_id = await client_1.store_program( diff --git a/client_multi_party_compute/02_store_secret_party_n.py b/examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py similarity index 94% rename from client_multi_party_compute/02_store_secret_party_n.py rename to examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py index 57fb3b0a..5a144542 100644 --- a/client_multi_party_compute/02_store_secret_party_n.py +++ b/examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py @@ -11,7 +11,7 @@ CONFIG_N_PARTIES ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -20,7 +20,7 @@ # N other parties store a secret async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( "--user_id_1", @@ -64,10 +64,10 @@ async def main(args = None): secret_bindings = nillion.ProgramBindings(program_id) secret_bindings.add_input_party(party_name, party_id_n) - # Create permissions object + # Create core_concept_permissions object permissions = nillion.Permissions.default_for_user(user_id_n) - # Give compute permissions to the first party + # Give compute core_concept_permissions to the first party compute_permissions = { args.user_id_1: {program_id}, } diff --git a/client_multi_party_compute/03_multi_party_compute.py b/examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py similarity index 98% rename from client_multi_party_compute/03_multi_party_compute.py rename to examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py index 3dc8e168..7889eb70 100644 --- a/client_multi_party_compute/03_multi_party_compute.py +++ b/examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py @@ -17,7 +17,7 @@ store_secret_party_1 = importlib.import_module("01_store_secret_party1") store_secret_party_n = importlib.import_module("02_store_secret_party_n") -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -25,7 +25,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( diff --git a/client_multi_party_compute/README.md b/examples_and_tutorials/core_concept_multi_party_compute/README.md similarity index 100% rename from client_multi_party_compute/README.md rename to examples_and_tutorials/core_concept_multi_party_compute/README.md diff --git a/client_multi_party_compute/config.py b/examples_and_tutorials/core_concept_multi_party_compute/config.py similarity index 100% rename from client_multi_party_compute/config.py rename to examples_and_tutorials/core_concept_multi_party_compute/config.py diff --git a/permissions/01_fetch_reader_userid.py b/examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py similarity index 92% rename from permissions/01_fetch_reader_userid.py rename to examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py index 4eb5669d..b6d6354b 100644 --- a/permissions/01_fetch_reader_userid.py +++ b/examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py @@ -5,7 +5,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): reader_user_id = reader.user_id() print("ā„¹ļø Fetched the reader's USER ID:", reader_user_id) - print("\n\nRun the following command to store a secret and give read/retrieve permissions to the READER USER ID") + print("\n\nRun the following command to store a secret and give read/retrieve core_concept_permissions to the READER USER ID") print(f"\nšŸ“‹ python3 02_store_permissioned_secret.py --retriever_user_id {reader.user_id()}") return reader.user_id() diff --git a/permissions/02_store_permissioned_secret.py b/examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py similarity index 92% rename from permissions/02_store_permissioned_secret.py rename to examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py index 1055c095..0f606012 100644 --- a/permissions/02_store_permissioned_secret.py +++ b/examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py @@ -7,7 +7,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -16,7 +16,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( "--retriever_user_id", @@ -35,7 +35,7 @@ async def main(args = None): writer_user_id = writer.user_id() print(writer_user_id, args.retriever_user_id) - # Writer gives themself default permissions + # Writer gives themself default core_concept_permissions permissions = nillion.Permissions.default_for_user(writer_user_id) # Writer gives the reader permission to read/retrieve secret permissions.add_retrieve_permissions(set([args.retriever_user_id, writer_user_id])) @@ -46,7 +46,7 @@ async def main(args = None): else "not allowed" ) if result == "not allowed": - raise Exception("failed to set permissions") + raise Exception("failed to set core_concept_permissions") print(f"ā„¹ļø Permissions set: Reader {args.retriever_user_id} is {result} to retrieve the secret") diff --git a/permissions/03_retrieve_secret.py b/examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py similarity index 89% rename from permissions/03_retrieve_secret.py rename to examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py index cdceafb3..6361636a 100644 --- a/permissions/03_retrieve_secret.py +++ b/examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -14,7 +14,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Use read permissions to retrieve a secret owned by another user on the Nillion network" + description="Use read core_concept_permissions to retrieve a secret owned by another user on the Nillion network" ) parser.add_argument( "--store_id", @@ -39,7 +39,7 @@ async def main(args = None): result = await reader.retrieve_secret(cluster_id, args.store_id, secret_name) print(f"šŸ¦„ Retrieved {secret_name} secret, value = {result[1].value}", file=sys.stderr) - print("\n\nRun the following command to revoke the reader's retrieve permissions to the secret") + print("\n\nRun the following command to revoke the reader's retrieve core_concept_permissions to the secret") print(f"\nšŸ“‹ python3 04_revoke_read_permissions.py --store_id {args.store_id} --revoked_user_id {reader_user_id}") return [args.store_id, reader_user_id] diff --git a/permissions/04_revoke_read_permissions.py b/examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py similarity index 71% rename from permissions/04_revoke_read_permissions.py rename to examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py index 71e4a5ac..c33feab9 100644 --- a/permissions/04_revoke_read_permissions.py +++ b/examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py @@ -7,7 +7,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -15,7 +15,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Revoke user read/retrieve permissions from a secret on the Nillion network" + description="Revoke user read/retrieve core_concept_permissions from a secret on the Nillion network" ) parser.add_argument( "--store_id", @@ -38,7 +38,7 @@ async def main(args = None): # Writer Nillion client writer = create_nillion_client(userkey, nodekey) - # Create new permissions object to rewrite permissions (reader no longer has retrieve permission) + # Create new core_concept_permissions object to rewrite core_concept_permissions (reader no longer has retrieve permission) new_permissions = nillion.Permissions.default_for_user(writer.user_id()) result = ( "allowed" @@ -46,14 +46,14 @@ async def main(args = None): else "not allowed" ) if result != "not allowed": - raise Exception("failed to create valid permissions object") + raise Exception("failed to create valid core_concept_permissions object") # Update the permission - print(f"ā„¹ļø Updating permissions for secret: {args.store_id}.") - print(f"ā„¹ļø Reset permissions so that user id {args.revoked_user_id} is {result} to retrieve object.", file=sys.stderr) + print(f"ā„¹ļø Updating core_concept_permissions for secret: {args.store_id}.") + print(f"ā„¹ļø Reset core_concept_permissions so that user id {args.revoked_user_id} is {result} to retrieve object.", file=sys.stderr) await writer.update_permissions( cluster_id, args.store_id , new_permissions) - print("\n\nRun the following command to test that permissions have been properly revoked") + print("\n\nRun the following command to test that core_concept_permissions have been properly revoked") print(f"\nšŸ“‹ python3 05_test_revoked_permissions.py --store_id {args.store_id}") return args.store_id diff --git a/permissions/05_test_revoked_permissions.py b/examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py similarity index 85% rename from permissions/05_test_revoked_permissions.py rename to examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py index e51379c4..54a41e9a 100644 --- a/permissions/05_test_revoked_permissions.py +++ b/examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py @@ -12,7 +12,7 @@ retrieve_secret = importlib.import_module("03_retrieve_secret") revoke_read_permissions = importlib.import_module("04_revoke_read_permissions") -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -20,7 +20,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Check that retrieval permissions on a Secret have been revoked" + description="Check that retrieval core_concept_permissions on a Secret have been revoked" ) parser.add_argument( "--store_id", @@ -41,10 +41,10 @@ async def main(args = None): try: secret_name = "my_int1" await reader.retrieve_secret(cluster_id, args.store_id, secret_name) - print(f"ā›” FAIL: {reader_user_id} user id with revoked permissions was allowed to access secret", file=sys.stderr) + print(f"ā›” FAIL: {reader_user_id} user id with revoked core_concept_permissions was allowed to access secret", file=sys.stderr) except Exception as e: if str(e) == "retrieving secret: the user is not authorized to access the secret": - print(f"šŸ¦„ Success: After user permissions were revoked, {reader_user_id} was not allowed to access secret", file=sys.stderr) + print(f"šŸ¦„ Success: After user core_concept_permissions were revoked, {reader_user_id} was not allowed to access secret", file=sys.stderr) else: raise(e) diff --git a/permissions/README.md b/examples_and_tutorials/core_concept_permissions/README.md similarity index 97% rename from permissions/README.md rename to examples_and_tutorials/core_concept_permissions/README.md index b70b4b77..5d462ede 100644 --- a/permissions/README.md +++ b/examples_and_tutorials/core_concept_permissions/README.md @@ -9,7 +9,7 @@ Before running through examples, `./bootstrap-local-environment.sh` creates user 5. The reader tries to retrieve the secret, but no longer has access to it ```shell -cd permissions +cd core_concept_permissions python3 01_fetch_reader_userid.py python3 02_store_permissioned_secret.py --retriever_user_id {READER_USER_ID} python3 03_retrieve_secret.py --store_id {STORE_ID} diff --git a/client_single_party_compute/README.md b/examples_and_tutorials/core_concept_single_party_compute/README.md similarity index 100% rename from client_single_party_compute/README.md rename to examples_and_tutorials/core_concept_single_party_compute/README.md diff --git a/client_single_party_compute/addition_simple.py b/examples_and_tutorials/core_concept_single_party_compute/addition_simple.py similarity index 96% rename from client_single_party_compute/addition_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/addition_simple.py index d1981380..483e14ad 100644 --- a/client_single_party_compute/addition_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/addition_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="addition_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/circuit_simple.py b/examples_and_tutorials/core_concept_single_party_compute/circuit_simple.py similarity index 96% rename from client_single_party_compute/circuit_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/circuit_simple.py index 1c98b173..91bd6543 100644 --- a/client_single_party_compute/circuit_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/circuit_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="circuit_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/circuit_simple_2.py b/examples_and_tutorials/core_concept_single_party_compute/circuit_simple_2.py similarity index 97% rename from client_single_party_compute/circuit_simple_2.py rename to examples_and_tutorials/core_concept_single_party_compute/circuit_simple_2.py index 15b251c2..f3ded42e 100644 --- a/client_single_party_compute/circuit_simple_2.py +++ b/examples_and_tutorials/core_concept_single_party_compute/circuit_simple_2.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="circuit_simple_2" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/complex.py b/examples_and_tutorials/core_concept_single_party_compute/complex.py similarity index 96% rename from client_single_party_compute/complex.py rename to examples_and_tutorials/core_concept_single_party_compute/complex.py index c0f6ca3b..c8558223 100644 --- a/client_single_party_compute/complex.py +++ b/examples_and_tutorials/core_concept_single_party_compute/complex.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="complex" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/correlation_coefficient.py b/examples_and_tutorials/core_concept_single_party_compute/correlation_coefficient.py similarity index 96% rename from client_single_party_compute/correlation_coefficient.py rename to examples_and_tutorials/core_concept_single_party_compute/correlation_coefficient.py index 624570c8..55d76297 100644 --- a/client_single_party_compute/correlation_coefficient.py +++ b/examples_and_tutorials/core_concept_single_party_compute/correlation_coefficient.py @@ -9,7 +9,7 @@ from math import sqrt import pytest -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -27,7 +27,7 @@ async def main(): party_1_name="Party1" out_party_name="OutParty" program_name="correlation_coefficient" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( @@ -67,7 +67,7 @@ async def main(): secret_bindings.add_input_party(party_0_name, party_id) secret_bindings.add_input_party(party_1_name, party_id) - # Give permissions to owner to compute with my vote + # Give core_concept_permissions to owner to compute with my vote secret_permissions = nillion.Permissions.default_for_user(user_id) secret_permissions.add_compute_permissions({ user_id: {program_id}, diff --git a/client_single_party_compute/division_simple.py b/examples_and_tutorials/core_concept_single_party_compute/division_simple.py similarity index 96% rename from client_single_party_compute/division_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/division_simple.py index 11d03c53..d0d11413 100644 --- a/client_single_party_compute/division_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/division_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="division_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/input_integer.py b/examples_and_tutorials/core_concept_single_party_compute/input_integer.py similarity index 96% rename from client_single_party_compute/input_integer.py rename to examples_and_tutorials/core_concept_single_party_compute/input_integer.py index 0702d9d1..5399d7e4 100644 --- a/client_single_party_compute/input_integer.py +++ b/examples_and_tutorials/core_concept_single_party_compute/input_integer.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="input_integer" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/input_single.py b/examples_and_tutorials/core_concept_single_party_compute/input_single.py similarity index 96% rename from client_single_party_compute/input_single.py rename to examples_and_tutorials/core_concept_single_party_compute/input_single.py index 76b46d43..c93c6c8e 100644 --- a/client_single_party_compute/input_single.py +++ b/examples_and_tutorials/core_concept_single_party_compute/input_single.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="input_single" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/modulo_simple.py b/examples_and_tutorials/core_concept_single_party_compute/modulo_simple.py similarity index 96% rename from client_single_party_compute/modulo_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/modulo_simple.py index e46fe1c1..bd75dff1 100644 --- a/client_single_party_compute/modulo_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/modulo_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="modulo_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/multiplication_simple.py b/examples_and_tutorials/core_concept_single_party_compute/multiplication_simple.py similarity index 96% rename from client_single_party_compute/multiplication_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/multiplication_simple.py index af6759e9..45788820 100644 --- a/client_single_party_compute/multiplication_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/multiplication_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -23,7 +23,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="multiplication_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/nada_fn_composition.py b/examples_and_tutorials/core_concept_single_party_compute/nada_fn_composition.py similarity index 96% rename from client_single_party_compute/nada_fn_composition.py rename to examples_and_tutorials/core_concept_single_party_compute/nada_fn_composition.py index be811a49..40282149 100644 --- a/client_single_party_compute/nada_fn_composition.py +++ b/examples_and_tutorials/core_concept_single_party_compute/nada_fn_composition.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="nada_fn_composition" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/nada_fn_simple.py b/examples_and_tutorials/core_concept_single_party_compute/nada_fn_simple.py similarity index 96% rename from client_single_party_compute/nada_fn_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/nada_fn_simple.py index 56efcc63..7f054f54 100644 --- a/client_single_party_compute/nada_fn_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/nada_fn_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="nada_fn_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reduce_simple.py b/examples_and_tutorials/core_concept_single_party_compute/reduce_simple.py similarity index 96% rename from client_single_party_compute/reduce_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/reduce_simple.py index 3d5dc427..006d0eef 100644 --- a/client_single_party_compute/reduce_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reduce_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reduce_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reuse.py b/examples_and_tutorials/core_concept_single_party_compute/reuse.py similarity index 96% rename from client_single_party_compute/reuse.py rename to examples_and_tutorials/core_concept_single_party_compute/reuse.py index 4775e862..bd01fd46 100644 --- a/client_single_party_compute/reuse.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reuse.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reuse" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reuse_flipped1.py b/examples_and_tutorials/core_concept_single_party_compute/reuse_flipped1.py similarity index 96% rename from client_single_party_compute/reuse_flipped1.py rename to examples_and_tutorials/core_concept_single_party_compute/reuse_flipped1.py index 55af5fd4..4f7b1e22 100644 --- a/client_single_party_compute/reuse_flipped1.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reuse_flipped1.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reuse_flipped1" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reuse_flipped2.py b/examples_and_tutorials/core_concept_single_party_compute/reuse_flipped2.py similarity index 96% rename from client_single_party_compute/reuse_flipped2.py rename to examples_and_tutorials/core_concept_single_party_compute/reuse_flipped2.py index 9fb28e92..f1b6e28b 100644 --- a/client_single_party_compute/reuse_flipped2.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reuse_flipped2.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reuse_flipped2" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reuse_simple_1.py b/examples_and_tutorials/core_concept_single_party_compute/reuse_simple_1.py similarity index 96% rename from client_single_party_compute/reuse_simple_1.py rename to examples_and_tutorials/core_concept_single_party_compute/reuse_simple_1.py index 9d6f83be..265779d1 100644 --- a/client_single_party_compute/reuse_simple_1.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reuse_simple_1.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reuse_simple_1" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reuse_simple_2.py b/examples_and_tutorials/core_concept_single_party_compute/reuse_simple_2.py similarity index 96% rename from client_single_party_compute/reuse_simple_2.py rename to examples_and_tutorials/core_concept_single_party_compute/reuse_simple_2.py index 6afb6d18..f3935f70 100644 --- a/client_single_party_compute/reuse_simple_2.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reuse_simple_2.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reuse_simple_2" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/reuse_simple_sub.py b/examples_and_tutorials/core_concept_single_party_compute/reuse_simple_sub.py similarity index 96% rename from client_single_party_compute/reuse_simple_sub.py rename to examples_and_tutorials/core_concept_single_party_compute/reuse_simple_sub.py index 99baf09f..0e307392 100644 --- a/client_single_party_compute/reuse_simple_sub.py +++ b/examples_and_tutorials/core_concept_single_party_compute/reuse_simple_sub.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="reuse_simple_sub" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/simple.py b/examples_and_tutorials/core_concept_single_party_compute/simple.py similarity index 96% rename from client_single_party_compute/simple.py rename to examples_and_tutorials/core_concept_single_party_compute/simple.py index 55e0999c..52c4f9e6 100644 --- a/client_single_party_compute/simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/simple_literals.py b/examples_and_tutorials/core_concept_single_party_compute/simple_literals.py similarity index 96% rename from client_single_party_compute/simple_literals.py rename to examples_and_tutorials/core_concept_single_party_compute/simple_literals.py index c172f233..1ce412aa 100644 --- a/client_single_party_compute/simple_literals.py +++ b/examples_and_tutorials/core_concept_single_party_compute/simple_literals.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="simple_literals" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/simple_public_variables.py b/examples_and_tutorials/core_concept_single_party_compute/simple_public_variables.py similarity index 96% rename from client_single_party_compute/simple_public_variables.py rename to examples_and_tutorials/core_concept_single_party_compute/simple_public_variables.py index 3be81867..701b92f6 100644 --- a/client_single_party_compute/simple_public_variables.py +++ b/examples_and_tutorials/core_concept_single_party_compute/simple_public_variables.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="simple_public_variables" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/simple_public_variables_only.py b/examples_and_tutorials/core_concept_single_party_compute/simple_public_variables_only.py similarity index 96% rename from client_single_party_compute/simple_public_variables_only.py rename to examples_and_tutorials/core_concept_single_party_compute/simple_public_variables_only.py index 02c74fc4..194690d2 100644 --- a/client_single_party_compute/simple_public_variables_only.py +++ b/examples_and_tutorials/core_concept_single_party_compute/simple_public_variables_only.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="simple_public_variables_only" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/simple_sub.py b/examples_and_tutorials/core_concept_single_party_compute/simple_sub.py similarity index 96% rename from client_single_party_compute/simple_sub.py rename to examples_and_tutorials/core_concept_single_party_compute/simple_sub.py index 1c204846..647c56db 100644 --- a/client_single_party_compute/simple_sub.py +++ b/examples_and_tutorials/core_concept_single_party_compute/simple_sub.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="simple_sub" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/single_addition.py b/examples_and_tutorials/core_concept_single_party_compute/single_addition.py similarity index 96% rename from client_single_party_compute/single_addition.py rename to examples_and_tutorials/core_concept_single_party_compute/single_addition.py index 89f8efd7..6a88e08f 100644 --- a/client_single_party_compute/single_addition.py +++ b/examples_and_tutorials/core_concept_single_party_compute/single_addition.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="single_addition" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/subtraction_simple.py b/examples_and_tutorials/core_concept_single_party_compute/subtraction_simple.py similarity index 96% rename from client_single_party_compute/subtraction_simple.py rename to examples_and_tutorials/core_concept_single_party_compute/subtraction_simple.py index f97e9d97..e9e8e7f1 100644 --- a/client_single_party_compute/subtraction_simple.py +++ b/examples_and_tutorials/core_concept_single_party_compute/subtraction_simple.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -22,7 +22,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="subtraction_simple" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/subtraction_simple_neg.py b/examples_and_tutorials/core_concept_single_party_compute/subtraction_simple_neg.py similarity index 96% rename from client_single_party_compute/subtraction_simple_neg.py rename to examples_and_tutorials/core_concept_single_party_compute/subtraction_simple_neg.py index 37be9f5a..84960857 100644 --- a/client_single_party_compute/subtraction_simple_neg.py +++ b/examples_and_tutorials/core_concept_single_party_compute/subtraction_simple_neg.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -21,7 +21,7 @@ async def main(): user_id = client.user_id() party_name="Party1" program_name="subtraction_simple_neg" - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # store program action_id = await client.store_program( diff --git a/client_single_party_compute/tiny_secret_addition.py b/examples_and_tutorials/core_concept_single_party_compute/tiny_secret_addition.py similarity index 96% rename from client_single_party_compute/tiny_secret_addition.py rename to examples_and_tutorials/core_concept_single_party_compute/tiny_secret_addition.py index d51611f0..2ad87f97 100644 --- a/client_single_party_compute/tiny_secret_addition.py +++ b/examples_and_tutorials/core_concept_single_party_compute/tiny_secret_addition.py @@ -5,7 +5,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -30,7 +30,7 @@ async def main(): # Set the program name program_name="tiny_secret_addition" # Set the path to the compiled program - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # Store the program # Create a variable for the program_id, which is the {user_id}/{program_name} diff --git a/client_single_party_compute/tiny_secret_addition_complete.py b/examples_and_tutorials/core_concept_single_party_compute/tiny_secret_addition_complete.py similarity index 97% rename from client_single_party_compute/tiny_secret_addition_complete.py rename to examples_and_tutorials/core_concept_single_party_compute/tiny_secret_addition_complete.py index afe5c1ce..5197d4d4 100644 --- a/client_single_party_compute/tiny_secret_addition_complete.py +++ b/examples_and_tutorials/core_concept_single_party_compute/tiny_secret_addition_complete.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -32,7 +32,7 @@ async def main(): # Set the program name program_name="tiny_secret_addition_complete" # Set the path to the compiled program - program_mir_path=f"../programs-compiled/{program_name}.nada.bin" + program_mir_path=f"../../programs-compiled/{program_name}.nada.bin" # Store the program action_id = await client.store_program( cluster_id, program_name, program_mir_path diff --git a/store_and_retrieve_secrets/store_and_retrieve_blob.py b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py similarity index 94% rename from store_and_retrieve_secrets/store_and_retrieve_blob.py rename to examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py index 948dbb5c..4e18ced8 100644 --- a/store_and_retrieve_secrets/store_and_retrieve_blob.py +++ b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -29,7 +29,7 @@ async def main(): }) # Store a SecretBlob - # Notice that both bindings and permissions are set to None + # Notice that both bindings and core_concept_permissions are set to None # Secrets of type SecretBlob don't need bindings because they aren't used in programs # Permissions need to be set to allow users other than the secret creator to use the secret store_id = await client.store_secrets( diff --git a/store_and_retrieve_secrets/store_and_retrieve_integer.py b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py similarity index 94% rename from store_and_retrieve_secrets/store_and_retrieve_integer.py rename to examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py index 4f2a10e1..54f9f6ce 100644 --- a/store_and_retrieve_secrets/store_and_retrieve_integer.py +++ b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -27,7 +27,7 @@ async def main(): }) # Store a SecretInteger - # Notice that both bindings and permissions are set to None + # Notice that both bindings and core_concept_permissions are set to None # Bindings need to be set to use secrets in programs # Permissions need to be set to allow users other than the secret creator to use the secret store_id = await client.store_secrets( diff --git a/millionaires_problem_example/01_store_secret_party1.py b/examples_and_tutorials/millionaires_problem_example/01_store_secret_party1.py similarity index 96% rename from millionaires_problem_example/01_store_secret_party1.py rename to examples_and_tutorials/millionaires_problem_example/01_store_secret_party1.py index 0d780f10..498e5b33 100644 --- a/millionaires_problem_example/01_store_secret_party1.py +++ b/examples_and_tutorials/millionaires_problem_example/01_store_secret_party1.py @@ -8,7 +8,7 @@ CONFIG_PARTY_1 ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -24,7 +24,7 @@ async def main(): millionaires_program_name = "millionaires" # Note: check out the code for the full millionaires program in the programs folder - program_mir_path = "./millionaires.nada.bin" + program_mir_path = "millionaires.nada.bin" # Store millionaires program in the network print(f"Storing program in the network: {millionaires_program_name}") diff --git a/millionaires_problem_example/02_store_secret_party_n.py b/examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py similarity index 88% rename from millionaires_problem_example/02_store_secret_party_n.py rename to examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py index d6117993..d72bb541 100644 --- a/millionaires_problem_example/02_store_secret_party_n.py +++ b/examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py @@ -10,7 +10,7 @@ CONFIG_N_PARTIES ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -19,7 +19,7 @@ # Bob and Charlie store their salaries in the network async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( "--user_id_1", @@ -65,15 +65,15 @@ async def main(args = None): secret_bindings.add_input_party(party_name, party_id_n) print(f"\nšŸ”— {party_name} sets bindings so that the secret can be input to a specific program (program_id: {args.program_id}) by a specific party (party_id: {party_id_n})") - # Create permissions object with default permissions for the current user + # Create core_concept_permissions object with default core_concept_permissions for the current user permissions = nillion.Permissions.default_for_user(user_id_n) - # Give compute permissions to Alice so she can use the secret in the specific millionionaires program by program id + # Give compute core_concept_permissions to Alice so she can use the secret in the specific millionionaires program by program id compute_permissions = { args.user_id_1: {args.program_id}, } permissions.add_compute_permissions(compute_permissions) - print(f"\nšŸ‘ {party_name} gives compute permissions on their secret to Alice's user_id: {args.user_id_1}") + print(f"\nšŸ‘ {party_name} gives compute core_concept_permissions on their secret to Alice's user_id: {args.user_id_1}") # Store the permissioned secret store_id = await client_n.store_secrets( diff --git a/millionaires_problem_example/03_multi_party_compute.py b/examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py similarity index 98% rename from millionaires_problem_example/03_multi_party_compute.py rename to examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py index 6d3f98e7..e8716d67 100644 --- a/millionaires_problem_example/03_multi_party_compute.py +++ b/examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py @@ -16,7 +16,7 @@ store_secret_party_1 = importlib.import_module("01_store_secret_party1") store_secret_party_n = importlib.import_module("02_store_secret_party_n") -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -24,7 +24,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( diff --git a/millionaires_problem_example/README.md b/examples_and_tutorials/millionaires_problem_example/README.md similarity index 100% rename from millionaires_problem_example/README.md rename to examples_and_tutorials/millionaires_problem_example/README.md diff --git a/millionaires_problem_example/config.py b/examples_and_tutorials/millionaires_problem_example/config.py similarity index 100% rename from millionaires_problem_example/config.py rename to examples_and_tutorials/millionaires_problem_example/config.py diff --git a/millionaires_problem_example/millionaires.nada.bin b/examples_and_tutorials/millionaires_problem_example/millionaires.nada.bin similarity index 100% rename from millionaires_problem_example/millionaires.nada.bin rename to examples_and_tutorials/millionaires_problem_example/millionaires.nada.bin diff --git a/voting_tutorial/01_store_program_party1.py b/examples_and_tutorials/voting_tutorial/01_store_program_party1.py similarity index 98% rename from voting_tutorial/01_store_program_party1.py rename to examples_and_tutorials/voting_tutorial/01_store_program_party1.py index d1cb6f5b..84bdf312 100644 --- a/voting_tutorial/01_store_program_party1.py +++ b/examples_and_tutorials/voting_tutorial/01_store_program_party1.py @@ -13,7 +13,7 @@ CONFIG_PARTY_1 ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile @@ -85,7 +85,7 @@ async def main(): # 2. Storing program # ##################################### - program_mir_path = f"../programs-compiled/{program_name}.nada.bin" + program_mir_path = f"../../programs-compiled/{program_name}.nada.bin" if os.path.exists(program_mir_path): None else: diff --git a/voting_tutorial/02_store_secret_party_n.py b/examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py similarity index 89% rename from voting_tutorial/02_store_secret_party_n.py rename to examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py index df2d187e..6931c927 100644 --- a/voting_tutorial/02_store_secret_party_n.py +++ b/examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py @@ -14,14 +14,14 @@ CONFIG_N_PARTIES ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile load_dotenv() parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( "--user_id_1", @@ -83,17 +83,17 @@ async def main(): print(f"\nšŸ”— {party_name} sets bindings so that the secret can be input to a specific program (program_id: {args.program_id}) by a specific party (party_id: {party_id_n})") ########################################### - # 4.2 Set compute permissions to owner # + # 4.2 Set compute core_concept_permissions to owner # ########################################### - # Create permissions object with default permissions for the current user + # Create core_concept_permissions object with default core_concept_permissions for the current user permissions = nillion.Permissions.default_for_user(user_id_n) - # Give compute permissions to Alice so she can use the secret in the specific voting program by program id + # Give compute core_concept_permissions to Alice so she can use the secret in the specific voting program by program id compute_permissions = { args.user_id_1: {args.program_id}, } permissions.add_compute_permissions(compute_permissions) - print(f"\nšŸ‘ {party_name} gives compute permissions on their secret to Alice's user_id: {args.user_id_1}") + print(f"\nšŸ‘ {party_name} gives compute core_concept_permissions on their secret to Alice's user_id: {args.user_id_1}") # Store the permissioned secret store_id = await client_n.store_secrets( diff --git a/voting_tutorial/03_multi_party_compute.py b/examples_and_tutorials/voting_tutorial/03_multi_party_compute.py similarity index 99% rename from voting_tutorial/03_multi_party_compute.py rename to examples_and_tutorials/voting_tutorial/03_multi_party_compute.py index 9033b382..f08928f9 100644 --- a/voting_tutorial/03_multi_party_compute.py +++ b/examples_and_tutorials/voting_tutorial/03_multi_party_compute.py @@ -17,7 +17,7 @@ CONFIG_N_PARTIES ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile from digest_result import digest_plurality_vote_honest_result, digest_plurality_vote_dishonest_with_abort_result, digest_plurality_vote_robust_result @@ -26,7 +26,7 @@ load_dotenv() parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve permissions" + description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" ) parser.add_argument( diff --git a/voting_tutorial/README.md b/examples_and_tutorials/voting_tutorial/README.md similarity index 81% rename from voting_tutorial/README.md rename to examples_and_tutorials/voting_tutorial/README.md index def0ba2d..f4ea3380 100644 --- a/voting_tutorial/README.md +++ b/examples_and_tutorials/voting_tutorial/README.md @@ -15,7 +15,7 @@ Please go to the [tutorial page](tutorial.md) to dive deeper into PyNada. ## Setup -Before running the example, [follow the repo README](../README.md) to install cli dependencies, complete environment setup, and activate your .venv environment. +Before running the example, [follow the repo README](../../README.md) to install cli dependencies, complete environment setup, and activate your .venv environment. ## Single file example @@ -30,7 +30,7 @@ In the single file version, the different roles are played by a single entity (` 5. (Real environment:) Voters send their their party IDs and store IDs to the owner. 6. Owner compute voting system using votes from voters. -Also, we present a function [`digest_plurality_vote_robust_result()`](./digest_result.py) that digests the result output by the [voting_dishonest_robust_6.py](../programs/voting_dishonest_robust_6.py). +Also, we present a function [`digest_plurality_vote_robust_result()`](digest_result.py) that digests the result output by the [voting_dishonest_robust_6.py](../../programs/voting_dishonest_robust_6.py). ### Run @@ -41,7 +41,7 @@ python3 client_voting.py ## Multiple files example -In this voting example, we maintain the same structure as in previous multiparty computation examples (please refer to the [client_multi_party_compute folder](../client_multi_party_compute/) and [Millionaires' problem example](../millionaires_problem_example/)): +In this voting example, we maintain the same structure as in previous multiparty computation examples: - Alice assumes the role of the owner and acts as voter 0. - Bob serves as voter 1. @@ -84,4 +84,4 @@ The script will provide the command to perform step 3. python3 03_multi_party_compute.py --program_id {program_id} --party_ids_to_store_ids {party_ids_to_store_ids} ``` -Also, we present a function [`digest_plurality_vote_robust_result()`](./digest_result.py) that digests the result output by the [voting_dishonest_robust_6.py](../programs/voting_dishonest_robust_6.py). +Also, we present a function [`digest_plurality_vote_robust_result()`](digest_result.py) that digests the result output by the [voting_dishonest_robust_6.py](../../programs/voting_dishonest_robust_6.py). diff --git a/voting_tutorial/client_voting.py b/examples_and_tutorials/voting_tutorial/client_voting.py similarity index 98% rename from voting_tutorial/client_voting.py rename to examples_and_tutorials/voting_tutorial/client_voting.py index cbc78012..5cc3e4fc 100644 --- a/voting_tutorial/client_voting.py +++ b/examples_and_tutorials/voting_tutorial/client_voting.py @@ -14,7 +14,7 @@ CONFIG ) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from helpers.nillion_client_helper import create_nillion_client from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile from digest_result import digest_plurality_vote_honest_result, digest_plurality_vote_dishonest_with_abort_result, digest_plurality_vote_robust_result @@ -142,7 +142,7 @@ async def main(): ##################################### # Note: do not forget to compile the programs and store the corresponding .nada.bin file. - program_mir_path = f"../programs-compiled/{program_name}.nada.bin" + program_mir_path = f"../../programs-compiled/{program_name}.nada.bin" if os.path.exists(program_mir_path): None else: @@ -205,9 +205,9 @@ async def main(): v_bindings.add_input_party("Voter"+str(v), voter_v.party_id()) ########################################### - # 4.2 Set compute permissions to owner # + # 4.2 Set compute core_concept_permissions to owner # ########################################### - # Give permissions to owner to compute with my vote + # Give core_concept_permissions to owner to compute with my vote v_permissions = nillion.Permissions.default_for_user(voter_v.user_id()) v_permissions.add_compute_permissions({ # owner.user_id(): {program_id}, diff --git a/voting_tutorial/config.py b/examples_and_tutorials/voting_tutorial/config.py similarity index 100% rename from voting_tutorial/config.py rename to examples_and_tutorials/voting_tutorial/config.py diff --git a/voting_tutorial/digest_result.py b/examples_and_tutorials/voting_tutorial/digest_result.py similarity index 100% rename from voting_tutorial/digest_result.py rename to examples_and_tutorials/voting_tutorial/digest_result.py diff --git a/voting_tutorial/image/architecture.png b/examples_and_tutorials/voting_tutorial/image/architecture.png similarity index 100% rename from voting_tutorial/image/architecture.png rename to examples_and_tutorials/voting_tutorial/image/architecture.png diff --git a/voting_tutorial/inputs/v0_input.txt b/examples_and_tutorials/voting_tutorial/inputs/v0_input.txt similarity index 100% rename from voting_tutorial/inputs/v0_input.txt rename to examples_and_tutorials/voting_tutorial/inputs/v0_input.txt diff --git a/voting_tutorial/inputs/v1_input.txt b/examples_and_tutorials/voting_tutorial/inputs/v1_input.txt similarity index 100% rename from voting_tutorial/inputs/v1_input.txt rename to examples_and_tutorials/voting_tutorial/inputs/v1_input.txt diff --git a/voting_tutorial/inputs/v2_input.txt b/examples_and_tutorials/voting_tutorial/inputs/v2_input.txt similarity index 100% rename from voting_tutorial/inputs/v2_input.txt rename to examples_and_tutorials/voting_tutorial/inputs/v2_input.txt diff --git a/voting_tutorial/tutorial.md b/examples_and_tutorials/voting_tutorial/tutorial.md similarity index 99% rename from voting_tutorial/tutorial.md rename to examples_and_tutorials/voting_tutorial/tutorial.md index c7ca903e..0fd3674b 100644 --- a/voting_tutorial/tutorial.md +++ b/examples_and_tutorials/voting_tutorial/tutorial.md @@ -67,7 +67,7 @@ Under this assumption, **all** the above voting systems can be reduced to **one* Let us start with a simple program with 3 voters and 2 candidates. Recall that the following program can be applied to any type of voting system described in the previous [chapter](#voting-systems). -Program: [voting_honest_1.py](../programs/voting_honest_1.py) +Program: [voting_honest_1.py](../../programs/voting_honest_1.py) ```python """ PROGRAM 1 @@ -166,7 +166,7 @@ We can make use of the Python run-time `for` loop to unroll the variables and cr Below, program 2 shows how we could use compiled-time `for` loops to assist us creating all parties, input votes and building the computation section. -Program: [voting_honest_2.py](../programs/voting_honest_2.py) +Program: [voting_honest_2.py](../../programs/voting_honest_2.py) ```python """ PROGRAM 2 @@ -492,7 +492,7 @@ Similarly, we can utilize compiled-time `for` loops and **Python functions** to >šŸ’” In addition to compiled-time `for` loops, leveraging **Python functions** can lead to more organized and cleaner code. Python functions are executed by the interpreter during compilation and cannot rely on runtime variables. In contrast, **Nada functions** rely on run-time variables and are only executed during run-time. This distinction becomes apparent when comparing with the example provided in program 3. -Program: [voting_dishonest_abort_5.py](../programs/voting_dishonest_abort_5.py) +Program: [voting_dishonest_abort_5.py](../../programs/voting_dishonest_abort_5.py) ```python """ PROGRAM 5 @@ -709,7 +709,7 @@ Then, we output the cheating conditions `comp_v1_sum`, `comp_v1_c0_prod` and `co Below, we put together the above two checks with our protocol. For readability purposes, we use a function `return_val_if_any_true(list_of_bool, val)` which returns the value `val` if at least on boolean in the list is false. -Program: [voting_dishonest_robust_6.py](../programs/voting_dishonest_robust_6.py) +Program: [voting_dishonest_robust_6.py](../../programs/voting_dishonest_robust_6.py) ```python """ PROGRAM 6 diff --git a/store_and_retrieve_secrets/store_and_retrieve_array.py b/store_and_retrieve_secrets/store_and_retrieve_array.py deleted file mode 100644 index 5af469c8..00000000 --- a/store_and_retrieve_secrets/store_and_retrieve_array.py +++ /dev/null @@ -1,68 +0,0 @@ -import asyncio -import py_nillion_client as nillion -import os -import sys -import pytest - -from dotenv import load_dotenv - -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from helpers.nillion_client_helper import create_nillion_client -from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile - -load_dotenv() - -# Store and retrieve a SecretArray using the Python Client -async def main(): - cluster_id = os.getenv("NILLION_CLUSTER_ID") - userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) - nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) - client = create_nillion_client(userkey, nodekey) - - # Create a SecretArray, a SecretInteger list - secret_name = "my_array" - secret_value = nillion.SecretArray([ - nillion.SecretInteger(1), - nillion.SecretInteger(2), - nillion.SecretInteger(3), - nillion.SecretInteger(4), - nillion.SecretInteger(5), - ]) - - secret_array = nillion.Secrets({ - secret_name: secret_value - }) - - # Store a SecretArray - # Notice that both bindings and permissions are set to None - # Bindings need to be set to use secrets in programs - # Permissions need to be set to allow users other than the secret creator to use the secret - store_id = await client.store_secrets( - cluster_id, None, secret_array, None - ) - - print(f"The secret is stored at store_id: {store_id}") - - # Retrieve the stored SecretArray - result_tuple = await client.retrieve_secret(cluster_id, store_id, secret_name) - - print(f"The secret name as a uuid is {result_tuple[0]}") - - # This is the list of secret objects - secret_results = result_tuple[1].value - - # Read the secret value of the 1st element in the secret array - print(f"The secret array value at index 0 is {secret_results[0].value}") - - # Read all secret values in the secret array - secret_array_values = [secret_value.value for secret_value in secret_results] - print("The secret array values are:", secret_array_values) - return secret_array_values - -if __name__ == "__main__": - asyncio.run(main()) - -@pytest.mark.asyncio -async def test_main(): - result = await main() - assert result == [1, 2, 3, 4, 5] From ca91df4ba556ebfee9279c124955ec76c1f28175 Mon Sep 17 00:00:00 2001 From: David Butler Date: Wed, 1 May 2024 17:38:00 +0100 Subject: [PATCH 2/3] README consistency and permissions strings changed --- README.md | 6 +++--- .../02_store_secret_party_n.py | 6 +++--- .../03_multi_party_compute.py | 2 +- .../core_concept_multi_party_compute/README.md | 2 +- .../01_fetch_reader_userid.py | 2 +- .../02_store_permissioned_secret.py | 2 +- .../core_concept_permissions/03_retrieve_secret.py | 4 ++-- .../04_revoke_read_permissions.py | 12 ++++++------ .../05_test_revoked_permissions.py | 6 +++--- .../core_concept_permissions/README.md | 3 ++- .../core_concept_single_party_compute/README.md | 2 +- .../store_and_retrieve_blob.py | 2 +- .../store_and_retrieve_integer.py | 2 +- .../02_store_secret_party_n.py | 8 ++++---- .../03_multi_party_compute.py | 2 +- .../millionaires_problem_example/README.md | 2 +- .../voting_tutorial/02_store_secret_party_n.py | 10 +++++----- .../voting_tutorial/03_multi_party_compute.py | 2 +- .../voting_tutorial/client_voting.py | 4 ++-- 19 files changed, 40 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index bafe59a2..ab1eda19 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ This is a python starter repo for building on the Nillion Network. Complete environment setup, then run the examples: -- To run multi party examples, go to the [client_multi_party_compute](examples_and_tutorials/core_concept_multi_party_compute) folder. +- To run multi party examples, go to the [multi party compute](examples_and_tutorials/core_concept_multi_party_compute) folder. -- To run single party examples, go to the [client_single_party_compute](examples_and_tutorials/core_concept_single_party_compute) folder. +- To run single party examples, go to the [single party compute](examples_and_tutorials/core_concept_single_party_compute) folder. - To run permissions examples (storing and retrieving permissioned secrets, revoking permissions, etc.), go to the [permissions](examples_and_tutorials/core_concept_permissions) folder. ### Prerequisites: Install the CLI Dependencies -The `run-local-cluster` tool spins up `anvil` under the hood, so you need to have `foundry` installed. The [`bootstrap-local-environment.sh`](./bootstrap-local-environment.sh) file uses `pidof` and `grep`. +The `nillion-devnet` tool spins up `anvil` under the hood, so you need to have `foundry` installed. The [`bootstrap-local-environment.sh`](./bootstrap-local-environment.sh) file uses `pidof` and `grep`. - [Install `foundry`](https://book.getfoundry.sh/getting-started/installation) - [Install `pidof`](https://command-not-found.com/pidof) diff --git a/examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py b/examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py index 5a144542..d3184d5d 100644 --- a/examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py +++ b/examples_and_tutorials/core_concept_multi_party_compute/02_store_secret_party_n.py @@ -20,7 +20,7 @@ # N other parties store a secret async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( "--user_id_1", @@ -64,10 +64,10 @@ async def main(args = None): secret_bindings = nillion.ProgramBindings(program_id) secret_bindings.add_input_party(party_name, party_id_n) - # Create core_concept_permissions object + # Create permissions object permissions = nillion.Permissions.default_for_user(user_id_n) - # Give compute core_concept_permissions to the first party + # Give compute permissions to the first party compute_permissions = { args.user_id_1: {program_id}, } diff --git a/examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py b/examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py index 7889eb70..77dbdd8b 100644 --- a/examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py +++ b/examples_and_tutorials/core_concept_multi_party_compute/03_multi_party_compute.py @@ -25,7 +25,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( diff --git a/examples_and_tutorials/core_concept_multi_party_compute/README.md b/examples_and_tutorials/core_concept_multi_party_compute/README.md index 0c36dca7..856a997c 100644 --- a/examples_and_tutorials/core_concept_multi_party_compute/README.md +++ b/examples_and_tutorials/core_concept_multi_party_compute/README.md @@ -37,7 +37,7 @@ The 3-part Multi Party example assumes there is a stored program that meets the For example before running addition_simple_multi_party.py, compile all programs and check that addition_simple_multi_party.nada.bin exists in the compiled-programs folder. ```bash -cd .. +cd ../.. ./compile_programs.sh ``` diff --git a/examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py b/examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py index b6d6354b..c083296f 100644 --- a/examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py +++ b/examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py @@ -21,7 +21,7 @@ async def main(): reader_user_id = reader.user_id() print("ā„¹ļø Fetched the reader's USER ID:", reader_user_id) - print("\n\nRun the following command to store a secret and give read/retrieve core_concept_permissions to the READER USER ID") + print("\n\nRun the following command to store a secret and give read/retrieve permissions to the READER USER ID") print(f"\nšŸ“‹ python3 02_store_permissioned_secret.py --retriever_user_id {reader.user_id()}") return reader.user_id() diff --git a/examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py b/examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py index 0f606012..f8e941a1 100644 --- a/examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py +++ b/examples_and_tutorials/core_concept_permissions/02_store_permissioned_secret.py @@ -16,7 +16,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( "--retriever_user_id", diff --git a/examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py b/examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py index 6361636a..73d8ba4d 100644 --- a/examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py +++ b/examples_and_tutorials/core_concept_permissions/03_retrieve_secret.py @@ -14,7 +14,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Use read core_concept_permissions to retrieve a secret owned by another user on the Nillion network" + description="Use read permissions to retrieve a secret owned by another user on the Nillion network" ) parser.add_argument( "--store_id", @@ -39,7 +39,7 @@ async def main(args = None): result = await reader.retrieve_secret(cluster_id, args.store_id, secret_name) print(f"šŸ¦„ Retrieved {secret_name} secret, value = {result[1].value}", file=sys.stderr) - print("\n\nRun the following command to revoke the reader's retrieve core_concept_permissions to the secret") + print("\n\nRun the following command to revoke the reader's retrieve permissions to the secret") print(f"\nšŸ“‹ python3 04_revoke_read_permissions.py --store_id {args.store_id} --revoked_user_id {reader_user_id}") return [args.store_id, reader_user_id] diff --git a/examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py b/examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py index c33feab9..c62eeb60 100644 --- a/examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py +++ b/examples_and_tutorials/core_concept_permissions/04_revoke_read_permissions.py @@ -15,7 +15,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Revoke user read/retrieve core_concept_permissions from a secret on the Nillion network" + description="Revoke user read/retrieve permissions from a secret on the Nillion network" ) parser.add_argument( "--store_id", @@ -38,7 +38,7 @@ async def main(args = None): # Writer Nillion client writer = create_nillion_client(userkey, nodekey) - # Create new core_concept_permissions object to rewrite core_concept_permissions (reader no longer has retrieve permission) + # Create new permissions object to rewrite permissions (reader no longer has retrieve permission) new_permissions = nillion.Permissions.default_for_user(writer.user_id()) result = ( "allowed" @@ -46,14 +46,14 @@ async def main(args = None): else "not allowed" ) if result != "not allowed": - raise Exception("failed to create valid core_concept_permissions object") + raise Exception("failed to create valid permissions object") # Update the permission - print(f"ā„¹ļø Updating core_concept_permissions for secret: {args.store_id}.") - print(f"ā„¹ļø Reset core_concept_permissions so that user id {args.revoked_user_id} is {result} to retrieve object.", file=sys.stderr) + print(f"ā„¹ļø Updating permissions for secret: {args.store_id}.") + print(f"ā„¹ļø Reset permissions so that user id {args.revoked_user_id} is {result} to retrieve object.", file=sys.stderr) await writer.update_permissions( cluster_id, args.store_id , new_permissions) - print("\n\nRun the following command to test that core_concept_permissions have been properly revoked") + print("\n\nRun the following command to test that permissions have been properly revoked") print(f"\nšŸ“‹ python3 05_test_revoked_permissions.py --store_id {args.store_id}") return args.store_id diff --git a/examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py b/examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py index 54a41e9a..c709d972 100644 --- a/examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py +++ b/examples_and_tutorials/core_concept_permissions/05_test_revoked_permissions.py @@ -20,7 +20,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Check that retrieval core_concept_permissions on a Secret have been revoked" + description="Check that retrieval permissions on a Secret have been revoked" ) parser.add_argument( "--store_id", @@ -41,10 +41,10 @@ async def main(args = None): try: secret_name = "my_int1" await reader.retrieve_secret(cluster_id, args.store_id, secret_name) - print(f"ā›” FAIL: {reader_user_id} user id with revoked core_concept_permissions was allowed to access secret", file=sys.stderr) + print(f"ā›” FAIL: {reader_user_id} user id with revoked permissions was allowed to access secret", file=sys.stderr) except Exception as e: if str(e) == "retrieving secret: the user is not authorized to access the secret": - print(f"šŸ¦„ Success: After user core_concept_permissions were revoked, {reader_user_id} was not allowed to access secret", file=sys.stderr) + print(f"šŸ¦„ Success: After user permissions were revoked, {reader_user_id} was not allowed to access secret", file=sys.stderr) else: raise(e) diff --git a/examples_and_tutorials/core_concept_permissions/README.md b/examples_and_tutorials/core_concept_permissions/README.md index 5d462ede..1be1b83b 100644 --- a/examples_and_tutorials/core_concept_permissions/README.md +++ b/examples_and_tutorials/core_concept_permissions/README.md @@ -8,8 +8,9 @@ Before running through examples, `./bootstrap-local-environment.sh` creates user 4. The writer revokes secret permissions by rewriting them 5. The reader tries to retrieve the secret, but no longer has access to it +To run through the example flow, simply run the python scripts in order. The output of a script will show you what to run next. Below gives the structure of the commands needed. + ```shell -cd core_concept_permissions python3 01_fetch_reader_userid.py python3 02_store_permissioned_secret.py --retriever_user_id {READER_USER_ID} python3 03_retrieve_secret.py --store_id {STORE_ID} diff --git a/examples_and_tutorials/core_concept_single_party_compute/README.md b/examples_and_tutorials/core_concept_single_party_compute/README.md index e44feded..a719c9e1 100644 --- a/examples_and_tutorials/core_concept_single_party_compute/README.md +++ b/examples_and_tutorials/core_concept_single_party_compute/README.md @@ -11,7 +11,7 @@ These compute examples only involve one party. For example before running addition_simple.py, compile all programs and check that addition_simple.nada.bin exists in the compiled-programs folder. ```bash -cd .. +cd ../.. ./compile_programs.sh ``` diff --git a/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py index 4e18ced8..90ca81fb 100644 --- a/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py +++ b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_blob.py @@ -29,7 +29,7 @@ async def main(): }) # Store a SecretBlob - # Notice that both bindings and core_concept_permissions are set to None + # Notice that both bindings and permissions are set to None # Secrets of type SecretBlob don't need bindings because they aren't used in programs # Permissions need to be set to allow users other than the secret creator to use the secret store_id = await client.store_secrets( diff --git a/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py index 54f9f6ce..781dcabb 100644 --- a/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py +++ b/examples_and_tutorials/core_concept_store_and_retrieve_secrets/store_and_retrieve_integer.py @@ -27,7 +27,7 @@ async def main(): }) # Store a SecretInteger - # Notice that both bindings and core_concept_permissions are set to None + # Notice that both bindings and permissions are set to None # Bindings need to be set to use secrets in programs # Permissions need to be set to allow users other than the secret creator to use the secret store_id = await client.store_secrets( diff --git a/examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py b/examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py index d72bb541..d2ac45e8 100644 --- a/examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py +++ b/examples_and_tutorials/millionaires_problem_example/02_store_secret_party_n.py @@ -19,7 +19,7 @@ # Bob and Charlie store their salaries in the network async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( "--user_id_1", @@ -65,15 +65,15 @@ async def main(args = None): secret_bindings.add_input_party(party_name, party_id_n) print(f"\nšŸ”— {party_name} sets bindings so that the secret can be input to a specific program (program_id: {args.program_id}) by a specific party (party_id: {party_id_n})") - # Create core_concept_permissions object with default core_concept_permissions for the current user + # Create permissions object with default permissions for the current user permissions = nillion.Permissions.default_for_user(user_id_n) - # Give compute core_concept_permissions to Alice so she can use the secret in the specific millionionaires program by program id + # Give compute permissions to Alice so she can use the secret in the specific millionionaires program by program id compute_permissions = { args.user_id_1: {args.program_id}, } permissions.add_compute_permissions(compute_permissions) - print(f"\nšŸ‘ {party_name} gives compute core_concept_permissions on their secret to Alice's user_id: {args.user_id_1}") + print(f"\nšŸ‘ {party_name} gives compute permissions on their secret to Alice's user_id: {args.user_id_1}") # Store the permissioned secret store_id = await client_n.store_secrets( diff --git a/examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py b/examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py index e8716d67..c416ba47 100644 --- a/examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py +++ b/examples_and_tutorials/millionaires_problem_example/03_multi_party_compute.py @@ -24,7 +24,7 @@ async def main(args = None): parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( diff --git a/examples_and_tutorials/millionaires_problem_example/README.md b/examples_and_tutorials/millionaires_problem_example/README.md index 885cac9f..181ec1a1 100644 --- a/examples_and_tutorials/millionaires_problem_example/README.md +++ b/examples_and_tutorials/millionaires_problem_example/README.md @@ -6,7 +6,7 @@ They want to figure out who has the highest salary without telling each other ho Alice suggests that this is the perfect opportunity for the friends to use Nillion for blind computation on high value data to determine who should pay for lunch. She offers to create a millionaires problem program, compile it, and store it in Nillion so that the friends can run multi party blind computation to figure out who should pay for lunch. -- Alice's millionaires program in NADA: [../programs/millionaires.py](https://github.com/NillionNetwork/nillion-python-starter/blob/main/programs/millionaires.py) +- Alice's millionaires program in NADA: [../../programs/millionaires.py](https://github.com/NillionNetwork/nillion-python-starter/blob/main/programs/millionaires.py) - Compiled program: [./millionaires.nada.bin](https://github.com/NillionNetwork/nillion-python-starter/blob/main/millionaires_problem_example/millionaires.nada.bin) ## Setup diff --git a/examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py b/examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py index 6931c927..40c89afa 100644 --- a/examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py +++ b/examples_and_tutorials/voting_tutorial/02_store_secret_party_n.py @@ -21,7 +21,7 @@ load_dotenv() parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( "--user_id_1", @@ -83,17 +83,17 @@ async def main(): print(f"\nšŸ”— {party_name} sets bindings so that the secret can be input to a specific program (program_id: {args.program_id}) by a specific party (party_id: {party_id_n})") ########################################### - # 4.2 Set compute core_concept_permissions to owner # + # 4.2 Set compute permissions to owner # ########################################### - # Create core_concept_permissions object with default core_concept_permissions for the current user + # Create permissions object with default permissions for the current user permissions = nillion.Permissions.default_for_user(user_id_n) - # Give compute core_concept_permissions to Alice so she can use the secret in the specific voting program by program id + # Give compute permissions to Alice so she can use the secret in the specific voting program by program id compute_permissions = { args.user_id_1: {args.program_id}, } permissions.add_compute_permissions(compute_permissions) - print(f"\nšŸ‘ {party_name} gives compute core_concept_permissions on their secret to Alice's user_id: {args.user_id_1}") + print(f"\nšŸ‘ {party_name} gives compute permissions on their secret to Alice's user_id: {args.user_id_1}") # Store the permissioned secret store_id = await client_n.store_secrets( diff --git a/examples_and_tutorials/voting_tutorial/03_multi_party_compute.py b/examples_and_tutorials/voting_tutorial/03_multi_party_compute.py index f08928f9..a9c9135b 100644 --- a/examples_and_tutorials/voting_tutorial/03_multi_party_compute.py +++ b/examples_and_tutorials/voting_tutorial/03_multi_party_compute.py @@ -26,7 +26,7 @@ load_dotenv() parser = argparse.ArgumentParser( - description="Create a secret on the Nillion network with set read/retrieve core_concept_permissions" + description="Create a secret on the Nillion network with set read/retrieve permissions" ) parser.add_argument( diff --git a/examples_and_tutorials/voting_tutorial/client_voting.py b/examples_and_tutorials/voting_tutorial/client_voting.py index 5cc3e4fc..cae868f4 100644 --- a/examples_and_tutorials/voting_tutorial/client_voting.py +++ b/examples_and_tutorials/voting_tutorial/client_voting.py @@ -205,9 +205,9 @@ async def main(): v_bindings.add_input_party("Voter"+str(v), voter_v.party_id()) ########################################### - # 4.2 Set compute core_concept_permissions to owner # + # 4.2 Set compute permissions to owner # ########################################### - # Give core_concept_permissions to owner to compute with my vote + # Give permissions to owner to compute with my vote v_permissions = nillion.Permissions.default_for_user(voter_v.user_id()) v_permissions.add_compute_permissions({ # owner.user_id(): {program_id}, From 6e0a829a7ef35fe94b4cd093cb6fa10718abcb96 Mon Sep 17 00:00:00 2001 From: Jmgr Date: Wed, 1 May 2024 20:41:02 +0100 Subject: [PATCH 3/3] testing: update paths --- testing/docker_main.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/testing/docker_main.sh b/testing/docker_main.sh index 7fb47e3e..3fef4690 100644 --- a/testing/docker_main.sh +++ b/testing/docker_main.sh @@ -32,7 +32,10 @@ echo "Waiting 60 seconds for preprocessing elements" && sleep 60 && \ sh compile_programs.sh && \ run_pytest_in_dir client_single_party_compute && \ -run_pytest_in_dir client_multi_party_compute && \ -run_pytest_in_dir millionaires_problem_example && \ -run_pytest_in_dir permissions && \ -run_pytest_in_dir store_and_retrieve_secrets +cd examples_and_tutorials && \ +run_pytest_in_dir core_concept_multi_party_compute && \ +run_pytest_in_dir core_concept_permissions && \ +run_pytest_in_dir core_concept_single_party_compute && \ +run_pytest_in_dir core_concept_permissions && \ +run_pytest_in_dir core_concept_store_and_retrieve_secrets && \ +run_pytest_in_dir millionaires_problem_example