presentproof

package
v0.0.0-...-57c6170 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Name defines the protocol name.
	Name = "present-proof"
	// SpecV2 defines the protocol spec.
	SpecV2 = "https://didcomm.org/present-proof/2.0/"
	// ProposePresentationMsgTypeV2 defines the protocol propose-presentation message type.
	ProposePresentationMsgTypeV2 = SpecV2 + "propose-presentation"
	// RequestPresentationMsgTypeV2 defines the protocol request-presentation message type.
	RequestPresentationMsgTypeV2 = SpecV2 + "request-presentation"
	// PresentationMsgTypeV2 defines the protocol presentation message type.
	PresentationMsgTypeV2 = SpecV2 + "presentation"
	// AckMsgTypeV2 defines the protocol ack message type.
	AckMsgTypeV2 = SpecV2 + "ack"
	// ProblemReportMsgTypeV2 defines the protocol problem-report message type.
	ProblemReportMsgTypeV2 = SpecV2 + "problem-report"
	// PresentationPreviewMsgTypeV2 defines the protocol presentation-preview inner object type.
	PresentationPreviewMsgTypeV2 = SpecV2 + "presentation-preview"

	// SpecV3 defines the protocol spec.
	SpecV3 = "https://didcomm.org/present-proof/3.0/"
	// ProposePresentationMsgTypeV3 defines the protocol propose-presentation message type.
	ProposePresentationMsgTypeV3 = SpecV3 + "propose-presentation"
	// RequestPresentationMsgTypeV3 defines the protocol request-presentation message type.
	RequestPresentationMsgTypeV3 = SpecV3 + "request-presentation"
	// PresentationMsgTypeV3 defines the protocol presentation message type.
	PresentationMsgTypeV3 = SpecV3 + "presentation"
	// AckMsgTypeV3 defines the protocol ack message type.
	AckMsgTypeV3 = SpecV3 + "ack"
	// ProblemReportMsgTypeV3 defines the protocol problem-report message type.
	ProblemReportMsgTypeV3 = SpecV3 + "problem-report"
	// PresentationPreviewMsgTypeV3 defines the protocol presentation-preview inner object type.
	PresentationPreviewMsgTypeV3 = SpecV3 + "presentation-preview"
)
View Source
const (

	// StateNameAbandoned is present proof protocol state 'abandoned'.
	StateNameAbandoned = "abandoned"
	// StateNameDone is present proof protocol state 'done'.
	StateNameDone = "done"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Protocol instance ID
	PIID     string
	Msg      service.DIDCommMsgMap
	MyDID    string
	TheirDID string
}

Action contains helpful information about action.

type Format

type Format struct {
	AttachID string `json:"attach_id,omitempty"`
	Format   string `json:"format,omitempty"`
}

Format contains the value of the attachment @id and the verifiable credential format of the attachment.

type Handler

type Handler interface {
	Handle(metadata Metadata) error
}

Handler describes middleware interface.

type HandlerFunc

type HandlerFunc func(metadata Metadata) error

HandlerFunc is a helper type which implements the middleware Handler interface.

func (HandlerFunc) Handle

func (hf HandlerFunc) Handle(metadata Metadata) error

Handle implements function to satisfy the Handler interface.

type Metadata

type Metadata interface {
	// Message contains the original inbound/outbound message
	Message() service.DIDCommMsg
	// Presentation is pointer to the message provided by the user through the Continue function.
	Presentation() *PresentationV2
	// ProposePresentation is pointer to the message provided by the user through the Continue function.
	ProposePresentation() *ProposePresentationV2
	// RequestPresentation is pointer to the message provided by the user through the Continue function.
	RequestPresentation() *RequestPresentationV2
	// PresentationV3 is pointer to the message provided by the user through the Continue function.
	PresentationV3() *PresentationV3
	// ProposePresentationV3 is pointer to the message provided by the user through the Continue function.
	ProposePresentationV3() *ProposePresentationV3
	// RequestPresentationV3 is pointer to the message provided by the user through the Continue function.
	RequestPresentationV3() *RequestPresentationV3
	// PresentationNames is a slice which contains presentation names provided by the user through the Continue function.
	PresentationNames() []string
	// StateName provides the state name
	StateName() string
	// Properties provides the possibility to set properties
	Properties() map[string]interface{}
	// GetAddProofFn provides function to sign the Presentation.
	GetAddProofFn() func(presentation *verifiable.Presentation) error
}

Metadata provides helpful information for the processing.

type Middleware

type Middleware func(next Handler) Handler

Middleware function receives next handler and returns handler that needs to be executed.

type Opt

type Opt func(md *metaData)

Opt describes option signature for the Continue function.

func WithAddProofFn

func WithAddProofFn(addProof func(presentation *verifiable.Presentation) error) Opt

WithAddProofFn allows providing function that will sign the Presentation. USAGE: This fn can be provided after receiving a Invitation message.

func WithFriendlyNames

func WithFriendlyNames(names ...string) Opt

WithFriendlyNames allows providing names for the presentations.

func WithMultiOptions

func WithMultiOptions(opts ...Opt) Opt

WithMultiOptions allows combining several options into one.

func WithPresentation

func WithPresentation(pp *PresentationParams) Opt

WithPresentation allows providing Presentation message USAGE: This message can be provided after receiving an Invitation message.

func WithProperties

func WithProperties(props map[string]interface{}) Opt

WithProperties allows providing custom properties.

func WithProposePresentation

func WithProposePresentation(pp *ProposePresentationParams) Opt

WithProposePresentation allows providing ProposePresentation message USAGE: This message can be provided after receiving an Invitation message.

func WithRequestPresentation

func WithRequestPresentation(msg *RequestPresentationParams) Opt

WithRequestPresentation allows providing RequestPresentation message USAGE: This message can be provided after receiving a propose message.

type PresentationParams

type PresentationParams struct {
	// Comment is a field that provides some human readable information about the provided presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300].
	Comment string
	// Formats contains an entry for each presentations~attach array entry, providing the the value of the attachment
	// @id and the verifiable presentation format and version of the attachment.
	Formats []Format
	// Attachments is an array of attachments containing verifiable presentations.
	Attachments []decorator.GenericAttachment
	// GoalCode is an optional goal code to indicate the intended use of the provided presentation(s).
	GoalCode string
}

PresentationParams holds the parameters for providing a presentation.

func (*PresentationParams) AsV2

AsV2 translates this presentation message into a present-proof 2.0 presentation message.

func (*PresentationParams) AsV3

AsV3 translates this presentation message into a present-proof 3.0 presentation message.

func (*PresentationParams) FromDIDCommMsgMap

func (p *PresentationParams) FromDIDCommMsgMap(msgMap service.DIDCommMsgMap) error

FromDIDCommMsgMap implements service.MsgMapDecoder.

func (*PresentationParams) FromV2

func (p *PresentationParams) FromV2(v2 *PresentationV2)

FromV2 initializes this presentation message from a present-proof 2.0 presentation message.

func (*PresentationParams) FromV3

func (p *PresentationParams) FromV3(v3 *PresentationV3)

FromV3 initializes this presentation message from a present-proof 3.0 presentation message.

func (*PresentationParams) UnmarshalJSON

func (p *PresentationParams) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type PresentationV2

type PresentationV2 struct {
	ID   string `json:"@id,omitempty"`
	Type string `json:"@type,omitempty"`
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300].
	Comment string `json:"comment,omitempty"`
	// Formats contains an entry for each presentations~attach array entry, providing the the value of the attachment
	// @id and the verifiable presentation format and version of the attachment.
	Formats []Format `json:"formats,omitempty"`
	// PresentationsAttach an array of attachments containing the presentation in the requested format(s).
	PresentationsAttach []decorator.Attachment `json:"presentations~attach,omitempty"`
}

PresentationV2 is a response to a RequestPresentationV2 message and contains signed presentations. TODO: Add ~please_ack decorator support for the protocol [Issue #2047].

type PresentationV3

type PresentationV3 struct {
	Type string             `json:"type,omitempty"`
	Body PresentationV3Body `json:"body,omitempty"`
	// Attachments is an array of attachments that further define the presentation request being proposed.
	// This might be used to clarify which formats or format versions are wanted.
	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
}

PresentationV3 is a response to a RequestPresentationV3 message and contains signed presentations.

type PresentationV3Body

type PresentationV3Body struct {
	GoalCode string `json:"goal_code,omitempty"`
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string `json:"comment,omitempty"`
}

PresentationV3Body represents body for PresentationV3.

type ProposePresentationParams

type ProposePresentationParams struct {
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string
	// Formats contains an entry for each proposal~attach array entry, including an optional value of the
	// attachment @id (if attachments are present) and the verifiable presentation format and version of the attachment.
	Formats  []Format
	GoalCode string
	// Attachments is an array of attachments that further define the presentation request being proposed.
	// This might be used to clarify which formats or format versions are wanted.
	Attachments []decorator.GenericAttachment
}

ProposePresentationParams holds the parameters for proposing a presentation.

func (*ProposePresentationParams) AsV2

AsV2 translates this presentation proposal into a present-proof 2.0 proposal message.

func (*ProposePresentationParams) AsV3

AsV3 translates this presentation proposal into a present-proof 3.0 proposal message.

func (*ProposePresentationParams) FromDIDCommMsgMap

func (p *ProposePresentationParams) FromDIDCommMsgMap(msgMap service.DIDCommMsgMap) error

FromDIDCommMsgMap implements service.MsgMapDecoder.

func (*ProposePresentationParams) FromV2

FromV2 initializes this presentation proposal from a present-proof 2.0 proposal message.

func (*ProposePresentationParams) FromV3

FromV3 initializes this presentation proposal from a present-proof 3.0 proposal message.

func (*ProposePresentationParams) UnmarshalJSON

func (p *ProposePresentationParams) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ProposePresentationV2

type ProposePresentationV2 struct {
	ID   string `json:"@id,omitempty"`
	Type string `json:"@type,omitempty"`
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string `json:"comment,omitempty"`
	// Formats contains an entry for each proposal~attach array entry, including an optional value of the
	// attachment @id (if attachments are present) and the verifiable presentation format and version of the attachment.
	Formats []Format `json:"formats,omitempty"`
	// ProposalsAttach is an array of attachments that further define the presentation request being proposed.
	// This might be used to clarify which formats or format versions are wanted.
	ProposalsAttach []decorator.Attachment `json:"proposals~attach,omitempty"`
}

ProposePresentationV2 is an optional message sent by the prover to the verifier to initiate a proof presentation process, or in response to a request-presentation message when the prover wants to propose using a different presentation format or request.

type ProposePresentationV3

type ProposePresentationV3 struct {
	ID   string                    `json:"id,omitempty"`
	Type string                    `json:"type,omitempty"`
	Body ProposePresentationV3Body `json:"body,omitempty"`
	// Attachments is an array of attachments that further define the presentation request being proposed.
	// This might be used to clarify which formats or format versions are wanted.
	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
}

ProposePresentationV3 is an optional message sent by the prover to the verifier to initiate a proof presentation process, or in response to a request-presentation message when the prover wants to propose using a different presentation format or request.

type ProposePresentationV3Body

type ProposePresentationV3Body struct {
	GoalCode string `json:"goal_code,omitempty"`
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string `json:"comment,omitempty"`
}

ProposePresentationV3Body represents body for ProposePresentationV3.

type Provider

type Provider interface {
	Messenger() service.Messenger
	StorageProvider() storage.Provider
}

Provider contains dependencies for the protocol and is typically created by using aries.Context().

type RequestPresentationParams

type RequestPresentationParams struct {
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string
	// WillConfirm is a field that defaults to "false" to indicate that the verifier will or will not
	// send a post-presentation confirmation ack message.
	WillConfirm bool
	// Formats contains an entry for each request_presentations~attach array entry, providing the the value of the
	// attachment @id and the verifiable presentation request format and version of the attachment.
	Formats []Format
	// Attachments is an array of attachments containing the acceptable verifiable presentation requests.
	Attachments []decorator.GenericAttachment
	// GoalCode is an optional goal code to indicate the desired use of the requested presentation.
	GoalCode string
}

RequestPresentationParams holds the parameters for requesting a presentation.

func (*RequestPresentationParams) AsV2

AsV2 translates this presentation request into a present-proof 2.0 request message.

func (*RequestPresentationParams) AsV3

AsV3 translates this presentation request into a present-proof 3.0 request message.

func (*RequestPresentationParams) FromDIDCommMsgMap

func (p *RequestPresentationParams) FromDIDCommMsgMap(msgMap service.DIDCommMsgMap) error

FromDIDCommMsgMap implements service.MsgMapDecoder.

func (*RequestPresentationParams) FromV2

FromV2 initializes this presentation request from a present-proof 2.0 request message.

func (*RequestPresentationParams) FromV3

FromV3 initializes this presentation request from a present-proof 3.0 request message.

func (*RequestPresentationParams) UnmarshalJSON

func (p *RequestPresentationParams) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type RequestPresentationV2

type RequestPresentationV2 struct {
	ID   string `json:"@id,omitempty"`
	Type string `json:"@type,omitempty"`
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string `json:"comment,omitempty"`
	// WillConfirm is a field that defaults to "false" to indicate that the verifier will or will not
	// send a post-presentation confirmation ack message.
	WillConfirm bool `json:"will_confirm,omitempty"`
	// Formats contains an entry for each request_presentations~attach array entry, providing the the value of the
	// attachment @id and the verifiable presentation request format and version of the attachment.
	Formats []Format `json:"formats,omitempty"`
	// RequestPresentationsAttach is an array of attachments containing the acceptable verifiable presentation requests.
	RequestPresentationsAttach []decorator.Attachment `json:"request_presentations~attach,omitempty"`
}

RequestPresentationV2 describes values that need to be revealed and predicates that need to be fulfilled.

type RequestPresentationV3

type RequestPresentationV3 struct {
	ID   string                    `json:"id,omitempty"`
	Type string                    `json:"type,omitempty"`
	Body RequestPresentationV3Body `json:"body,omitempty"`
	// Attachments is an array of attachments containing the acceptable verifiable presentation requests.
	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
}

RequestPresentationV3 describes values that need to be revealed and predicates that need to be fulfilled.

type RequestPresentationV3Body

type RequestPresentationV3Body struct {
	GoalCode string `json:"goal_code,omitempty"`
	// Comment is a field that provides some human readable information about the proposed presentation.
	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
	Comment string `json:"comment,omitempty"`
	// WillConfirm is a field that defaults to "false" to indicate that the verifier will or will not
	// send a post-presentation confirmation ack message.
	WillConfirm bool `json:"will_confirm,omitempty"`
}

RequestPresentationV3Body represents body for RequestPresentationV3.

type Service

type Service struct {
	service.Action
	service.Message
	// contains filtered or unexported fields
}

Service for the presentproof protocol.

func New

func New(p Provider) (*Service, error)

New returns the presentproof service.

func (*Service) Accept

func (s *Service) Accept(msgType string) bool

Accept msg checks the msg type.

func (*Service) ActionContinue

func (s *Service) ActionContinue(piID string, opts ...Opt) error

ActionContinue allows proceeding with the action by the piID.

func (*Service) ActionStop

func (s *Service) ActionStop(piID string, cErr error, opts ...Opt) error

ActionStop allows stopping the action by the piID.

func (*Service) Actions

func (s *Service) Actions() ([]Action, error)

Actions returns actions for the async usage.

func (*Service) HandleInbound

func (s *Service) HandleInbound(msg service.DIDCommMsg, ctx service.DIDCommContext) (string, error)

HandleInbound handles inbound message (presentproof protocol).

func (*Service) HandleOutbound

func (s *Service) HandleOutbound(msg service.DIDCommMsg, myDID, theirDID string) (string, error)

HandleOutbound handles outbound message (presentproof protocol).

func (*Service) Initialize

func (s *Service) Initialize(prov interface{}) error

Initialize initializes the Service. If Initialize succeeds, any further call is a no-op.

func (*Service) Name

func (s *Service) Name() string

Name returns service name.

func (*Service) Use

func (s *Service) Use(items ...Middleware)

Use allows providing middlewares.

Jump to

Keyboard shortcuts

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