stream

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: EPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvenCountForRange

func EvenCountForRange(startIdx, n int) int

EvenCountForRange returns even-stream bytes needed for n plaintext bytes at startIdx.

func EverySecondByte

func EverySecondByte(chunk []byte, startIdx int) []byte

EverySecondByte returns every second byte of chunk starting at startIdx.

func MaxReadable

func MaxReadable(evenAvail, oddAvail, startIdx, want int) int

MaxReadable returns the largest n <= want where even/odd streams have enough bytes.

func MergeInterleaved

func MergeInterleaved(even, odd []byte, startIdx, n int) []byte

MergeInterleaved reconstructs n plaintext bytes from even/odd particle chunks.

func MergeInterleavedInto

func MergeInterleavedInto(even, odd []byte, startIdx int, dst []byte)

MergeInterleavedInto writes reconstructed bytes into dst[:n].

func ReconstructCollect

func ReconstructCollect(partner, parity []byte, role RecoverRole, oddLength bool) ([]byte, error)

ReconstructCollect reads partner+parity fully and returns synthesized core bytes (tests).

func SplitStartIndices

func SplitStartIndices(globalByteIndex int) (startEven, startOdd int)

SplitStartIndices returns even/odd start indices for a chunk at globalByteIndex.

Types

type DecodeMeta

type DecodeMeta struct {
	SHA256    [32]byte
	Footers   map[pcs.ParticleKind]*footer.Footer
	BytesRead int64
}

DecodeMeta captures streaming decode metadata.

func DecodeCollect

func DecodeCollect(particles map[pcs.ParticleKind][]byte) ([]byte, *DecodeMeta, error)

DecodeCollect is a test helper that decodes in-memory particle+footer blobs.

type DecodeOptions

type DecodeOptions struct {
	StartOffset int64
}

DecodeOptions controls offset for streaming range reads.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder reconstructs a document from six particle sources.

func NewDecoder

func NewDecoder(chunkSize int) *Decoder

NewDecoder creates a decoder with the given chunk size.

func (*Decoder) Decode

func (d *Decoder) Decode(sources Sources, out io.Writer, opts DecodeOptions) (*DecodeMeta, error)

Decode reconstructs secret from six sources, verifying footers at end.

type EncodeMeta

type EncodeMeta struct {
	SHA256         [32]byte
	Fingerprint    *pcs.EncodeResult
	Footers        map[pcs.ParticleKind]*footer.Footer
	BytesProcessed int64
}

EncodeMeta captures streaming encode metadata.

func EncodeCollect

func EncodeCollect(secret, noise []byte, chunkSize int) (map[pcs.ParticleKind][]byte, *EncodeMeta, error)

EncodeCollect runs streaming encode into memory buffers (tests).

type EncodeOptions

type EncodeOptions struct {
	WriteID uint64
	Mtime   time.Time
}

EncodeOptions controls footer fields stamped during streaming encode.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder streams PCS encode from a document reader to six particle writers.

func NewEncoder

func NewEncoder(chunkSize int) *Encoder

NewEncoder creates an encoder with cryptographically random noise.

func NewEncoderWithNoise

func NewEncoderWithNoise(chunkSize int, noise io.Reader) *Encoder

NewEncoderWithNoise creates an encoder with deterministic noise (tests).

func (*Encoder) Encode

func (e *Encoder) Encode(secret io.Reader, outs Writers, opts EncodeOptions) (*EncodeMeta, error)

Encode writes payloads and appends six v1 footers at EOF.

type RecoverRole

type RecoverRole int

RecoverRole selects which core stream is synthesized from partner + parity.

const (
	RecoverEven RecoverRole = iota
	RecoverOdd
)

type Source

type Source struct {
	R          io.Reader
	PayloadLen int64 // -1 when missing/unknown
}

Source is one particle input stream with a known payload length.

type Sources

type Sources struct {
	EC, OC, EN, ON, CP, NP Source
}

Sources holds six particle sources.

type Writers

type Writers struct {
	EC, OC, EN, ON, CP, NP io.Writer
}

Writers holds six particle output streams in protocol order.

Jump to

Keyboard shortcuts

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