c0dearm / sharks

Fast, small and secure Shamir's Secret Sharing library crate
https://crates.io/crates/sharks
Other
59 stars 12 forks source link

Support no_std #13

Closed l4l closed 4 years ago

c0dearm commented 4 years ago

Hi! Thanks for your contribution. I will review it and hopefully merge it to master

c0dearm commented 4 years ago

Hi @l4l, so I was taking a look at your changes. I see that because rand can't work with std thread_rng is not available and you need to pass a Rng to the dealer. Is it possible to create that number generator or does it have to be provided by the crate user?

l4l commented 4 years ago

I guess rand_chacha might do the thing, like that:

let sharks = sharks::Sharks(2);
let mut rand = rand_chacha::ChaCha8Rng::from_seed([0x90; 32]);
let secret = [1, 2, 3, 4, 5, 6];
let shares = sharks.dealer_with_rng(&mut rand, &secret);

I think it is better give a user to decide what Rng to use, if there is no rand/std. Particularly, there can be some hardware entropy source, so it is better implement RngCore, rather than use rand_chacha.

c0dearm commented 4 years ago

Hi @l4l! I've pushed a new commit simplifying a bit the RNG usage as well as updating the docs and tests. Also pinned a new version. Let me know if you like it and make any improvement if you will. :smile:

l4l commented 4 years ago

Looks great, I've also added a few fixes: one un-ignores doc-tests via the cfg blocks (that look quite clumsy, but at least checked in ci) and the second one is a test refactorings, so that final diff is smaller (and hopefully more readable as well).