slhdsa

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressTypeWOTSHash addressType = iota
	AddressTypeWOTSPK
	AddressTypeTree
	AddressTypeFORSTree
	AddressTypeFORSRoots
	AddressTypeWOTSPRF
	AddressTypeFORSPRF
)

Variables

View Source
var (
	SLHDSA128SmallSHA2 = params{
						// contains filtered or unexported fields
	}
	SLHDSA128SmallSM3 = params{
						// contains filtered or unexported fields
	}
	SLHDSA128SmallSHAKE = params{
						// contains filtered or unexported fields
	}
	SLHDSA128FastSHA2 = params{
						// contains filtered or unexported fields
	}
	SLHDSA128FastSM3 = params{
						// contains filtered or unexported fields
	}
	SLHDSA128FastSHAKE = params{
						// contains filtered or unexported fields
	}
	SLHDSA192SmallSHA2 = params{
						// contains filtered or unexported fields
	}
	SLHDSA192SmallSHAKE = params{
						// contains filtered or unexported fields
	}
	SLHDSA192FastSHA2 = params{
						// contains filtered or unexported fields
	}
	SLHDSA192FastSHAKE = params{
						// contains filtered or unexported fields
	}
	SLHDSA256SmallSHA2 = params{
						// contains filtered or unexported fields
	}
	SLHDSA256SmallSHAKE = params{
						// contains filtered or unexported fields
	}
	SLHDSA256FastSHA2 = params{
						// contains filtered or unexported fields
	}
	SLHDSA256FastSHAKE = params{
						// contains filtered or unexported fields
	}
)

sigLen = (1+k*(1+a)+d*(hm+len))*n

Functions

func GetParameterSet

func GetParameterSet(name string) (*params, bool)

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	// contains filtered or unexported fields
}

func GenerateKey

func GenerateKey(rand io.Reader, params *params) (*PrivateKey, error)

GenerateKey generates a new private key based on the provided parameters. It initializes the key structure, fills the necessary fields with provided entropy, and computes the root node for the XMSS tree.

func NewPrivateKey

func NewPrivateKey(bytes []byte, params *params) (*PrivateKey, error)

NewPrivateKey creates a new PrivateKey instance from the provided priv.seed||priv.prf||pub.seed||pub.root and parameters. The function validates the length of the input byte slice and initializes the PrivateKey structure, including its PublicKey field. It also verifies the integrity of the key by comparing the root hash with the expected value. If any validation or initialization step fails, an error is returned.

func (*PrivateKey) Bytes

func (sk *PrivateKey) Bytes() []byte

Bytes serializes the PrivateKey into a byte slice.

func (*PrivateKey) Equal

func (sk *PrivateKey) Equal(x any) bool

func (*PrivateKey) Public

func (sk *PrivateKey) Public() *PublicKey

Public returns the public key of the private key.

func (*PrivateKey) Sign

func (sk *PrivateKey) Sign(message, context, addRand []byte) ([]byte, error)

Sign generates a pure SLH-DSA signature for the given message. The signature is deterministic if the addRand parameter is nil. If addRand is not nil, it must be of the same length as n.

See FIPS 205 Algorithm 22 slh_sign

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func NewPublicKey

func NewPublicKey(bytes []byte, params *params) (*PublicKey, error)

NewPublicKey creates a new PublicKey instance from the provided seed||root and parameters. Note this method can NOT verify the validity of the public key.

func (*PublicKey) Bytes

func (pk *PublicKey) Bytes() []byte

Bytes returns the byte representation of the PublicKey. It combines the seed and root fields of the PublicKey.

func (*PublicKey) Equal

func (pk *PublicKey) Equal(x any) bool

func (*PublicKey) Verify

func (pk *PublicKey) Verify(signature, message, context []byte) bool

Verify verifies a pure SLH-DSA signature for the given message.

See FIPS 205 Algorithm 24 slh_verify

Jump to

Keyboard shortcuts

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