c0dearm / sharks

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

Added Share Serialization and Created Share Struct #2

Closed zer0x64 closed 4 years ago

zer0x64 commented 4 years ago

The goal of this PR is to add serialization support to the library so that we can convert a share to and from a byte array easily. This way, shares can be stored, transmitted or even printed, depending on the use case.

To do this, I had to create a struct for a share, instead of the tuple that was used.

Let me know what you think about it and if you want me to change something!

zer0x64 commented 4 years ago

On hold, something happened during commit and the code is broken, trying to fix it now.

zer0x64 commented 4 years ago

Fixed, I was missing a semicolon somewhere.

zer0x64 commented 4 years ago

One issue with this is that the threshold is not encoded with the share, as with "standard" implementations of Shamir, which means that we must know the threshold to recover the secret. I don't really see how to fix this with the current architecture. What do you think about it?

c0dearm commented 4 years ago

Wow! Thank you very much for your contribution! I am checking right now your code from my phone, which is of course not ideal, but I love what I am seeing so far :)

Tomorrow morning (it's 12 AM here now) I will pull your code and take a better look at it, I will let you know if there is something odd, but it looks promising!

Indeed, shares serialzation was something todo and also it makes the code more readable, I am astonished how fast you picked up with the current code.

Thank you very much!

c0dearm commented 4 years ago

Hi @zer0x64 ! I just pushed a commit with mostly a cleanup of the doc tests, I also included unit and benchmark tests for the new functionality. Please, let me know if there is something not clear :)

c0dearm commented 4 years ago

Not necessary, I disabled it. I had to do it once for the helm/charts project and it is a pain in the ass :see_no_evil: