crypto

package
v1.8.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	// NewSigner creates a new signer from a private key
	NewSigner(scheme SignatureScheme, privateKey []byte) (Signer, error)

	// NewSignerFromSeed creates a signer from a seed
	NewSignerFromSeed(scheme SignatureScheme, seed []byte) (Signer, error)

	// GenerateKey generates a new private key
	GenerateKey(scheme SignatureScheme) (privateKey []byte, err error)
}

Factory creates signers for different schemes

func NewFactory

func NewFactory() Factory

NewFactory creates a new crypto factory

type KeyManager

type KeyManager interface {
	// DeriveKey derives a key using BIP32/BIP44 path
	DeriveKey(path string) ([]byte, error)

	// SupportsScheme checks if the key manager supports the scheme
	SupportsScheme(scheme SignatureScheme) bool
}

KeyManager handles key derivation and storage

type SignatureScheme

type SignatureScheme uint8

SignatureScheme represents the type of cryptographic signature scheme

const (
	// Classic cryptography
	SECP256K1 SignatureScheme = iota
	SECP256R1
	BLS

	// Post-quantum cryptography (NIST standards)
	MLDSA87   // ML-DSA-87 (Dilithium5 equivalent)
	MLDSA65   // ML-DSA-65 (Dilithium3 equivalent)
	MLDSA44   // ML-DSA-44 (Dilithium2 equivalent)
	SLHDSA256 // SLH-DSA-256 (SPHINCS+ equivalent)
	SLHDSA192 // SLH-DSA-192
	SLHDSA128 // SLH-DSA-128

	// Hybrid schemes (classic + PQC)
	SECP256K1_MLDSA87 // secp256k1 + ML-DSA-87
	BLS_MLDSA87       // BLS + ML-DSA-87
)

type Signer

type Signer interface {
	// Sign signs the message with the private key
	Sign(msg []byte) ([]byte, error)

	// PublicKey returns the public key
	PublicKey() []byte

	// Address returns the address derived from the public key
	Address() ids.ShortID

	// Scheme returns the signature scheme used
	Scheme() SignatureScheme

	// Verify verifies a signature
	Verify(msg, sig []byte) bool
}

Signer represents a unified interface for signing transactions across all chains (P, X, C, EVM) with both classic and PQC support

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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