INNER CODE UNIT · Python

r

lschoe/mpyc · demos/PrefixOrExplained.py:125

        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]
    print(f'or-complexity: {secint.or_complexity}')
    print(f'or-depth: {max(or_depths)} (per output element: {or_depths})')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…