wallet

package
v0.0.0-...-ce8ee10 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package wallet will contain the logic for managing user wallets. In blockchain, a wallet is a digital container that stores the cryptographic keys used to access and manage a user’s assets. It consists of a private key and a public key. The public key is shared within the blockchain network and is mainly used to receive funds and verify the authenticity of digital signatures. With a public key, anyone can encrypt data that can only be decrypted by the corresponding private key. The private key is a secret cryptographic key that should be kept secure and known only to the owner. It creates digital signatures, signs transactions, and decrypts data encrypted with the corresponding public key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRSAKeys

func GenerateRSAKeys() (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateRSAKeys generates a private, public key pair

func VerifyTransaction

func VerifyTransaction(transaction *transaction.Transaction, publicKey *rsa.PublicKey, signature string) error

VerifyTransaction verifies a given transaction with a public key and the signature returning an error if verification fails

Types

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

Wallet structure representing a user's wallet with access to assets. RSA is sued for key generation, signing of transactions, and verification of transaction signatures.

func New

func New(userID string) (*Wallet, error)

New creates a new wallet structure

func (*Wallet) PublicKey

func (w *Wallet) PublicKey() *rsa.PublicKey

PublicKey returns the publicKey associated with this wallet

func (*Wallet) SignTransaction

func (w *Wallet) SignTransaction(transaction *transaction.Transaction) (string, error)

SignTransaction signs a given transaction and returns the signature of the signing or an error the signature is then used to validate a transaction

func (*Wallet) UserID

func (w *Wallet) UserID() string

UserID is the ID of the user who owns this wallet

Jump to

Keyboard shortcuts

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