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
- Variables
- func ConvertNormalToReplicaEpoch(normalEpoch uint64) uint64
- func GetConfiguredReplicaKeys(doc *pki.Document) ([][]byte, error)
- func GetRemoteShards(replicaIdPubKey sign.PublicKey, boxid *[32]byte, doc *pki.Document) ([]*pki.ReplicaDescriptor, error)
- func GetShards(boxid *[32]byte, doc *pki.Document) ([]*pki.ReplicaDescriptor, error)
- func ReplicaNow() (current uint64, elapsed, till time.Duration)
- func ReplicaNum(replicaID uint8, doc *pki.Document) (*pki.ReplicaDescriptor, error)
- func Shard(boxID *[32]byte, serverIdKeys [][]byte) [][]byte
- func Shard2(boxID *[32]byte, serverIdKeys [][]byte) [][]byte
- type EnvelopeKey
- type ReplicaMap
Constants ¶
const (
// K represents the number of shards per entry into the system.
K = 2
)
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 ¶
var MKEMNikeScheme = mkem.NewScheme(NikeScheme)
var NikeScheme nike.Scheme = schemes.ByName("CTIDH1024-X25519")
Functions ¶
func ConvertNormalToReplicaEpoch ¶
ConvertNormalToReplicaEpoch converts a 20-minute epoch number to a weekly replica epoch.
func GetConfiguredReplicaKeys ¶ added in v0.0.73
GetConfiguredReplicaKeys returns the stable set of replica identity keys from the authority configuration. This set does NOT change when replicas go offline, ensuring consistent sharding.
func GetRemoteShards ¶
func GetShards ¶
GetShards returns the ReplicaDescriptors for the replicas that should store data for a boxID. Uses the stable ConfiguredReplicaIdentityKeys for consistent sharding. Only returns descriptors for replicas that are currently online (present in StorageReplicas). The returned slice may have fewer than K elements if some shard replicas are offline.
func ReplicaNow ¶
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 ¶
ReplicaNum looks up a replica by its static ReplicaID. The replicaID parameter is the static uint8 identifier assigned to a replica, not an array index into StorageReplicas.
Types ¶
type EnvelopeKey ¶
type EnvelopeKey struct {
PrivateKey nike.PrivateKey
PublicKey nike.PublicKey
}
EnvelopeKey encapsulates the public and private NIKE keys.
func EnvelopeKeyFromFiles ¶
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 (*EnvelopeKey) PurgeKeyFiles ¶
func (e *EnvelopeKey) PurgeKeyFiles(dataDir string, scheme nike.Scheme, epoch uint64)
func (*EnvelopeKey) WriteKeyFiles ¶
WriteKeyFiles generates and writes new key files, or loads existing ones if they already exist. This ensures that a replica can safely restart or re-publish for the same epoch without errors.
type ReplicaMap ¶
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)