Lagrange interpolation, named after Joseph-Louis Lagrange, finds the unique polynomial of degree at most n − 1 through n points with distinct x-coordinates. I built this demo to show how the curve changes as you add and move points.
Open the full-screen interpolation demo.
Tap to add a point. Drag a point to move it. Keep the points at distinct x-coordinates so the polynomial is defined.
Shamir's Secret Sharing divides a secret into n shares, with a threshold t. Any t distinct valid shares can reconstruct the secret; no particular combination is required.
The demo above uses real-number coordinates to illustrate interpolation. It is not a cryptographic implementation. Shamir's scheme, introduced by Adi Shamir, needs finite-field arithmetic and securely generated random coefficients.
n distinct non-zero x-coordinates. Choose a threshold t between 1 and n.s as a field element. Choose t − 1 coefficients independently and uniformly at random from the field, using a cryptographically secure random source. With s as the constant term, these form a polynomial of degree at most t − 1.t distinct valid shares. Evaluate the recovered polynomial at zero to obtain s.With this construction, fewer than t shares reveal no additional information about the secret. Using ordinary real-number arithmetic or predictable coefficients does not provide that guarantee.
One use is master-key recovery, as explored in my password manager project. Shares can be held by different people or stored separately, with a threshold needed to recover the key.
This video explains the connection between interpolation and secret sharing: