Help us shape the future of Go! Take the 2026 Go Developer Survey

keychain

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: BSD-3-Clause Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKeyType = errors.New("invalid key type")
	ErrKeyNotFound    = errors.New("key not found")
)

Functions

This section is empty.

Types

type KeyType added in v1.16.16

type KeyType uint8

KeyType represents the type of cryptographic key

const (
	// Classical cryptography
	KeyTypeSecp256k1 KeyType = iota
	KeyTypeBLS               // BLS signatures for consensus

	// Post-quantum cryptography (NIST FIPS standards)
	KeyTypeMLDSA44   // FIPS 204 - ML-DSA-44
	KeyTypeMLDSA65   // FIPS 204 - ML-DSA-65
	KeyTypeMLDSA87   // FIPS 204 - ML-DSA-87
	KeyTypeSLHDSA128 // FIPS 205 - SLH-DSA-128
	KeyTypeSLHDSA192 // FIPS 205 - SLH-DSA-192
	KeyTypeSLHDSA256 // FIPS 205 - SLH-DSA-256

	// Key encapsulation (FIPS 203)
	KeyTypeMLKEM512  // ML-KEM-512
	KeyTypeMLKEM768  // ML-KEM-768
	KeyTypeMLKEM1024 // ML-KEM-1024

	// Privacy-preserving
	KeyTypeRingtail // Ring signatures

	// Hybrid modes (classical + post-quantum)
	KeyTypeHybridSecp256k1MLDSA44
	KeyTypeHybridSecp256k1SLHDSA128
	KeyTypeHybridBLSMLDSA44
)

type Keychain

type Keychain interface {
	Addresses() []ids.ShortID
	Get(ids.ShortID) (Signer, bool)
}

Keychain interface that wallet signers can use This allows both secp256k1fx.Keychain and ledger-lux-go/keychain.Keychain to be used Generic across chains, DAGs, and post-quantum crypto

type PQKeychain added in v1.16.16

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

PQKeychain implements Keychain with post-quantum support

func NewPQKeychain added in v1.16.16

func NewPQKeychain(defaultType KeyType) *PQKeychain

NewPQKeychain creates a new post-quantum keychain

func (*PQKeychain) AddHybrid added in v1.16.16

func (kc *PQKeychain) AddHybrid(classical *secp256k1.PrivateKey, pq interface{}) ids.ShortID

AddHybrid adds a hybrid classical+PQ key pair

func (*PQKeychain) AddMLDSA added in v1.16.16

func (kc *PQKeychain) AddMLDSA(key *mldsa.PrivateKey, keyType KeyType) ids.ShortID

AddMLDSA adds an ML-DSA key to the keychain

func (*PQKeychain) AddSLHDSA added in v1.16.16

func (kc *PQKeychain) AddSLHDSA(key *slhdsa.PrivateKey, keyType KeyType) ids.ShortID

AddSLHDSA adds an SLH-DSA key to the keychain

func (*PQKeychain) AddSecp256k1 added in v1.16.16

func (kc *PQKeychain) AddSecp256k1(key *secp256k1.PrivateKey) ids.ShortID

AddSecp256k1 adds a secp256k1 key to the keychain

func (*PQKeychain) Addresses added in v1.16.16

func (kc *PQKeychain) Addresses() []ids.ShortID

Addresses returns all addresses in the keychain

func (*PQKeychain) GenerateKey added in v1.16.16

func (kc *PQKeychain) GenerateKey() (ids.ShortID, error)

GenerateKey generates a new key of the default type

func (*PQKeychain) Get added in v1.16.16

func (kc *PQKeychain) Get(addr ids.ShortID) (Signer, bool)

Get returns the signer for the given address

func (*PQKeychain) GetPQSigner added in v1.16.16

func (kc *PQKeychain) GetPQSigner(addr ids.ShortID) (*PQSigner, bool)

GetPQSigner returns the PQ signer for advanced operations

func (*PQKeychain) SetDefaultType added in v1.16.16

func (kc *PQKeychain) SetDefaultType(keyType KeyType)

SetDefaultType sets the default key type for new keys

type PQSigner added in v1.16.16

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

PQSigner implements Signer with post-quantum support

func (*PQSigner) Address added in v1.16.16

func (s *PQSigner) Address() ids.ShortID

Address returns the address associated with this signer

func (*PQSigner) Sign added in v1.16.16

func (s *PQSigner) Sign(msg []byte) ([]byte, error)

Sign signs a message with the appropriate algorithm

func (*PQSigner) SignHash added in v1.16.16

func (s *PQSigner) SignHash(hash []byte) ([]byte, error)

SignHash signs a hash with the appropriate algorithm

type Signer

type Signer interface {
	SignHash([]byte) ([]byte, error)
	Sign([]byte) ([]byte, error)
	Address() ids.ShortID
}

Signer interface for signing operations Generic interface for all signing needs (classical and post-quantum)

Jump to

Keyboard shortcuts

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