didsignjwt

package
v0.0.0-...-64dd8ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSigningVM

func ResolveSigningVM(kid string, didResolver didResolver) (*did.VerificationMethod, string, error)

ResolveSigningVM resolves a DID KeyID using the given did resolver, and returns either:

  • the Verification Method identified by the given key ID, or
  • the first Assertion Method in the DID doc, if the DID provided has no fragment component.

Returns:

  • a verification method suitable for signing.
  • the full DID#KID identifier of the returned verification method.

func ResolveSigningVMWithRelationship

func ResolveSigningVMWithRelationship(
	kid string,
	didResolver didResolver,
) (*did.VerificationMethod, string, string, error)

ResolveSigningVMWithRelationship resolves a DID KeyID using the given did resolver, and returns either:

  • the Verification Method identified by the given key ID, or
  • the first Assertion Method in the DID doc, if the DID provided has no fragment component.

Returns:

  • a verification method suitable for signing.
  • the full DID#KID identifier of the returned verification method.
  • the name of the signing-supporting verification relationship found for this verification method.

func SignJWT

func SignJWT(
	headers,
	claims map[string]interface{},
	kid string,
	signerProvider SignerGetter,
	didResolver didResolver,
) (string, error)

SignJWT signs a JWT using a key in the given KMS, identified by an owned DID.

Args:
	- Headers to include in the created JWT.
	- Claims for the created JWT.
	- The ID of the key to use for signing, as a DID, either with a fragment identifier to specify a verification
	  method, or without, in which case the first Authentication or Assertion verification method is used.
	- A SignerGetter that can provide a signer when given the key ID for the signing key.
	- A VDR that can resolve the provided DID.

func VerifyJWT

func VerifyJWT(compactJWT string,
	didResolver didResolver) error

VerifyJWT verifies a JWT that was signed with a DID.

Args:

  • JWT to verify.
  • A VDR that can resolve the JWT's signing DID.

Types

type PublicKeyFetcher

type PublicKeyFetcher func(issuerID, keyID string) (*verifier.PublicKey, error)

PublicKeyFetcher fetches public key for JWT signing verification based on Issuer ID (possibly DID) and Key ID. If not defined, JWT encoding is not tested.

type Signer

type Signer interface {
	// Sign provides a signature for msg.
	Sign(msg []byte) ([]byte, error)
}

A Signer is capable of signing data.

type SignerGetter

type SignerGetter func(vm *did.VerificationMethod) (Signer, error)

SignerGetter creates a signer that signs with the private key corresponding to the given public key.

func UseDefaultSigner

func UseDefaultSigner(r keyReader, s cryptoSigner) SignerGetter

UseDefaultSigner provides SignJWT with a signer that uses the given KMS and Crypto instances.

type VDRKeyResolver

type VDRKeyResolver struct {
	// contains filtered or unexported fields
}

VDRKeyResolver resolves DID in order to find public keys for VC verification using vdr.Registry. A source of DID could be issuer of VC or holder of VP. It can be also obtained from JWS "issuer" claim or "verificationMethod" of Linked Data Proof.

func NewVDRKeyResolver

func NewVDRKeyResolver(vdr didResolver) *VDRKeyResolver

NewVDRKeyResolver creates VDRKeyResolver.

func (*VDRKeyResolver) PublicKeyFetcher

func (r *VDRKeyResolver) PublicKeyFetcher() PublicKeyFetcher

PublicKeyFetcher returns Public Key Fetcher via DID resolution mechanism.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL