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 00000000..c412da58 Binary files /dev/null and b/quickstart/nada_quickstart_programs/target/main.nada.bin differ 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 4351b211..a1d10a27 100644 Binary files a/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin and b/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin differ