"Sigurd Torkel Meldgaard" <[EMAIL PROTECTED]> writes:

> Thanks for the review

No problem! I love looking at code...

> On Fri, Oct 24, 2008 at 11:56 AM, Martin Geisler <[EMAIL PROTECTED]> wrote:
>> "Sigurd Torkel Meldgaard" <[EMAIL PROTECTED]> writes:
>>
>> Right. But don't we know the precision parameter from the field
>> size? So using math.log(x.field.modulus, 2) would work, wouldn't
>> it? That could be done in the __div__ method on Share so as to not
>> mess up the nice property that divide works with both ints and
>> Shares.
>
> That could be done, but unfortunately the limits are lower, it seems
> it stops working at around 27-28-bits, you mentioned the other day
> that comparisons can only be done in half of the bits, is that true?

Yes, the comparison protocols need some "head-room" in the field. The
bit_length parameter (in options.bit_length) defaults to 32, and this
means that the input numbers to the comparison protocols should be 32
bit at most.

The Toft05 protocol does

  l = self.options.bit_length
  m = l + self.options.security_parameter
  t = m + 1

  assert 2**(l+1) + 2**t < field.modulus, "2^(l+1) + 2^t < p must hold"

and so with l = 32 and m = 32 + 30 the field modulus must be at least
m bits. Nothing checks this at the moment...

> Anyway the precision parameter times y must be less than the number
> of bits in the field (or half the number of bits) so I guess it is
> only rarely useful to do the division without specifying the
> precision. But maybe we can find an acceptable default.

Hmm, it does sounds tricky since y is secret as well.

>>> +"""This program does a secret division between two secret shared
>>> +values It is of course mostly meaningless for this example (you can
>>
>> Missing full stop.
>>
>>> +compute the inputs from your own value and the output)
>>
>> Ditto :-)
>>
>
> You are really sharp, I should install a spell-and-grammar-checker
> for my comments.

Hehe :-) It is just that Mikkel and I are currently following a course
in academic English, and the teacher has been very careful to stress
that all English sentences must a) begin with a capital letter, b) end
with a full stop, question mark or exclamation mark (except that we
don't want any !-marks in academic English) and c) contain a subject,
noun and verb. So there... :-)

>>> +def bits_to_val(bits):
>>> +    b_r = bits[:]
>>> +    b_r.reverse()
>>> +    return sum([2**i * b for (i, b) in enumerate(b_r)])

Here I would just do

  return sum([2**i * b for (i, b) in enumerate(reversed(bits))])

>>> +    parser.add_option("-n", "--number", type="int",
>>> +                     help="number to compare")
>>
>> This "option" is not an option at all, it is a required argument
>> :-) The optparse documentation has something to say about this:
>
> Hmm, the players with id above 2 should not input a number. But I
> guess it makes sense to make it a positional argument anyway.

It's just a matter of looking in args as defined below.

>>> +    parser.set_defaults(modulus=2**65, number=None)
>>> +
>>> +    Runtime.add_options(parser)
>>> +
>>> +    options, args = parser.parse_args()
>>> +
>>> +    if len(args) == 0:
>>> +        parser.error("you must specify a config file")

Here you can check if len(args) == 1 or 2 for the appropriate players.
No need to fiddle with sys.argv. Using sys.argv wont work anyway if
people start the players like

  ./divide --no-ssl player-1.ini --modulus 2**120 7

Here args will be ['player-1.ini', '7'].

> Attached is a revised patch - I am sorry my email client (gmail)
> does not allow me to specify the Mime-type...

Don't worry, mine does! :-) I press "t" and it suggests "text/x-patch"
for the type of your attachment. I press enter and the patch is
highlighted as such by Emacs. What a nice OS that editor has...!

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
_______________________________________________
viff-patches mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-patches-viff.dk

Reply via email to