Right Shift
- Nada program
- Test file
src/shift_right.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))
# right shift is the same as (base // 2^shift)
# where // represents integer division discarding any remainder
result = base >> shift
return [Output(result, "right_shift_result", party=party_charlie)]
tests/shift_right_test.yaml
---
program: shift_right
inputs:
shift: 3
base: 65
expected_outputs:
right_shift_result: 8
Run and test the shift_right program
1. Open "Nada by Example"
2. Run the program with inputs
from the test file
nada run shift_right_test
3. Test the program with inputs
from the test file against the expected_outputs
from the test file
nada test shift_right_test