dataintegrity

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// AssertionMethod assertionMethod.
	AssertionMethod = "assertionMethod"

	// Authentication authentication.
	Authentication = "authentication"

	// CapabilityDelegation capabilityDelegation.
	CapabilityDelegation = "capabilityDelegation"

	// CapabilityInvocation capabilityInvocation.
	CapabilityInvocation = "capabilityInvocation"
)

Variables

View Source
var (
	// ErrUnsupportedSuite is returned when a Signer or Verifier is required to use
	// a cryptographic suite for which it doesn't have a suite.Signer or
	// suite.Verifier (respectively) initialized.
	ErrUnsupportedSuite = errors.New("data integrity proof requires unsupported cryptographic suite")
	// ErrNoResolver is returned when a Signer or Verifier needs to resolve a
	// verification method but has no DID resolver.
	ErrNoResolver = errors.New("either did resolver or both verification method and verification relationship must be provided") //nolint:lll
	// ErrVMResolution is returned when a Signer or Verifier needs to resolve a
	// verification method but this fails.
	ErrVMResolution = errors.New("failed to resolve verification method")
)
View Source
var (
	// ErrMissingProof is returned when Verifier.VerifyProof() is given a document
	// without a data integrity proof field.
	ErrMissingProof = errors.New("missing data integrity proof")
	// ErrMalformedProof is returned when Verifier.VerifyProof() is given a document
	// with a proof that isn't a JSON object or is missing necessary standard
	// fields.
	ErrMalformedProof = errors.New("malformed data integrity proof")
	// ErrWrongProofType is returned when Verifier.VerifyProof() is given a document
	// with a proof that isn't a Data Integrity proof.
	ErrWrongProofType = errors.New("proof provided is not a data integrity proof")
	// ErrMismatchedPurpose is returned when Verifier.VerifyProof() is given a
	// document with a proof whose Purpose does not match the expected purpose
	// provided in the proof options.
	ErrMismatchedPurpose = errors.New("data integrity proof does not match expected purpose")
	// ErrOutOfDate is returned when Verifier.VerifyProof() is given a document with
	// a proof that was created more than models.ProofOptions.MaxAge seconds ago.
	ErrOutOfDate = errors.New("data integrity proof out of date")
	// ErrInvalidDomain is returned when Verifier.VerifyProof() is given a document
	// with a proof without the expected domain.
	ErrInvalidDomain = errors.New("data integrity proof has invalid domain")
	// ErrInvalidChallenge is returned when Verifier.VerifyProof() is given a
	// document with a proof without the expected challenge.
	ErrInvalidChallenge = errors.New("data integrity proof has invalid challenge")
)
View Source
var (
	// ErrProofGeneration is returned when Signer.AddProof() fails to generate a
	// proof using a supported cryptographic suite.
	ErrProofGeneration = errors.New("data integrity proof generation error")
)

Functions

This section is empty.

Types

type Options

type Options struct {
	DIDResolver didResolver
}

Options contains initialization parameters for Data Integrity Signer and Verifier.

type Signer

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

Signer implements the Add Proof algorithm of the verifiable credential data integrity specification, using a set of provided cryptographic suites.

func NewSigner

func NewSigner(opts *Options, suites ...suite.SignerInitializer) (*Signer, error)

NewSigner initializes a Signer that supports using the provided cryptographic suites to perform data integrity signing.

func (*Signer) AddProof

func (s *Signer) AddProof(doc []byte, opts *models.ProofOptions) ([]byte, error)

AddProof returns the provided JSON doc, with a top-level "proof" field added, signed using the provided options.

If the provided options request a cryptographic suite that this Signer does not support, AddProof returns ErrUnsupportedSuite.

If signing fails, or the created proof is invalid, AddProof returns ErrProofGeneration.

type Verifier

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

Verifier implements the CheckJWTProof Proof algorithm of the verifiable credential data integrity specification, using a set of provided cryptographic suites.

func NewVerifier

func NewVerifier(opts *Options, suites ...suite.VerifierInitializer) (*Verifier, error)

NewVerifier initializes a Verifier that supports using the provided cryptographic suites to perform data integrity verification.

func (*Verifier) VerifyProof

func (v *Verifier) VerifyProof(doc []byte, opts *models.ProofOptions) error

VerifyProof verifies the data integrity proof on the given JSON document, returning an error if proof verification fails, and nil if verification succeeds.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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