{"id":15497191,"url":"https://github.com/jwerle/shamirs-secret-sharing","last_synced_at":"2025-10-30T15:13:41.432Z","repository":{"id":57103756,"uuid":"142622924","full_name":"jwerle/shamirs-secret-sharing","owner":"jwerle","description":"A simple implementation of Shamir's Secret Sharing configured to use a finite field in GF(2^8) with 128 bit padding","archived":false,"fork":false,"pushed_at":"2024-05-30T13:40:41.000Z","size":37,"stargazers_count":95,"open_issues_count":0,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T10:46:58.425Z","etag":null,"topics":["crypto","cryptography","secret","shamir","shamir-secret-sharing","sharing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwerle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-27T20:56:38.000Z","updated_at":"2025-03-14T01:31:26.000Z","dependencies_parsed_at":"2024-06-18T18:28:36.093Z","dependency_job_id":null,"html_url":"https://github.com/jwerle/shamirs-secret-sharing","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":"0.16666666666666663","last_synced_commit":"4c4e921d010a2befdc60b3bd12ac385daa38af9e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fshamirs-secret-sharing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fshamirs-secret-sharing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fshamirs-secret-sharing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Fshamirs-secret-sharing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwerle","download_url":"https://codeload.github.com/jwerle/shamirs-secret-sharing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085951,"owners_count":21045243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypto","cryptography","secret","shamir","shamir-secret-sharing","sharing"],"created_at":"2024-10-02T08:31:34.024Z","updated_at":"2025-09-24T16:32:08.339Z","avatar_url":"https://github.com/jwerle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"shamirs-secret-sharing\n======================\n\nA simple implementation of Shamir's Secret Sharing configured to use a\nfinite field in GF(2^8) with 128 bit padding.\n\n## Preface\n\nMuch of what you see in this module has been ported from or\ndirectly influenced by\n[secrets.js](https://github.com/grempe/secrets.js),\n[c-sss](https://github.com/fletcher/c-sss), and\n[libgfshare](https://launchpad.net/libgfshare)\n\n## Installation\n\n```sh\n$ npm install shamirs-secret-sharing\n```\n\n## Example Usage (Node.js)\n\n```js\nimport sss from 'shamirs-secret-sharing'\n\nconst secret = Buffer.from('secret key')\nconst shares = sss.split(secret, { shares: 10, threshold: 4 })\nconst recovered = sss.combine(shares.slice(3, 7))\n\nconsole.log(recovered.toString()) // 'secret key'\n```\n\n## Example Usage ([Socket Runtime](https://github.com/socketsupply/socket))\n\nConfigure the `[build.copy-map]` section in `socket.ini`:\n\n```ini\n[build.copy-map]\nnode_modules/shamirs-secret-sharing = shares-secret-sharing\n```\n\n```js\nimport Buffer form 'socket:buffer'\nimport combine from 'npm:shares-secret-sharing/combine.js'\nimport split from 'npm:shares-secret-sharing/split.js'\n\nconst secret = Buffer.from('secret key')\nconst shares = sss.split(secret, { shares: 10, threshold: 4 })\nconst recovered = sss.combine(shares.slice(3, 7))\n\nconsole.log(recovered.toString()) // 'secret key'\n```\n\n## API\n\n### `shares = sss.split(secret, opts)`\n\nGenerate a set of unique and distinct shares for a secret with a\nconfigured threshold.\n\n* `secret` (**required**) - A `Buffer` instance or `string` that represents a\n  secret for which shares are created for\n* `opts` (**required**) - An object of options for configuring how\n  shares are created for a secret\n  * `opts.shares` (**required**) - The number of `n` shares that should\n    be created for this secret\n  * `opts.threshold` (**required**) - The number of `t` of `n` distinct share\n    that are required to reconstruct this secret\n  * `opts.random` (*optional*) - An optional _Pseudorandom number\n    generator_ (PRNG) function that should generate a random value\n    buffer based on some input. e.g `opts.random = (size) =\u003e\n    randomBytes(size)`\n\n### `secret = sss.combine(shares)`\n\nReconstruct a secret from a distinct set of shares. This function _will\nnot_ throw an error for incorrect shares or if `p(0)` is not the correct\nsecret for the given shares.\n\n* `shares` (**required**) - An array of shares, that is an array of\n  equally sized and distinct `Buffer` instances, or _strings_\n\n## See Also\n\n* https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing\n* https://en.wikipedia.org/wiki/Secret_sharing\n* https://en.wikipedia.org/wiki/Lagrange_polynomial\n* https://en.wikipedia.org/wiki/Horner%27s_method\n* https://en.wikipedia.org/wiki/Pseudorandom_number_generator\n* https://codesandbox.io/s/shamirs-secret-sharing-pcsbk\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Fshamirs-secret-sharing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwerle%2Fshamirs-secret-sharing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Fshamirs-secret-sharing/lists"}