lamport

package
v1.17.28 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SHA256 parameters
	SHA256HashSize = 32
	SHA256KeySize  = 256 * 2 * SHA256HashSize // 256 bits * 2 (for 0 and 1) * hash size
	SHA256SigSize  = 256 * SHA256HashSize     // 256 bits * hash size

	// SHA512 parameters
	SHA512HashSize = 64
	SHA512KeySize  = 512 * 2 * SHA512HashSize
	SHA512SigSize  = 512 * SHA512HashSize
)

Parameters for Lamport signatures

Variables

This section is empty.

Functions

func GetPublicKeySize

func GetPublicKeySize(hashFunc HashFunc) int

GetPublicKeySize returns the size of a public key for the given hash function

func GetSignatureSize

func GetSignatureSize(hashFunc HashFunc) int

GetSignatureSize returns the size of a signature for the given hash function

Types

type HashFunc

type HashFunc int

HashFunc represents the hash function to use

const (
	SHA256 HashFunc = iota
	SHA512
	SHA3_256
	SHA3_512
)

type PrivateKey

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

PrivateKey represents a Lamport private key

func GenerateKey

func GenerateKey(rng io.Reader, hashFunc HashFunc) (*PrivateKey, error)

GenerateKey generates a new Lamport keypair

func (*PrivateKey) Public

func (priv *PrivateKey) Public() *PublicKey

Public returns the public key corresponding to this private key

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(message []byte) (*Signature, error)

Sign creates a Lamport signature for the given message IMPORTANT: Each private key can only be used ONCE

func (*PrivateKey) SignHash added in v1.3.0

func (priv *PrivateKey) SignHash(msgHash []byte) (*Signature, error)

SignHash creates a signature for the given message hash WARNING: The message must already be hashed with the appropriate hash function IMPORTANT: Each private key can only be used ONCE

type PublicKey

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

PublicKey represents a Lamport public key

func PublicKeyFromBytes

func PublicKeyFromBytes(data []byte) (*PublicKey, error)

PublicKeyFromBytes deserializes a public key

func (*PublicKey) Bytes

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

Bytes serializes the public key

func (*PublicKey) Verify

func (pub *PublicKey) Verify(message []byte, sig *Signature) bool

Verify checks if a signature is valid for the given message

func (*PublicKey) VerifyHash added in v1.3.0

func (pub *PublicKey) VerifyHash(msgHash []byte, sig *Signature) bool

VerifyHash checks if a signature is valid for the given message hash

type Signature

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

Signature represents a Lamport signature

func SignatureFromBytes

func SignatureFromBytes(data []byte) (*Signature, error)

SignatureFromBytes deserializes a signature

func (*Signature) Bytes

func (sig *Signature) Bytes() []byte

Bytes serializes the signature

Jump to

Keyboard shortcuts

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