crypto

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 8 Imported by: 1

README

crypto

crypto library for eth that use the MIT license.

use case
  • Verification signature
message := "hello"
address := "0x8fd379246834eac74B8419FfdA202CF8051F7A03"

sign := "0x182dc2e4432e152adb9c8a8837474986469144160b09f77a45645b6d9240ceb0368de7f12b5c522171ea4139c8dfa030c868710d39eedb0172e69a88904174d400"

valid := ValidateSignature(message, sign, address)

println(valid) // true

Documentation

Index

Constants

View Source
const EthPrefix = "\x19Ethereum Signed Message:\n"
View Source
const PrivateKeyLen = 64
View Source
const PublicKeyLen = 65 // 04 + X + Y
View Source
const SignatureLen = 65 // R + S + V

Variables

This section is empty.

Functions

func GetEcdsaPublicKeyByPrivateKey

func GetEcdsaPublicKeyByPrivateKey(prikey *ecdsa.PrivateKey) (publicKeyECDSA *ecdsa.PublicKey, err error)

func GetEthAddressByBytePublicKey

func GetEthAddressByBytePublicKey(publicKey []byte) (address string, err error)

func GetEthMessageHash

func GetEthMessageHash(message string) (msgHash []byte)

func GetKeccak256Hash

func GetKeccak256Hash(msg []byte) (msgHash []byte)

func GetPrivateKeyWithEcdsa

func GetPrivateKeyWithEcdsa(privateKey string) (prikey *ecdsa.PrivateKey, err error)

func GetPublicKeyBySign

func GetPublicKeyBySign(msgHash, signature []byte) (sigPublicKey []byte, err error)

func ValidateSignature

func ValidateSignature(message, signature, address string) (valid bool)

Types

type Bytes

type Bytes []byte

func GetBytesPublicKeyByPrivateKey

func GetBytesPublicKeyByPrivateKey(publicKeyECDSA *ecdsa.PublicKey) (publicKey Bytes)

func GetPublicKeyByPrivateKey

func GetPublicKeyByPrivateKey(prikey *ecdsa.PrivateKey) (publicKey Bytes, err error)

func (Bytes) EncodeToString

func (b Bytes) EncodeToString() string

Jump to

Keyboard shortcuts

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