Left Shift
- Nada program
- Test file
src/shift_left.py
from nada_dsl import *
def nada_main():
party_alice = Party(name="Alice")
party_bob = Party(name="Bob")
party_charlie = Party(name="Charlie")
base = SecretInteger(Input(name="base", party=party_alice))
shift = PublicUnsignedInteger(Input(name="shift", party=party_bob))
# left shift is the same as (base * 2^shift)
result = base << shift
return [Output(result, "left_shift_result", party=party_charlie)]
tests/shift_left_test.yaml
---
program: shift_left
inputs:
base: 5
shift: 3
expected_outputs:
left_shift_result: 40
Run and test the shift_left program
1. Open "Nada by Example"
2. Run the program with inputs
from the test file
nada run shift_left_test
3. Test the program with inputs
from the test file against the expected_outputs
from the test file
nada test shift_left_test