Data Types
Overview of the primitive and the compound Nada data types.
Primitive Data Types
Public | Secret | Literals |
|---|---|---|
PublicInteger | SecretInteger | Integer |
PublicUnsignedInteger | SecretUnsignedInteger | UnsignedInteger |
Public and Secret data types can be used to specify user inputs as:
a = SecretInteger(Input(name="a", party=party1))
b = SecretUnsignedInteger(Input(name="b", party=party2))
c = PublicInteger(Input(name="c", party=party1))
d = PublicUnsignedInteger(Input(name="d", party=party2))
Similarly, Literals can only be used within a program as:
a = SecretInteger(Input(name="a", party=party1))
b = SecretUnsignedInteger(Input(name="b", party=party2))
new_int = a + Integer(13)
new_uint = b + UnsignedInteger(13)
Compound Data Types (Experimental Feature)
Compound types are a new feature in the Nada language. We hope you find them handy, though there might still be undiscovered bugs. If you encounter anything, please flag them by opening an issue in nillion-python-starter.
Nada also support compound types, which include Arrays and Tuples.
An Array has a fixed number of fields which can be any of a Primitive Data Type or a Nada Compound Data Type, but all need to be of the same type. For example:
a = SecretInteger(Input(name="a", party=party1))
b = SecretInteger(Input(name="b", party=party1))
my_integer_array = Array.new(a, b)
or more complicated like:
a = SecretInteger(Input(name="a", party=party1))
b = SecretInteger(Input(name="b", party=party1))
c = SecretInteger(Input(name="c", party=party1))
sum = a + b
my_integer_array = Array.new(sum, c)
Arrays can also be used as inputs as follows:
loading...
A Tuple has two fields, which can be any combination of a Primitive Data Type or a Compound Data Type. For example a Tuple can be as simple as:
a = SecretInteger(Input(name="a", party=party1))
b = SecretInteger(Input(name="b", party=party1))
my_tuple = Tuple.new(a, b)
or more complicated like:
a = PublicInteger(Input(name="a", party=party1))
b = SecretInteger(Input(name="b", party=party1))
c = PublicInteger(Input(name="c", party=party1))
my_tuple = Tuple.new(a, Tuple.new(b, c))
Lastly, Arrays and Tuples can be combined as:
loading...