sign

package
v1.17.17 Latest Latest
Warning

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

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

Documentation

Overview

Package sign provides post-quantum signature algorithms

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyTranscript

func VerifyTranscript(signer Signer, pk PublicKey, transcript, signature []byte) bool

VerifyTranscript verifies a transcript signature

Types

type MLDSA2Impl

type MLDSA2Impl struct{}

MLDSA2Impl implements ML-DSA-44 (Dilithium2)

func (*MLDSA2Impl) GenerateKeyPair

func (m *MLDSA2Impl) GenerateKeyPair() (PublicKey, PrivateKey, error)

GenerateKeyPair generates a new ML-DSA-44 key pair

func (*MLDSA2Impl) PrivateKeySize

func (m *MLDSA2Impl) PrivateKeySize() int

func (*MLDSA2Impl) PublicKeySize

func (m *MLDSA2Impl) PublicKeySize() int

Size methods for ML-DSA-44

func (*MLDSA2Impl) Sign

func (m *MLDSA2Impl) Sign(sk PrivateKey, message []byte) ([]byte, error)

Sign creates a signature

func (*MLDSA2Impl) SignatureSize

func (m *MLDSA2Impl) SignatureSize() int

func (*MLDSA2Impl) Verify

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

Verify verifies a signature

type MLDSA2PrivateKey

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

MLDSA2PrivateKey represents an ML-DSA-44 private key

func (*MLDSA2PrivateKey) Bytes

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

PrivateKey methods

func (*MLDSA2PrivateKey) Equal

func (sk *MLDSA2PrivateKey) Equal(other PrivateKey) bool

func (*MLDSA2PrivateKey) Public

func (sk *MLDSA2PrivateKey) Public() PublicKey

type MLDSA2PublicKey

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

MLDSA2PublicKey represents an ML-DSA-44 public key

func (*MLDSA2PublicKey) Bytes

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

PublicKey methods

func (*MLDSA2PublicKey) Equal

func (pk *MLDSA2PublicKey) Equal(other PublicKey) bool

type MLDSA3Impl

type MLDSA3Impl struct{}

MLDSA3Impl implements ML-DSA-65 (Dilithium3)

func (*MLDSA3Impl) GenerateKeyPair

func (m *MLDSA3Impl) GenerateKeyPair() (PublicKey, PrivateKey, error)

GenerateKeyPair generates a new ML-DSA-65 key pair

func (*MLDSA3Impl) PrivateKeySize

func (m *MLDSA3Impl) PrivateKeySize() int

func (*MLDSA3Impl) PublicKeySize

func (m *MLDSA3Impl) PublicKeySize() int

Size methods for ML-DSA-65

func (*MLDSA3Impl) Sign

func (m *MLDSA3Impl) Sign(sk PrivateKey, message []byte) ([]byte, error)

Sign creates a signature

func (*MLDSA3Impl) SignatureSize

func (m *MLDSA3Impl) SignatureSize() int

func (*MLDSA3Impl) Verify

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

Verify verifies a signature

type PrivateKey

type PrivateKey interface {
	Bytes() []byte
	Public() PublicKey
	Equal(PrivateKey) bool
}

PrivateKey represents a signature private key

type PublicKey

type PublicKey interface {
	Bytes() []byte
	Equal(PublicKey) bool
}

PublicKey represents a signature public key

type SigID

type SigID string

SigID identifies a signature algorithm

const (
	MLDSA2 SigID = "mldsa2"
	MLDSA3 SigID = "mldsa3"
	SLHDSA SigID = "slhdsa"
)

type Signer

type Signer interface {
	// GenerateKeyPair generates a new signing key pair
	GenerateKeyPair() (PublicKey, PrivateKey, error)

	// Sign creates a signature
	Sign(sk PrivateKey, message []byte) ([]byte, error)

	// Verify verifies a signature
	Verify(pk PublicKey, message, signature []byte) bool

	// PublicKeySize returns the size of public keys
	PublicKeySize() int

	// PrivateKeySize returns the size of private keys
	PrivateKeySize() int

	// SignatureSize returns the size of signatures
	SignatureSize() int
}

Signer interface for signature algorithms

func GetSigner

func GetSigner(id SigID) (Signer, error)

GetSigner returns a Signer implementation for the given ID

func NewMLDSA2

func NewMLDSA2() Signer

NewMLDSA2 creates a new ML-DSA-44 instance

func NewMLDSA3

func NewMLDSA3() Signer

NewMLDSA3 creates a new ML-DSA-65 instance

type TranscriptSigner

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

TranscriptSigner signs protocol transcripts

func NewTranscriptSigner

func NewTranscriptSigner(signer Signer, sk PrivateKey) *TranscriptSigner

NewTranscriptSigner creates a new transcript signer

func (*TranscriptSigner) SignTranscript

func (ts *TranscriptSigner) SignTranscript(transcript []byte) ([]byte, error)

SignTranscript signs a protocol transcript

Jump to

Keyboard shortcuts

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