# JavaScript digital signature libraries

JavaScript digital signature libraries sign data with a private key and verify the signature with the matching public key. A verified signature shows that the data came from the key holder and has not changed since signing. These libraries sign the login tokens, API requests, software releases, and certificates that apps and services exchange.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [jose](#jose) | 878.5M | 7.9K | Nov 2026 | MIT |
| [node-jws](#jws) | 483.8M | 721 | Dec 2025 | MIT |
| [node-jwa](#jwa) | 481.7M | 103 | May 2025 | MIT |
| [jsonwebtoken](#jsonwebtoken) | 317.9M | 18.2K | Dec 2025 | MIT |
| [Forge](#forge) | 211.3M | 5.4K | Nov 2026 | (BSD-3-Clause OR GPL-2.0) |
| [TweetNaCl.js](#tweetnacl) | 195.3M | 1.9K | Feb 2020 | Unlicense |
| [@noble/curves](#noble-curves) | 188.7M | 972 | Aug 2026 | MIT |
| [@peculiar/x509](#peculiar-xfivezeronine) | 85.7M | 137 | Oct 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[jose](#jose) has the most monthly downloads in this comparison, at 878.5M.

## Capabilities

| Library | JWS envelopes | Certificate issuance |
| --- | --- | --- |
| [jose](#jose) | Yes | No |
| [node-jws](#jws) | Yes | No |
| [node-jwa](#jwa) | No | No |
| [jsonwebtoken](#jsonwebtoken) | Yes | No |
| [Forge](#forge) | No | Yes |
| [TweetNaCl.js](#tweetnacl) | No | No |
| [@noble/curves](#noble-curves) | No | No |
| [@peculiar/x509](#peculiar-xfivezeronine) | No | Yes |

## Libraries

### jose

[GitHub](https://github.com/panva/jose) · [npm](https://www.npmjs.com/package/jose)

Provides JSON Web Signature and JSON Web Token APIs.

- Downloads / mo: 878.5M
- Stars: 7.9K
- Last release: 6.2.17
- License: MIT
- Capabilities: [From the jose docs](https://github.com/panva/jose)

**Strengths**

- **Supports general JSON signatures.** Use GeneralSign to produce a signed JSON JWS envelope.
- **Imports existing PEM keys.** Load supported public or private keys with the import helpers.

**Watch out for**

- **Algorithms depend on the runtime.** Select an algorithm supported by the target runtime.
- **Private keys start non-extractable.** Set extractable when generated private keys must be exported.

```sh
npm install jose
```

**better-auth/better-auth** (30.8K stars)

[better-auth/better-auth](https://github.com/better-auth/better-auth) 

```javascript
export async function signJWT(
	ctx: GenericEndpointContext,
	config: {
		options?: JwtOptions | undefined;
		payload: JWTPayloadWithOptional;
		/** Pre-resolved key from resolveSigningKey. Skips redundant DB lookup. */
		resolvedKey?: ResolvedSigningKey;
		/**
		 * Extra JWS Protected Header parameters to merge with the defaults
		 * (`alg` and `kid`). Used by token profiles that require an explicit
		 * media type, such as OIDC Back-Channel Logout's `typ: "logout+jwt"`.
		 *
		 * @see https://www.rfc-editor.org/rfc/rfc8725#section-3.11
		 */
		header?: {
			typ?: string;
			cty?: string;
		};
		/**
		 * Optional override for the signing key. When set, looks up the key
		 * by its `id` (matches the JWS `kid` header) via the JWKS adapter.
		 * Throws if no key with that id exists.
		 *
		 * When unset, falls back to the most recently created key with the
		 * primary `keyPairConfig.alg` (the historical default).
		 */
		signingKeyId?: string | undefined;
		/**
		 * Optional override for the signing algorithm. Selects the most
		 * recent key with this algorithm. When neither this nor
		 * `signingKeyId` is set, the most recent key matching
		 * `keyPairConfig.alg` is used (historical default).
		 *
		 * If both `signingKeyId` and `signingAlgorithm` are set, `signingKeyId`
		 * wins; the algorithm is validated to match the resolved key and
		 * the call throws on mismatch.
		 */
		signingAlgorithm?: JWSAlgorithms | undefined;
	},
) {
	const { options } = config;
	const payload = config.payload as JWTPayload;

	// Iat
	const nowSeconds = Math.floor(Date.now() / 1000);
	const iat = payload.iat!;

	// Exp
	let exp = payload.exp;
	const defaultExp = toExpJWT(
		options?.jwt?.expirationTime ?? "15m",
		iat ?? nowSeconds,
	);
	exp = exp ?? defaultExp;

	// Nbf
	const nbf = payload.nbf!;

	// Empty only for a direct `auth.api` call when no baseURL is configured
	const baseURLOrigin =
		typeof ctx.context.options.baseURL === "string"
			? ctx.context.options.baseURL
			: "";

	// Iss
	const iss = payload.iss;
	const defaultIss = options?.jwt?.issuer ?? baseURLOrigin;

	// Aud
	const aud = payload.aud;
	const defaultAud = options?.jwt?.audience ?? baseURLOrigin;

	if (!(iss ?? defaultIss) || !(aud ?? defaultAud)) {
		ctx.context.logger.warn(
			"[better-auth] The JWT plugin signed a JWT without an issuer or audience because no base URL was resolved for this call. Set `baseURL`, or `jwt.issuer` and `jwt.audience` in the JWT plugin options.",
		);
	}

	// Custom/remote signing function
	if (options?.jwt?.sign) {
		const jwtPayload = {
			...payload,
			iat,
			exp,
			nbf,
			iss: iss ?? defaultIss,
			aud: aud ?? defaultAud,
		};
		// Forward extra protected-header parameters (e.g. `typ: "logout+jwt"`)
		// so profiles that require an explicit media type stay conformant even
		// with a remote signer. The signer still owns `alg`/`kid`. Also forward
		// per-call signing overrides as a third arg so remote KMS integrations
		// can honor per-resource kid/alg pinning. Both extra args are optional,
		// so existing single-arg implementations continue to work unchanged.
		return options.jwt.sign(jwtPayload, config.header, {
			signingKeyId: config.signingKeyId,
			signingAlgorithm: config.signingAlgorithm,
		});
	}

	// Use pre-resolved key if available, otherwise resolve from DB with
	// any per-call overrides plumbed through.
	const { alg, kid, privateKey } =
		config.resolvedKey ??
		(await resolveSigningKey(ctx, options, {
			signingKeyId: config.signingKeyId,
			signingAlgorithm: config.signingAlgorithm,
		}))!;

	const jwt = new SignJWT(payload)
		.setProtectedHeader({
			// Spread caller header first so the resolved `alg`/`kid` always win.
			...config.header,
			alg,
			kid,
		})
		.setExpirationTime(exp)
		.setIssuer(iss ?? defaultIss)
		.setAudience(aud ?? defaultAud);
	if (iat) jwt.setIssuedAt(iat);
	if (payload.sub) jwt.setSubject(payload.sub);
	if (payload.nbf) jwt.setNotBefore(payload.nbf);
	if (payload.jti) jwt.setJti(payload.jti);
	return await jwt.sign(privateKey);
}

```

[packages/better-auth/src/plugins/jwt/sign.ts](https://github.com/better-auth/better-auth/blob/8382ce613f04bf590d3cb6c1363dfd0e41110944/packages/better-auth/src/plugins/jwt/sign.ts#L232-L356) · [More projects using jose →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20jose%20for%20digital%20signatures%20with%20signing%20verification%20and%20key%20imports&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import * as jose from "jose";

const { privateKey } = await jose.generateKeyPair("ES256");
const token = await new jose.SignJWT({ sub: "example" })
  .setProtectedHeader({ alg: "ES256" })
  .sign(privateKey);
console.log(token);

```

From [README.md](https://github.com/panva/jose/blob/main/docs/jwt/sign/classes/SignJWT.md)

### node-jws

[GitHub](https://github.com/auth0/node-jws) · [npm](https://www.npmjs.com/package/jws)

Implements JSON Web Signatures.

- Downloads / mo: 483.8M
- Stars: 721
- Last release: 4.0.1
- License: MIT
- Capabilities: [From the node-jws docs](https://github.com/auth0/node-jws)

**Strengths**

- **Synchronous and streaming APIs.** Sign with jws.sign, or stream large payloads through jws.createSign.

**Watch out for**

- **No certificate chain signing.** Certificate chain signing and verifying fall outside the library.

```sh
npm install jws
```

**auth0/node-jsonwebtoken** (18.2K stars)

[auth0/node-jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) 

```javascript
function (payload, secretOrPrivateKey, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  } else {
    options = options || {};
  }

  const isObjectPayload = typeof payload === 'object' &&
                        !Buffer.isBuffer(payload);

  const header = Object.assign({
    alg: options.algorithm || 'HS256',
    typ: isObjectPayload ? 'JWT' : undefined,
    kid: options.keyid
  }, options.header);

  function failure(err) {
    if (callback) {
      return callback(err);
    }
    throw err;
  }

  if (!secretOrPrivateKey && options.algorithm !== 'none') {
    return failure(new Error('secretOrPrivateKey must have a value'));
  }

  if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) {
    try {
      secretOrPrivateKey = createPrivateKey(secretOrPrivateKey)
    } catch (_) {
      try {
        secretOrPrivateKey = createSecretKey(typeof secretOrPrivateKey === 'string' ? Buffer.from(secretOrPrivateKey) : secretOrPrivateKey)
      } catch (_) {
        return failure(new Error('secretOrPrivateKey is not valid key material'));
      }
    }
  }

  if (header.alg.startsWith('HS') && secretOrPrivateKey.type !== 'secret') {
    return failure(new Error((`secretOrPrivateKey must be a symmetric key when using ${header.alg}`)))
  } else if (/^(?:RS|PS|ES)/.test(header.alg)) {
    if (secretOrPrivateKey.type !== 'private') {
      return failure(new Error((`secretOrPrivateKey must be an asymmetric key when using ${header.alg}`)))
    }
    if (!options.allowInsecureKeySizes &&
      !header.alg.startsWith('ES') &&
      secretOrPrivateKey.asymmetricKeyDetails !== undefined && //KeyObject.asymmetricKeyDetails is supported in Node 15+
      secretOrPrivateKey.asymmetricKeyDetails.modulusLength < 2048) {
      return failure(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`));
    }
  }

  if (typeof payload === 'undefined') {
    return failure(new Error('payload is required'));
  } else if (isObjectPayload) {
    try {
      validatePayload(payload);
    }
    catch (error) {
      return failure(error);
    }
    if (!options.mutatePayload) {
      payload = Object.assign({},payload);
    }
  } else {
    const invalid_options = options_for_objects.filter(function (opt) {
      return typeof options[opt] !== 'undefined';
    });

    if (invalid_options.length > 0) {
      return failure(new Error('invalid ' + invalid_options.join(',') + ' option for ' + (typeof payload ) + ' payload'));
    }
  }

  if (typeof payload.exp !== 'undefined' && typeof options.expiresIn !== 'undefined') {
    return failure(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));
  }

  if (typeof payload.nbf !== 'undefined' && typeof options.notBefore !== 'undefined') {
    return failure(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));
  }

  try {
    validateOptions(options);
  }
  catch (error) {
    return failure(error);
  }

  if (!options.allowInvalidAsymmetricKeyTypes) {
    try {
      validateAsymmetricKey(header.alg, secretOrPrivateKey);
    } catch (error) {
      return failure(error);
    }
  }

  const timestamp = payload.iat || Math.floor(Date.now() / 1000);

  if (options.noTimestamp) {
    delete payload.iat;
  } else if (isObjectPayload) {
    payload.iat = timestamp;
  }

  if (typeof options.notBefore !== 'undefined') {
    try {
      payload.nbf = timespan(options.notBefore, timestamp);
    }
    catch (err) {
      return failure(err);
    }
    if (typeof payload.nbf === 'undefined') {
      return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
    }
  }

  if (typeof options.expiresIn !== 'undefined' && typeof payload === 'object') {
    try {
      payload.exp = timespan(options.expiresIn, timestamp);
    }
    catch (err) {
      return failure(err);
    }
    if (typeof payload.exp === 'undefined') {
      return failure(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
    }
  }

  Object.keys(options_to_payload).forEach(function (key) {
    const claim = options_to_payload[key];
    if (typeof options[key] !== 'undefined') {
      if (typeof payload[claim] !== 'undefined') {
        return failure(new Error('Bad "options.' + key + '" option. The payload already has an "' + claim + '" property.'));
      }
      payload[claim] = options[key];
    }
  });

  const encoding = options.encoding || 'utf8';

  if (typeof callback === 'function') {
    callback = callback && once(callback);

    jws.createSign({
      header: header,
      privateKey: secretOrPrivateKey,
      payload: payload,
      encoding: encoding
    }).once('error', callback)
      .once('done', function (signature) {
        // TODO: Remove in favor of the modulus length check before signing once node 15+ is the minimum supported version
        if(!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) {
          return callback(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`))
        }
        callback(null, signature);
      });
  } else {
    let signature = jws.sign({header: header, payload: payload, secret: secretOrPrivateKey, encoding: encoding});
    // TODO: Remove in favor of the modulus length check before signing once node 15+ is the minimum supported version
    if(!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) {
      throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`)
    }
    return signature
  }
}

```

[sign.js](https://github.com/auth0/node-jsonwebtoken/blob/b924272f29192e12926b5414546f7c5bfcc9579d/sign.js#L86-L253) · [More projects using node-jws →](https://dashboard.exa.ai/playground/search?q=jws%20GitHub%20projects)

**Quickstart**

```javascript
const fs = require("node:fs");
const jws = require("jws");
const privateKey = fs.readFileSync("private.key");
const signature = jws.sign({
  header: { alg: "RS256" }, payload: "example", privateKey,
});

```

From [readme.md](https://github.com/auth0/node-jws/blob/master/readme.md)

### node-jwa

[GitHub](https://github.com/auth0/node-jwa) · [npm](https://www.npmjs.com/package/jwa)

Implements the JSON Web Algorithms that JWS signing uses.

- Downloads / mo: 481.7M
- Stars: 103
- Last release: 2.0.1
- License: MIT
- Capabilities: [From the node-jwa docs](https://github.com/auth0/node-jwa)

**Strengths**

- **Returns sign and verify methods.** Pick an algorithm such as HS256 to get its sign and verify functions.

**Watch out for**

- **Invalid algorithm names throw.** An unknown or miscased algorithm name throws a TypeError.

```sh
npm install jwa
```

**auth0/node-jws** (721 stars)

[auth0/node-jws](https://github.com/auth0/node-jws) 

```javascript
function jwsSign(opts) {
  var header = opts.header;
  var payload = opts.payload;
  var secretOrKey = opts.secret || opts.privateKey;
  var encoding = opts.encoding;
  var algo = jwa(header.alg);
  var securedInput = jwsSecuredInput(header, payload, encoding);
  var signature = algo.sign(securedInput, secretOrKey);
  return util.format('%s.%s', securedInput, signature);
}

```

[lib/sign-stream.js](https://github.com/auth0/node-jws/blob/44e90947915a238c5bca6bf66d5d7d36edb656a6/lib/sign-stream.js#L25-L34) · [More projects using node-jwa →](https://dashboard.exa.ai/playground/search?q=jwa%20GitHub%20projects)

**Quickstart**

```javascript
const fs = require("node:fs");
const jwa = require("jwa");
const privateKey = fs.readFileSync("ecdsa-p521-private.pem");
const ecdsa = jwa("ES512");
const signature = ecdsa.sign("very important stuff", privateKey);

```

From [README.md](https://github.com/auth0/node-jwa/blob/master/README.md)

### jsonwebtoken

[GitHub](https://github.com/auth0/node-jsonwebtoken) · [npm](https://www.npmjs.com/package/jsonwebtoken)

Signs and verifies JSON Web Tokens with symmetric or asymmetric keys.

- Downloads / mo: 317.9M
- Stars: 18.2K
- Last release: 9.0.3
- License: MIT
- Capabilities: [From the jsonwebtoken docs](https://github.com/auth0/node-jsonwebtoken)

**Strengths**

- **Checks expiration, audience, and issuer.** jwt.verify returns the payload only after the signature and claims pass.
- **Accepts readable expiry times.** Set expiresIn in seconds or as a time-span string.

```sh
npm install jsonwebtoken
```

**umami-software/umami** (40.2K stars)

[umami-software/umami](https://github.com/umami-software/umami) 

```javascript
export function parseToken(token: string, secret: any) {
  try {
    return jwt.verify(token, secret);
  } catch {
    return null;
  }
}

```

[src/lib/jwt.ts](https://github.com/umami-software/umami/blob/a3733b0424727ebe02b97aecf732e3891d677b76/src/lib/jwt.ts#L8-L14) · [More projects using jsonwebtoken →](https://dashboard.exa.ai/playground/search?q=jsonwebtoken%20GitHub%20projects)

**Quickstart**

```javascript
const fs = require('node:fs');
const jwt = require('jsonwebtoken');
const privateKey = fs.readFileSync('private.key');
const token = jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' });

```

From [README.md](https://github.com/auth0/node-jsonwebtoken/blob/master/README.md)

### Forge

[GitHub](https://github.com/digitalbazaar/forge) · [npm](https://www.npmjs.com/package/node-forge)

Provides RSA and Ed25519 key generation and signature operations.

- Downloads / mo: 211.3M
- Stars: 5.4K
- Last release: 1.4.3
- License: (BSD-3-Clause OR GPL-2.0)
- Capabilities: [From the Forge docs](https://github.com/digitalbazaar/forge)

**Strengths**

- **Builds certificate-backed signed messages.** Create PKCS signed data with certificates and authenticated attributes.
- **Imports existing PEM public keys.** Use publicKeyFromPem to load a PEM-encoded RSA public key.

**Watch out for**

- **Signed-data verification is unfinished.** PKCS signed-data verification remains unimplemented; use another verifier for those messages.
- **Synchronous RSA generation blocks execution.** Use asynchronous key generation when the event loop must stay responsive.

```sh
npm install node-forge
```

**vbuch/node-signpdf** (943 stars)

[vbuch/node-signpdf](https://github.com/vbuch/node-signpdf) 

```javascript
async sign(pdfBuffer, signingTime = undefined) {
    if (!(pdfBuffer instanceof Buffer)) {
        throw new SignPdfError(
            'PDF expected as Buffer.',
            SignPdfError.TYPE_INPUT,
        );
    }

    // Convert Buffer P12 to a forge implementation.
    const p12Asn1 = forge.asn1.fromDer(this.cert);
    const p12 = forge.pkcs12.pkcs12FromAsn1(
        p12Asn1,
        this.options.asn1StrictParsing,
        this.options.passphrase,
    );

    // Extract safe bags by type.
    // We will need all the certificates and the private key.
    const certBags = p12.getBags({
        bagType: forge.pki.oids.certBag,
    })[forge.pki.oids.certBag];
    const keyBags = p12.getBags({
        bagType: forge.pki.oids.pkcs8ShroudedKeyBag,
    })[forge.pki.oids.pkcs8ShroudedKeyBag];

    const privateKey = keyBags[0].key;
    // Here comes the actual PKCS#7 signing.
    const p7 = forge.pkcs7.createSignedData();
    // Start off by setting the content.
    p7.content = forge.util.createBuffer(pdfBuffer.toString('binary'));

    // Then add all the certificates (-cacerts & -clcerts)
    // Keep track of the last found client certificate.
    // This will be the public key that will be bundled in the signature.
    let certificate;
    Object.keys(certBags).forEach((i) => {
        const {publicKey} = certBags[i].cert;

        p7.addCertificate(certBags[i].cert);

        // Try to find the certificate that matches the private key.
        if (privateKey.n.compareTo(publicKey.n) === 0
            && privateKey.e.compareTo(publicKey.e) === 0
        ) {
            certificate = certBags[i].cert;
        }
    });

    if (typeof certificate === 'undefined') {
        throw new SignPdfError(
            'Failed to find a certificate that matches the private key.',
            SignPdfError.TYPE_INPUT,
        );
    }

    // Add a sha256 signer. That's what Adobe.PPKLite adbe.pkcs7.detached expects.
    // Note that the authenticatedAttributes order is relevant for correct
    // EU signature validation:
    // https://ec.europa.eu/digital-building-blocks/DSS/webapp-demo/validation
    p7.addSigner({
        key: privateKey,
        certificate,
        digestAlgorithm: forge.pki.oids.sha256,
        authenticatedAttributes: [
            {
                type: forge.pki.oids.contentType,
                value: forge.pki.oids.data,
            }, {
                type: forge.pki.oids.signingTime,
                // value can also be auto-populated at signing time
                value: signingTime ?? new Date(),
            }, {
                type: forge.pki.oids.messageDigest,
                // value will be auto-populated at signing time
            },
        ],
    });

    // Sign in detached mode.
    p7.sign({detached: true});

    return Buffer.from(forge.asn1.toDer(p7.toAsn1()).getBytes(), 'binary');
}

```

[packages/signer-p12/src/P12Signer.js](https://github.com/vbuch/node-signpdf/blob/95fb0fa05d46dda89bb5731d63eb306def4b8365/packages/signer-p12/src/P12Signer.js#L33-L115) · [More projects using Forge →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20node-forge%20for%20digital%20signatures%20with%20signing%20verification%20and%20key%20imports&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
const forge = require("node-forge");
const ed25519 = forge.pki.ed25519;
const keypair = ed25519.generateKeyPair();
const signature = ed25519.sign({
  message: "test", encoding: "utf8", privateKey: keypair.privateKey,
});

```

From [README.md](https://github.com/digitalbazaar/forge/blob/main/README.md)

### TweetNaCl.js

[GitHub](https://github.com/dchest/tweetnacl-js) · [npm](https://www.npmjs.com/package/tweetnacl)

Ports the TweetNaCl cryptography library to JavaScript.

- Downloads / mo: 195.3M
- Stars: 1.9K
- Last release: 1.0.3
- License: Unlicense
- Capabilities: [From the TweetNaCl.js docs](https://github.com/dchest/tweetnacl-js)

**Strengths**

- **Signs with Ed25519.** Generate a key pair with nacl.sign.keyPair and sign byte arrays.
- **Bundles encryption with signing.** The same package covers authenticated encryption, hashing, and random bytes.

```sh
npm install tweetnacl
```

**solana-foundation/solana-web3.js** (2.8K stars)

[solana-foundation/solana-web3.js](https://github.com/solana-foundation/solana-web3.js) 

```javascript
_verifySignatures(signData: Buffer, requireAllSignatures: boolean): boolean {
  for (const {signature, publicKey} of this.signatures) {
    if (signature === null) {
      if (requireAllSignatures) {
        return false;
      }
    } else {
      if (
        !nacl.sign.detached.verify(signData, signature, publicKey.toBuffer())
      ) {
        return false;
      }
    }
  }
  return true;
}

```

[src/transaction/legacy.ts](https://github.com/solana-foundation/solana-web3.js/blob/ef5a6daf1c404b51bdda186274a955276c8b6e90/src/transaction/legacy.ts#L702-L717) · [More projects using TweetNaCl.js →](https://dashboard.exa.ai/playground/search?q=tweetnacl%20GitHub%20projects)

**Quickstart**

```javascript
const nacl = require("tweetnacl");
const keypair = nacl.sign.keyPair();
const message = new Uint8Array([1, 2, 3]);
const signature = nacl.sign.detached(message, keypair.secretKey);

```

From [README.md](https://github.com/dchest/tweetnacl-js/blob/master/README.md)

### @noble/curves

[GitHub](https://github.com/paulmillr/noble-curves) · [npm](https://www.npmjs.com/package/@noble/curves)

Provides ECDSA, EdDSA, Schnorr, and BLS signing primitives.

- Downloads / mo: 188.7M
- Stars: 972
- Last release: 2.4.0
- License: MIT
- Capabilities: [From the @noble/curves docs](https://github.com/paulmillr/noble-curves)

**Strengths**

- **Supports several curve signature schemes.** Use ECDSA, EdDSA, Schnorr, or BLS through the curve modules.
- **Can sign already-hashed messages.** Set prehash=false when passing an existing ECDSA digest.

**Watch out for**

- **Hashes ECDSA messages by default.** Disable prehash when the application already supplies the required digest.
- **DER signatures need explicit configuration.** Specify the DER format when verifying DER-encoded ECDSA signatures.

```sh
npm install @noble/curves
```

**dfinity/icp-js-core** (171 stars)

[dfinity/icp-js-core](https://github.com/dfinity/icp-js-core) 

```javascript
public async sign(challenge: Uint8Array): Promise<Signature> {
  // Some implementations of Ed25519 private keys append a public key to the end of the private key. We only want the private key.
  const signature = ed25519.sign(challenge, this.#privateKey.slice(0, 32));
  // add { __signature__: void; } to the signature to make it compatible with the agent

  Object.defineProperty(signature, '__signature__', {
    enumerable: false,
    value: undefined,
  });

  return signature as Signature;
}

```

[packages/core/src/identity/identity/ed25519.ts](https://github.com/dfinity/icp-js-core/blob/eac56b8c6132a07059ae168dd5b6acb759fd15e8/packages/core/src/identity/identity/ed25519.ts#L211-L222) · [More projects using @noble/curves →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20%40noble/curves%20for%20digital%20signatures%20with%20signing%20verification%20and%20key%20imports&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { ed25519 } from '@noble/curves/ed25519.js';
const { secretKey, publicKey } = ed25519.keygen();
const msg = new TextEncoder().encode('hello noble');
const sig = ed25519.sign(msg, secretKey);

```

From [README.md](https://github.com/paulmillr/noble-curves/blob/main/README.md)

### @peculiar/x509

[GitHub](https://github.com/PeculiarVentures/x509) · [npm](https://www.npmjs.com/package/@peculiar/x509) · [Docs](https://peculiarventures.github.io/x509/)

Generates X.509 certificates and certificate requests and validates certificate chains in TypeScript or JavaScript.

- Downloads / mo: 85.7M
- Stars: 137
- Last release: 3.1.0
- License: MIT
- Capabilities: [From the @peculiar/x509 docs](https://peculiarventures.github.io/x509/)

**Strengths**

- **Creates and verifies certificates.** Issue, parse, and verify certificates, requests, and revocation lists with WebCrypto.

**Watch out for**

- **Needs a Reflect polyfill.** Import reflect-metadata or another Reflect polyfill at the entry point.

```sh
npm install @peculiar/x509 reflect-metadata
```

**jfromaniello/selfsigned** (253 stars)

[jfromaniello/selfsigned](https://github.com/jfromaniello/selfsigned) 

```javascript
function buildExtensions(userExtensions, commonName) {
  if (!userExtensions || userExtensions.length === 0) {
    // Default extensions
    return [
      new BasicConstraintsExtension(false, undefined, true),
      new KeyUsagesExtension(KeyUsageFlags.digitalSignature | KeyUsageFlags.keyEncipherment, true),
      new ExtendedKeyUsageExtension([ExtendedKeyUsage.serverAuth, ExtendedKeyUsage.clientAuth], false),
      new SubjectAlternativeNameExtension([
        { type: 'dns', value: commonName },
        ...(commonName === 'localhost' ? [{ type: 'ip', value: '127.0.0.1' }] : [])
      ], false)
    ];
  }

  // Convert user extensions from node-forge format to @peculiar/x509 format
  const extensions = [];

  for (const ext of userExtensions) {
    const critical = ext.critical || false;

    switch (ext.name) {
      case 'basicConstraints':
        extensions.push(new BasicConstraintsExtension(
          ext.cA || false,
          ext.pathLenConstraint,
          critical
        ));
        break;

      case 'keyUsage':
        let flags = 0;
        if (ext.digitalSignature) flags |= KeyUsageFlags.digitalSignature;
        if (ext.nonRepudiation || ext.contentCommitment) flags |= KeyUsageFlags.nonRepudiation;
        if (ext.keyEncipherment) flags |= KeyUsageFlags.keyEncipherment;
        if (ext.dataEncipherment) flags |= KeyUsageFlags.dataEncipherment;
        if (ext.keyAgreement) flags |= KeyUsageFlags.keyAgreement;
        if (ext.keyCertSign) flags |= KeyUsageFlags.keyCertSign;
        if (ext.cRLSign) flags |= KeyUsageFlags.cRLSign;
        if (ext.encipherOnly) flags |= KeyUsageFlags.encipherOnly;
        if (ext.decipherOnly) flags |= KeyUsageFlags.decipherOnly;
        extensions.push(new KeyUsagesExtension(flags, critical));
        break;

      case 'extKeyUsage':
        const usages = [];
        if (ext.serverAuth) usages.push(ExtendedKeyUsage.serverAuth);
        if (ext.clientAuth) usages.push(ExtendedKeyUsage.clientAuth);
        if (ext.codeSigning) usages.push(ExtendedKeyUsage.codeSigning);
        if (ext.emailProtection) usages.push(ExtendedKeyUsage.emailProtection);
        if (ext.timeStamping) usages.push(ExtendedKeyUsage.timeStamping);
        extensions.push(new ExtendedKeyUsageExtension(usages, critical));
        break;

      case 'subjectAltName':
        const altNames = (ext.altNames || []).map(alt => {
          // node-forge type values:
          // 1 = email (rfc822Name)
          // 2 = DNS
          // 6 = URI
          // 7 = IP
          switch (alt.type) {
            case 1: // email
              return { type: 'email', value: alt.value };
            case 2: // DNS
              return { type: 'dns', value: alt.value };
            case 6: // URI
              return { type: 'url', value: alt.value };
            case 7: // IP
              return { type: 'ip', value: alt.ip || alt.value };
            default:
              // Try to infer type from properties
              if (alt.ip) return { type: 'ip', value: alt.ip };
              if (alt.dns) return { type: 'dns', value: alt.dns };
              if (alt.email) return { type: 'email', value: alt.email };
              if (alt.uri || alt.url) return { type: 'url', value: alt.uri || alt.url };
              return { type: 'dns', value: alt.value };
          }
        });
        extensions.push(new SubjectAlternativeNameExtension(altNames, critical));
        break;

      default:
        // Skip unknown extensions with a warning
        console.warn(`Unknown extension "${ext.name}" ignored`);
    }
  }

  return extensions;
}
```

[index.js](https://github.com/jfromaniello/selfsigned/blob/master/index.js#L73-L161) · [More projects using @peculiar/x509 →](https://dashboard.exa.ai/playground/search?q=%40peculiar/x509%20GitHub%20projects)

**Quickstart**

```javascript
import "reflect-metadata";
import * as x509 from "@peculiar/x509";

const algorithm = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
const keys = await crypto.subtle.generateKey(algorithm, false, ["sign", "verify"]);
const cert = await x509.X509CertificateGenerator.createSelfSigned({
  name: "CN=Example Root CA, O=Example Org, C=US", keys, signingAlgorithm: algorithm,
});

```

From [self-signed.example.ts](https://github.com/PeculiarVentures/x509/blob/master/website/docs/examples/certificates/self-signed.example.ts)

## FAQ

### What is jsonwebtoken?

[jsonwebtoken](#jsonwebtoken) is a Node.js implementation of JSON Web Tokens built on node-jws. Its verify function returns the decoded payload only when the signature and any expiration, audience, or issuer checks are valid.

### What is node-forge?

[Forge](#forge), published on npm as node-forge, is a pure JavaScript toolkit for RSA keys, signatures, signed-data messages, and certificates.

### What is the difference between JWS and JWT?

A JSON Web Signature (JWS) signs any payload, while a JSON Web Token (JWT) is a set of claims that usually travels inside a JWS. [node-jws](#jws) produces the signatures that [jsonwebtoken](#jsonwebtoken) builds its tokens on.

### Should I use jose or jsonwebtoken?

[jose](#jose) covers JWS, JWT, and encrypted JWE messages across Node.js, browsers, and other web runtimes through WebCrypto. [jsonwebtoken](#jsonwebtoken) targets Node.js and signs and verifies JWTs only.

### What is TweetNaCl?

[TweetNaCl.js](#tweetnacl) is a port of the TweetNaCl cryptography library to JavaScript for browsers and Node.js. Its nacl.sign functions create and verify signatures with a public and secret key pair.

### How is a digital signature different from encrypting data?

jose JWS signing creates signed messages, while its JWE support handles encrypted messages. Forge separately exposes signing/verifying and encryption/decryption APIs.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript digital signature libraries jose noble-curves node-forge elliptic code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
