Documentation
¶
Index ¶
- func ECDSASign(message []byte, privateKey *ecdsa.PrivateKey) (string, error)
- func ECDSAVerify(message []byte, publicKey *ecdsa.PublicKey, signatureBase64 string) (bool, error)
- func GenerateRandomAlphanumericString(length int) (string, error)
- func GenerateRandomNumericString(length int) (string, error)
- func Int64ToInt32(n int64) (int32, error)
- func IntToInt32(n int) (int32, error)
- func IsEthereumSignatureValid(walletAddress string, message string, signature string) (bool, error)
- func NormalizeHexString(s string) string
- func ParsePrivateKeyFromPEM(privateKeyPEM string) (*ecdsa.PrivateKey, error)
- func ParsePublicKeyFromPEM(publicKeyPEM string) (*ecdsa.PublicKey, error)
- func SignMessageEthereum(privateKeyHex string, message string) (string, error)
- type EthereumWallet
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 ¶
ECDSAVerify verifies a base64-encoded ECDSA signature against the given message and public key. The message is hashed with SHA-256 before verification.
func Int64ToInt32 ¶
Int64ToInt32 safely converts int64 to int32 with bounds checking. Returns an error if the value cannot fit in int32.
func IntToInt32 ¶
IntToInt32 safely converts int to int32 with bounds checking. Returns an error if the value cannot fit in int32.
func NormalizeHexString ¶
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 ¶
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.
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)