Skip to main content

Left Shift

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)]

Run and test the shift_left program

1. Open "Nada by Example"

Open in Gitpod

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
Feedback