Inspiration
Inspired by the challenges of implementing this algorithm in Leo :)
What it does
The project implements the Shamir Secret Sharing algorithm using Leo programming language. The current implementation is limited to the thresholds of 2 or 3 (2 or 3 shares holders are required), and the number of generated shares is fixed and equals 5.
How we built it
There are 3 transitions in the smart contract:
- create_shares - takes a secret, threshold, seed, and 5 addresses and creates 5 shares (as Records)
- restore_secret_from_shares - restores secret from 3 shares (quadratic polynom)
- restore_secret_from_n_shares - generic version of secret restoration, works for shares =2 or 3 (linear or quadratic polynoms). can be extended further (needs lagrange interpolation formulae).
Challenges we ran into
Hard to generify the interface (API) due to language limitations, e.g.:
- parameterize the number of share receivers - can't output an array of records, have to always return a tuple of 5 records, and have to always pass 5 addresses as inputs.
- potential overflows
- no way to pass Records owned by different addresses as inputs to a transition. We tackled this by passing the shares as structs into restore_secret_from_n_shares.
Accomplishments that we're proud of
We were able to make a transition restore_secret_from_n_shares that is capable of receiving varying number of shares and a counter, and restoring a secret from this data.
What we learned
Learned Leo from 0 to being able to implement Shamir Secret Sharing =)
What's next for Shamir Secret Sharing (Avail Bounty)
Parametrize share creation (at the moment we only use threshold = 3 when creating shares) Parametrize calc_poly function UI/UX (frontend) for the convenience of usage
Built With
- bash
- leo
Log in or sign up for Devpost to join the conversation.