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
- Variables
- func Cksm(coefs []uint8, w ByteWindow, LS uint64) uint16
- func Coefs(x []byte, w ByteWindow) []uint8
- func Expand(msg []byte, mode LmsOtsAlgorithmType) ([]uint8, error)
- func Uint32ToLmsType(x uint32) lms_type_code
- type ByteWindow
- type Hasher
- type ID
- type LmsAlgorithmType
- type LmsOtsAlgorithmType
- type LmsOtsParam
- type LmsParam
- type Sha256Hasher
Constants ¶
const ( WINDOW_W1 window = 1 << iota WINDOW_W2 WINDOW_W4 WINDOW_W8 )
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 )
const ID_LEN uint64 = 16
Variables ¶
var D_INTR = [2]uint8{0x83, 0x83}
var D_LEAF = [2]uint8{0x82, 0x82}
var D_MESG = [2]uint8{0x81, 0x81}
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 LmsAlgorithmType ¶
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