11.3.1 • Published 3 months ago

jsonld-signatures v11.3.1

Weekly downloads
4,158
License
BSD-3-Clause
Repository
github
Last release
3 months ago

JSON-LD Signatures (jsonld-signatures)

Build status Coverage status Dependency Status NPM Version

An implementation of the Linked Data Signatures specification for JSON-LD, for Node.js and browsers.

Table of Contents

Version Compatibility

jsonld-signatures v9.0 is compatible with the following signature suites:

and the following related libraries:

Background

A Linked Data Signature proof is created (or verified) by specifying a signature suite and a proof purpose.

The signature suite performs the cryptographic operation required to sign (or verify) a digital signature and includes information in a proof such as the verificationMethod identifier, the proof's controller, and the date the proof was created.

The proof purpose indicates why the proof was created and what its intended use is. This information can also be used to make sure that the verificationMethod was authorized for the stated purpose in the proof. Using a proof purpose helps to encourage people to authorize certain cryptographic keys (verification methods) for explicit purposes rather than granting them ambient authority. This approach can help prevent people from accidentally signing documents for reasons they did not intend.

This library provides base classes for signature suites and proof purposes so that custom extensions can be written. It also provides some commonly used proof purposes.

Relationship to Verifiable Credentials

jsonld-signatures is a low-level library that is meant to sign any JSON-LD document.

One common use case for creating these signatures is for use with Verifiable Credentials (VCs). If you're working with those, you should use a higher-level library that's specifically made for that purpose, such as vc-js. (Incidentally, vc-js uses this library, jsonld-signatures, under the hood.)

Security

As with most security- and cryptography-related tools, the overall security of your system will largely depend on your design decisions (which key types you will use, where you'll store the private keys, what you put into your credentials, and so on).

Document Loader

During verification, the key and key controller information must be discovered. This library allows for the key and key controller information to be looked up via a documentLoader or it can be provided directly to the API via the signature suite or proof purpose, respectively.

This library's default documentLoader is very strict for security and content integrity purposes. It will only load locally available copies of the context documents that define the terms it uses internally. Any attempt to load any other documents (including other contexts) will throw an error. If other documents such as verification methods (e.g., public key documents), cannot be provided directly to the API and thus need to be loaded, a custom document loader must be passed. For the sake of clarity, the default document loader will only load locally available copies of the following documents:

If you require other documents to be loaded then you will need to provide a documentLoader that can provide them. jsonld.js provides both a node and browser documentLoader you can use, however, depending on your use case, you may increase security by using a custom documentLoader that is similarly strict and will only load a subset of documents that is constrained by some technical, security, or business rules.

Install

  • Browsers and Node.js 14+ are supported.

To install from NPM:

npm install jsonld-signatures

To install locally (for development):

git clone https://github.com/digitalbazaar/jsonld-signatures.git
cd jsonld-signatures
npm install

Usage

jsonld-signatures (version 8.x and above) is not meant for standalone use. Instead, it's generally used through an individual crypto suite. For detailed usage instructions, see the READMEs of the supported suites:

Most of the usages with individual suites and key types will have elements in common. You'll need to:

  • Generate or import cryptographic keys to sign with (see the @digitalbazaar/crypto-ld >=v5.0) library), or use a secure signer() function provided by your secure cryptographic module.
  • Authorize those keys for the specific purpose you're using them for (see section on Proof Purpose below), using a Controller Document (such as a DID Document or similar).
  • Pair those keys with a corresponding cryptographic Signature Suite. For greenfield development, we recommend the Ed25519Signature2020 suite, and for legacy/compatibility work, you can use Ed25519Signature2018 suite. See also the Choosing a Key Type section of crypto-ld documentation.
  • Set up your documentLoader to fetch contexts and documents securely.
  • Lastly, perform the jsigs.sign() or jsigs.verify() operations.

Node.js Native Canonize Bindings

Specialized use cases may wish to use the native canonize bindings. This mode can be enabled by setting the useNativeCanonize option to true. See the jsonld.js notes on this feature and note you should benchmark performance before using it.

Contribute

See the contribute file!

PRs accepted.

If editing the Readme, please conform to the standard-readme specification.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: support@digitalbazaar.com

License

New BSD License (3-clause) © Digital Bazaar

@jchartrand/sign-and-verify-base@owlmeans/regov-ssi-did@trustcerts/vc-createfib-did-sdk@infinitebrahmanuniverse/nolb-jsonl@everything-registry/sub-chunk-1987epcis-signing-testspidchain-loginvc-js@nghaninn/w3c-issuer@nghaninn/w3c-vcjsonld-signatures-bbsjsonld-signatures-merkleproof2019hs-ssi-sdkhttp-signature-middlewareinfra-did-jslds-jws2020lds-sdkgithub-did-librarygithub-did-library-web3myinfo-vc-verifierocapldssif-apitrustgraphtrust-exchange@affinityproject/issuer-util@affinityproject/tiny-lds-ecdsa-secp256k1-2019@affinityproject/verifier-util@affinidi/wallet-node-sdk@affinidi/issuer-util@affinidi/tiny-lds-ecdsa-secp256k1-2019@affinidi/vc-common@affinidi/verifier-util@albus-finance/core@bedrock/web-wallet@bloomprotocol/vc@bloomprotocol/ecdsa-secp256k1-signature-2019@blockcerts/cert-verifier-js@blockcerts/cert-verifier-js-v1-legacy@blockcerts/ecdsa-secp256k1-signature-2019@dicdikshaorg/client-services@digitalbazaar/ed25519-signature-2020@digitalbazaar/ezcap@digitalbazaar/ezcap-express@digitalbazaar/jws-linked-data-signature@digitalbazaar/data-integrityverification-sdkveres-one-validator@github-did/lib@kskhasegawa/jsonld-signatures-bbs@extrimian/kms-suite-jsonld@extrimian/kms-suite-rsa-signature-2018@extrimian/vc-verifier@mattrglobal/jsonld-signatures-bbs@kiltprotocol/vc-export@project-sunbird/client-services@proofid/vc-export@quarkid/kms-suite-jsonld@quarkid/kms-suite-rsa-signature-2018@quarkid/vc-verifier@po.et/poet-js@owlmeans/regov-ssi-core@owlmeans/tiny-lds-ecdsa-secp256k1-2019@owlmeans/vc-core@sunbird-rc/verification-sdk@sphereon/ssi-sdk-vc-handler-ld-local@sphereon/ed25519-signature@sphereon/credential-ld@sphereon/ssi-sdk.vc-handler-ld-local@semapps/crypto@digitalcredentials/sign-and-verify@docknetwork/credential-sdk@docknetwork/sdk@dsnp/verifiable-credentials@digitalbazaar/zcap@digitalbazaar/zcapld@digitalbazaar/vcecdsa-secp256k1-signature-2019epcis-signing@transmute/lds-ecdsa-secp256k1-2019@transmute/lds-ecdsa-secp256k1-recovery2020@transmute/lds-ss256k@trinsic/jsonld-signatures-bbs@twipped/activitystreams@trustcerts/vc@trustcerts/vc-bbs@trustvc/w3c-vcfib-jsonld-sign@vckit/revocationlist@verixyz/credential-ldactivitystrea.ms@zkp-ld/jsonld-signatures-bbs@zkp-ld/rdf-signatures-bbs@yamdan/jsonld-signatures-bbs@tangleid/jsonldbedrock-did-clientbedrock-authn-did-jwtbedrock-credential-handlerbedrock-data-hub-storagebedrock-credential-curator
11.3.1

3 months ago

11.3.0

5 months ago

11.2.1

2 years ago

11.2.0

2 years ago

11.1.0

2 years ago

11.0.0

2 years ago

10.0.0

3 years ago

9.3.1

3 years ago

9.3.0

3 years ago

9.2.1

3 years ago

9.2.0

3 years ago

9.1.1

3 years ago

9.1.0

3 years ago

9.0.2

4 years ago

9.0.1

4 years ago

9.0.0

4 years ago

8.0.1

4 years ago

8.0.0

4 years ago

8.0.2

4 years ago

7.0.0

4 years ago

6.0.0

4 years ago

5.2.0

4 years ago

5.1.0

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.6.0

5 years ago

4.5.1

5 years ago

4.5.0

5 years ago

4.4.0

5 years ago

4.3.0

5 years ago

4.2.1

5 years ago

4.2.0

6 years ago

4.1.3

6 years ago

4.1.2

6 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.3.1

6 years ago

2.3.0

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.5

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

1.0.0

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago