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/.tmprywQZx (79.99Gbs available)
🏃 starting nilchain node in: /tmp/.tmprywQZx/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
38 changes: 38 additions & 0 deletions quickstart/client_code/run_my_first_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from nada_dsl import *

def nada_main():
# Define the parties for the ATM users
atm_user_1 = Party(name="ATM User 1 💳")
atm_user_2 = Party(name="ATM User 2 💳")

# Define secret inputs for the initial balances, deposit amounts, withdrawal amounts, and transfer amounts
initial_balance_1 = SecretInteger(Input(name="initial_balance_1", party=atm_user_1))
initial_balance_2 = SecretInteger(Input(name="initial_balance_2", party=atm_user_2))
deposit_amount_1 = SecretInteger(Input(name="deposit_amount_1", party=atm_user_1))
withdrawal_amount_1 = SecretInteger(Input(name="withdrawal_amount_1", party=atm_user_1))
transfer_amount_1_to_2 = SecretInteger(Input(name="transfer_amount_1_to_2", party=atm_user_1))

# Calculate the new balance for ATM User 1 after deposit
balance_after_deposit_1 = initial_balance_1 + deposit_amount_1

# Ensure the withdrawal does not exceed the balance after deposit for ATM User 1
sufficient_funds_after_withdrawal_1 = (balance_after_deposit_1 >= withdrawal_amount_1).if_else(
balance_after_deposit_1 - withdrawal_amount_1,
balance_after_deposit_1
)

# Ensure the transfer does not exceed the balance after withdrawal for ATM User 1
sufficient_funds_after_transfer_1 = (sufficient_funds_after_withdrawal_1 >= transfer_amount_1_to_2).if_else(
sufficient_funds_after_withdrawal_1 - transfer_amount_1_to_2,
sufficient_funds_after_withdrawal_1
)

# Calculate the new balance for ATM User 2 after receiving the transfer
balance_after_transfer_2 = initial_balance_2 + transfer_amount_1_to_2

# Output the final balances for both users
final_balance_1 = Output(sufficient_funds_after_transfer_1, "final_balance_1", atm_user_1)
final_balance_2 = Output(balance_after_transfer_2, "final_balance_2", atm_user_2)

return [final_balance_1, final_balance_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
38 changes: 38 additions & 0 deletions quickstart/nada_quickstart_programs/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from nada_dsl import *

def nada_main():
# Define the parties for the ATM users
atm_user_1 = Party(name="ATM User 1 💳")
atm_user_2 = Party(name="ATM User 2 💳")

# Define secret inputs for the initial balances, deposit amounts, withdrawal amounts, and transfer amounts
initial_balance_1 = SecretInteger(Input(name="initial_balance_1", party=atm_user_1))
initial_balance_2 = SecretInteger(Input(name="initial_balance_2", party=atm_user_2))
deposit_amount_1 = SecretInteger(Input(name="deposit_amount_1", party=atm_user_1))
withdrawal_amount_1 = SecretInteger(Input(name="withdrawal_amount_1", party=atm_user_1))
transfer_amount_1_to_2 = SecretInteger(Input(name="transfer_amount_1_to_2", party=atm_user_1))

# Calculate the new balance for ATM User 1 after deposit
balance_after_deposit_1 = initial_balance_1 + deposit_amount_1

# Ensure the withdrawal does not exceed the balance after deposit for ATM User 1
sufficient_funds_after_withdrawal_1 = (balance_after_deposit_1 >= withdrawal_amount_1).if_else(
balance_after_deposit_1 - withdrawal_amount_1,
balance_after_deposit_1
)

# Ensure the transfer does not exceed the balance after withdrawal for ATM User 1
sufficient_funds_after_transfer_1 = (sufficient_funds_after_withdrawal_1 >= transfer_amount_1_to_2).if_else(
sufficient_funds_after_withdrawal_1 - transfer_amount_1_to_2,
sufficient_funds_after_withdrawal_1
)

# Calculate the new balance for ATM User 2 after receiving the transfer
balance_after_transfer_2 = initial_balance_2 + transfer_amount_1_to_2

# Output the final balances for both users
final_balance_1 = Output(sufficient_funds_after_transfer_1, "final_balance_1", atm_user_1)
final_balance_2 = Output(balance_after_transfer_2, "final_balance_2", atm_user_2)

return [final_balance_1, final_balance_2]

Binary file not shown.
Binary file not shown.