Beginner question about mpc.input and mpc.output #95
-
Hello, I am trying to understand how MPyC handles secret inputs and outputs. I wrote the following code: Could you explain why this happens and if there is a way to ensure the values remain secret until the final output phase? Additionally, am I misunderstanding something fundamental about how MPyC handles inputs and outputs? Thank you very much, I appreciate any clarification you can provide. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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:
|
Beta Was this translation helpful? Give feedback.
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:
This gives as result, when running it with 5 parties: