From 7d7a4558a8110926fbf2ac9c5f72a262f7f612b6 Mon Sep 17 00:00:00 2001 From: Jmgr Date: Thu, 4 Apr 2024 19:33:57 +0100 Subject: [PATCH 1/6] fix: update user_id and party_id being attributes and not methods --- .../01_store_secret_party1.py | 4 ++-- .../02_store_secret_party_n.py | 4 ++-- .../03_multi_party_compute.py | 4 ++-- .../addition_simple.py | 4 ++-- client_single_party_compute/circuit_simple.py | 4 ++-- .../circuit_simple_2.py | 4 ++-- client_single_party_compute/complex.py | 4 ++-- .../division_simple.py | 4 ++-- client_single_party_compute/input_integer.py | 4 ++-- client_single_party_compute/input_single.py | 4 ++-- client_single_party_compute/modulo_simple.py | 4 ++-- .../multiplication_simple.py | 6 +++--- .../nada_fn_composition.py | 4 ++-- client_single_party_compute/nada_fn_simple.py | 4 ++-- client_single_party_compute/reduce_simple.py | 4 ++-- client_single_party_compute/reuse.py | 4 ++-- client_single_party_compute/reuse_flipped1.py | 4 ++-- client_single_party_compute/reuse_flipped2.py | 4 ++-- client_single_party_compute/reuse_simple_1.py | 4 ++-- client_single_party_compute/reuse_simple_2.py | 4 ++-- .../reuse_simple_sub.py | 4 ++-- client_single_party_compute/simple.py | 4 ++-- .../simple_literals.py | 4 ++-- .../simple_public_variables.py | 4 ++-- .../simple_public_variables_only.py | 4 ++-- client_single_party_compute/simple_sub.py | 4 ++-- .../single_addition.py | 4 ++-- .../subtraction_simple.py | 4 ++-- .../subtraction_simple_neg.py | 4 ++-- .../tiny_secret_addition_complete.py | 4 ++-- .../01_store_secret_party1.py | 2 +- .../02_store_secret_party_n.py | 4 ++-- .../03_multi_party_compute.py | 2 +- permissions/01_fetch_reader_userid.py | 6 +++--- permissions/02_store_permissioned_secret.py | 2 +- permissions/03_retrieve_secret.py | 2 +- permissions/04_revoke_read_permissions.py | 2 +- permissions/05_test_revoked_permissions.py | 2 +- voting_tutorial/01_store_program_party1.py | 2 +- voting_tutorial/02_store_secret_party_n.py | 4 ++-- voting_tutorial/03_multi_party_compute.py | 2 +- voting_tutorial/client_voting.py | 20 +++++++++---------- 42 files changed, 86 insertions(+), 86 deletions(-) diff --git a/client_multi_party_compute/01_store_secret_party1.py b/client_multi_party_compute/01_store_secret_party1.py index 1b450153..c700076d 100644 --- a/client_multi_party_compute/01_store_secret_party1.py +++ b/client_multi_party_compute/01_store_secret_party1.py @@ -22,8 +22,8 @@ async def main(): client_1 = create_nillion_client( getUserKeyFromFile(CONFIG_PARTY_1["userkey_file"]), getNodeKeyFromFile(CONFIG_PARTY_1["nodekey_file"]) ) - party_id_1 = client_1.party_id() - user_id_1 = client_1.user_id() + party_id_1 = client_1.party_id + user_id_1 = client_1.user_id program_mir_path=f"../programs-compiled/{CONFIG_PROGRAM_NAME}.nada.bin" diff --git a/client_multi_party_compute/02_store_secret_party_n.py b/client_multi_party_compute/02_store_secret_party_n.py index 57fb3b0a..be9b0fc1 100644 --- a/client_multi_party_compute/02_store_secret_party_n.py +++ b/client_multi_party_compute/02_store_secret_party_n.py @@ -49,8 +49,8 @@ async def main(args = None): getUserKeyFromFile(party_info["userkey_file"]), getNodeKeyFromFile(party_info["nodekey_file"]) ) - party_id_n = client_n.party_id() - user_id_n = client_n.user_id() + party_id_n = client_n.party_id + user_id_n = client_n.user_id party_name = party_info["party_name"] secret_name = party_info["secret_name"] secret_value = party_info["secret_value"] diff --git a/client_multi_party_compute/03_multi_party_compute.py b/client_multi_party_compute/03_multi_party_compute.py index 3dc8e168..48658bcc 100644 --- a/client_multi_party_compute/03_multi_party_compute.py +++ b/client_multi_party_compute/03_multi_party_compute.py @@ -52,8 +52,8 @@ async def main(args = None): getUserKeyFromFile(CONFIG_PARTY_1["userkey_file"]), getNodeKeyFromFile(CONFIG_PARTY_1["nodekey_alternate_file"]), ) - user_id_1 = client_1.user_id() - party_id_1 = client_1.party_id() + user_id_1 = client_1.user_id + party_id_1 = client_1.party_id program_id=f"{user_id_1}/{CONFIG_PROGRAM_NAME}" diff --git a/client_single_party_compute/addition_simple.py b/client_single_party_compute/addition_simple.py index d1981380..966e91fc 100644 --- a/client_single_party_compute/addition_simple.py +++ b/client_single_party_compute/addition_simple.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="addition_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/circuit_simple.py b/client_single_party_compute/circuit_simple.py index 1c98b173..1ddb59c9 100644 --- a/client_single_party_compute/circuit_simple.py +++ b/client_single_party_compute/circuit_simple.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="circuit_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/circuit_simple_2.py b/client_single_party_compute/circuit_simple_2.py index 15b251c2..feef3d04 100644 --- a/client_single_party_compute/circuit_simple_2.py +++ b/client_single_party_compute/circuit_simple_2.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="circuit_simple_2" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/complex.py b/client_single_party_compute/complex.py index c0f6ca3b..81be01c4 100644 --- a/client_single_party_compute/complex.py +++ b/client_single_party_compute/complex.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="complex" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/division_simple.py b/client_single_party_compute/division_simple.py index 11d03c53..e6324b93 100644 --- a/client_single_party_compute/division_simple.py +++ b/client_single_party_compute/division_simple.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="division_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/input_integer.py b/client_single_party_compute/input_integer.py index 0702d9d1..9c9ff7c4 100644 --- a/client_single_party_compute/input_integer.py +++ b/client_single_party_compute/input_integer.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="input_integer" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/input_single.py b/client_single_party_compute/input_single.py index 76b46d43..8a0ace80 100644 --- a/client_single_party_compute/input_single.py +++ b/client_single_party_compute/input_single.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="input_single" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/modulo_simple.py b/client_single_party_compute/modulo_simple.py index e46fe1c1..ba63638e 100644 --- a/client_single_party_compute/modulo_simple.py +++ b/client_single_party_compute/modulo_simple.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="modulo_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/multiplication_simple.py b/client_single_party_compute/multiplication_simple.py index af6759e9..d5b306c1 100644 --- a/client_single_party_compute/multiplication_simple.py +++ b/client_single_party_compute/multiplication_simple.py @@ -18,9 +18,9 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id + user_id = client.user_id party_name="Party1" program_name="multiplication_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/nada_fn_composition.py b/client_single_party_compute/nada_fn_composition.py index be811a49..00844328 100644 --- a/client_single_party_compute/nada_fn_composition.py +++ b/client_single_party_compute/nada_fn_composition.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="nada_fn_composition" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/nada_fn_simple.py b/client_single_party_compute/nada_fn_simple.py index 56efcc63..b0f39294 100644 --- a/client_single_party_compute/nada_fn_simple.py +++ b/client_single_party_compute/nada_fn_simple.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="nada_fn_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reduce_simple.py b/client_single_party_compute/reduce_simple.py index 3d5dc427..d76aa3b5 100644 --- a/client_single_party_compute/reduce_simple.py +++ b/client_single_party_compute/reduce_simple.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reduce_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reuse.py b/client_single_party_compute/reuse.py index 4775e862..4a95081d 100644 --- a/client_single_party_compute/reuse.py +++ b/client_single_party_compute/reuse.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reuse" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reuse_flipped1.py b/client_single_party_compute/reuse_flipped1.py index 55af5fd4..5a9e2e69 100644 --- a/client_single_party_compute/reuse_flipped1.py +++ b/client_single_party_compute/reuse_flipped1.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reuse_flipped1" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reuse_flipped2.py b/client_single_party_compute/reuse_flipped2.py index 9fb28e92..b194b2af 100644 --- a/client_single_party_compute/reuse_flipped2.py +++ b/client_single_party_compute/reuse_flipped2.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reuse_flipped2" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reuse_simple_1.py b/client_single_party_compute/reuse_simple_1.py index 9d6f83be..c3eff49a 100644 --- a/client_single_party_compute/reuse_simple_1.py +++ b/client_single_party_compute/reuse_simple_1.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reuse_simple_1" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reuse_simple_2.py b/client_single_party_compute/reuse_simple_2.py index 6afb6d18..5e2f544b 100644 --- a/client_single_party_compute/reuse_simple_2.py +++ b/client_single_party_compute/reuse_simple_2.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reuse_simple_2" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/reuse_simple_sub.py b/client_single_party_compute/reuse_simple_sub.py index 99baf09f..a8597f6c 100644 --- a/client_single_party_compute/reuse_simple_sub.py +++ b/client_single_party_compute/reuse_simple_sub.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="reuse_simple_sub" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/simple.py b/client_single_party_compute/simple.py index 55e0999c..c7608984 100644 --- a/client_single_party_compute/simple.py +++ b/client_single_party_compute/simple.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/simple_literals.py b/client_single_party_compute/simple_literals.py index c172f233..70a6d8d7 100644 --- a/client_single_party_compute/simple_literals.py +++ b/client_single_party_compute/simple_literals.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="simple_literals" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/simple_public_variables.py b/client_single_party_compute/simple_public_variables.py index 3be81867..812a0fda 100644 --- a/client_single_party_compute/simple_public_variables.py +++ b/client_single_party_compute/simple_public_variables.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="simple_public_variables" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/simple_public_variables_only.py b/client_single_party_compute/simple_public_variables_only.py index 02c74fc4..fe30a669 100644 --- a/client_single_party_compute/simple_public_variables_only.py +++ b/client_single_party_compute/simple_public_variables_only.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="simple_public_variables_only" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/simple_sub.py b/client_single_party_compute/simple_sub.py index 1c204846..9cb3e6da 100644 --- a/client_single_party_compute/simple_sub.py +++ b/client_single_party_compute/simple_sub.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="simple_sub" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/single_addition.py b/client_single_party_compute/single_addition.py index 89f8efd7..822ea2e8 100644 --- a/client_single_party_compute/single_addition.py +++ b/client_single_party_compute/single_addition.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="single_addition" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/subtraction_simple.py b/client_single_party_compute/subtraction_simple.py index f97e9d97..8f271988 100644 --- a/client_single_party_compute/subtraction_simple.py +++ b/client_single_party_compute/subtraction_simple.py @@ -18,8 +18,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="subtraction_simple" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/subtraction_simple_neg.py b/client_single_party_compute/subtraction_simple_neg.py index 37be9f5a..e0fc7890 100644 --- a/client_single_party_compute/subtraction_simple_neg.py +++ b/client_single_party_compute/subtraction_simple_neg.py @@ -17,8 +17,8 @@ async def main(): userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1")) client = create_nillion_client(userkey, nodekey) - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id party_name="Party1" program_name="subtraction_simple_neg" program_mir_path=f"../programs-compiled/{program_name}.nada.bin" diff --git a/client_single_party_compute/tiny_secret_addition_complete.py b/client_single_party_compute/tiny_secret_addition_complete.py index afe5c1ce..5fa9c282 100644 --- a/client_single_party_compute/tiny_secret_addition_complete.py +++ b/client_single_party_compute/tiny_secret_addition_complete.py @@ -25,8 +25,8 @@ async def main(): client = create_nillion_client(userkey, nodekey) # āœ… 2. Get the user id and party id from NillionClient - party_id = client.party_id() - user_id = client.user_id() + party_id = client.party_id + user_id = client.user_id # āœ… 3. Store a compiled Nada program in the network # Set the program name diff --git a/millionaires_problem_example/01_store_secret_party1.py b/millionaires_problem_example/01_store_secret_party1.py index 0d780f10..ad0df3ea 100644 --- a/millionaires_problem_example/01_store_secret_party1.py +++ b/millionaires_problem_example/01_store_secret_party1.py @@ -32,7 +32,7 @@ async def main(): cluster_id, millionaires_program_name, program_mir_path ) - user_id_alice = client_alice.user_id() + user_id_alice = client_alice.user_id program_id = f"{user_id_alice}/{millionaires_program_name}" print(f"Alice stores millionaires program at program_id: {program_id}") diff --git a/millionaires_problem_example/02_store_secret_party_n.py b/millionaires_problem_example/02_store_secret_party_n.py index d6117993..143b343d 100644 --- a/millionaires_problem_example/02_store_secret_party_n.py +++ b/millionaires_problem_example/02_store_secret_party_n.py @@ -47,8 +47,8 @@ async def main(args = None): getUserKeyFromFile(party_info["userkey_file"]), getNodeKeyFromFile(party_info["nodekey_file"]) ) - party_id_n = client_n.party_id() - user_id_n = client_n.user_id() + party_id_n = client_n.party_id + user_id_n = client_n.user_id party_name = party_info["party_name"] secret_name = party_info["secret_name"] secret_value = party_info["secret_value"] diff --git a/millionaires_problem_example/03_multi_party_compute.py b/millionaires_problem_example/03_multi_party_compute.py index 6d3f98e7..6c25b563 100644 --- a/millionaires_problem_example/03_multi_party_compute.py +++ b/millionaires_problem_example/03_multi_party_compute.py @@ -52,7 +52,7 @@ async def main(args = None): getUserKeyFromFile(CONFIG_PARTY_1["userkey_file"]), getNodeKeyFromFile(CONFIG_PARTY_1["nodekey_alternate_file"]) ) - party_id_alice = client_alice.party_id() + party_id_alice = client_alice.party_id # Create computation bindings for millionaires program compute_bindings = nillion.ProgramBindings(args.program_id) diff --git a/permissions/01_fetch_reader_userid.py b/permissions/01_fetch_reader_userid.py index 4eb5669d..2f5f7f27 100644 --- a/permissions/01_fetch_reader_userid.py +++ b/permissions/01_fetch_reader_userid.py @@ -18,12 +18,12 @@ async def main(): # Reader Nillion client reader = create_nillion_client(userkey, nodekey) # Get the reader's user id - reader_user_id = reader.user_id() + 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(f"\nšŸ“‹ python3 02_store_permissioned_secret.py --retriever_user_id {reader.user_id()}") - return reader.user_id() + print(f"\nšŸ“‹ python3 02_store_permissioned_secret.py --retriever_user_id {reader.user_id}") + return reader.user_id if __name__ == "__main__": asyncio.run(main()) diff --git a/permissions/02_store_permissioned_secret.py b/permissions/02_store_permissioned_secret.py index 1055c095..cbad7deb 100644 --- a/permissions/02_store_permissioned_secret.py +++ b/permissions/02_store_permissioned_secret.py @@ -32,7 +32,7 @@ async def main(args = None): # Writer Nillion client writer = create_nillion_client(userkey, nodekey) - writer_user_id = writer.user_id() + writer_user_id = writer.user_id print(writer_user_id, args.retriever_user_id) # Writer gives themself default permissions diff --git a/permissions/03_retrieve_secret.py b/permissions/03_retrieve_secret.py index cdceafb3..45771d5c 100644 --- a/permissions/03_retrieve_secret.py +++ b/permissions/03_retrieve_secret.py @@ -30,7 +30,7 @@ async def main(args = None): # Reader Nillion client reader = create_nillion_client(userkey, nodekey) - reader_user_id = reader.user_id() + reader_user_id = reader.user_id secret_name = "my_int1" diff --git a/permissions/04_revoke_read_permissions.py b/permissions/04_revoke_read_permissions.py index 71e4a5ac..fb7efcef 100644 --- a/permissions/04_revoke_read_permissions.py +++ b/permissions/04_revoke_read_permissions.py @@ -39,7 +39,7 @@ async def main(args = None): writer = create_nillion_client(userkey, nodekey) # Create new permissions object to rewrite permissions (reader no longer has retrieve permission) - new_permissions = nillion.Permissions.default_for_user(writer.user_id()) + new_permissions = nillion.Permissions.default_for_user(writer.user_id) result = ( "allowed" if new_permissions.is_retrieve_allowed(args.revoked_user_id) diff --git a/permissions/05_test_revoked_permissions.py b/permissions/05_test_revoked_permissions.py index e51379c4..b59a666e 100644 --- a/permissions/05_test_revoked_permissions.py +++ b/permissions/05_test_revoked_permissions.py @@ -36,7 +36,7 @@ async def main(args = None): # Reader Nillion client reader = create_nillion_client(userkey, nodekey) - reader_user_id = reader.user_id() + reader_user_id = reader.user_id try: secret_name = "my_int1" diff --git a/voting_tutorial/01_store_program_party1.py b/voting_tutorial/01_store_program_party1.py index d1cb6f5b..960564e5 100644 --- a/voting_tutorial/01_store_program_party1.py +++ b/voting_tutorial/01_store_program_party1.py @@ -97,7 +97,7 @@ async def main(): cluster_id, program_name, program_mir_path ) print("action_id is: ", action_id) - user_id_alice = client_alice.user_id() + user_id_alice = client_alice.user_id program_id = f"{user_id_alice}/{program_name}" print("program_id is: ", program_id) diff --git a/voting_tutorial/02_store_secret_party_n.py b/voting_tutorial/02_store_secret_party_n.py index df2d187e..a15a2da2 100644 --- a/voting_tutorial/02_store_secret_party_n.py +++ b/voting_tutorial/02_store_secret_party_n.py @@ -59,8 +59,8 @@ async def main(): getUserKeyFromFile(party_info["userkey_file"]), getNodeKeyFromFile(party_info["nodekey_file"]) ) - party_id_n = client_n.party_id() - user_id_n = client_n.user_id() + party_id_n = client_n.party_id + user_id_n = client_n.user_id party_name = party_info["party_name"] party_role = party_info["party_role"] secret_votes = party_info["secret_votes"] diff --git a/voting_tutorial/03_multi_party_compute.py b/voting_tutorial/03_multi_party_compute.py index 9033b382..0e0c1b84 100644 --- a/voting_tutorial/03_multi_party_compute.py +++ b/voting_tutorial/03_multi_party_compute.py @@ -61,7 +61,7 @@ async def main(): getUserKeyFromFile(CONFIG_PARTY_1["userkey_file"]), getNodeKeyFromFile(CONFIG_PARTY_1["nodekey_file"]) ) - party_id_alice = client_alice.party_id() + party_id_alice = client_alice.party_id ##################################### # 4. Storing votes # diff --git a/voting_tutorial/client_voting.py b/voting_tutorial/client_voting.py index cbc78012..e8133988 100644 --- a/voting_tutorial/client_voting.py +++ b/voting_tutorial/client_voting.py @@ -155,8 +155,8 @@ async def main(): cluster_id, program_name, program_mir_path ) print("action_id is: ", action_id) - # program_id = owner.user_id() + "/" + program_name - program_id = general_client.user_id() + "/" + program_name + # program_id = owner.user_id + "/" + program_name + program_id = general_client.user_id + "/" + program_name print("program_id is: ", program_id) ##################################### @@ -202,16 +202,16 @@ async def main(): # 4.1 Bind voter to party in the program # ########################################### v_bindings = nillion.ProgramBindings(program_id) - v_bindings.add_input_party("Voter"+str(v), voter_v.party_id()) + v_bindings.add_input_party("Voter"+str(v), voter_v.party_id) ########################################### # 4.2 Set compute permissions to owner # ########################################### # Give permissions to owner to compute with my vote - v_permissions = nillion.Permissions.default_for_user(voter_v.user_id()) + v_permissions = nillion.Permissions.default_for_user(voter_v.user_id) v_permissions.add_compute_permissions({ - # owner.user_id(): {program_id}, - general_client.user_id(): {program_id}, + # owner.user_id: {program_id}, + general_client.user_id: {program_id}, }) # Store in the network @@ -239,15 +239,15 @@ async def main(): ################################################# owner_bindings = nillion.ProgramBindings(program_id) for v in range(nr_voters): - # owner_bindings_0.add_input_party("Voter"+str(v), voters[v].party_id()) - owner_bindings.add_input_party("Voter"+str(v), general_client.party_id()) + # owner_bindings_0.add_input_party("Voter"+str(v), voters[v].party_id) + owner_bindings.add_input_party("Voter"+str(v), general_client.party_id) ################################################## # 6.2 Bind owner to output party in the program # ################################################## # Bind the "OutParty" party in the computation to the owner's client - # owner_bindings.add_output_party("OutParty", owner.party_id()) - owner_bindings.add_output_party("OutParty", general_client.party_id()) + # owner_bindings.add_output_party("OutParty", owner.party_id) + owner_bindings.add_output_party("OutParty", general_client.party_id) # No secret is directly passed to 'compute'. It only uses # stored secrets. From a69bad4c13b1531bd5c9007cebcb99bc9e165819 Mon Sep 17 00:00:00 2001 From: David Butler Date: Wed, 1 May 2024 16:18:40 +0100 Subject: [PATCH 2/6] 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 | 8 +-- .../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 | 6 +- .../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, 131 insertions(+), 199 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 (86%) 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 c700076d..a1025c66 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 be9b0fc1..4bc4e9dd 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 48658bcc..b9b1edb2 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 86% rename from permissions/01_fetch_reader_userid.py rename to examples_and_tutorials/core_concept_permissions/01_fetch_reader_userid.py index 2f5f7f27..3e66940c 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,9 +21,9 @@ 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(f"\nšŸ“‹ python3 02_store_permissioned_secret.py --retriever_user_id {reader.user_id}") - return 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 if __name__ == "__main__": asyncio.run(main()) 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 cbad7deb..d728a7af 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 45771d5c..12336926 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 fb7efcef..26b29f32 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 b59a666e..70d7f38b 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 966e91fc..400cc1c3 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 1ddb59c9..86194bcd 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 feef3d04..0fe9db9d 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 81be01c4..5cb0d2e7 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 e6324b93..10749918 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 9c9ff7c4..ab468c81 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 8a0ace80..da14b96f 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 ba63638e..6dc55160 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 d5b306c1..2f682ddf 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 00844328..a4987ff0 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 b0f39294..f45734c9 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 d76aa3b5..52766d9d 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 4a95081d..55d61343 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 5a9e2e69..57e74be8 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 b194b2af..006d8f89 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 c3eff49a..44716cee 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 5e2f544b..a10f2617 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 a8597f6c..3becc296 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 c7608984..ef2b1fef 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 70a6d8d7..7dba12cf 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 812a0fda..95354635 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 fe30a669..ba97ffba 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 9cb3e6da..261a66df 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 822ea2e8..ff36d500 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 8f271988..e25df271 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 e0fc7890..8bdb441a 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 5fa9c282..84213fe7 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 ad0df3ea..f97083ba 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 143b343d..cd5a9686 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 6c25b563..0eeaacd2 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 960564e5..afbe2cbb 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 a15a2da2..e7c67eaf 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 0e0c1b84..c5596024 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 e8133988..5dbee5e3 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,7 +205,7 @@ 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 v_permissions = nillion.Permissions.default_for_user(voter_v.user_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 95e596d1f2f65a09e148319405cf2ccc60fea504 Mon Sep 17 00:00:00 2001 From: David Butler Date: Wed, 1 May 2024 17:38:00 +0100 Subject: [PATCH 3/6] 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 | 2 +- 19 files changed, 39 insertions(+), 38 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 4bc4e9dd..45dd79c7 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 b9b1edb2..04591710 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 3e66940c..f41f4636 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 d728a7af..82c344a0 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 12336926..5076a968 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 26b29f32..3a6d73ca 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 70d7f38b..21c257c1 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 cd5a9686..63f5e910 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 0eeaacd2..d8ac2776 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 e7c67eaf..8a5ce0a5 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 c5596024..f357de86 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 5dbee5e3..8ac02a7d 100644 --- a/examples_and_tutorials/voting_tutorial/client_voting.py +++ b/examples_and_tutorials/voting_tutorial/client_voting.py @@ -205,7 +205,7 @@ 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 permissions to owner to compute with my vote v_permissions = nillion.Permissions.default_for_user(voter_v.user_id) From 53042aeed073694c686dc5e976116cc08a818605 Mon Sep 17 00:00:00 2001 From: Jmgr Date: Wed, 1 May 2024 20:41:02 +0100 Subject: [PATCH 4/6] 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 From 815f1331c1e0acc0379903395ce739f3ba133395 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Mon, 6 May 2024 19:17:38 -0700 Subject: [PATCH 5/6] bump nada and python client versions to 0.2.0 --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4cb7b6cd..3ea4e53d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ python-dotenv==1.0.0 -nada-dsl>=0.0.7 -py-nillion-client>=0.0.7 +nada-dsl>=0.2.0 +py-nillion-client>=0.2.0 pytest-asyncio>=0.23.6 From c18b821d22caca2bfae1b77316f7d4cfc1ddc055 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 7 May 2024 08:02:11 -0700 Subject: [PATCH 6/6] bump up to version 0.2.1 for release --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3ea4e53d..b5f8c0a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ python-dotenv==1.0.0 -nada-dsl>=0.2.0 -py-nillion-client>=0.2.0 +nada-dsl>=0.2.1 +py-nillion-client>=0.2.1 pytest-asyncio>=0.23.6