Shamir's Secret Sharing Scheme
This is a demo of a Javascript implementation of Shamir's Secret Sharing Scheme. The bulk of this demo is relevant to a project we're working on at UMass Amherst: the Privacy Preserving Search Logger, a Firefox and Chrome extension that relies on SSSS and requires that it be implemented in Javascript. Feel free to use the code. It relies on several open source libraries.

[Back to homepage] [Download this example]

The input message

pass phrase:You'd use the same phrase across all installations of the extension.
job salt:Some job-specific string
n:The number of distinct shares to give out
k: The number of distinct shares required to reconstruct the secret (i.e., the password); k≤n
k': (the number of parts we should use to try to re-establish the private key; k'≥k should work; k'<k should not)
Primary data:e.g., a normalized query
Secondary data:e.g., an un-normalized query
Compute shares

The output shares

Password (y-intercept for SSSS polynomial):
Reconstructed key (using k' random shares):
User share:
All shares:
Shares used in reconstruction:
Encrypted primary data (AES encryption):
Encrypted secondary data (AES encryption):
Data as handed off to server (RSA+AES encryption):

Private/Public RSA Keys

The above RSA encryption was created using the following public and private keys:

Private key:

$ openssl genrsa -out x.pem 2048
Generating RSA private key, 2048 bit long modulus
........+++
..+++
e is 65537 (0x10001)
$ cat x.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAr0V86BxxU+giF0s0fxJWunDad/NUFUqfiStGhREbb6u5TvTb
WMyDbCW8Xj/WMC+qZoGD0eLi0NhGSMnqn+4AdQGnSRdtXePIq+1o784/RjsHgTjK
qgh685iiAeSfWYrMth3KMS5GPKjCC7egsGHgB7Lvu2XvXfnyMiVAI5fxx1UKPPHl
4IpUlSXb9Uqia5rVurDbQuICk4DEK21POtvUC5wqnkc1OY//SSHeU6aKvVupaGbo
6jv3FM178mByX9Q6jJUoyVvtYcxYCg3eeLzNuUz+IKepUZZauyUNSo321rTIiibb
LyQNloUeZIgYynR20EPuPDExN96s1eG8RMn4IwIDAQABAoIBABmWq4W3oVP+r/t2
n1Nt+ft+PmcEv2HcYy5DgygqNzc2evdsCBoOwaEoYTfhWgPu8ZHFltktpq+W46v8
zqRKuwZaF3I0WWM7vjBbmNZp5hL6yz2yb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TJkHShk9OqVMnB3TRQpdiBizLFRZy/LcVgvuKjjwRid/eSWYBcyA==
-----END RSA PRIVATE KEY-----

Public key:

$ openssl rsa -in x.pem -pubout
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr0V86BxxU+giF0s0fxJW
unDad/NUFUqfiStGhREbb6u5TvTbWMyDbCW8Xj/WMC+qZoGD0eLi0NhGSMnqn+4A
dQGnSRdtXePIq+1o784/RjsHgTjKqgh685iiAeSfWYrMth3KMS5GPKjCC7egsGHg
B7Lvu2XvXfnyMiVAI5fxx1UKPPHl4IpUlSXb9Uqia5rVurDbQuICk4DEK21POtvU
C5wqnkc1OY//SSHeU6aKvVupaGbo6jv3FM178mByX9Q6jJUoyVvtYcxYCg3eeLzN
uUz+IKepUZZauyUNSo321rTIiibbLyQNloUeZIgYynR20EPuPDExN96s1eG8RMn4
IwIDAQAB
-----END PUBLIC KEY-----