pack

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBits is returned when a bit-width is out of the supported range.
	ErrInvalidBits = errors.New("pack: invalid bit width")
	// ErrOverflow is returned when a value does not fit within the requested width.
	ErrOverflow = errors.New("pack: value does not fit in requested bit width")
	// ErrInvalidLength is returned when the supplied byte slice is too short.
	ErrInvalidLength = errors.New("pack: input too short for requested unpack length")
)
View Source
var ErrInvalidHint = errors.New("pack: invalid hint encoding")

ErrInvalidHint indicates an invalid hint encoding.

Functions

func PackBits

func PackBits(vals []uint32, bits int) ([]byte, error)

PackBits packs the provided coefficients into a byte slice using the supplied bit width. Values must already be reduced to fit within the provided width.

func PackPolyCoeffs

func PackPolyCoeffs(p *poly.Poly, bits int) ([]byte, error)

PackPolyCoeffs encodes the polynomial coefficients into a bit-packed byte slice.

func UnpackBits

func UnpackBits(data []byte, bits int, count int) ([]uint32, error)

UnpackBits unpacks exactly count values from data, each encoded with the supplied bit width.

func UnpackHint added in v0.2.4

func UnpackHint(data []byte, omega int) ([]uint8, error)

UnpackHint decodes the hint vector h from the compressed representation used in ML-DSA. The encoding consists of omega indices followed by padding with 0xFF.

func UnpackPolyCoeffs

func UnpackPolyCoeffs(data []byte, bits int) (*poly.Poly, error)

UnpackPolyCoeffs decodes a bit-packed buffer into a polynomial, using the supplied bit width.

func UnpackPolyLeGamma1 added in v0.2.4

func UnpackPolyLeGamma1(data []byte, bits int) (*poly.Poly, error)

UnpackPolyLeGamma1 decodes a polynomial from the two's-complement centered representation used for z coefficients in ML-DSA. Each coefficient is stored as a signed little-endian integer with b bits (typically 18 or 20 depending on parameter set).

Types

This section is empty.

Jump to

Keyboard shortcuts

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