evmutils

package
v0.0.0-...-e70b4cf Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZXAddressLength    = 22
	ZXAddrPrefixLength = 2
	ZXAddrSuffixLength = 20
	ZXAddrPrefix       = "ZX"
)
View Source
const (
	AddressLength = 20
)

Variables

View Source
var (
	BlankHash = make([]byte, hashLength)
	ZeroHash  = Keccak256(nil)
)

Functions

func EVMIntToHashBytes

func EVMIntToHashBytes(i *Int) [hashLength]byte

EVMIntToHashBytes returns the absolute value of x as a big-endian fixed length byte slice.

func FromHex

func FromHex(s string) ([]byte, error)

func GetDataFrom

func GetDataFrom(src []byte, offset uint64, size uint64) []byte

func Has0xPrefix

func Has0xPrefix(str string) bool

func Keccak256

func Keccak256(data []byte) []byte

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func LeftPaddingSlice

func LeftPaddingSlice(src []byte, toSize int) []byte

func MinI

func MinI(i, j int64) int64

func RightPaddingSlice

func RightPaddingSlice(src []byte, toSize int) []byte

func ZXAddress

func ZXAddress(data []byte) (string, error)

func ZXAddressFromCertificatePEM

func ZXAddressFromCertificatePEM(certPEM []byte) (string, error)

ZXAddressFromCertificatePEM computes the address in Zhi Xin Lian format from a certificate PEM

func ZXAddressFromCertificatePath

func ZXAddressFromCertificatePath(certPath string) (string, error)

ZXAddressFromCertificatePath computes the address in Zhi Xin Lian format from a certificate file path

func ZXAddressFromPublicKey

func ZXAddressFromPublicKey(pk crypto.PublicKey) (string, error)

ZXAddressFromPublicKey computes the address of the given public key object in Zhi Xin Lian format

func ZXAddressFromPublicKeyDER

func ZXAddressFromPublicKeyDER(pkDER []byte) (string, error)

ZXAddressFromPublicKeyDER computes the address in Zhi Xin Lian format from a public key DER

func ZXAddressFromPublicKeyPEM

func ZXAddressFromPublicKeyPEM(pkPEM []byte) (string, error)

ZXAddressFromPublicKeyPEM computes the address in Zhi Xin Lian format from a public key PEM

Types

type Address

type Address [AddressLength]byte

func BigToAddress

func BigToAddress(b *Int) Address

BigToAddress math.bigInt to evm address

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress any byte set to a evm address

func HexToAddress

func HexToAddress(s string) (Address, error)

HexToAddress any hex make a evm address

func StringToAddress

func StringToAddress(s string) (Address, error)

StringToAddress any string make a evm address

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

type Int

type Int struct {
	*big.Int
}

func BytesDataToEVMIntHash

func BytesDataToEVMIntHash(data []byte) *Int

BytesDataToEVMIntHash fixed length bytes

func EthHashBytesToEVMInt

func EthHashBytesToEVMInt(hash [hashLength]byte) (*Int, error)

EthHashBytesToEVMInt EVMIntToHashBytes reverse

func FromBigInt

func FromBigInt(i *big.Int) *Int

func FromDecimalString

func FromDecimalString(s string) *Int

FromString from fmt data Int.String()

func FromHexString

func FromHexString(s string) *Int

FromString from fmt data hex.encodeToString([]byte(Int.AsStringKey))

func FromString

func FromString(ss string) *Int

FromString from fmt data Int.AsStringKey

func HashBytesToEVMInt

func HashBytesToEVMInt(hash []byte) (*Int, error)

HashBytesToEVMInt byte to bigInt

func MakeAddress

func MakeAddress(data []byte) *Int

MakeAddress any byte make a evm.Int

func MakeAddressFromHex

func MakeAddressFromHex(str string) (*Int, error)

MakeAddressFromHex any hex str make a evm.Int

func MakeAddressFromString

func MakeAddressFromString(str string) (*Int, error)

MakeAddressFromString any str make a evm.Int

func MinInt

func MinInt(i, j *Int) *Int

func New

func New(i int64) *Int

func (*Int) Add

func (i *Int) Add(y *Int) *Int

func (*Int) AddMod

func (i *Int) AddMod(y *Int, m *Int) *Int

func (*Int) And

func (i *Int) And(y *Int) *Int

func (*Int) AsStringKey

func (i *Int) AsStringKey() string

func (*Int) ByteAt

func (i *Int) ByteAt(n int) byte

func (Int) Clone

func (i Int) Clone() *Int

func (*Int) Div

func (i *Int) Div(y *Int) *Int

func (*Int) EQ

func (i *Int) EQ(y *Int) bool

func (*Int) Exp

func (i *Int) Exp(e *Int) *Int

func (*Int) GT

func (i *Int) GT(y *Int) bool

func (*Int) GetSigned

func (i *Int) GetSigned() *Int

func (*Int) IsZero

func (i *Int) IsZero() bool

func (*Int) LT

func (i *Int) LT(y *Int) bool

func (*Int) Mod

func (i *Int) Mod(m *Int) *Int

func (*Int) Mul

func (i *Int) Mul(y *Int) *Int

func (*Int) MulMod

func (i *Int) MulMod(y *Int, m *Int) *Int

func (*Int) Not

func (i *Int) Not(y *Int) *Int

func (*Int) Or

func (i *Int) Or(y *Int) *Int

func (*Int) SAR

func (i *Int) SAR(n uint64) *Int

func (*Int) SDiv

func (i *Int) SDiv(y *Int) *Int

func (*Int) SGT

func (i *Int) SGT(y *Int) bool

func (*Int) SHL

func (i *Int) SHL(n uint64) *Int

func (*Int) SHR

func (i *Int) SHR(n uint64) *Int

func (*Int) SLT

func (i *Int) SLT(y *Int) bool

func (*Int) SMod

func (i *Int) SMod(m *Int) *Int

func (*Int) SignExtend

func (i *Int) SignExtend(baseBytes *Int) *Int

func (*Int) Sub

func (i *Int) Sub(y *Int) *Int

func (*Int) XOr

func (i *Int) XOr(y *Int) *Int

Jump to

Keyboard shortcuts

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