From fdb25e6093a7164ad1e03879d9a838f9dea0cf5f Mon Sep 17 00:00:00 2001 From: visheshind Date: Sun, 14 Jul 2024 20:05:46 +0000 Subject: [PATCH] my new nada program --- nohup.out | 14 +++++++++ .../client_code/run_my_first_program.py | 29 ++++++++++++++++++ .../nada-project.toml | 7 +++++ .../nada_quickstart_programs/src/main.py | 29 ++++++++++++++++++ .../target/main.nada.bin | Bin 0 -> 901 bytes .../target/secret_addition_complete.nada.bin | Bin 975 -> 975 bytes 6 files changed, 79 insertions(+) create mode 100644 nohup.out create mode 100644 quickstart/nada_quickstart_programs/nada-project.toml create mode 100644 quickstart/nada_quickstart_programs/src/main.py create mode 100644 quickstart/nada_quickstart_programs/target/main.nada.bin diff --git a/nohup.out b/nohup.out new file mode 100644 index 00000000..2e3c7f28 --- /dev/null +++ b/nohup.out @@ -0,0 +1,14 @@ +ℹ️ cluster id is 9e68173f-9c23-4acc-ba81-4f079b639964 +ℹ️ using 256 bit prime +ℹ️ storing state in /tmp/.tmphPYQUb (80.04Gbs available) +🏃 starting nilchain node in: /tmp/.tmphPYQUb/nillion-chain +⛓ nilchain JSON RPC available at http://127.0.0.1:48102 +⛓ nilchain REST API available at http://localhost:26650 +⛓ nilchain gRPC available at localhost:26649 +🏃 starting node 12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS +⏳ waiting until bootnode is up... +🏃 starting node 12D3KooWAiwGZUwSUaT2bYVxGS8jmfMrfsanZYkHwH3uL7WJPsFq +🏃 starting node 12D3KooWM3hsAswc7ZT6VpwQ1TCZU4GCYY55nLhcsxCcfjuixW57 +👛 funding nilchain keys +📝 nillion CLI configuration written to /root/.config/nillion/nillion-cli.yaml +🌄 environment file written to /root/.config/nillion/nillion-devnet.env diff --git a/quickstart/client_code/run_my_first_program.py b/quickstart/client_code/run_my_first_program.py index e69de29b..f901ae66 100644 --- a/quickstart/client_code/run_my_first_program.py +++ b/quickstart/client_code/run_my_first_program.py @@ -0,0 +1,29 @@ +from nada_dsl import * + +def nada_main(): + # Define the parties for the voters and election officials + voter_1 = Party(name="Voter 1 🗳️") + voter_2 = Party(name="Voter 2 🗳️") + election_official = Party(name="Election Official 🏛️") + + # Define secret inputs for the votes cast by each voter + vote_voter_1 = SecretInteger(Input(name="vote_voter_1", party=voter_1)) # 1 for Candidate 1, 2 for Candidate 2 + vote_voter_2 = SecretInteger(Input(name="vote_voter_2", party=voter_2)) # 1 for Candidate 1, 2 for Candidate 2 + + # Define secret inputs for the current total votes for each candidate + total_votes_candidate_1 = SecretInteger(Input(name="total_votes_candidate_1", party=election_official)) + total_votes_candidate_2 = SecretInteger(Input(name="total_votes_candidate_2", party=election_official)) + + # Calculate the new vote count for Candidate 1 + vote_count_candidate_1 = (vote_voter_1 == 1).if_else(total_votes_candidate_1 + 1, total_votes_candidate_1) + \ + (vote_voter_2 == 1).if_else(total_votes_candidate_1 + 1, total_votes_candidate_1) + + # Calculate the new vote count for Candidate 2 + vote_count_candidate_2 = (vote_voter_1 == 2).if_else(total_votes_candidate_2 + 1, total_votes_candidate_2) + \ + (vote_voter_2 == 2).if_else(total_votes_candidate_2 + 1, total_votes_candidate_2) + + # Output the updated vote counts for each candidate + final_vote_count_candidate_1 = Output(vote_count_candidate_1, "final_vote_count_candidate_1", election_official) + final_vote_count_candidate_2 = Output(vote_count_candidate_2, "final_vote_count_candidate_2", election_official) + + return [final_vote_count_candidate_1, final_vote_count_candidate_2] \ No newline at end of file diff --git a/quickstart/nada_quickstart_programs/nada-project.toml b/quickstart/nada_quickstart_programs/nada-project.toml new file mode 100644 index 00000000..da166dde --- /dev/null +++ b/quickstart/nada_quickstart_programs/nada-project.toml @@ -0,0 +1,7 @@ +name = "nada_quickstart_programs" +version = "0.1.0" +authors = [""] + +[[programs]] +path = "src/main.py" +prime_size = 128 diff --git a/quickstart/nada_quickstart_programs/src/main.py b/quickstart/nada_quickstart_programs/src/main.py new file mode 100644 index 00000000..6bcc12f3 --- /dev/null +++ b/quickstart/nada_quickstart_programs/src/main.py @@ -0,0 +1,29 @@ +from nada_dsl import * + +def nada_main(): + # Define the parties for the voters and election officials + voter_1 = Party(name="Voter 1 🗳️") + voter_2 = Party(name="Voter 2 🗳️") + election_official = Party(name="Election Official 🏛️") + + # Define secret inputs for the votes cast by each voter + vote_voter_1 = SecretInteger(Input(name="vote_voter_1", party=voter_1)) # 1 for Candidate 1, 2 for Candidate 2 + vote_voter_2 = SecretInteger(Input(name="vote_voter_2", party=voter_2)) # 1 for Candidate 1, 2 for Candidate 2 + + # Define secret inputs for the current total votes for each candidate + total_votes_candidate_1 = SecretInteger(Input(name="total_votes_candidate_1", party=election_official)) + total_votes_candidate_2 = SecretInteger(Input(name="total_votes_candidate_2", party=election_official)) + + # Calculate the new vote count for Candidate 1 + vote_count_candidate_1 = (vote_voter_1 == 1).if_else(total_votes_candidate_1 + 1, total_votes_candidate_1) + \ + (vote_voter_2 == 1).if_else(total_votes_candidate_1 + 1, total_votes_candidate_1) + + # Calculate the new vote count for Candidate 2 + vote_count_candidate_2 = (vote_voter_1 == 2).if_else(total_votes_candidate_2 + 1, total_votes_candidate_2) + \ + (vote_voter_2 == 2).if_else(total_votes_candidate_2 + 1, total_votes_candidate_2) + + # Output the updated vote counts for each candidate + final_vote_count_candidate_1 = Output(vote_count_candidate_1, "final_vote_count_candidate_1", election_official) + final_vote_count_candidate_2 = Output(vote_count_candidate_2, "final_vote_count_candidate_2", election_official) + + return [final_vote_count_candidate_1, final_vote_count_candidate_2] \ No newline at end of file diff --git a/quickstart/nada_quickstart_programs/target/main.nada.bin b/quickstart/nada_quickstart_programs/target/main.nada.bin new file mode 100644 index 0000000000000000000000000000000000000000..c412da589e270c498febe0858b7c48cdc8a3fa5c GIT binary patch literal 901 zcmaJ<%}T^D5U&4PM8qeEJ+-=s+jgW-ZUEu3j~H1* z<-!ed6|!2Ym5%#xrNJF1G1;+P)bSbO4C0qMM0NUydK>T;qecp9b_~GlaZ$;#lBZu! zZ^fh4V5Ev#J?)|uWc<1NpIW>J81AuB(&N#-*Xzepi+j|jJ=*rIuxa&vxX1eF)nnlT z{T<=}0!vx9yfFAw6rAKVqvLEbCo^6aLXsob&Dd1KYJ&XW+$FHeX0}L7nj!OZ%318` zf%AeTBkW^@ZAR3`hzx_m#~XGpm>lJjJuu;qa(F;fF7XDsk63pT=)#kKMQK+Qf~aX% huthbOAf@D(Oc0Zm$jR+hGd8}a42btLN$3>?ci+1mx(@&V literal 0 HcmV?d00001 diff --git a/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin b/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin index 4351b211b5ee0e0c053040d7af6f7bfb2346d48a..a1d10a27b8ef007b9e03c68021b0ab827c073185 100644 GIT binary patch delta 112 zcmX@lex7}U8Y5f6UhlgN^^3 d1_l3D)=%NBqz`(!)5(X=VNi#46 nTmxxlV3_=YQGIeA6ORx~0AvP)J-L(7g^_XMd9BS$nY0)Ix6B