Documentation ¶
Overview ¶
Package ecdsa provides utilities for generating and managing ECDSA key pairs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(bytes []byte) (*ecdsa.PrivateKey, error)
privateKeyFromBytes reconstructs an ECDSA private key from a given byte slice. It returns the resulting private key and an error if the conversion fails.
func PublicKeyFromBytes ¶
publicKeyFromBytes reconstructs an ECDSA public key from a given byte slice. It returns the resulting public key and an error if the conversion fails.
func VerifySignature ¶
VerifySignature verifies the given signature against the hash of the data using the public key of the ecdsaKeyPair.
Parameters:
- hash: The cryptographic hash of the original data that was signed.
- signature: The ASN.1 signature to verify.
Returns:
- A boolean indicating whether the verification was successful.
Types ¶
type KeyPair ¶
type KeyPair interface { PrivateKeyString() (string, error) PublicKeyString() (string, error) PrivateKey() *ecdsa.PrivateKey PublicKey() *ecdsa.PublicKey PrivateKeyToBytes() ([]byte, error) PublicKeyToBytes() ([]byte, error) Sign(hash []byte) ([]byte, error) SaveKeys(privateKeyFilename, publicKeyFilename, storagePath string) error }
KeyPair represents the interface to interact with an ECDSA key pair.
func LoadKeys ¶
LoadKeys retrieves the private and public keys from specified files and constructs an ECDSA key pair.
func NewECDSAKeyPair ¶
NewECDSAKeyPair initializes a new ECDSA key pair using the P-256 elliptic curve. It returns a pointer to an ecdsaKeyPair instance and an error, if any occurred during key generation.