Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions nohup.out
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions quickstart/client_code/run_my_first_program.py
Original file line number Diff line number Diff line change
@@ -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]
7 changes: 7 additions & 0 deletions quickstart/nada_quickstart_programs/nada-project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "nada_quickstart_programs"
version = "0.1.0"
authors = [""]

[[programs]]
path = "src/main.py"
prime_size = 128
29 changes: 29 additions & 0 deletions quickstart/nada_quickstart_programs/src/main.py
Original file line number Diff line number Diff line change
@@ -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]
Binary file not shown.
Binary file not shown.