{"id":13733121,"url":"https://github.com/mattrglobal/bbs-signatures","last_synced_at":"2025-05-08T09:31:44.587Z","repository":{"id":37332816,"uuid":"256108504","full_name":"mattrglobal/bbs-signatures","owner":"mattrglobal","description":"An implementation of BBS+ signatures for node and browser environments","archived":false,"fork":false,"pushed_at":"2024-11-05T22:14:13.000Z","size":1239,"stargazers_count":112,"open_issues_count":11,"forks_count":30,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-05T22:19:04.788Z","etag":null,"topics":["assurance","cryptography","digital-signature","nucleus","wasm","zero-knowledge-proofs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattrglobal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-16T04:25:15.000Z","updated_at":"2024-11-05T22:14:15.000Z","dependencies_parsed_at":"2023-09-27T09:52:36.304Z","dependency_job_id":"e429ba50-bea0-4b30-b999-16ccb2b8e677","html_url":"https://github.com/mattrglobal/bbs-signatures","commit_stats":{"total_commits":156,"total_committers":16,"mean_commits":9.75,"dds":0.5833333333333333,"last_synced_commit":"954c72213f3e89bb435222ccff02c193581589f9"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattrglobal%2Fbbs-signatures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattrglobal%2Fbbs-signatures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattrglobal%2Fbbs-signatures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattrglobal%2Fbbs-signatures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattrglobal","download_url":"https://codeload.github.com/mattrglobal/bbs-signatures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224717561,"owners_count":17357905,"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":["assurance","cryptography","digital-signature","nucleus","wasm","zero-knowledge-proofs"],"created_at":"2024-08-03T03:00:37.887Z","updated_at":"2025-05-08T09:31:44.575Z","avatar_url":"https://github.com/mattrglobal.png","language":"TypeScript","funding_links":[],"categories":["Libraries"],"sub_categories":["Wrapped library"],"readme":"[![MATTR](./docs/assets/mattr-logo-square.svg)](https://github.com/mattrglobal)\n\n## Deprecation Notice\n\nThis library has been deprecated in favor of the [Pairing Cryptography](https://github.com/mattrglobal/pairing_crypto)\nlibrary which implements the more modern\n[BBS Signature Scheme](https://www.ietf.org/archive/id/draft-irtf-cfrg-bbs-signatures-03.html).\n\n# bbs-signatures\n\n![npm-version](https://badgen.net/npm/v/@mattrglobal/bbs-signatures)\n![npm-unstable-version](https://badgen.net/npm/v/@mattrglobal/bbs-signatures/unstable)\n![Master](https://github.com/mattrglobal/bbs-signatures/workflows/push-master/badge.svg)\n![Release](https://github.com/mattrglobal/bbs-signatures/workflows/push-release/badge.svg)\n![codecov](https://codecov.io/gh/mattrglobal/bbs-signatures/branch/master/graph/badge.svg)\n\nThis repository is the home to a performant multi-message digital signature algorithm implementation which supports\nderiving zero knowledge proofs that enable selective disclosure from the originally signed message set.\n\n[BBS+ Signatures](https://github.com/mattrglobal/bbs-signatures-spec) are a digital signature algorithm originally born from the work on\n[Short group signatures](https://crypto.stanford.edu/~xb/crypto04a/groupsigs.pdf) by Boneh, Boyen, and Shachum which was\nlater improved on in [Constant-Size Dynamic k-TAA](http://web.cs.iastate.edu/~wzhang/teach-552/ReadingList/552-14.pdf)\nas BBS+ and touched on again in section 4.3 in\n[Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited ](https://www.researchgate.net/publication/306347781_Anonymous_Attestation_Using_the_Strong_Diffie_Hellman_Assumption_Revisited).\n\nBBS+ signatures require a\n[pairing-friendly curve](https://tools.ietf.org/html/draft-irtf-cfrg-pairing-friendly-curves-03), this library includes\nsupport for [BLS12-381](https://tools.ietf.org/html/draft-irtf-cfrg-pairing-friendly-curves-03#section-2.4).\n\nBBS+ Signatures allow for multi-message signing whilst producing a single output signature. With a BBS signature, a\n[proof of knowledge](https://en.wikipedia.org/wiki/Proof_of_knowledge) based proof can be produced where only some of\nthe originally signed messages are revealed at the discretion of the prover.\n\nFor more details on the signature algorithm please refer to [here](https://github.com/mattrglobal/bbs-signatures-spec).\n\n## Getting started\n\nTo use this package within your project simply run\n\n```\nnpm install @mattrglobal/bbs-signatures\n```\n\nOr with [Yarn](https://yarnpkg.com/)\n\n```\nyarn add @mattrglobal/bbs-signatures\n```\n\n### Environment Support\n\nThis library includes a couple of features to ensure the most performant implementation of BBS is running in a execution environment. The order of selection is the following.\n\n1. If in a node js based environment and the optional dependency of [@mattrglobal/node-bbs-signatures](https://github.com/mattrglobal/node-bbs-signatures) is installed use this.\n2. If in an environment that supports [Web Assembly](https://webassembly.org/) use this.\n\n**Note** Please refer to running the benchmarks below where you can compare these different implementations, the differences are very notable.\n\n**Note** To force the usage of a particular environment set the `BBS_SIGNATURES_MODE` environment variable to one of the following values\n\n- `NODE_JS_MODULE` - Use native node module, ensure [@mattrglobal/node-bbs-signatures](https://github.com/mattrglobal/node-bbs-signatures) is installed\n- `WASM` - Use the wasm module\n\n**Note** Previous releases of this library supported an asm.js compilation for usage in react native environments, however this has been deprecated due to performance issues.\n\n## Usage\n\nSee the [sample](./sample) directory for a runnable demo's.\n\nThe following is a short sample on how to use the API\n\n```typescript\nimport {\n  generateBls12381G2KeyPair,\n  blsSign,\n  blsVerify,\n  blsCreateProof,\n  blsVerifyProof,\n} from \"@mattrglobal/bbs-signatures\";\n\n//Generate a new key pair\nconst keyPair = await generateBls12381G2KeyPair();\n\n//Set of messages we wish to sign\nconst messages = [\n  Uint8Array.from(Buffer.from(\"message1\", \"utf-8\")),\n  Uint8Array.from(Buffer.from(\"message2\", \"utf-8\")),\n];\n\n//Create the signature\nconst signature = await blsSign({\n  keyPair,\n  messages: messages,\n});\n\n//Verify the signature\nconst isVerified = await blsVerify({\n  publicKey: keyPair.publicKey,\n  messages: messages,\n  signature,\n});\n\n//Derive a proof from the signature revealing the first message\nconst proof = await blsCreateProof({\n  signature,\n  publicKey: keyPair.publicKey,\n  messages,\n  nonce: Uint8Array.from(Buffer.from(\"nonce\", \"utf8\")),\n  revealed: [0],\n});\n\n//Verify the created proof\nconst isProofVerified = await blsVerifyProof({\n  proof,\n  publicKey: keyPair.publicKey,\n  messages: messages.slice(0, 1),\n  nonce: Uint8Array.from(Buffer.from(\"nonce\", \"utf8\")),\n});\n```\n\n## Element Size\n\nWithin a digital signature there are several elements for which it is useful to know the size, the following table\noutlines the general equation for calculating element sizes in relation to BBS+ signatures as it is dependent on the\npairing friendly curve used.\n\n| Element     | Size Equation                        |\n| ----------- | ------------------------------------ |\n| Private Key | F                                    |\n| Public Key  | G2                                   |\n| Signature   | G1 + 2\\*F                            |\n| Proof       | 5*G1 + (4 + no_of_hidden_messages)*F |\n\n- `F` A field element\n- `G1` A point in the field of G1\n- `G2` A point in the field of G2\n- `no_of_hidden_messages` The number of the hidden messages\n\nThis library includes specific support for BLS12-381 keys with BBS+ signatures and hence gives rise to the following\nconcrete sizes\n\n| Element     | Size with BLS12-381                     |\n| ----------- | --------------------------------------- |\n| Private Key | 32 Bytes                                |\n| Public Key  | 96 Bytes                                |\n| Signature   | 112 Bytes                               |\n| Proof       | 368 + (no_of_hidden_messages)\\*32 Bytes |\n\n## Getting started as a contributor\n\nThe following describes how to get started as a contributor to this project\n\n### Prerequisites\n\nThe following is a list of dependencies you must install to build and contribute to this project\n\n- [Yarn](https://yarnpkg.com/)\n- [Rust](https://www.rust-lang.org/)\n\nFor more details see our [contribution guidelines](./docs/CONTRIBUTING.md)\n\n#### Install\n\nTo install the package dependencies run:\n\n```\nyarn install --frozen-lockfile\n```\n\n#### Build\n\nTo build the project for debug run:\n\n```\nyarn build\n```\n\n#### Test\n\nTo run the all test in the project run:\n\n```\nyarn test\n```\n\nTo run just the tests for a node environment using the native node module of [@mattrglobal-node-bbs-signatures](https://github.com/mattrglobal/node-bbs-signatures) run:\n\n```\nyarn test:node\n```\n\nTo run just the tests for a node environment using the wasm module run:\n\n```\nyarn test:wasm\n```\n\nTo run just the tests for a browser environment run:\n\n```\nyarn test:browser\n```\n\n#### Benchmark\n\nTo benchmark the implementation locally in a node environment using the native node module of [@mattrglobal-node-bbs-signatures](https://github.com/mattrglobal/node-bbs-signatures) run:\n\n```\nyarn benchmark:node\n```\n\nTo benchmark the implementation locally in a node environment using the wasm module run:\n\n```\nyarn benchmark:wasm\n```\n\n## Dependencies\n\nThis library uses the [bbs](https://crates.io/crates/bbs) rust crate for the implementation of BBS+ signatures and\nBLS12-381 which is then wrapped and exposed in javascript/typescript using [Web Assembly](https://webassembly.org/).\n\n## Security Policy\n\nPlease see our [security policy](./SECURITY.md) for additional details about responsible disclosure of security related issues.\n\n## Relevant References\n\nFor those interested in more details, you might find the following resources helpful\n\n- [Details on the algorithm](docs/ALGORITHM.md)\n- [BLS12-381 For The Rest Of Us](https://hackmd.io/@benjaminion/bls12-381)\n- [Pairing-based cryptography](https://en.wikipedia.org/wiki/Pairing-based_cryptography)\n- [Exploring Elliptic Curve Pairings](https://vitalik.ca/general/2017/01/14/exploring_ecp.html)\n- [Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited](https://www.researchgate.net/publication/306347781_Anonymous_Attestation_Using_the_Strong_Diffie_Hellman_Assumption_Revisited)\n- [Pairing Friendly Curves](https://tools.ietf.org/html/draft-irtf-cfrg-pairing-friendly-curves-01)\n- [BLS Signatures](https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-02)\n\n---\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mattr.global\" target=\"_blank\"\u003e\u003cimg height=\"40px\" src =\"./docs/assets/mattr-logo-tm.svg\"\u003e\u003c/a\u003e\u003c/p\u003e\u003cp align=\"center\"\u003eCopyright © MATTR Limited. \u003ca href=\"./LICENSE\"\u003eSome rights reserved.\u003c/a\u003e\u003cbr/\u003e“MATTR” is a trademark of MATTR Limited, registered in New Zealand and other countries.\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattrglobal%2Fbbs-signatures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattrglobal%2Fbbs-signatures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattrglobal%2Fbbs-signatures/lists"}