common

package
v0.0.66 Latest Latest
Warning

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

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

Documentation

Overview

Package common contains code that is useful to replicas and couriers.

Package common contains code that is useful to replicas and couriers.

Index

Constants

View Source
const (
	// K represents the number of shards per entry into the system.
	K = 2
)
View Source
const ReplicaEpochPeriod = 7 * (24 * time.Hour)

ReplicaEpochPeriod is the length of time of the Repica Epoch. Storage Replicas garbage collect their replica keys every Replica Epoch.

Variables

View Source
var MKEMNikeScheme = mkem.NewScheme(NikeScheme)
View Source
var NikeScheme nike.Scheme = schemes.ByName("CTIDH1024-X25519")

Functions

func ConvertNormalToReplicaEpoch

func ConvertNormalToReplicaEpoch(normalEpoch uint64) uint64

ConvertNormalToReplicaEpoch converts a 20-minute epoch number to a weekly replica epoch.

func GetRemoteShards

func GetRemoteShards(replicaIdPubKey sign.PublicKey, boxid *[32]byte, doc *pki.Document) ([]*pki.ReplicaDescriptor, error)

func GetReplicaKeys

func GetReplicaKeys(doc *pki.Document) ([][]byte, error)

func GetShards

func GetShards(boxid *[32]byte, doc *pki.Document) ([]*pki.ReplicaDescriptor, error)

func ReplicaNow

func ReplicaNow() (current uint64, elapsed, till time.Duration)

ReplicaNow returns the current Replica Epoch, time since the start of the current epoch, and time till the next epoch for a weekly epoch duration.

func ReplicaNum

func ReplicaNum(n uint8, doc *pki.Document) (*pki.ReplicaDescriptor, error)

func Shard

func Shard(boxID *[32]byte, serverIdKeys [][]byte) [][]byte

Shard is slower than Shard2. therefore use Shard2 instead.

func Shard2

func Shard2(boxID *[32]byte, serverIdKeys [][]byte) [][]byte

Shard2 implements our consistent hashing scheme for the sharded pigeonhole database where K is fixed to 2. It returns the first K`th entries from our sorted list of hashes where each hash is the hash of the boxID concatenated with the server ID key.

Types

type EnvelopeKey

type EnvelopeKey struct {
	PrivateKey nike.PrivateKey
	PublicKey  nike.PublicKey
}

EnvelopeKey encapsulates the public and private NIKE keys.

func EnvelopeKeyFromFiles

func EnvelopeKeyFromFiles(dataDir string, scheme nike.Scheme, epoch uint64) (*EnvelopeKey, error)

EnvelopeKeyFromFiles loads the PEM key files from disk.

func NewEnvelopeKey

func NewEnvelopeKey(scheme nike.Scheme) *EnvelopeKey

NewEnvelopeKey creates a new EnvelopeKey type.

func (*EnvelopeKey) KeyFileNames

func (e *EnvelopeKey) KeyFileNames(dataDir string, scheme nike.Scheme, epoch uint64) (string, string)

func (*EnvelopeKey) PurgeKeyFiles

func (e *EnvelopeKey) PurgeKeyFiles(dataDir string, scheme nike.Scheme, epoch uint64)

func (*EnvelopeKey) WriteKeyFiles

func (e *EnvelopeKey) WriteKeyFiles(dataDir string, scheme nike.Scheme, epoch uint64) error

type ReplicaMap

type ReplicaMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewReplicaMap

func NewReplicaMap() *ReplicaMap

func (*ReplicaMap) Copy

func (r *ReplicaMap) Copy() map[[32]byte]*pki.ReplicaDescriptor

func (*ReplicaMap) GetReplicaDescriptor

func (r *ReplicaMap) GetReplicaDescriptor(nodeID *[32]byte) (*pki.ReplicaDescriptor, bool)

func (*ReplicaMap) Replace

func (r *ReplicaMap) Replace(newMap map[[32]byte]*pki.ReplicaDescriptor)

func (*ReplicaMap) UpdateFromPKIDoc

func (r *ReplicaMap) UpdateFromPKIDoc(doc *pki.Document)

Jump to

Keyboard shortcuts

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