Hello, When instrumenting the code, I found that we save 10 bytes per share when sending just share.value instead of (share.value, share.modulus). Looking at the output of marshal.dumps it seems that it introduces these overheads:
* Integers: 1 byte (marker) * Long integers: 1 byte (marker) + 4 bytes (length) + some more I couldn't figure out. * Strings, tuples: 1 byte (marker) + 4 bytes (length) Since we don't just send a share over the network but also a program counter and a type tag, the total savings from not sending the modulus are not two thirds, but rather a reduction from 68.42 KiB to 48.85 KiB (about one third). That is when multiplying 1000 65-bit numbers. I tested the marshal module in comparison to what the GMPY module when dumping long integers: >>> len(marshal.dumps(2**256 - 11))*8, len(mpz(2**256 - 11).binary())*8 (328, 264) >>> len(marshal.dumps(2**512 - 11))*8, len(mpz(2**512 - 11).binary())*8 (600, 520) >>> len(marshal.dumps(2**1024 - 11))*8, len(mpz(2**1024 - 11).binary())*8 (1144, 1032) It seems that GMPY uses just one extra byte whereas marshal uses about 10 bytes extra. Another problem with the marshal module is the security problems discussed here: http://article.gmane.org/gmane.comp.cryptography.viff.devel/19/ The marshal module seems very fast when it comes to dumping data. Here I am testing it with a ~1024 number: % python -m timeit -s 'from gmpy import mpz' \ -s 'x = mpz(2**1024 - 11)' \ 'x.binary()' 100000 loops, best of 3: 13.5 usec per loop % python -m timeit -s 'from marshal import dumps' \ -s 'x = 2**1024 - 11' \ 'dumps(x)' 1000000 loops, best of 3: 1.38 usec per loop When it comes to multiplications, the GMPY module is faster, though: % python -m timeit -s 'x = 2**1024 - 11' -s 'y = 2**1024 - 31' 'x * y' 100000 loops, best of 3: 18.8 usec per loop % python -m timeit -s 'from gmpy import mpz' \ -s 'x = mpz(2**1024 - 11)' -s 'y = mpz(2**1024 - 31)' 'x * y' 100000 loops, best of 3: 4.57 usec per loop So, that was just some food for your thoughts... :-) -- Martin Geisler _______________________________________________ viff-devel mailing list (http://viff.dk/) [email protected] http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk
