fit

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package fit holds closed-form byte-function fitters over Z/256: given observed (input → output) byte pairs, find the affine coefficients that best explain them and report how many observations conflict. A zero-conflict fit means the data follows that closed form; a nonzero floor is the toolkit's evidence that no such low-degree form exists (the signature of a hidden table).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Affine1

type Affine1 struct {
	A, B      uint8
	Conflicts int
}

Affine1 is the best affine model Y = A·X + B (mod 256) for the data, together with the count of observations it fails to reproduce.

func FitAffine1

func FitAffine1(obs []Obs1, requireOddA bool) Affine1

FitAffine1 returns the affine model minimizing conflicts. It is exact and fast: for each of the 256 candidate slopes A, the intercept is forced by the first observation and the rest are checked. RequireOddA restricts the slope to invertible (odd) multipliers — the regime the alias keystream fit lives in.

type Affine2

type Affine2 struct {
	A, B, C   uint8
	Conflicts int
}

Affine2 is the best affine model Z = A·X + B·Y + C (mod 256).

func FitAffine2

func FitAffine2(obs []Obs2) Affine2

FitAffine2 fits Z = A·X + B·Y + C by brute-forcing the slope A and reducing the remainder to a one-input affine fit in Y. Cost is O(256·256·N); intended for bounded observation sets (callers subsample for the full 32,768-gauge sweep and log the cap).

type Obs1

type Obs1 struct{ X, Y uint8 }

Obs1 is one observation of a one-input byte function: Y = f(X).

type Obs2

type Obs2 struct{ X, Y, Z uint8 }

Obs2 is one observation of a two-input byte function: Z = f(X, Y).

Jump to

Keyboard shortcuts

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