kat

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EdgeMsgs = [][]byte{
	{},
	make([]byte, 512),
	[]byte{0x00, 0x01, 0x02, 0x03, 0x04},
	bytesRepeat(0xff, 128),
	[]byte("The quick brown fox jumps over the lazy dog."),
	append([]byte{0x80}, make([]byte, 64)...),
	append(bytesRepeat(0xaa, 64), bytesRepeat(0x55, 64)...),
}

EdgeMsgs enumerates adversarial message patterns useful for stress testing.

Functions

func HashDeterministic

func HashDeterministic(parts ...[]byte) []byte

HashDeterministic computes a length-prefixed sha256 hash across each part, providing a stable synthetic primitive suitable for tests.

func Verify

func Verify(cases []Case, sign SignFunc, verify VerifyFunc) error

Verify executes a set of KAT cases using the supplied signing and verification functions. When a case does not provide a signature, the sign function is invoked to compute one.

Types

type Case

type Case struct {
	Message   []byte
	PublicKey []byte
	SecretKey []byte
	Signature []byte
	Meta      map[string]string
}

Case represents a single request/response test vector.

func Load

func Load(path string) ([]Case, error)

Load reads a simple req/rsp-like file and returns parsed cases. The format accepts key=value pairs per line, with "end" or a blank line delimiting cases. Lines beginning with "#" are treated as comments.

type SignFunc

type SignFunc func(pk, sk, msg []byte) ([]byte, error)

SignFunc produces a signature for the supplied message and key material.

type VerifyFunc

type VerifyFunc func(pk, msg, sig []byte) error

VerifyFunc validates a signature for the supplied public key and message. Implementations should return a non-nil error when verification fails.

Jump to

Keyboard shortcuts

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