Skip to content

Beginner question about mpc.input and mpc.output #95

Answered by lschoe
MargaroneGiada asked this question in Q&A
Discussion options

You must be logged in to vote

Not sure what you've been printing. The input values are really split into random secret shares, and then combined again to print the output in the clear. Maybe run the next program to see this in action:

from mpyc.runtime import mpc

async def main():
    async with mpc:
        a = mpc.input(mpc.SecInt(16)(1))  # each party splits 1 into m shares
        a = await mpc.gather(a)  # wait for the secret shares, one per party
        print(a)  # prints list with m random shares
        print(await mpc.output(a))  # prints [1] * m 
                
mpc.run(main())

This gives as result, when running it with 5 parties:

$ python disc95.py -M5
2024-06-05 23:08:27,757 Start MPyC runtime v0.10.1
2…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by lschoe
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants