Comparison
Less than <
- Nada program
- Test file
src/comparison_lt.py
from nada_dsl import *
def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
x = SecretInteger(Input(name="x", party=party_alice))
y = SecretInteger(Input(name="y", party=party_bob))
# Comparison: x < y (Less Than)
result = x < y
return [Output(result, "x_less_than_y", party=party_charlie)]
tests/comparison_lt_test.yaml
---
program: comparison_lt
inputs:
y: 20
x: 10
expected_outputs:
x_less_than_y: true
Run and test the comparison_lt program
1. Open "Nada by Example"
2. Run the program with inputs
from the test file
nada run comparison_lt_test
3. Test the program with inputs
from the test file against the expected_outputs
from the test file
nada test comparison_lt_test
Less than or equal to <=
- Nada program
- Test file
src/comparison_lte.py
from nada_dsl import *
def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
x = SecretInteger(Input(name="x", party=party_alice))
y = SecretInteger(Input(name="y", party=party_bob))
# Comparison: x <= y (Less Than or Equal To)
result = x <= y
return [Output(result, "x_less_than_or_equal_y", party=party_charlie)]
tests/comparison_lte_test.yaml
---
program: comparison_lte
inputs:
y: 30
x: 30
expected_outputs:
x_less_than_or_equal_y: true
Run and test the comparison_lte program
1. Open "Nada by Example"
2. Run the program with inputs
from the test file
nada run comparison_lte_test
3. Test the program with inputs
from the test file against the expected_outputs
from the test file
nada test comparison_lte_test
Greater than >
- Nada program
- Test file
src/comparison_gt.py
from nada_dsl import *
def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
x = SecretInteger(Input(name="x", party=party_alice))
y = SecretInteger(Input(name="y", party=party_bob))
# Comparison: x > y (Greater Than)
result = x > y
return [Output(result, "x_greater_than_y", party=party_charlie)]
tests/comparison_gt_test.yaml
---
program: comparison_gt
inputs:
y: 5
x: 3
expected_outputs:
x_greater_than_y: false
Run and test the comparison_gt program
1. Open "Nada by Example"
2. Run the program with inputs
from the test file
nada run comparison_gt_test
3. Test the program with inputs
from the test file against the expected_outputs
from the test file
nada test comparison_gt_test
Greater than or equal to >=
- Nada program
- Test file
src/comparison_gte.py
from nada_dsl import *
def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
x = SecretInteger(Input(name="x", party=party_alice))
y = SecretInteger(Input(name="y", party=party_bob))
# Comparison: x >= y (Greater Than or Equal To)
result = x >= y
return [Output(result, "x_greater_than_or_equal_y", party=party_charlie)]
tests/comparison_gte_test.yaml
---
program: comparison_gte
inputs:
y: 3
x: 4
expected_outputs:
x_greater_than_or_equal_y: true
Run and test the comparison_gte program
1. Open "Nada by Example"
2. Run the program with inputs
from the test file
nada run comparison_gte_test
3. Test the program with inputs
from the test file against the expected_outputs
from the test file
nada test comparison_gte_test