Live data from Hacker News

Shamir Secret Sharing

max.levch.in

1–10 of 69 posts

Re: Shamir Secret Sharing

#6

>The idea (proposed by Adi Shamir – the A of RSA! – in 1979) is as simple as it is beautiful. Leonard Adleman might have something to say about that sentence.

If Adleman just had a first name starting with S, it would still work!

Re: Shamir Secret Sharing

#7
For those who would like to play around with Shamir secret sharing, here is a Python implementation I wrote to check out something I was curious about [1]. Note: requires at least Python 3.8.

The function make_sss(secret, num_shares, p=0) makes a polynomial for sharing the given secret that requires num_shares shares to recover. P is the prime. If p is 0 then make_sss will pick a random prime large enough for the secret. Make_sss returns the prime and the polynomial. The polynomial is represented by an array of coefficients.

The function make_share(sss, i) takes a secret sharing scheme sss of the form [p, polynomial] and returns share i.

The function recover_secret(share_list, p) takes an array of num_shares shares and the prime, and return the polynomial. Each share in the share list is represented by an array that contains the share number and the share.

If you run this from the command line it will run a demo. The demo will make a random 128 bit secret, use make_sss to make a sharing system for that secret that requires 3 shares for recover, print the prime and the polynomial, then generate 3 shares (shares 1, 2, and 5), use those shares to recover the polynomial and print the recovered polynomial, and finally print the 3 shares.

This implementation is a bit different from most others I've seen. Most use Lagrange interpolating polynomials to recover the polynomial fro a set of shares. I was curious about whether it would work reasonably to instead just solve the system of linear equations for recovery the way I would have done it by hand in high school--good old fashioned straightforward Gaussian elimination.

[1] https://pastebin.com/zePiXVUj

Re: Shamir Secret Sharing

#9
OK, since we're pitching our SSS implementations here in comments, I welcome everyone to check out BananaSplit, https://bs.parity.io

Not sure about year 2023, but at the time I wrote it for my previous employer there was nothing remotely usable for regular user.

Thus, BananaSplit. It doesn't allow you to specify many parameters (just the number of shards, and then requires 50%+1 to recover); aimed at printed backups (generates printable full-page QR codes, while asking to copy a decryption phrase to the pages by hand to avoid an "evil printer" attack); and takes the concept of _portable web app_ to its extreme, being a self-contained single html file which requires you to save it locally and open via file:// protocol for it to work.

Disclaimer: while being in use for years, the code had never seen a proper independent code review; there might be bugs, despite me trying to minimize their impact by design, and using only reputable (and pretty minimalistic) JS primitives. If you want to check out the sources yourself before using, of course those are available under GPL at https://github.com/paritytech/banana_split/

Post reply on HN