common

package
v0.0.0-...-21b5147 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package common contains some data types and utilities used throughout the lms and ots packages.

This file defines values that should be treated as constants.

Package common contains some data types and utilities used throughout the lms and ots packages.

This file includes some utility functions.

Index

Constants

View Source
const (
	WINDOW_W1 window = 1 << iota
	WINDOW_W2
	WINDOW_W4
	WINDOW_W8
)
View Source
const (
	LMS_RESERVED lms_type_code = iota
	LMOTS_SHA256_N32_W1
	LMOTS_SHA256_N32_W2
	LMOTS_SHA256_N32_W4
	LMOTS_SHA256_N32_W8
	LMS_SHA256_M32_H5
	LMS_SHA256_M32_H10
	LMS_SHA256_M32_H15
	LMS_SHA256_M32_H20
	LMS_SHA256_M32_H25
)
View Source
const ID_LEN uint64 = 16

Variables

View Source
var D_INTR = [2]uint8{0x83, 0x83}
View Source
var D_LEAF = [2]uint8{0x82, 0x82}
View Source
var D_MESG = [2]uint8{0x81, 0x81}
View Source
var D_PBLC = [2]uint8{0x80, 0x80}

arrays cannot be constant in go please never change these values

Functions

func Cksm

func Cksm(coefs []uint8, w ByteWindow, LS uint64) uint16

Returns a checksum calculated over a slice of Winternitz coefficients

func Coefs

func Coefs(x []byte, w ByteWindow) []uint8

Returns a []byte representing the Winternitz coefficients of x for a given window, w

func Expand

func Expand(msg []byte, mode LmsOtsAlgorithmType) ([]uint8, error)

expands a message into the winternitz coefficients of the message and its checksum returns a slice of length P

func Uint32ToLmsType

func Uint32ToLmsType(x uint32) lms_type_code

Returns a lms_type_code, given a uint32 of the same value

Types

type ByteWindow

type ByteWindow interface {
	Window() window
	Mask() uint8
}

ByteWindow is the representation of bytes used in calculating LM-OTS signatures

type Hasher

type Hasher interface {
	New() hash.Hash
}

Hasher represents a streaming hash function

type ID

type ID [ID_LEN]byte

ID is a fixed-legnth []byte used in LM-OTS and LM-OTS

type LmsAlgorithmType

type LmsAlgorithmType interface {
	LmsType() (lms_type_code, error)
	LmsParams() (LmsParam, error)
}

LmsAlgorithmType represents a specific instance of LMS

type LmsOtsAlgorithmType

type LmsOtsAlgorithmType interface {
	LmsOtsType() (lms_type_code, error)
	Params() (LmsOtsParam, error)
}

LmsOtsAlgorithmType represents a specific instance of LM-OTS

type LmsOtsParam

type LmsOtsParam struct {
	H       Hasher     // Used for hashing
	N       uint64     // number of bytes of the output of H
	W       ByteWindow // width (in bits) of Winternitz coefficients
	P       uint64     // number of N-byte elements that make up the signature
	LS      uint64     // left-shift used in checksum calculation
	SIG_LEN uint64     // total byte length for a valid signature
}

type LmsParam

type LmsParam struct {
	Hash Hasher // Used to return an instance of a hash function in streaming mode
	M    uint64 // number of bytes associated with each node
	H    uint64 // height of the tree
}

LmsParam represents the parameters for a given instance of the LMS algorithm

type Sha256Hasher

type Sha256Hasher struct{}

func (Sha256Hasher) New

func (_ Sha256Hasher) New() hash.Hash

Jump to

Keyboard shortcuts

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