Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeSha256Cid ¶ added in v0.6.0
ComputeSha256Cid calculates the CID (Content Identifier) for a given string.
Parameters:
- str: The input string for which to compute the CID.
Returns:
- string: The computed CID as a string.
- error: An error, if any occurred during the CID computation.
The function uses the multihash package to create a SHA2-256 hash of the input string. It then creates a CID (version 1) from the multihash and returns the CID as a string. If an error occurs during the multihash computation or CID creation, it is returned.
func GenerateSelfSignedCert ¶
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.
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.