Mikkel Krøigård <[EMAIL PROTECTED]> writes:
>> > if runtime.id == 1:
>> > a = runtime.broadcast(1, "foo")
>> > b = runtime.broadcast(2)
>> > if runtime.id == 2:
>> > a = runtime.broadcast(1)
>> > b = runtime.broadcast(2, "bar")
>> > if runtime.id == 3:
>> > a = runtime.broadcast(1)
>> > b = runtime.broadcast(2)
>> >
>> > This does not match the shamir_share method, which allows you to write
>> >
>> > a, b = runtime.shamir_share([1, 2], input)
>> >
>> > where input is different for each of the two inputters.
>>
>> That code is actually wrong, the correct code would be:
>>
>> if runtime.id == 1 or runtime.id == 2:
>> a, b = runtime.shamir_share([1, 2], input)
>> else:
>> a, b = runtime.shamir_share([1, 2])
>
> This code assumes that the input is already determined above based
> on whether we have id 1 or 2. So there is somehow the same branch as
> in the broadcast case, only hidden here.
You're right, silly me! :-)
So we are really comparing code like this:
if runtime.id == 1:
a = runtime.broadcast(1, "foo")
b = runtime.broadcast(2)
if runtime.id == 2:
a = runtime.broadcast(1)
b = runtime.broadcast(2, "bar")
if runtime.id == 3:
a = runtime.broadcast(1)
b = runtime.broadcast(2)
with code like this:
if runtime.id == 1:
a, b = runtime.shamir_share([1, 2], Zp(123))
if runtime.id == 2:
a, b = runtime.shamir_share([1, 2], Zp(456))
if runtime.id == 3:
a, b = runtime.shamir_share([1, 2])
Looking at it that way it also becomes much clearer exactly how much
the second style saves us: it "collapses" all the lines in which no
input is given into the line where input *is* actually given.
I think the second piece of code looks nice, so I propose that we keep
the syntax used by shamir_share and thus change broadcast to match it.
--
Martin Geisler
_______________________________________________
viff-devel mailing list (http://viff.dk/)
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk