Skip to main content

Secret

The Secret data type is used for inputs that need to be kept confidential during computation. These input values are not visible to the program.

SecretInteger

SecretInteger represents a user input secret integer value. This value can be a negative integer, a positive integer, or zero.

src/multiplication.py
from nada_dsl import *

def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
num_1 = SecretInteger(Input(name="num_1", party=party_alice))
num_2 = SecretInteger(Input(name="num_2", party=party_bob))
product = num_1 * num_2
return [Output(product, "product", party_charlie)]

Run and test the multiplication program

1. Open "Nada by Example"

Open in Gitpod

2. Run the program with inputs from the test file

nada run multiplication_test

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

nada test multiplication_test

SecretUnsignedInteger

SecretUnsignedInteger represents a user input secret unsigned integer value. This value can be zero or a positive integer.

src/addition_unsigned.py
from nada_dsl import *

def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
num_1 = SecretUnsignedInteger(Input(name="num_1", party=party_alice))
num_2 = SecretUnsignedInteger(Input(name="num_2", party=party_bob))
sum = num_1 + num_2
return [Output(sum, "sum", party_charlie)]

Run and test the addition_unsigned program

1. Open "Nada by Example"

Open in Gitpod

2. Run the program with inputs from the test file

nada run addition_unsigned_test

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

nada test addition_unsigned_test

SecretBoolean

SecretBoolean represents a user input secret boolean value. This value can be true or false.

src/secret_conditional.py
from nada_dsl import *

def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")

# Alice inputs a secret boolean that determines whether or not to double Bob's secret input
should_double = SecretBoolean(Input(name="should_double", party=party_alice))
secret_num = SecretInteger(Input(name="secret_num", party=party_bob))

result = should_double.if_else(secret_num * Integer(2), secret_num)

# Charlie receives the result, but doesn't know
# whether Bob's original input has doubled
return [Output(result, "result", party_charlie)]

Run and test the secret_conditional program

1. Open "Nada by Example"

Open in Gitpod

2. Run the program with inputs from the test file

nada run secret_conditional_test

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

nada test secret_conditional_test
Feedback