util

package
v0.0.0-...-59b8511 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ECDSASign

func ECDSASign(message []byte, privateKey *ecdsa.PrivateKey) (string, error)

ECDSASign signs the given message using the provided ECDSA private key and returns a base64-encoded signature.

func ECDSAVerify

func ECDSAVerify(message []byte, publicKey *ecdsa.PublicKey, signatureBase64 string) (bool, error)

ECDSAVerify verifies a base64-encoded ECDSA signature against the given message and public key. The message is hashed with SHA-256 before verification.

func GenerateRandomAlphanumericString

func GenerateRandomAlphanumericString(length int) (string, error)

func GenerateRandomNumericString

func GenerateRandomNumericString(length int) (string, error)

func Int64ToInt32

func Int64ToInt32(n int64) (int32, error)

Int64ToInt32 safely converts int64 to int32 with bounds checking. Returns an error if the value cannot fit in int32.

func IntToInt32

func IntToInt32(n int) (int32, error)

IntToInt32 safely converts int to int32 with bounds checking. Returns an error if the value cannot fit in int32.

func IsEthereumSignatureValid

func IsEthereumSignatureValid(walletAddress string, message string, signature string) (bool, error)

func NormalizeHexString

func NormalizeHexString(s string) string

func ParsePrivateKeyFromPEM

func ParsePrivateKeyFromPEM(privateKeyPEM string) (*ecdsa.PrivateKey, error)

ParsePrivateKeyFromPEM parses a PEM-encoded ECDSA private key string and returns the *ecdsa.PrivateKey. If the input is missing the standard PEM headers, they are automatically added. Returns an error if the input is not a valid PEM block or does not contain a valid EC private key.

func ParsePublicKeyFromPEM

func ParsePublicKeyFromPEM(publicKeyPEM string) (*ecdsa.PublicKey, error)

ParsePublicKeyFromPEM parses a PEM-encoded ECDSA public key string and returns the *ecdsa.PublicKey. If the input is missing the standard PEM headers, they are automatically added. Returns an error if the input is not a valid PEM block or does not contain an ECDSA public key.

func SignMessageEthereum

func SignMessageEthereum(privateKeyHex string, message string) (string, error)

Types

type EthereumWallet

type EthereumWallet struct {
	PublicKey     string `json:"public_key"`
	PrivateKey    string `json:"private_key"`
	Address       string `json:"address"`
	PublicKeyHash string `json:"public_key_hash"`
}

func NewEthereumWallet

func NewEthereumWallet() (*EthereumWallet, error)

Jump to

Keyboard shortcuts

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