Skip to main content

Equality (Equals)

Private equality ==

src/equality.py
from nada_dsl import *

def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
secret_target = SecretInteger(Input(name="secret_target", party=party_alice))
secret_guess = SecretInteger(Input(name="secret_guess", party=party_bob))
is_same_num = secret_target == secret_guess
return [Output(is_same_num, "is_same_num", party=party_charlie)]

Run and test the equality program

1. Open "Nada by Example"

Open in Gitpod

2. Run the program with inputs from the test file

nada run equality_test

3. Test the program with inputs from the test file against the expected_outputs from the test file

nada test equality_test

Public output equality ==

src/equality_public.py
from nada_dsl import *

def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
secret_target = SecretInteger(Input(name="secret_target", party=party_alice))
secret_guess = SecretInteger(Input(name="secret_guess", party=party_bob))
is_same_num = secret_target.public_equals(secret_guess)
return [Output(is_same_num, "is_same_num", party=party_charlie)]

Run and test the equality_public program

1. Open "Nada by Example"

Open in Gitpod

2. Run the program with inputs from the test file

nada run equality_public_test

3. Test the program with inputs from the test file against the expected_outputs from the test file

nada test equality_public_test
Feedback