INNER CODE UNIT · Python

correctness

lschoe/mpyc · demos/PrefixOrExplained.py:118

def correctness(pf):
    l = secint.bit_length
    if l <= 8:
        # loop over all l-bit values in two's complement
        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):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…