Documentation
¶
Index ¶
- Constants
- Variables
- func AllShardKeys(logicalKey string) map[ParticleKind]string
- func CRC32IEEE(data []byte) uint32
- func DecodeFingerprint(present map[ParticleKind]bool, shards map[ParticleKind][]byte) ([32]byte, error)
- func DecodeFromParticles(evenCypher, oddCypher, evenNoise, oddNoise []byte) ([]byte, error)
- func DecodeWithRecovery(inv *ParticleInventory, particles map[ParticleKind][]byte, logicalSize int64) ([]byte, bool, error)
- func Decrypt(cypher, noise []byte) ([]byte, error)
- func EncodeResultShard(r *EncodeResult, kind ParticleKind) []byte
- func Encrypt(secret, noise []byte) []byte
- func IsParticleShard(key string) bool
- func Merge(even, odd []byte) []byte
- func ParityPadded(even, odd []byte) []byte
- func ParticleSuffix(kind ParticleKind) string
- func RandomNoise(n int) ([]byte, error)
- func ReconstructEvenFromParityOdd(haveOdd, parity []byte) ([]byte, error)
- func ReconstructFromParityEven(have, parity []byte) ([]byte, error)
- func ReconstructOddFromParityOdd(haveEven, parity []byte) ([]byte, error)
- func RecoverAllFingerprintShards(present map[ParticleKind]bool, shards map[ParticleKind][]byte) (map[ParticleKind][]byte, error)
- func RecoverCoreParticlesInto(inv *ParticleInventory, data map[ParticleKind][]byte, logicalSize int64) error
- func ShardKey(logicalKey string, kind ParticleKind) string
- func Split(text []byte) ([]byte, []byte)
- func StorageForParticle(kind ParticleKind) string
- type EncodeResult
- type ParticleInventory
- type ParticleKind
Constants ¶
const ( StorageA = "storageA" StorageB = "storageB" StorageC = "storageC" )
Logical storage roles.
Variables ¶
var ( // AllParticleKinds lists all six particle kinds in stable order. AllParticleKinds = []ParticleKind{ EvenCypher, OddCypher, EvenNoise, OddNoise, CypherParity, NoiseParity, } // CoreParticleKinds are the four payload-determining particles. CoreParticleKinds = []ParticleKind{EvenCypher, OddCypher, EvenNoise, OddNoise} )
Functions ¶
func AllShardKeys ¶
func AllShardKeys(logicalKey string) map[ParticleKind]string
AllShardKeys returns all six shard keys for a logical object key.
func DecodeFingerprint ¶
func DecodeFingerprint(present map[ParticleKind]bool, shards map[ParticleKind][]byte) ([32]byte, error)
DecodeFingerprint reconstructs the digest from six fingerprint shard blobs.
func DecodeFromParticles ¶
DecodeFromParticles reconstructs the original secret from four core particles.
func DecodeWithRecovery ¶
func DecodeWithRecovery(inv *ParticleInventory, particles map[ParticleKind][]byte, logicalSize int64) ([]byte, bool, error)
DecodeWithRecovery reconstructs the secret using parity when cores are missing.
func EncodeResultShard ¶
func EncodeResultShard(r *EncodeResult, kind ParticleKind) []byte
EncodeResultShard returns the particle bytes for kind from an encode result.
func IsParticleShard ¶
IsParticleShard reports whether key ends with a known particle suffix.
func ParityPadded ¶
ParityPadded computes XOR parity with odd-length tail handling.
func ParticleSuffix ¶
func ParticleSuffix(kind ParticleKind) string
ParticleSuffix returns the unified particle suffix for kind.
func RandomNoise ¶
RandomNoise returns n cryptographically secure random bytes.
func ReconstructEvenFromParityOdd ¶
ReconstructEvenFromParityOdd rebuilds the even particle from odd + parity (odd original length).
func ReconstructFromParityEven ¶
ReconstructFromParityEven rebuilds the missing partner when both particles are equal length.
func ReconstructOddFromParityOdd ¶
ReconstructOddFromParityOdd rebuilds the odd particle from even + parity (odd original length).
func RecoverAllFingerprintShards ¶
func RecoverAllFingerprintShards(present map[ParticleKind]bool, shards map[ParticleKind][]byte) (map[ParticleKind][]byte, error)
RecoverAllFingerprintShards recovers missing fingerprint shards via parity math.
func RecoverCoreParticlesInto ¶
func RecoverCoreParticlesInto(inv *ParticleInventory, data map[ParticleKind][]byte, logicalSize int64) error
RecoverCoreParticlesInto fills missing core particles using parity shards.
func ShardKey ¶
func ShardKey(logicalKey string, kind ParticleKind) string
ShardKey returns the full shard key for a logical key and particle kind.
func StorageForParticle ¶
func StorageForParticle(kind ParticleKind) string
StorageForParticle returns the storage role that holds the given particle.
Types ¶
type EncodeResult ¶
type EncodeResult struct {
EvenCypher []byte
OddCypher []byte
EvenNoise []byte
OddNoise []byte
CypherParity []byte
NoiseParity []byte
}
EncodeResult holds the six particle payloads from a PCS encode.
func Encode ¶
func Encode(secret []byte) (*EncodeResult, error)
Encode generates random noise and PCS-encodes secret.
func EncodeFingerprint ¶
func EncodeFingerprint(digest [32]byte) (*EncodeResult, error)
EncodeFingerprint PCS-encodes a 32-byte SHA-256 digest.
func EncodeWithNoise ¶
func EncodeWithNoise(secret, noise []byte) (*EncodeResult, error)
EncodeWithNoise runs the PCS encode pipeline with caller-supplied noise.
type ParticleInventory ¶
type ParticleInventory struct {
Present map[ParticleKind]bool
}
ParticleInventory tracks which particles are present for one logical object.
func InventoryFromPresent ¶
func InventoryFromPresent(present map[ParticleKind]bool) (*ParticleInventory, error)
InventoryFromPresent builds an inventory from remote presence information.
func NewParticleInventory ¶
func NewParticleInventory(present map[ParticleKind]bool) *ParticleInventory
NewParticleInventory builds an inventory from a presence map.
func (*ParticleInventory) MissingCoreParticles ¶
func (inv *ParticleInventory) MissingCoreParticles() []ParticleKind
func (*ParticleInventory) NeedsParityRecovery ¶
func (inv *ParticleInventory) NeedsParityRecovery() bool
type ParticleKind ¶
type ParticleKind int
ParticleKind identifies one of the six particles in footer order.
const ( EvenCypher ParticleKind = iota OddCypher EvenNoise OddNoise CypherParity NoiseParity )
func LogicalKeyFromShard ¶
func LogicalKeyFromShard(shardKey string) (logicalKey string, kind ParticleKind, ok bool)
LogicalKeyFromShard strips a known particle suffix and returns the logical key.
func (ParticleKind) String ¶
func (k ParticleKind) String() string