api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package api is a generated protocol buffer package.

It is generated from these files:

librarian/api/documents.proto
librarian/api/librarian.proto

It has these top-level messages:

Document
Envelope
Entry
Metadata
PageKeys
Page
RequestMetadata
ResponseMetadata
IntroduceRequest
IntroduceResponse
FindRequest
FindResponse
VerifyRequest
VerifyResponse
PeerAddress
StoreRequest
StoreResponse
GetRequest
GetResponse
PutRequest
PutResponse
SubscribeRequest
SubscribeResponse
Publication
Subscription
BloomFilter

Index

Constants

View Source
const (
	// ECPubKeyLength is the length of a 256-bit ECDSA public key point serialized
	// (uncompressed) to a byte string.
	ECPubKeyLength = 65

	// DocumentKeyLength is the byte length a document's key.
	DocumentKeyLength = id.Length

	// AESKeyLength is the byte length of an AES-256 encryption key.
	AESKeyLength = 32

	// PageIVSeedLength is the byte length of the Page block cipher initialization vector (IV)
	// seed.
	PageIVSeedLength = 32

	// HMACKeyLength is the byte length of the Page HMAC-256 key.
	HMACKeyLength = 32

	// BlockCipherIVLength is the byte length of a block cipher initialization vector.
	BlockCipherIVLength = 12

	// KEKLength is the total byte length of the key encryption keys.
	KEKLength = AESKeyLength + BlockCipherIVLength + HMACKeyLength

	// EEKLength is the total byte length of the entry encryption keys.
	EEKLength = AESKeyLength +
		PageIVSeedLength +
		HMACKeyLength +
		BlockCipherIVLength

	// EEKCiphertextLength is the length of the EEK ciphertext, which includes 16 bytes of
	// encryption info.
	EEKCiphertextLength = EEKLength + 16

	// HMAC256Length is the byte length of an HMAC-256.
	HMAC256Length = sha256.Size
)

field lengths

View Source
const (

	// MetadataEntryMediaType indicates the media type.
	MetadataEntryMediaType = metadataEntryPrefix + "media_type"

	// MetadataEntryCiphertextSize indicates the total ciphertext size across all pages.
	MetadataEntryCiphertextSize = metadataEntryPrefix + "ciphertext_size"

	// MetadataEntryCiphertextMAC indicates the MAC of the entire ciphertext.
	MetadataEntryCiphertextMAC = metadataEntryPrefix + "ciphertext_mac"

	// MetadataEntryUncompressedSize indicates the total size of the entire uncompressed entry.
	MetadataEntryUncompressedSize = metadataEntryPrefix + "uncompressed_size"

	// MetadataEntryUncompressedMAC indicates the MAC of the entire uncompressed entry.
	MetadataEntryUncompressedMAC = metadataEntryPrefix + "uncompressed_mac"
)

required Entry metadata fields

View Source
const (
	// MetadataEntryFilepath indicates the (relative) filepath of the data contained in the
	// entry.
	MetadataEntryFilepath = metadataEntryPrefix + "filepath"

	// MetadataEntrySchema indicates the schema (however defined) of the data contained in the
	// entry.
	MetadataEntrySchema = metadataEntryPrefix + "schema"
)

optional Entry metadata fields

Variables

View Source
var (
	// ErrUnexpectedDocumentType indicates when a document type is not expected (e.g., a Page
	// when expecting an Entry).
	ErrUnexpectedDocumentType = errors.New("unexpected document type")

	// ErrUnknownDocumentType indicates when a document type is not known (usually, this
	// error should never actually be thrown).
	ErrUnknownDocumentType = errors.New("unknown document type")

	// ErrUnexpectedKey indicates when a key does not match the expected key (from GetKey)
	// for a given value.
	ErrUnexpectedKey = errors.New("unexpected key for value")
)
View Source
var ErrEmptySubscriptionFilters = errors.New("subscription has empty filters")

ErrEmptySubscriptionFilters indicates when a *Subscription has an empty author or reader public key filter.

View Source
var ErrUnexpectedNilValue = errors.New("unexpected nil value")

ErrUnexpectedNilValue indicates when a value is unexpectedly nil.

View Source
var (
	// ErrUnexpectedZero describes when an error is unexpectedly zero.
	ErrUnexpectedZero = errors.New("unexpected zero value")
)
View Source
var PutOperation_name = map[int32]string{
	0: "STORED",
	1: "LEFT_EXISTING",
}
View Source
var PutOperation_value = map[string]int32{
	"STORED":        0,
	"LEFT_EXISTING": 1,
}

Functions

func GetAuthorPub

func GetAuthorPub(d *Document) []byte

GetAuthorPub returns the author public key for a given document.

func GetEntryPageKeys

func GetEntryPageKeys(entry *Document) ([]id.ID, error)

GetEntryPageKeys returns the []id.ID page keys if the entry is multi-page. It returns nil for single-page entries.

func GetKey

func GetKey(value proto.Message) (id.ID, error)

GetKey calculates the key from the has of the proto.Message.

func RandBytes

func RandBytes(rng *rand.Rand, length int) []byte

RandBytes generates a random bytes slice of a given length.

func RegisterLibrarianServer

func RegisterLibrarianServer(s *grpc.Server, srv LibrarianServer)

func ValidateAESKey

func ValidateAESKey(value []byte) error

ValidateAESKey checks the a value can be a 256-bit AES key.

func ValidateBytes

func ValidateBytes(value []byte, expectedLen int, name string) error

ValidateBytes returns whether the byte slice is not empty and has an expected length.

func ValidateDocument

func ValidateDocument(d *Document) error

ValidateDocument checks that all fields of a Document are populated and have the expected lengths.

func ValidateEntry

func ValidateEntry(e *Entry) error

ValidateEntry checks that all fields of an Entry are populated and have the expected byte lengths.

func ValidateEnvelope

func ValidateEnvelope(e *Envelope) error

ValidateEnvelope checks that all fields of an Envelope are populated and have the expected lengths.

func ValidateHMAC256

func ValidateHMAC256(value []byte) error

ValidateHMAC256 checks that a value can be an HMAC-256.

func ValidateHMACKey

func ValidateHMACKey(value []byte) error

ValidateHMACKey checks that a value can be an HMAC-256 key.

func ValidateMetadata

func ValidateMetadata(m *Metadata) error

ValidateMetadata checks that the metadata has all the required non-zero values.

func ValidateMetadataIV

func ValidateMetadataIV(value []byte) error

ValidateMetadataIV checks that a value can be a 12-byte GCM initialization vector.

func ValidateNotEmpty

func ValidateNotEmpty(value []byte, name string) error

ValidateNotEmpty returns whether the byte slice is not empty.

func ValidatePage

func ValidatePage(p *Page) error

ValidatePage checks that all fields of a Page are populated and have the expected lengths.

func ValidatePageIVSeed

func ValidatePageIVSeed(value []byte) error

ValidatePageIVSeed checks that a value can be a 256-bit initialization vector seed.

func ValidatePageKeys

func ValidatePageKeys(pk *PageKeys) error

ValidatePageKeys checks that all fields of a PageKeys are populated and have the expected lengths.

func ValidatePublicKey

func ValidatePublicKey(value []byte) error

ValidatePublicKey checks that a value can be a 256-bit elliptic curve public key.

func ValidatePublication

func ValidatePublication(p *Publication) error

ValidatePublication validates that a publication has all fields of the correct length.

func ValidateSubscription

func ValidateSubscription(s *Subscription) error

ValidateSubscription validates that a subscription is not missing any required fields. It returns nil if the subscription is valid.

Types

type BloomFilter

type BloomFilter struct {
	// using https://godoc.org/github.com/willf/bloom#BloomFilter.GobEncode
	Encoded []byte `protobuf:"bytes,1,opt,name=encoded,proto3" json:"encoded,omitempty"`
}

func (*BloomFilter) Descriptor

func (*BloomFilter) Descriptor() ([]byte, []int)

func (*BloomFilter) GetEncoded

func (m *BloomFilter) GetEncoded() []byte

func (*BloomFilter) ProtoMessage

func (*BloomFilter) ProtoMessage()

func (*BloomFilter) Reset

func (m *BloomFilter) Reset()

func (*BloomFilter) String

func (m *BloomFilter) String() string

type Document

type Document struct {
	// Types that are valid to be assigned to Contents:
	//	*Document_Envelope
	//	*Document_Entry
	//	*Document_Page
	Contents isDocument_Contents `protobuf_oneof:"contents"`
}

Document contains either an Envelope, Entry, or Page message.

func GetPageDocument

func GetPageDocument(page *Page) (*Document, id.ID, error)

GetPageDocument wraps a Page into a Document, returning it and its key.

func NewTestDocument

func NewTestDocument(rng *rand.Rand) (*Document, id.ID)

NewTestDocument generates a dummy Entry document for use in testing.

func (*Document) Descriptor

func (*Document) Descriptor() ([]byte, []int)

func (*Document) GetContents

func (m *Document) GetContents() isDocument_Contents

func (*Document) GetEntry

func (m *Document) GetEntry() *Entry

func (*Document) GetEnvelope

func (m *Document) GetEnvelope() *Envelope

func (*Document) GetPage

func (m *Document) GetPage() *Page

func (*Document) ProtoMessage

func (*Document) ProtoMessage()

func (*Document) Reset

func (m *Document) Reset()

func (*Document) String

func (m *Document) String() string

func (*Document) XXX_OneofFuncs

func (*Document) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type Document_Entry

type Document_Entry struct {
	Entry *Entry `protobuf:"bytes,2,opt,name=entry,oneof"`
}

type Document_Envelope

type Document_Envelope struct {
	Envelope *Envelope `protobuf:"bytes,1,opt,name=envelope,oneof"`
}

type Document_Page

type Document_Page struct {
	Page *Page `protobuf:"bytes,3,opt,name=page,oneof"`
}

type Entry

type Entry struct {
	// ECDSA public key of the entry author
	AuthorPublicKey []byte `protobuf:"bytes,1,opt,name=author_public_key,json=authorPublicKey,proto3" json:"author_public_key,omitempty"`
	// contents of the entry, either a single Page or a list of page keys
	//
	// Types that are valid to be assigned to Contents:
	//	*Entry_Page
	//	*Entry_PageKeys
	Contents isEntry_Contents `protobuf_oneof:"contents"`
	// created epoch time (seconds since 1970-01-01)
	CreatedTime int64 `protobuf:"varint,4,opt,name=created_time,json=createdTime" json:"created_time,omitempty"`
	// ciphertext of marshalled Metadata message properties
	MetadataCiphertext []byte `protobuf:"bytes,5,opt,name=metadata_ciphertext,json=metadataCiphertext,proto3" json:"metadata_ciphertext,omitempty"`
	// 32-byte MAC of metatadata ciphertext, encrypted with the 32-byte Entry AES-256 key and
	// 12-byte metadata block cipher IV
	MetadataCiphertextMac []byte `` /* 126-byte string literal not displayed */
}

Entry is the main unit of storage in the Libri network.

func NewTestMultiPageEntry

func NewTestMultiPageEntry(rng *rand.Rand) *Entry

NewTestMultiPageEntry generates a dummy Entry document with two page keys for use in testing.

func NewTestSinglePageEntry

func NewTestSinglePageEntry(rng *rand.Rand) *Entry

NewTestSinglePageEntry generates a dummy Entry document with a single Page for use in testing.

func (*Entry) Descriptor

func (*Entry) Descriptor() ([]byte, []int)

func (*Entry) GetAuthorPublicKey

func (m *Entry) GetAuthorPublicKey() []byte

func (*Entry) GetContents

func (m *Entry) GetContents() isEntry_Contents

func (*Entry) GetCreatedTime

func (m *Entry) GetCreatedTime() int64

func (*Entry) GetMetadataCiphertext

func (m *Entry) GetMetadataCiphertext() []byte

func (*Entry) GetMetadataCiphertextMac

func (m *Entry) GetMetadataCiphertextMac() []byte

func (*Entry) GetPage

func (m *Entry) GetPage() *Page

func (*Entry) GetPageKeys

func (m *Entry) GetPageKeys() *PageKeys

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) Reset

func (m *Entry) Reset()

func (*Entry) String

func (m *Entry) String() string

func (*Entry) XXX_OneofFuncs

func (*Entry) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type Entry_Page

type Entry_Page struct {
	Page *Page `protobuf:"bytes,2,opt,name=page,oneof"`
}

type Entry_PageKeys

type Entry_PageKeys struct {
	PageKeys *PageKeys `protobuf:"bytes,3,opt,name=page_keys,json=pageKeys,oneof"`
}

type Envelope

type Envelope struct {
	// 32-byte key of the Entry whose encryption keys are being sent
	EntryKey []byte `protobuf:"bytes,1,opt,name=entry_key,json=entryKey,proto3" json:"entry_key,omitempty"`
	// ECDH public key of the entry author/sender
	AuthorPublicKey []byte `protobuf:"bytes,2,opt,name=author_public_key,json=authorPublicKey,proto3" json:"author_public_key,omitempty"`
	// ECDH public key of the entry reader/recipient
	ReaderPublicKey []byte `protobuf:"bytes,3,opt,name=reader_public_key,json=readerPublicKey,proto3" json:"reader_public_key,omitempty"`
	// ciphertext of 108-byte entry encryption key (EEK), encrypted with a KEK from the shared
	// ECDH shared secret
	EekCiphertext []byte `protobuf:"bytes,4,opt,name=eek_ciphertext,json=eekCiphertext,proto3" json:"eek_ciphertext,omitempty"`
	// 32-byte MAC of the EEK
	EekCiphertextMac []byte `protobuf:"bytes,5,opt,name=eek_ciphertext_mac,json=eekCiphertextMac,proto3" json:"eek_ciphertext_mac,omitempty"`
}

Envelope defines the public keys an author uses to share an entry encryption key with a particular reader. The shared ECDH secret is used with a key derivation function to generate the key encryption key (KEK), which contains 2 sub-keys: 1) 32-byte AES-256 key, used for encrypting/decrypting the entry encryption key (EEK) 2) 12-byte EEK block cipher initialization vector 3) 32-byte HMAC-256 key, used for EEK MAC

This AES-256 KEK is then used to decrypt the EEK ciphertext, which contains 4 sub-keys: 1) 32-byte AES-256 key, used to enrypt Pages and Entry metadata 2) 32-byte Page initialization vector (IV) seed 3) 32-byte HMAC-256 key 4) 12-byte metadata block cipher initialization vector

func NewTestEnvelope

func NewTestEnvelope(rng *rand.Rand) *Envelope

NewTestEnvelope generates a dummy Envelope document for use in testing.

func (*Envelope) Descriptor

func (*Envelope) Descriptor() ([]byte, []int)

func (*Envelope) GetAuthorPublicKey

func (m *Envelope) GetAuthorPublicKey() []byte

func (*Envelope) GetEekCiphertext

func (m *Envelope) GetEekCiphertext() []byte

func (*Envelope) GetEekCiphertextMac

func (m *Envelope) GetEekCiphertextMac() []byte

func (*Envelope) GetEntryKey

func (m *Envelope) GetEntryKey() []byte

func (*Envelope) GetReaderPublicKey

func (m *Envelope) GetReaderPublicKey() []byte

func (*Envelope) ProtoMessage

func (*Envelope) ProtoMessage()

func (*Envelope) Reset

func (m *Envelope) Reset()

func (*Envelope) String

func (m *Envelope) String() string

type FindRequest

type FindRequest struct {
	Metadata *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// 32-byte target to find peers around
	Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	// the number of closests peers to return
	NumPeers uint32 `protobuf:"varint,3,opt,name=num_peers,json=numPeers" json:"num_peers,omitempty"`
}

func (*FindRequest) Descriptor

func (*FindRequest) Descriptor() ([]byte, []int)

func (*FindRequest) GetKey

func (m *FindRequest) GetKey() []byte

func (*FindRequest) GetMetadata

func (m *FindRequest) GetMetadata() *RequestMetadata

func (*FindRequest) GetNumPeers

func (m *FindRequest) GetNumPeers() uint32

func (*FindRequest) ProtoMessage

func (*FindRequest) ProtoMessage()

func (*FindRequest) Reset

func (m *FindRequest) Reset()

func (*FindRequest) String

func (m *FindRequest) String() string

type FindResponse

type FindResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// list of peers closest to target
	Peers []*PeerAddress `protobuf:"bytes,2,rep,name=peers" json:"peers,omitempty"`
	// value, if found
	Value *Document `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"`
}

func (*FindResponse) Descriptor

func (*FindResponse) Descriptor() ([]byte, []int)

func (*FindResponse) GetMetadata

func (m *FindResponse) GetMetadata() *ResponseMetadata

func (*FindResponse) GetPeers

func (m *FindResponse) GetPeers() []*PeerAddress

func (*FindResponse) GetValue

func (m *FindResponse) GetValue() *Document

func (*FindResponse) ProtoMessage

func (*FindResponse) ProtoMessage()

func (*FindResponse) Reset

func (m *FindResponse) Reset()

func (*FindResponse) String

func (m *FindResponse) String() string

type Finder

type Finder interface {
	// Find returns the value for a key or the closest peers to it.
	Find(ctx context.Context, in *FindRequest, opts ...grpc.CallOption) (*FindResponse, error)
}

Finder issues Find queries.

type GetRequest

type GetRequest struct {
	Metadata *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// 32-byte key of document to get
	Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
}

func (*GetRequest) Descriptor

func (*GetRequest) Descriptor() ([]byte, []int)

func (*GetRequest) GetKey

func (m *GetRequest) GetKey() []byte

func (*GetRequest) GetMetadata

func (m *GetRequest) GetMetadata() *RequestMetadata

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) String

func (m *GetRequest) String() string

type GetResponse

type GetResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// value to store for key
	Value *Document `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
}

func (*GetResponse) Descriptor

func (*GetResponse) Descriptor() ([]byte, []int)

func (*GetResponse) GetMetadata

func (m *GetResponse) GetMetadata() *ResponseMetadata

func (*GetResponse) GetValue

func (m *GetResponse) GetValue() *Document

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) Reset

func (m *GetResponse) Reset()

func (*GetResponse) String

func (m *GetResponse) String() string

type Getter

type Getter interface {
	// Get retrieves a value, if it exists.
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
}

Getter issues Get queries.

type IntroduceRequest

type IntroduceRequest struct {
	Metadata *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// info about the peer making the introduction
	Self *PeerAddress `protobuf:"bytes,2,opt,name=self" json:"self,omitempty"`
	// number of peer librarians to request info for
	NumPeers uint32 `protobuf:"varint,3,opt,name=num_peers,json=numPeers" json:"num_peers,omitempty"`
}

func (*IntroduceRequest) Descriptor

func (*IntroduceRequest) Descriptor() ([]byte, []int)

func (*IntroduceRequest) GetMetadata

func (m *IntroduceRequest) GetMetadata() *RequestMetadata

func (*IntroduceRequest) GetNumPeers

func (m *IntroduceRequest) GetNumPeers() uint32

func (*IntroduceRequest) GetSelf

func (m *IntroduceRequest) GetSelf() *PeerAddress

func (*IntroduceRequest) ProtoMessage

func (*IntroduceRequest) ProtoMessage()

func (*IntroduceRequest) Reset

func (m *IntroduceRequest) Reset()

func (*IntroduceRequest) String

func (m *IntroduceRequest) String() string

type IntroduceResponse

type IntroduceResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// info about the peer receiving the introduction
	Self *PeerAddress `protobuf:"bytes,2,opt,name=self" json:"self,omitempty"`
	// info about other peers
	Peers []*PeerAddress `protobuf:"bytes,3,rep,name=peers" json:"peers,omitempty"`
}

func (*IntroduceResponse) Descriptor

func (*IntroduceResponse) Descriptor() ([]byte, []int)

func (*IntroduceResponse) GetMetadata

func (m *IntroduceResponse) GetMetadata() *ResponseMetadata

func (*IntroduceResponse) GetPeers

func (m *IntroduceResponse) GetPeers() []*PeerAddress

func (*IntroduceResponse) GetSelf

func (m *IntroduceResponse) GetSelf() *PeerAddress

func (*IntroduceResponse) ProtoMessage

func (*IntroduceResponse) ProtoMessage()

func (*IntroduceResponse) Reset

func (m *IntroduceResponse) Reset()

func (*IntroduceResponse) String

func (m *IntroduceResponse) String() string

type Introducer

type Introducer interface {
	// Introduce identifies the node by name and ID.
	Introduce(ctx context.Context, in *IntroduceRequest, opts ...grpc.CallOption) (
		*IntroduceResponse, error)
}

Introducer issues Introduce queries.

type LibrarianClient

type LibrarianClient interface {
	// Introduce identifies the node by name and ID.
	Introduce(ctx context.Context, in *IntroduceRequest, opts ...grpc.CallOption) (*IntroduceResponse, error)
	// Find returns the value for a key or the closest peers to it.
	Find(ctx context.Context, in *FindRequest, opts ...grpc.CallOption) (*FindResponse, error)
	// Verify checks that a peer has the value for a given key or returns the closest peers to
	// that value.
	Verify(ctx context.Context, in *VerifyRequest, opts ...grpc.CallOption) (*VerifyResponse, error)
	// Store stores a value in a given key.
	Store(ctx context.Context, in *StoreRequest, opts ...grpc.CallOption) (*StoreResponse, error)
	// Get retrieves a value, if it exists.
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
	// Put stores a value.
	Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
	// Subscribe streams Publications to the client per a subscription filter.
	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (Librarian_SubscribeClient, error)
}

func NewLibrarianClient

func NewLibrarianClient(cc *grpc.ClientConn) LibrarianClient

type LibrarianServer

type LibrarianServer interface {
	// Introduce identifies the node by name and ID.
	Introduce(context.Context, *IntroduceRequest) (*IntroduceResponse, error)
	// Find returns the value for a key or the closest peers to it.
	Find(context.Context, *FindRequest) (*FindResponse, error)
	// Verify checks that a peer has the value for a given key or returns the closest peers to
	// that value.
	Verify(context.Context, *VerifyRequest) (*VerifyResponse, error)
	// Store stores a value in a given key.
	Store(context.Context, *StoreRequest) (*StoreResponse, error)
	// Get retrieves a value, if it exists.
	Get(context.Context, *GetRequest) (*GetResponse, error)
	// Put stores a value.
	Put(context.Context, *PutRequest) (*PutResponse, error)
	// Subscribe streams Publications to the client per a subscription filter.
	Subscribe(*SubscribeRequest, Librarian_SubscribeServer) error
}

type Librarian_SubscribeClient

type Librarian_SubscribeClient interface {
	Recv() (*SubscribeResponse, error)
	grpc.ClientStream
}

type Librarian_SubscribeServer

type Librarian_SubscribeServer interface {
	Send(*SubscribeResponse) error
	grpc.ServerStream
}

type Metadata

type Metadata struct {
	Properties map[string][]byte `` /* 147-byte string literal not displayed */
}

Metadata is a map of (property, value) combinations.

func NewEntryMetadata

func NewEntryMetadata(
	mediaType string,
	ciphertextSize uint64,
	ciphertextMAC []byte,
	uncompressedSize uint64,
	uncompressedMAC []byte,
) (*Metadata, error)

NewEntryMetadata creates a new *Metadata instance with the given (required) fields.

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

func (*Metadata) GetBytes

func (m *Metadata) GetBytes(key string) ([]byte, bool)

GetBytes returns the byte slice value for a given key.

func (*Metadata) GetCiphertextMAC

func (m *Metadata) GetCiphertextMAC() ([]byte, bool)

GetCiphertextMAC returns the ciphertext MAC.

func (*Metadata) GetCiphertextSize

func (m *Metadata) GetCiphertextSize() (uint64, bool)

GetCiphertextSize returns the size of the ciphertext.

func (*Metadata) GetMediaType

func (m *Metadata) GetMediaType() (string, bool)

GetMediaType returns the media type.

func (*Metadata) GetProperties

func (m *Metadata) GetProperties() map[string][]byte

func (*Metadata) GetString

func (m *Metadata) GetString(key string) (string, bool)

GetString returns the string value for a given key.

func (*Metadata) GetUint64

func (m *Metadata) GetUint64(key string) (uint64, bool)

GetUint64 returns the uint64 value for a given key.

func (*Metadata) GetUncompressedMAC

func (m *Metadata) GetUncompressedMAC() ([]byte, bool)

GetUncompressedMAC returns the MAC of the uncompressed data.

func (*Metadata) GetUncompressedSize

func (m *Metadata) GetUncompressedSize() (uint64, bool)

GetUncompressedSize returns the size of the uncompressed data.

func (*Metadata) MarshalLogObject

func (m *Metadata) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject converts the metadata into an object (which will become json) for logging.

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) SetBytes

func (m *Metadata) SetBytes(key string, value []byte)

SetBytes sets the byte slice value for a given key.

func (*Metadata) SetString

func (m *Metadata) SetString(key string, value string)

SetString sets the string value for a given key.

func (*Metadata) SetUint64

func (m *Metadata) SetUint64(key string, value uint64)

SetUint64 sets the uint64 value for a given key.

func (*Metadata) String

func (m *Metadata) String() string

type Page

type Page struct {
	// ECDSA public key of the entry author
	AuthorPublicKey []byte `protobuf:"bytes,1,opt,name=author_public_key,json=authorPublicKey,proto3" json:"author_public_key,omitempty"`
	// index of Page within Entry contents
	Index uint32 `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
	// ciphertext of Page contents, encrypted using the 32-byte AES-256 key with the block cipher
	// initialized by the first 12 bytes of HMAC-256(IV seed, page index)
	Ciphertext []byte `protobuf:"bytes,3,opt,name=ciphertext,proto3" json:"ciphertext,omitempty"`
	// 32-byte MAC of ciphertext using the 32-byte Page ciphertext HMAC-256 key
	CiphertextMac []byte `protobuf:"bytes,4,opt,name=ciphertext_mac,json=ciphertextMac,proto3" json:"ciphertext_mac,omitempty"`
}

Page is a portion (possibly all) of an Entry document.

func NewTestPage

func NewTestPage(rng *rand.Rand) *Page

NewTestPage generates a dummy Page for use in testing.

func (*Page) Descriptor

func (*Page) Descriptor() ([]byte, []int)

func (*Page) GetAuthorPublicKey

func (m *Page) GetAuthorPublicKey() []byte

func (*Page) GetCiphertext

func (m *Page) GetCiphertext() []byte

func (*Page) GetCiphertextMac

func (m *Page) GetCiphertextMac() []byte

func (*Page) GetIndex

func (m *Page) GetIndex() uint32

func (*Page) ProtoMessage

func (*Page) ProtoMessage()

func (*Page) Reset

func (m *Page) Reset()

func (*Page) String

func (m *Page) String() string

type PageKeys

type PageKeys struct {
	Keys [][]byte `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"`
}

PageKeys is an ordered list of keys to Page documents that comprise an Entry document.

func (*PageKeys) Descriptor

func (*PageKeys) Descriptor() ([]byte, []int)

func (*PageKeys) GetKeys

func (m *PageKeys) GetKeys() [][]byte

func (*PageKeys) ProtoMessage

func (*PageKeys) ProtoMessage()

func (*PageKeys) Reset

func (m *PageKeys) Reset()

func (*PageKeys) String

func (m *PageKeys) String() string

type PeerAddress

type PeerAddress struct {
	// 32-byte peer ID
	PeerId []byte `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
	// self-reported name of the peer
	PeerName string `protobuf:"bytes,2,opt,name=peer_name,json=peerName" json:"peer_name,omitempty"`
	// public IP address
	Ip string `protobuf:"bytes,3,opt,name=ip" json:"ip,omitempty"`
	// public address TCP port
	Port uint32 `protobuf:"varint,4,opt,name=port" json:"port,omitempty"`
}

func (*PeerAddress) Descriptor

func (*PeerAddress) Descriptor() ([]byte, []int)

func (*PeerAddress) GetIp

func (m *PeerAddress) GetIp() string

func (*PeerAddress) GetPeerId

func (m *PeerAddress) GetPeerId() []byte

func (*PeerAddress) GetPeerName

func (m *PeerAddress) GetPeerName() string

func (*PeerAddress) GetPort

func (m *PeerAddress) GetPort() uint32

func (*PeerAddress) ProtoMessage

func (*PeerAddress) ProtoMessage()

func (*PeerAddress) Reset

func (m *PeerAddress) Reset()

func (*PeerAddress) String

func (m *PeerAddress) String() string

type Publication

type Publication struct {
	EnvelopeKey     []byte `protobuf:"bytes,1,opt,name=envelope_key,json=envelopeKey,proto3" json:"envelope_key,omitempty"`
	EntryKey        []byte `protobuf:"bytes,2,opt,name=entry_key,json=entryKey,proto3" json:"entry_key,omitempty"`
	AuthorPublicKey []byte `protobuf:"bytes,3,opt,name=author_public_key,json=authorPublicKey,proto3" json:"author_public_key,omitempty"`
	ReaderPublicKey []byte `protobuf:"bytes,4,opt,name=reader_public_key,json=readerPublicKey,proto3" json:"reader_public_key,omitempty"`
}

func GetPublication

func GetPublication(key []byte, value *Document) *Publication

GetPublication returns a *Publication object if one can be made from the given document key and value. If not, it returns nil.

func NewTestPublication

func NewTestPublication(rng *rand.Rand) *Publication

NewTestPublication generates a dummy Publication for use in testing.

func (*Publication) Descriptor

func (*Publication) Descriptor() ([]byte, []int)

func (*Publication) GetAuthorPublicKey

func (m *Publication) GetAuthorPublicKey() []byte

func (*Publication) GetEntryKey

func (m *Publication) GetEntryKey() []byte

func (*Publication) GetEnvelopeKey

func (m *Publication) GetEnvelopeKey() []byte

func (*Publication) GetReaderPublicKey

func (m *Publication) GetReaderPublicKey() []byte

func (*Publication) ProtoMessage

func (*Publication) ProtoMessage()

func (*Publication) Reset

func (m *Publication) Reset()

func (*Publication) String

func (m *Publication) String() string

type PutOperation

type PutOperation int32
const (
	// new value was added
	PutOperation_STORED PutOperation = 0
	// value already existed
	PutOperation_LEFT_EXISTING PutOperation = 1
)

func (PutOperation) EnumDescriptor

func (PutOperation) EnumDescriptor() ([]byte, []int)

func (PutOperation) String

func (x PutOperation) String() string

type PutRequest

type PutRequest struct {
	Metadata *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// key to store value under
	Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	// value to store for key
	Value *Document `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"`
}

func (*PutRequest) Descriptor

func (*PutRequest) Descriptor() ([]byte, []int)

func (*PutRequest) GetKey

func (m *PutRequest) GetKey() []byte

func (*PutRequest) GetMetadata

func (m *PutRequest) GetMetadata() *RequestMetadata

func (*PutRequest) GetValue

func (m *PutRequest) GetValue() *Document

func (*PutRequest) ProtoMessage

func (*PutRequest) ProtoMessage()

func (*PutRequest) Reset

func (m *PutRequest) Reset()

func (*PutRequest) String

func (m *PutRequest) String() string

type PutResponse

type PutResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// result of the put operation
	Operation PutOperation `protobuf:"varint,2,opt,name=operation,enum=api.PutOperation" json:"operation,omitempty"`
	// number of replicas of the stored value; only populated for operation = STORED
	NReplicas uint32 `protobuf:"varint,3,opt,name=n_replicas,json=nReplicas" json:"n_replicas,omitempty"`
}

func (*PutResponse) Descriptor

func (*PutResponse) Descriptor() ([]byte, []int)

func (*PutResponse) GetMetadata

func (m *PutResponse) GetMetadata() *ResponseMetadata

func (*PutResponse) GetNReplicas

func (m *PutResponse) GetNReplicas() uint32

func (*PutResponse) GetOperation

func (m *PutResponse) GetOperation() PutOperation

func (*PutResponse) ProtoMessage

func (*PutResponse) ProtoMessage()

func (*PutResponse) Reset

func (m *PutResponse) Reset()

func (*PutResponse) String

func (m *PutResponse) String() string

type Putter

type Putter interface {
	// Put stores a value.
	Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
}

Putter issues Put queries.

type PutterGetter

type PutterGetter interface {
	Getter
	Putter
}

PutterGetter issues Put and Get queries.

type RequestMetadata

type RequestMetadata struct {
	// 32-byte unique request ID
	RequestId []byte `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
	// peer's ECDSA public key
	PubKey []byte `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`
}

RequestMetadata defines metadata associated with every request.

func (*RequestMetadata) Descriptor

func (*RequestMetadata) Descriptor() ([]byte, []int)

func (*RequestMetadata) GetPubKey

func (m *RequestMetadata) GetPubKey() []byte

func (*RequestMetadata) GetRequestId

func (m *RequestMetadata) GetRequestId() []byte

func (*RequestMetadata) ProtoMessage

func (*RequestMetadata) ProtoMessage()

func (*RequestMetadata) Reset

func (m *RequestMetadata) Reset()

func (*RequestMetadata) String

func (m *RequestMetadata) String() string

type ResponseMetadata

type ResponseMetadata struct {
	// 32-byte request ID that generated this response
	RequestId []byte `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
	// peer's ECDSA public key
	PubKey []byte `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`
}

func (*ResponseMetadata) Descriptor

func (*ResponseMetadata) Descriptor() ([]byte, []int)

func (*ResponseMetadata) GetPubKey

func (m *ResponseMetadata) GetPubKey() []byte

func (*ResponseMetadata) GetRequestId

func (m *ResponseMetadata) GetRequestId() []byte

func (*ResponseMetadata) ProtoMessage

func (*ResponseMetadata) ProtoMessage()

func (*ResponseMetadata) Reset

func (m *ResponseMetadata) Reset()

func (*ResponseMetadata) String

func (m *ResponseMetadata) String() string

type StoreRequest

type StoreRequest struct {
	Metadata *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// key to store value under
	Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	// value to store for key
	Value *Document `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"`
}

func (*StoreRequest) Descriptor

func (*StoreRequest) Descriptor() ([]byte, []int)

func (*StoreRequest) GetKey

func (m *StoreRequest) GetKey() []byte

func (*StoreRequest) GetMetadata

func (m *StoreRequest) GetMetadata() *RequestMetadata

func (*StoreRequest) GetValue

func (m *StoreRequest) GetValue() *Document

func (*StoreRequest) ProtoMessage

func (*StoreRequest) ProtoMessage()

func (*StoreRequest) Reset

func (m *StoreRequest) Reset()

func (*StoreRequest) String

func (m *StoreRequest) String() string

type StoreResponse

type StoreResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
}

func (*StoreResponse) Descriptor

func (*StoreResponse) Descriptor() ([]byte, []int)

func (*StoreResponse) GetMetadata

func (m *StoreResponse) GetMetadata() *ResponseMetadata

func (*StoreResponse) ProtoMessage

func (*StoreResponse) ProtoMessage()

func (*StoreResponse) Reset

func (m *StoreResponse) Reset()

func (*StoreResponse) String

func (m *StoreResponse) String() string

type Storer

type Storer interface {
	// Store stores a value in a given key.
	Store(ctx context.Context, in *StoreRequest, opts ...grpc.CallOption) (*StoreResponse,
		error)
}

Storer issues Store queries.

type SubscribeRequest

type SubscribeRequest struct {
	Metadata     *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	Subscription *Subscription    `protobuf:"bytes,2,opt,name=subscription" json:"subscription,omitempty"`
}

func (*SubscribeRequest) Descriptor

func (*SubscribeRequest) Descriptor() ([]byte, []int)

func (*SubscribeRequest) GetMetadata

func (m *SubscribeRequest) GetMetadata() *RequestMetadata

func (*SubscribeRequest) GetSubscription

func (m *SubscribeRequest) GetSubscription() *Subscription

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) Reset

func (m *SubscribeRequest) Reset()

func (*SubscribeRequest) String

func (m *SubscribeRequest) String() string

type SubscribeResponse

type SubscribeResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	Key      []byte            `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	Value    *Publication      `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"`
}

func (*SubscribeResponse) Descriptor

func (*SubscribeResponse) Descriptor() ([]byte, []int)

func (*SubscribeResponse) GetKey

func (m *SubscribeResponse) GetKey() []byte

func (*SubscribeResponse) GetMetadata

func (m *SubscribeResponse) GetMetadata() *ResponseMetadata

func (*SubscribeResponse) GetValue

func (m *SubscribeResponse) GetValue() *Publication

func (*SubscribeResponse) ProtoMessage

func (*SubscribeResponse) ProtoMessage()

func (*SubscribeResponse) Reset

func (m *SubscribeResponse) Reset()

func (*SubscribeResponse) String

func (m *SubscribeResponse) String() string

type Subscriber

type Subscriber interface {
	// Subscribe subscribes to a defined publication stream.
	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (
		Librarian_SubscribeClient, error)
}

Subscriber issues Subscribe queries.

type Subscription

type Subscription struct {
	AuthorPublicKeys *BloomFilter `protobuf:"bytes,1,opt,name=author_public_keys,json=authorPublicKeys" json:"author_public_keys,omitempty"`
	ReaderPublicKeys *BloomFilter `protobuf:"bytes,2,opt,name=reader_public_keys,json=readerPublicKeys" json:"reader_public_keys,omitempty"`
}

func (*Subscription) Descriptor

func (*Subscription) Descriptor() ([]byte, []int)

func (*Subscription) GetAuthorPublicKeys

func (m *Subscription) GetAuthorPublicKeys() *BloomFilter

func (*Subscription) GetReaderPublicKeys

func (m *Subscription) GetReaderPublicKeys() *BloomFilter

func (*Subscription) ProtoMessage

func (*Subscription) ProtoMessage()

func (*Subscription) Reset

func (m *Subscription) Reset()

func (*Subscription) String

func (m *Subscription) String() string

type Verifier

type Verifier interface {
	// Verify verifies that a peer has a given value.
	Verify(ctx context.Context, in *VerifyRequest, opts ...grpc.CallOption) (*VerifyResponse, error)
}

Verifier issues Verify queries.

type VerifyRequest

type VerifyRequest struct {
	Metadata *RequestMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// 32-byte key of document to verify
	Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	// 32-byte key to use in HMAC-256 verification
	MacKey []byte `protobuf:"bytes,3,opt,name=mac_key,json=macKey,proto3" json:"mac_key,omitempty"`
	// the number of closests peers to return
	NumPeers uint32 `protobuf:"varint,4,opt,name=num_peers,json=numPeers" json:"num_peers,omitempty"`
}

func (*VerifyRequest) Descriptor

func (*VerifyRequest) Descriptor() ([]byte, []int)

func (*VerifyRequest) GetKey

func (m *VerifyRequest) GetKey() []byte

func (*VerifyRequest) GetMacKey

func (m *VerifyRequest) GetMacKey() []byte

func (*VerifyRequest) GetMetadata

func (m *VerifyRequest) GetMetadata() *RequestMetadata

func (*VerifyRequest) GetNumPeers

func (m *VerifyRequest) GetNumPeers() uint32

func (*VerifyRequest) ProtoMessage

func (*VerifyRequest) ProtoMessage()

func (*VerifyRequest) Reset

func (m *VerifyRequest) Reset()

func (*VerifyRequest) String

func (m *VerifyRequest) String() string

type VerifyResponse

type VerifyResponse struct {
	Metadata *ResponseMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
	// nil if the peer does not have the document, otherwise the HMAC-256 of the document's
	// serialized bytes given the MAC key in the request
	Mac []byte `protobuf:"bytes,2,opt,name=mac,proto3" json:"mac,omitempty"`
	// list of peers closest to target
	Peers []*PeerAddress `protobuf:"bytes,3,rep,name=peers" json:"peers,omitempty"`
}

func (*VerifyResponse) Descriptor

func (*VerifyResponse) Descriptor() ([]byte, []int)

func (*VerifyResponse) GetMac

func (m *VerifyResponse) GetMac() []byte

func (*VerifyResponse) GetMetadata

func (m *VerifyResponse) GetMetadata() *ResponseMetadata

func (*VerifyResponse) GetPeers

func (m *VerifyResponse) GetPeers() []*PeerAddress

func (*VerifyResponse) ProtoMessage

func (*VerifyResponse) ProtoMessage()

func (*VerifyResponse) Reset

func (m *VerifyResponse) Reset()

func (*VerifyResponse) String

func (m *VerifyResponse) String() string

Jump to

Keyboard shortcuts

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