ecdsa

package
v1.0.0-release Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 9 Imported by: 0

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

func PublicKeyFromBytes(bytes []byte) (*ecdsa.PublicKey, error)

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

func VerifySignature(publicKey *ecdsa.PublicKey, hash, signature []byte) bool

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

func LoadKeys(privateKeyFilename, publicKeyFilename, storagePath string) (KeyPair, error)

LoadKeys retrieves the private and public keys from specified files and constructs an ECDSA key pair.

func NewECDSAKeyPair

func NewECDSAKeyPair() (KeyPair, error)

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.

Jump to

Keyboard shortcuts

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