Path: blob/main/frontier/12-mpc/sage/12a-secret-sharing-shamir.ipynb
483 views
Notebook 12a: Shamir Secret Sharing
Module 12: Multi-Party Computation
Motivating Question. You want to split a cryptographic key among 5 people so that any 3 of them can reconstruct it, but any 2 (or fewer) learn absolutely nothing. Is this possible? Shamir's Secret Sharing (1979) solves this elegantly using polynomial interpolation over finite fields.
Prerequisites. You should be comfortable with:
Modular arithmetic and finite fields (Module 01)
Polynomial evaluation and interpolation (Module 02)
Learning objectives. By the end of this notebook you will be able to:
Construct a secret sharing scheme using random polynomials.
Generate shares by polynomial evaluation.
Reconstruct the secret using Lagrange interpolation.
Verify the threshold property: shares reveal nothing.
Perform basic operations on secret-shared data.
1. The Idea: Hide a Secret in a Polynomial
Bridge from Module 01. In Module 01, we worked with polynomials over finite fields and saw that a degree- polynomial is uniquely determined by points. Shamir's scheme uses this fact: hide the secret as the constant term of a random polynomial, and distribute evaluations as shares.
The threshold scheme:
Secret
Pick random
Define
Share : the point for
Any shares determine uniquely (and thus )
Any shares reveal nothing about
Checkpoint 1. The secret is . The shares are . Since a degree- polynomial is determined by points, any shares can reconstruct (and thus ), but shares leave completely undetermined.
2. Sharing: Distributing the Shares
3. Reconstruction via Lagrange Interpolation
Given points , Lagrange interpolation recovers the unique polynomial of degree passing through them:
We only need , so we can compute just:
The products are called Lagrange coefficients.
Checkpoint 2. Any shares reconstruct the secret correctly, regardless of which parties participate. This is the beauty of the threshold property.
4. The Threshold Property: Shares Reveal Nothing
This is the security property of Shamir's scheme. With shares, the secret could be any value in , each equally likely.
Why? A degree- polynomial has free coefficients. With equations (shares), one degree of freedom remains, exactly the secret .
Misconception alert. " shares narrow down the secret to a smaller set." No, they narrow it down to all possible values in , each equally likely. This is perfect secrecy, like a one-time pad.
5. Operations on Shares
A remarkable property: we can perform some computations directly on the shares without reconstructing the secret.
Addition: If parties hold shares of and , they can locally add their shares to get shares of . This works because polynomial addition is linear:
and .
6. What Can Go Wrong?
Shamir's basic scheme assumes an honest dealer who correctly distributes shares from a single polynomial. What if the dealer cheats?
Crypto foreshadowing. Shamir's scheme is the foundation of MPC. In the SPDZ protocol (Notebook 12e), parties hold Shamir shares of values and perform computations using Beaver triples for multiplication, with MACs to detect cheating.
7. Exercises
Exercise 1 (Worked): Different Thresholds
Problem. Create a sharing of the secret over . Verify that any 2 shares reconstruct correctly and that 1 share reveals nothing.
Solution:
Exercise 2 (Guided): Weighted Voting
Problem. Share the secret with a scheme. Compute using only share operations (no reconstruction). Verify the result.
Fill in the TODOs:
Exercise 3 (Independent): Threshold Choice
Problem.
In a 10-party system, what threshold ensures security against up to 4 corrupted parties?
Create a sharing of your chosen secret and verify the threshold property.
What is the maximum number of corrupted parties a Shamir scheme can tolerate? How does this relate to the degree of the polynomial?
Summary
| Concept | Key Fact |
|---|---|
| scheme | shares, any reconstruct, reveal nothing |
| Polynomial | Degree , secret = , shares = |
| Reconstruction | Lagrange interpolation at |
| Security | Information-theoretic: shares leave all secrets equally likely |
| Linearity | Addition and scalar multiplication work directly on shares |
| Multiplication | Requires interaction between parties (degree doubles) |
Shamir's secret sharing is the workhorse of threshold cryptography and MPC. Its linearity makes addition cheap (local), while multiplication requires clever protocols like Beaver triples.