common

package
v0.0.69 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: AGPL-3.0, AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapServiceName = "map"
)

Variables

View Source
var (
	ReadCap  = []byte("read")
	WriteCap = []byte("write")
)
View Source
var (
	ErrStatusNotFound = errors.New("StatusNotFound")
	ErrStatusFailed   = errors.New("StatusFailed")
)

Functions

This section is empty.

Types

type Cap

type Cap interface {
	Addr(addr []byte) MessageID
}

type MapRequest

type MapRequest struct {
	// ID is the ID of the block which is a ed25519 PublicKey
	ID MessageID

	// Future version may wish to include the PublicKey
	// if PublicKeySize is
	// Signature is the signature over Payload with
	// The Read or Write capability keys for the entry
	// identified by ID
	Signature []byte

	// Payload is the contents to store or nil
	Payload []byte
}

func (*MapRequest) Marshal

func (m *MapRequest) Marshal() ([]byte, error)

func (*MapRequest) Unmarshal

func (m *MapRequest) Unmarshal(b []byte) error

type MapResponse

type MapResponse struct {
	Status  MapStatus
	Payload []byte
}

func (*MapResponse) Marshal

func (m *MapResponse) Marshal() ([]byte, error)

func (*MapResponse) Unmarshal

func (m *MapResponse) Unmarshal(b []byte) error

type MapStatus

type MapStatus uint8
const (
	StatusOK MapStatus = iota
	StatusNotFound
	StatusFailed
)

type MessageID

type MessageID [ed25519.PublicKeySize]byte

MessageID represents a storage address with Read/Write capability

func (MessageID) Bytes

func (m MessageID) Bytes() []byte

func (MessageID) ReadVerifier

func (m MessageID) ReadVerifier() *ed25519.PublicKey

ReadVerifier returns the verifier of ReadCap for this ID

func (MessageID) WriteVerifier

func (m MessageID) WriteVerifier() *ed25519.PublicKey

WriteVerifier returns the verifier of WriteCap for this ID

type ROCap

type ROCap struct {
	RootCap
	// Read capability keys
	CapRSk *ed25519.BlindedPrivateKey
	CapRPk *ed25519.PublicKey
}

ROCap holds the keys implementing Read Capabilities using blinded ed25519 keys

func NewROCap

func NewROCap(pRoot *ed25519.PublicKey, rSk *ed25519.BlindedPrivateKey) *ROCap

NewROCap returns a Cap initialized with read capability and root public key

func (*ROCap) ReadKey

func (s *ROCap) ReadKey(addr []byte) *ed25519.BlindedPrivateKey

ReadKey(addr) returns a key from which to sign the command reading from addr

type RWCap

type RWCap struct {
	RootCap
	ROCap
	WOCap
	// capability root private key from which other keys are derived
	CapSk *ed25519.PrivateKey
}

RWCap holds the keys implementing Read/Write Capabilities using blinded ed25519 keys

func NewRWCap

func NewRWCap(root *ed25519.PrivateKey) *RWCap

NewRWCap returns a Cap initialized with capability keys from a root key

func (*RWCap) ReadOnly

func (s *RWCap) ReadOnly() *ROCap

RO returns a ReadOnlyCap from RWCap

func (*RWCap) WriteOnly

func (s *RWCap) WriteOnly() *WOCap

WO returns a WriteOnlyCap from RWCap

type ReadOnlyCap

type ReadOnlyCap interface {
	Cap
	ReadKey(addr []byte) *ed25519.BlindedPrivateKey
}

ReadOnlyCap describes a Capability that has Read capability only.

type ReadWriteCap

type ReadWriteCap interface {
	Cap
	ReadOnlyCap
	WriteOnlyCap
	ReadOnly() ReadOnlyCap
	WriteOnly() WriteOnlyCap
}

ReadWriteCap describes a Capability that has Read and Write capabilities and can return ReadOnly and WriteOnly capabilities

type RootCap

type RootCap struct {
	CapPk *ed25519.PublicKey
}

RootCap holds CapPk and implements the Addr method which other capability types inherit.

func (*RootCap) Addr

func (s *RootCap) Addr(addr []byte) MessageID

Addr returns the capability id (publickey) for addr, used as map address

type WOCap

type WOCap struct {
	RootCap
	// Write capability keys
	CapWSk *ed25519.BlindedPrivateKey
	CapWPk *ed25519.PublicKey
}

WOCap holds the keys implementing Write Capabilities using blinded ed25519 keys

func NewWOCap

func NewWOCap(pRoot *ed25519.PublicKey, wSk *ed25519.BlindedPrivateKey) *WOCap

NewROCap returns a Cap initialized with read capability and root public key

func (*WOCap) WriteKey

func (s *WOCap) WriteKey(addr []byte) *ed25519.BlindedPrivateKey

WriteKey(addr) returns a key from which to sign the command writing to addr

type WriteOnlyCap

type WriteOnlyCap interface {
	Cap
	WriteKey(addr []byte) *ed25519.BlindedPrivateKey
}

ReadOnlyCap describes a Capability that has Write capability only.

Jump to

Keyboard shortcuts

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