<>ts-stack
Get StartedArchitecturePackagesSpecsGuides
⌘K
Reference
Home
Get StartedOverviewInstallChoose your stackKey concepts
ArchitectureOverviewStack layersBEEF (BRC-62)BRC-100 Wallet InterfaceIdentity & AuthConformance pipeline
PackagesOverviewSDKWalletNetworkOverlaysMessagingMiddlewareHelpers
@bsv/simple@bsv/templates@bsv/did@bsv/did-client@bsv/wallet-helper@bsv/amountinator@bsv/air-gap@bsv/fund-wallet
InfrastructureOverviewmessage-box-serveroverlay-serveruhrp-server-basicuhrp-server-cloud-bucketwabwallet-infrachaintracks-server
SpecsOverviewBRC-100 Wallet InterfaceOverlay HTTPMessage-box HTTPAuthsocket (WebSocket)BRC-31 Auth HandshakeBRC-29 Peer PaymentBRC-121 / HTTP 402ARC BroadcastMerkle ServiceStorage AdapterGASP SyncUHRPAir-Gap Optical (BRC-141)
ConformanceOverviewVector catalogTS runnerContributing vectors
GuidesOverviewBuild a wallet-aware appRun an overlay nodePeer-to-peer messagingHTTP 402 payments
ReferenceOverviewBRC indexRepository health
AboutVersioningContributingDoc agentDocumentation sources
npmhttps://www.npmjs.com/package/@bsv/didv0.2.4betaAPI reference (TypeDoc) ↗
Loading…
Edit this page on GitHub
© 2026 BSV Blockchain. ts-stack is open-source.
GitHubContributingVersioning

@bsv/did

SD-JWT VC and optional did:key helpers for BSV SDK identity keys.

Install

bash
npm install @bsv/did

Quick start

typescript
import { PrivateKey } from '@bsv/sdk'
import { BsvDid, SdJwtVcIssuer, SdJwtVcHolder, SdJwtVcPresenter, SdJwtVcVerifier } from '@bsv/did'

const issuerPrivateKey = PrivateKey.fromRandom()
const holderPrivateKey = PrivateKey.fromRandom()
const issuer = BsvDid.fromPublicKey(issuerPrivateKey.toPublicKey().toDER() as number[])

const vc = await SdJwtVcIssuer.create({
  issuer,
  issuerPrivateKey,
  holderPublicKey: holderPrivateKey.toPublicKey(),
  vct: 'https://credentials.example.com/identity_credential',
  claims: {
    given_name: 'Alice',
    email: 'alice@example.com',
    is_over_21: true
  },
  disclosureFrame: {
    given_name: true,
    email: true,
    is_over_21: true
  }
})

const presentation = await SdJwtVcHolder.generatePresentation(vc, ['is_over_21'], {
  holderPrivateKey,
  audience: 'https://verifier.example',
  nonce: 'nonce-123'
})

const result = await SdJwtVcVerifier.verify(SdJwtVcPresenter.present(presentation), {
  expectedAudience: 'https://verifier.example',
  expectedNonce: 'nonce-123',
  requireKeyBinding: true
})

What it provides

  • BsvDid — Generate secp256k1 did:key identifiers, DID Documents, and QR codes
  • SdJwtVcIssuer — Issue SD-JWT VCs with salted Disclosures and holder cnf.jwk
  • SdJwtVcHolder — Store credentials and generate selective presentations
  • SdJwtVcPresenter — Serialize presentation payloads for transport or QR display
  • SdJwtVcVerifier — Verify issuer signatures, Disclosures, and KB-JWT holder binding

Algorithm note

BSV identity keys are secp256k1. JOSE identifies secp256k1 ECDSA as ES256K; ES256 is P-256. This package uses ES256K for BSV identity-key compatibility.

Some eIDAS/EUDI profiles might require P-256 ES256. Those profiles need a P-256 key mode in addition to BSV identity-key mode.

Standards

  • RFC 9901: Selective Disclosure for JSON Web Tokens
  • SD-JWT-based Verifiable Credentials, draft-ietf-oauth-sd-jwt-vc-16
  • DID Core v1.0
  • did:key Method v0.9

Related packages

  • @bsv/sdk — Core keys, signatures, and wallet interfaces
  • @bsv/simple — Higher-level wallet-aware app helpers