event

package
v0.0.0-...-a65a15d Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultVersionString

func DefaultVersionString(in FORMAT) string

DefaultVersionString returns a weGetDigestll formated version string for the provided format, with 0s for size

func Digest

func Digest(data []byte, code derivation.Code) ([]byte, error)

Digest returns the raw derived data of code for provided data

func DigestString

func DigestString(data []byte, code derivation.Code) (string, error)

DigestString returns a prefix for the provided data

func MarshalReceipt

func MarshalReceipt(rct *Event, sig derivation.Derivation) ([]byte, error)

func NextDigest

func NextDigest(threshold string, code derivation.Code, keys ...prefix.Prefix) (string, error)

func Serialize

func Serialize(e *Event, to FORMAT) ([]byte, error)

Serialize the provided event to the format specifeid

func VersionString

func VersionString(in FORMAT, keriVer string, size int) string

VersionString returns a well formated version string populated with the provide KERI version and message size

Types

type Attachment

type Attachment struct {
	Code                    derivation.CountCode
	Signatures              []derivation.Derivation
	TransferableReceipts    []*Quadlet
	NonTransferableReceipts []*Couplet
	WitnessReceipts         []*Couplet
}

func ParseAttached

func ParseAttached(c derivation.CountCode, buf io.Reader) (*Attachment, error)

func ParseAttachment

func ParseAttachment(rd io.Reader) (*Attachment, error)

type AttachmentParser

type AttachmentParser func(buf io.Reader) ([]derivation.Derivation, error)

type Couplet

type Couplet struct {
	Prefix    *derivation.Derivation
	Signature *derivation.Derivation
}

func ParseAttachedCouplet

func ParseAttachedCouplet(r io.Reader) (*Couplet, error)

func ParseAttachedCouplets

func ParseAttachedCouplets(buf io.Reader) ([]*Couplet, error)

type Event

type Event struct {
	Version           string         `json:"v"`
	Prefix            string         `json:"i,omitempty"`
	Sequence          string         `json:"s,omitempty"`
	EventType         string         `json:"t"`
	EventDigest       string         `json:"d,omitempty"`
	PriorEventDigest  string         `json:"p,omitempty"`
	SigThreshold      *SigThreshold  `json:"kt,omitempty"`
	Keys              []string       `json:"k,omitempty"`
	Next              string         `json:"n,omitempty"`
	WitnessThreshold  string         `json:"wt,omitempty"`
	Witnesses         []string       `json:"w,omitempty"`
	AddWitness        []string       `json:"wa,omitempty"`
	RemoveWitness     []string       `json:"wr,omitempty"`
	Config            []prefix.Trait `json:"c,omitempty" cbor:",omitempty"`
	Seals             SealArray      `json:"a,omitempty"`
	DelegatorSeal     *Seal          `json:"da,omitempty"`
	LastEvent         *Seal          `json:"e,omitempty"`
	LastEstablishment *Seal          `json:"ee,omitempty"`
	// contains filtered or unexported fields
}

func Deserialize

func Deserialize(data []byte, from FORMAT) (*Event, error)

func NewEvent

func NewEvent(opts ...EventOption) (*Event, error)

NewEvent returns a new event with the specified options applied

func NewInceptionEvent

func NewInceptionEvent(opts ...EventOption) (*Event, error)

NewInceptionEvent returns and incpetion configured with the provided parameters New Inception Events will have empty 'v' and 'i' strings

func NewInteractionEvent

func NewInteractionEvent(opts ...EventOption) (*Event, error)

NewRotationEvent returns and incpetion configured with the provided parameters New Rotation Events will have empty 'v' and 'i' strings

func NewRotationEvent

func NewRotationEvent(opts ...EventOption) (*Event, error)

NewRotationEvent returns and incpetion configured with the provided parameters New Rotation Events will have empty 'v' and 'i' strings

func UnmarshalReceipt

func UnmarshalReceipt(d []byte) (*Event, derivation.Derivation, error)

func (*Event) GetDigest

func (e *Event) GetDigest() (string, error)

func (*Event) ILK

func (e *Event) ILK() ILK

ILK returns the ILK iota value for the event

func (*Event) IsEstablishment

func (e *Event) IsEstablishment() bool

func (*Event) KeyDerivation

func (e *Event) KeyDerivation(index int) (*derivation.Derivation, error)

KeyDerivation returns a dervation for the key prefix at the provided index

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

MarshalJSON interface implementation. not all events requrie all fields, and some event types requrie empty arrays in place of null values. This allows us to correctly marhsal the Event data to JSON

func (*Event) NextDigest

func (e *Event) NextDigest(code derivation.Code) (string, error)

NextDigest returns the calculated next digest for the event

func (*Event) SequenceInt

func (e *Event) SequenceInt() int

SequenceInt returns an integer representation of the hex sequence string

func (*Event) Serialize

func (e *Event) Serialize() ([]byte, error)

Serialize returns a byte array of the current event serialized according to its Version

func (*Event) WitnessDerivation

func (e *Event) WitnessDerivation(index int) (*derivation.Derivation, error)

WitnessDerivation returns a dervation for the key prefix at the provided index

type EventOption

type EventOption func(*Event) error

func WithDefaultVersion

func WithDefaultVersion(in FORMAT) EventOption

func WithDigest

func WithDigest(digest string) EventOption

WithDigest sets the digest for the event

func WithKeys

func WithKeys(keys ...prefix.Prefix) EventOption

WithKeys sets the keys that are applicable for the event

func WithMultiWeightedThesholds

func WithMultiWeightedThesholds(thresholds ...[]string) EventOption

WithMultiWeightedThesholds sets multiple weighted signing thresholds using provided string values.

func WithNext

func WithNext(threshold string, code derivation.Code, keys ...prefix.Prefix) EventOption

WithNext keys must be self adressing prefixs. Do not use a basic prefix otherwise the public key data will be exposed in the log breaking post-quantum security. To support multi-sig, next is a prefix of the commitment to a signing threshold along with all of the keys to be rotated to, combined using XOR. Each of the provided keys, along with the derivation to use for the next, must use the same derivaiton code.

func WithPrefix

func WithPrefix(prefix string) EventOption

func WithSeals

func WithSeals(seals SealArray) EventOption

func WithSequence

func WithSequence(sequence int) EventOption

/ WithSequence sets the sequence number for this event

func WithThreshold

func WithThreshold(threshold int64) EventOption

WithThreshold sets the key threshold

func WithType

func WithType(eventType ILK) EventOption

WithType specifies the event type

func WithWeightedTheshold

func WithWeightedTheshold(conditions ...string) EventOption

WithWeightedTheshold sets a weighted signing threshold using provided string int or fraction values. The total for all conditions must be >= 1 otherwise the threshold can not be met. The order in which the conditions are provided is important: they map to the specific key index in the keys list, e.g, the second condition provided to this configuration function would be the weight of a signature by the second key in the keys list.

func WithWitnessThreshold

func WithWitnessThreshold(threshold int) EventOption

WithWitnessThreshold sets the witness duplicity threshold for the event

func WithWitnesses

func WithWitnesses(keys ...prefix.Prefix) EventOption

WithWitnesses sets the witness keys for the event

type FORMAT

type FORMAT int
const (
	JSON FORMAT = iota
	CBOR
	MSGPK
	EDS
)

EDS stands for Extracted Data Set format that is used to create cryptographic digests

and signatures for Events but does not have to be deserialized therefore does not
have to preserve symantic structure.

func Format

func Format(f string) (FORMAT, error)

func FormatFromVersion

func FormatFromVersion(vs string) (FORMAT, error)

FormatFromVersion returns the message format parsed from the given version string

type ILK

type ILK int
const (
	ICP ILK = iota
	ROT
	IXN
	DIP
	RCT
	VRC
	DRT
	KST
)

func (ILK) Establishment

func (i ILK) Establishment() bool

Establishment returns true if the ILK is an establishment event type

func (ILK) String

func (i ILK) String() string

type Message

type Message struct {
	Event                   *Event
	Signatures              []derivation.Derivation
	TransferableReceipts    []*Receipt
	NonTransferableReceipts []*Receipt
	WitnessReceipts         []*Receipt
}

an event message holds the deserialized event along with the provided signature

func NewMessage

func NewMessage(evt *Event, opts ...MessageOption) (*Message, error)

type MessageOption

type MessageOption func(*Message) error

func WithNonTransferableReceipts

func WithNonTransferableReceipts(couples []*Couplet) MessageOption

func WithSignatures

func WithSignatures(sigs []derivation.Derivation) MessageOption

func WithTransferableReceipts

func WithTransferableReceipts(quads []*Quadlet) MessageOption

func WithWitnessReceipts

func WithWitnessReceipts(couples []*Couplet) MessageOption

type Quadlet

type Quadlet struct {
	Prefix    *derivation.Derivation
	Signature *derivation.Derivation
	Digest    *derivation.Derivation
	Sequence  int
}

func ParseAttachedQuadlet

func ParseAttachedQuadlet(r io.Reader) (*Quadlet, error)

func ParseAttachedQuadlets

func ParseAttachedQuadlets(buf io.Reader) ([]*Quadlet, error)

type Receipt

type Receipt struct {
	Prefix   string
	Digest   string
	Sequence int

	RctType   ILK
	Signature *derivation.Derivation //The Signature of the receipted event

	EstPrefix   string // The Witness Identifier Prefix for Receipt Signatures (Transferable and Non-Transferable)
	EstSequence int    // The sn of Latest Establishment Event for Transferable Receipt signatures
	EstDigest   string // The dig of Latest Establishment Event for Transferable Receipt signatures
	// contains filtered or unexported fields
}

func NewReceipt

func NewReceipt(evt *Event, opts ...ReceiptOpt) (*Receipt, error)

func (*Receipt) Bin

func (r *Receipt) Bin() []byte

func (*Receipt) Message

func (r *Receipt) Message() (*Message, error)

func (*Receipt) Text

func (r *Receipt) Text() []byte

type ReceiptOpt

type ReceiptOpt func(r *Receipt) error

func WithEstablishmentEvent

func WithEstablishmentEvent(est *Event) ReceiptOpt

func WithEstablishmentSeal

func WithEstablishmentSeal(s *Seal) ReceiptOpt

func WithQB64

func WithQB64(qb64 []byte) ReceiptOpt

func WithSignature

func WithSignature(der *derivation.Derivation) ReceiptOpt

func WithSignerPrefix

func WithSignerPrefix(pre string) ReceiptOpt

type Seal

type Seal struct {
	Type      SealType `json:"-"`
	Root      string   `json:"rd,omitempty"`
	Prefix    string   `json:"i,omitempty"`
	Sequence  string   `json:"s,omitempty"`
	EventType string   `json:"t,omitempty"`
	Digest    string   `json:"d,omitempty"`
}

Seal is used to anchor particular data to an event There are multiple types of seals, each with a different combination of data points.

func NewDigestSeal

func NewDigestSeal(dig string) (*Seal, error)

func NewEventLocationSeal

func NewEventLocationSeal(dig, pre, sn string, ilk ILK) (*Seal, error)

func NewEventSeal

func NewEventSeal(dig, pre, sn string) (*Seal, error)

func NewRootSeal

func NewRootSeal(rt string) (*Seal, error)

func NewSeal

func NewSeal(typ SealType, opts ...SealOption) (*Seal, error)

func SealEstablishment

func SealEstablishment(evt *Event) (*Seal, error)

func (*Seal) SequenceInt

func (r *Seal) SequenceInt() int

SequenceInt returns an integer representation of the hex sequence string

type SealArray

type SealArray []*Seal

func (*SealArray) MarshalJSON

func (r *SealArray) MarshalJSON() ([]byte, error)

func (*SealArray) UnmarshalJSON

func (r *SealArray) UnmarshalJSON(b []byte) error

type SealOption

type SealOption func(*Seal) error

func WithRoot

func WithRoot(rt string) SealOption

func WithSealDigest

func WithSealDigest(dig string) SealOption

func WithSealEventType

func WithSealEventType(eventType ILK) SealOption

func WithSealPrefix

func WithSealPrefix(pre string) SealOption

func WithSealSequence

func WithSealSequence(sn string) SealOption

type SealType

type SealType int
const (
	DigestSeal SealType = iota
	RootSeal
	EventSeal
	EventLocationSeal
)

type SigThreshold

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

func NewMultiWeighted

func NewMultiWeighted(conditions ...[]string) (*SigThreshold, error)

NewMultiWeighted creates a new signing threshold with multiple conditions

func NewSigThreshold

func NewSigThreshold(threshold int64) (*SigThreshold, error)

New returns a signing threshold requiring 'threshold' signatures

func NewWeighted

func NewWeighted(conditions ...string) (*SigThreshold, error)

NewWeighted creates a new sighing threshold with a weighted multisig

func (*SigThreshold) MarshalJSON

func (s *SigThreshold) MarshalJSON() ([]byte, error)

MarshalJSON is used to correctly output the JSON since this field can contain a single int, a list, or a list of lists

func (*SigThreshold) Satisfied

func (s *SigThreshold) Satisfied(sigs []derivation.Derivation) bool

Satisfied takes the provided signature derivations and checkes each weighted threshold

func (*SigThreshold) String

func (s *SigThreshold) String() string

String returns the threshold as a raw string representation sufficient for use in the next digest commitment

func (*SigThreshold) UnmarshalJSON

func (s *SigThreshold) UnmarshalJSON(in []byte) error

func (*SigThreshold) Weighted

func (s *SigThreshold) Weighted() bool

returns true if this is a weighted threshold - i.e. there is one or more lists of weights

Jump to

Keyboard shortcuts

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