cbor

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEvent added in v0.1.6

func CreateEvent(
	ctx context.Context,
	dag format.DAGService,
	body format.Node,
	rkey crypto.EncryptionKey,
) (service.Event, error)

CreateEvent create a new event by wrapping the body node.

func CreateRecord added in v0.1.6

func CreateRecord(
	ctx context.Context,
	dag format.DAGService,
	block format.Node,
	prev cid.Cid,
	sk ic.PrivKey,
	key crypto.EncryptionKey,
) (service.Record, error)

CreateRecord returns a new record from the given block and log private key.

func DecodeBlock

func DecodeBlock(block blocks.Block, key crypto.DecryptionKey) (format.Node, error)

DecodeBlock returns a node by decrypting the block's raw bytes with key.

func EncodeBlock

func EncodeBlock(block blocks.Block, key crypto.EncryptionKey) (format.Node, error)

EncodeBlock returns a node by encrypting the block's raw bytes with key.

func GetEvent

func GetEvent(ctx context.Context, dag format.DAGService, id cid.Cid) (service.Event, error)

GetEvent returns the event node for the given cid.

func GetRecord

func GetRecord(ctx context.Context, dag format.DAGService, id cid.Cid, key crypto.DecryptionKey) (service.Record, error)

GetRecord returns a record from the given cid.

func RecordFromNode

func RecordFromNode(coded format.Node, key crypto.DecryptionKey) (service.Record, error)

RecordFromNode decodes a record from a node using the given key.

func RecordFromProto

func RecordFromProto(rec *pb.Log_Record, key crypto.DecryptionKey) (service.Record, error)

Unmarshal returns a node from a serialized version that contains link data.

func RecordToProto

func RecordToProto(ctx context.Context, dag format.DAGService, rec service.Record) (*pb.Log_Record, error)

RecordToProto returns a proto version of a record for transport. Nodes are sent encrypted.

Types

type Event

type Event struct {
	format.Node
	// contains filtered or unexported fields
}

Event is a IPLD node representing an event.

func EventFromNode

func EventFromNode(node format.Node) (*Event, error)

EventFromNode decodes the given node into an event.

func EventFromRecord

func EventFromRecord(ctx context.Context, dag format.DAGService, rec service.Record) (*Event, error)

EventFromRecord returns the event within the given node.

func (*Event) BodyID

func (e *Event) BodyID() cid.Cid

BodyID returns the cid of the body.

func (*Event) GetBody

func (e *Event) GetBody(ctx context.Context, dag format.DAGService, key crypto.DecryptionKey) (format.Node, error)

GetBody returns the body node.

func (*Event) GetHeader

func (e *Event) GetHeader(
	ctx context.Context,
	dag format.DAGService,
	key crypto.DecryptionKey,
) (service.EventHeader, error)

GetHeader returns the header node.

func (*Event) HeaderID

func (e *Event) HeaderID() cid.Cid

HeaderID returns the cid of the header.

type EventHeader

type EventHeader struct {
	format.Node
	// contains filtered or unexported fields
}

EventHeader is an IPLD node representing an event header.

func (*EventHeader) Key

func (h *EventHeader) Key() (crypto.DecryptionKey, error)

Key returns the key needed to decrypt the event body if it has been decoded.

func (*EventHeader) Time

func (h *EventHeader) Time() (*time.Time, error)

Time returns the wall-clock time when the event was created if it has been decoded.

type Record

type Record struct {
	format.Node
	// contains filtered or unexported fields
}

Record is an IPLD node representing a record.

func (*Record) BlockID

func (r *Record) BlockID() cid.Cid

BlockID returns the cid of the block.

func (*Record) GetBlock

func (r *Record) GetBlock(ctx context.Context, dag format.DAGService) (format.Node, error)

GetBlock returns the block.

func (*Record) PrevID

func (r *Record) PrevID() cid.Cid

PrevID returns the cid of the previous linked record.

func (*Record) Sig

func (r *Record) Sig() []byte

Sig returns the record signature.

func (*Record) Verify

func (r *Record) Verify(pk ic.PubKey) error

Verify whether or not the signature is valid against the given public key.

Jump to

Keyboard shortcuts

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