masacrypto

package
v0.0.11-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSelfSignedCert

func GenerateSelfSignedCert(certPath, keyPath string) error

GenerateSelfSignedCert generates a self-signed X.509 certificate and private key, saving them to the provided file paths.

It generates a new ECDSA P-256 private key. It sets the certificate fields like validity period, subject, extensions etc. based on best practices. Finally, it encodes the certificate and private key in PEM format and saves them to the provided file paths.

func Libp2pPubKeyToEthAddress

func Libp2pPubKeyToEthAddress(pubKey crypto.PubKey) (string, error)

Types

type KeyManager

type KeyManager struct {
	Libp2pPrivKey crypto.PrivKey    // Libp2p private key
	Libp2pPubKey  crypto.PubKey     // Libp2p public key
	EcdsaPrivKey  *ecdsa.PrivateKey // ECDSA private key
	EcdsaPubKey   *ecdsa.PublicKey  // ECDSA public key
	HexPrivKey    string            // Hex-encoded private key
	HexPubKey     string            // Hex-encoded public key
	EthAddress    string            // Ethereum format address
}

KeyManager holds all the cryptographic entities used in the application.

func KeyManagerInstance

func KeyManagerInstance() *KeyManager

KeyManagerInstance returns the singleton instance of KeyManager, initializing it if necessary.

Jump to

Keyboard shortcuts

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