proof

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EcdsaSecp256k1Signature2019 = ssi.ProofType("EcdsaSecp256k1Signature2019")

EcdsaSecp256k1Signature2019 contains the string value for the EcdsaSecp256k1Signature2019 signature type

View Source
const RsaSignature2018 = ssi.ProofType("RsaSignature2018")

RsaSignature2018 contains the string value for the RsaSignature2018 signature type

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document map[string]interface{}

Document represents the document to sign. It does not contain proofs or signatures

type LDProof

type LDProof struct {
	ProofOptions
	Nonce *string `json:"nonce,omitempty"`
	// Type contains the signature type. Its is determined from the key type.
	Type ssi.ProofType `json:"type"`
	// VerificationMethod is the key identifier for the public/private key pair used to sign this proof
	// should be resolvable, e.g. did:nuts:123#key-1
	VerificationMethod ssi.URI `json:"verificationMethod"`
	// proofValue holds the representation of the proof value.
	// This can be several keys, dependent on the suite like jws, proofValue or signatureValue
	//proofValue map[string]interface{}
	JWS        string      `json:"jws,omitempty"`
	ProofValue interface{} `json:"proofValue,omitempty"`
	Signature  interface{} `json:"signature,omitempty"`
}

LDProof contains the fields of the Proof data model: https://w3c-ccg.github.io/data-integrity-spec/#proofs

func NewLDProof

func NewLDProof(options ProofOptions) *LDProof

NewLDProof creates a new LDProof from the ProofOptions param

func (*LDProof) Sign

func (p *LDProof) Sign(document Document, suite signature.Suite, key nutsCrypto.Key) (interface{}, error)

Sign signs the provided document with this proof and a signature suit and signer. It returns the complete signed JSON-LD document

func (LDProof) Verify

func (p LDProof) Verify(document Document, suite signature.Suite, key crypto.PublicKey) error

Verify verifies the correctness of the signature value in the LDProof given a document, signature suite and a public key. Note that the document must not contain a proof

type LegacyLDProof

type LegacyLDProof struct {
	vc.JSONWebSignature2020Proof
}

LegacyLDProof is a simple/wrong implementation of the ldProof specification. It uses a simple canonicalization algorithm and base64 encodes the payload before signing. It is here for backwards compatibility.

func NewLegacyLDProof

func NewLegacyLDProof(options ProofOptions) *LegacyLDProof

NewLegacyLDProof creates a new LegacyLDProof from proofOptions

func (LegacyLDProof) Sign

func (p LegacyLDProof) Sign(document Document, suite signature.Suite, key nutsCrypto.Key) (interface{}, error)

Sign signs a provided document with the provided key. Deprecated: this method is the initial and wrong implementation of a JSON-LD proof. There will be a new method added in the near future.

func (LegacyLDProof) Verify

func (p LegacyLDProof) Verify(document Document, suite signature.Suite, key crypto2.PublicKey) error

Verify verifies the legacy proof for correctness Note that the document must not contain a proof

type Proof

type Proof interface {
	// Sign defines the basic signing operation on the proof.
	Sign(document Document, suite signature.Suite, key nutsCrypto.Key) (interface{}, error)
}

Proof is the interface that defines a set of methods which a proof should implement.

type ProofOptions

type ProofOptions struct {
	// Created contains the date and time of signing. When not set, the current date time will be used.
	Created time.Time `json:"created"`
	// Domain property is used to associate a domain with a proof
	// https://w3c-ccg.github.io/security-vocab/#domain
	Domain *string `json:"domain,omitempty"`
	//The challenge property is used to associate a challenge with a proof
	// https://w3c-ccg.github.io/security-vocab/#challenge
	Challenge *string `json:"challenge,omitempty"`
	// The Expires property is used to associate an expiration date with a proof
	Expires *time.Time `json:"expires,omitempty"`
	// ProofPurpose contains a specific intent for the proof, the reason why an entity created it.
	// Acts as a safeguard to prevent the proof from being misused for a purpose other than the one it was intended for.
	ProofPurpose string `json:"proofPurpose"`
}

ProofOptions contains the options for a specific proof. When set they wil

type ProofVerifier

type ProofVerifier interface {
	// Verify verifies the Document with the provided public key. If the document is valid, it returns no error.
	Verify(document Document, suite signature.Suite, key crypto.PublicKey) error
}

ProofVerifier defines the generic verifier interface

type SignedDocument

type SignedDocument map[string]interface{}

SignedDocument represents a generic signed document with a proof It bundles helper functions to easily work with proofs.

func NewSignedDocument

func NewSignedDocument(source interface{}) (SignedDocument, error)

NewSignedDocument creates a new SignedDocument from a source struct

func (SignedDocument) DocumentWithoutProof

func (d SignedDocument) DocumentWithoutProof() Document

DocumentWithoutProof returns the Document without the proof.

func (SignedDocument) UnmarshalProofValue

func (d SignedDocument) UnmarshalProofValue(target interface{}) error

UnmarshalProofValue unmarshalls the signature of the document in the provided target

Jump to

Keyboard shortcuts

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