shea256 / secret-sharing

A system for securely splitting secrets with Shamir's Secret Sharing Scheme
MIT License
483 stars 143 forks source link

Running examples a few times and it computer hanged #17

Open UrsaEli opened 8 years ago

UrsaEli commented 8 years ago

Hi Ryan, I ran the examples, it seems to hang at the entropy part.

Thank you.

Elfrania commented 8 years ago

I face the same issue. I tried to abort and I get this:

in secret_int_to_points coefficients = random_polynomial(point_threshold-1, secret_int, prime) File "/usr/local/lib/python2.7/dist-packages/secretsharing/polynomials.py", line 34, in random_polynomial random_coeff = randint(0, upper_bound-1) File "/usr/local/lib/python2.7/dist-packages/secretsharing/entropy.py", line 41, in randint byte_from_entropy = get_entropy(numbytes_of_entropy) File "/usr/local/lib/python2.7/dist-packages/secretsharing/entropy.py", line 23, in get_entropy return dev_random_entropy(numbytes) File "/usr/local/lib/python2.7/dist-packages/secretsharing/entropy.py", line 14, in dev_random_entropy return open("/dev/random", "rb").read(numbytes)

shea256 commented 8 years ago

Hey @UrsaEli @Elfrania the reason for this is it is using /dev/random (which blocks if there's not enough entropy in the entropy pool) instead of /dev/urandom (which doesn't block). I'm going to change it to use the latter and then I'll let you know.

shea256 commented 8 years ago

There was a controversy in the crypto community in the past over which was better, but it's become pretty clear that /dev/urandom uses a better model. I'll make this fix and we'll get you up and running in no time.

shea256 commented 8 years ago

Actually this shouldn't be happening. @Elfrania I believe you might have an older version of this library. Can you let me know what the version number is? And if you do pip install secretsharing --upgrade is the problem fixed?

Elfrania commented 8 years ago

Same issue:

I just run this. The first time it may work, but if I run it a few times, it will hang.

from secretsharing import SecretSharer

total_number_of_shares = 3; shares = SecretSharer.split_secret("c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a", 2, total_number_of_shares);

print len(shares); # total_number_of_shares print "Splitting into shares: ", shares;

Elfrania commented 8 years ago

I retested the code, it's slow but it's completing now.

Thank you, Ryan.

shea256 commented 8 years ago

@Elfrania can you please type pip freeze in your command line and then let me know what the version number is for your copy of the secretsharing library?

Thanks!

Elfrania commented 8 years ago

secretsharing==0.2.6