Inspiration

We have targeted the following bounty:

​Avail Bounty: ​> Bounty Name: Shamir’s Secret Sharing Algorithm in Leo

About

This project includes a Leo code generator using TypeScript & Bun, that generates Leo code for Shamir's Secret Sharing with the given parameters (k, n) where k is the minimum number of shares to recover the secret, and n is the number of shares generated.

Challenges

Leo, due to nature of zk-friendliness, is a rather constrained language when it comes to syntax and flexibility. To combat these, we have written a wrapper code that generates the Leo code with desired parameters.

Two particular things were major factors in the way we generate the code:

  • There can't be for loops with a decreasing variable in Leo. Due to this, we wrote the expressions within the Horner evaluation function in a loop-unrolled fashion.
  • Max allowed array size is 32. To allow more than 32 values, we have nested two arrays, obtaining 32*32 values max. When the number of values are less than 32, we pad the rest of first 32 array with zeros.

Future Work

A natural extension of this project would be to allow higher values of k and n, which translate to more nested arrays.

Built With

Share this project:

Updates