INNER CODE UNIT · Python
r
lschoe/mpyc · demos/PrefixOrExplained.py:122
r = range(-2**(l-1), 2**(l-1))
else:
# loop over 100 random l-bit values in two's complement
r = (random.randrange(-2**(l-1), 2**(l-1)) for _ in range(100))
for i in r:
i = mpc.input(secint(i), senders=0)
x = mpc.to_bits(i)
y = mpc.run(mpc.output(pf(x)))
x = mpc.run(mpc.output(x))
assert y == prefix_or0(x), (x, y, prefix_or0(x))
print(f'{pf.__name__} OK')
def complexity(pf, n):
# We take the all-zero list as input (complexity is data-independent anyway):
x = [secint(0) for _ in range(n)]
secint.or_complexity = 0
y = pf(x)
or_depths = [a.or_depth for a in y]