Documentation ¶
Index ¶
- Constants
- Variables
- func EVMIntToHashBytes(i *Int) [hashLength]byte
- func FromHex(s string) ([]byte, error)
- func GetDataFrom(src []byte, offset uint64, size uint64) []byte
- func Has0xPrefix(str string) bool
- func Keccak256(data []byte) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func LeftPaddingSlice(src []byte, toSize int) []byte
- func MarshalPublicKey(pk crypto.PublicKey) (pkBytes []byte, err error)
- func MinI(i, j int64) int64
- func RightPaddingSlice(src []byte, toSize int) []byte
- func ZXAddress(data []byte) (string, error)
- func ZXAddressFromCertificatePEM(certPEM []byte) (string, error)
- func ZXAddressFromCertificatePath(certPath string) (string, error)
- func ZXAddressFromPublicKey(pk crypto.PublicKey) (string, error)
- func ZXAddressFromPublicKeyDER(pkDER []byte) (string, error)
- func ZXAddressFromPublicKeyPEM(pkPEM []byte) (string, error)
- type Address
- type Int
- func BytesDataToEVMIntHash(data []byte) *Int
- func EthHashBytesToEVMInt(hash [hashLength]byte) (*Int, error)
- func FromBigInt(i *big.Int) *Int
- func FromDecimalString(s string) *Int
- func FromHexString(s string) *Int
- func FromString(ss string) *Int
- func HashBytesToEVMInt(hash []byte) (*Int, error)
- func MakeAddress(data []byte) *Int
- func MakeAddressFromHex(str string) (*Int, error)
- func MakeAddressFromString(str string) (*Int, error)
- func MinInt(i, j *Int) *Int
- func New(i int64) *Int
- func (i *Int) Add(y *Int) *Int
- func (i *Int) AddMod(y *Int, m *Int) *Int
- func (i *Int) And(y *Int) *Int
- func (i *Int) AsStringKey() string
- func (i *Int) ByteAt(n int) byte
- func (i Int) Clone() *Int
- func (i *Int) Div(y *Int) *Int
- func (i *Int) EQ(y *Int) bool
- func (i *Int) Exp(e *Int) *Int
- func (i *Int) GT(y *Int) bool
- func (i *Int) GetSigned() *Int
- func (i *Int) IsZero() bool
- func (i *Int) LT(y *Int) bool
- func (i *Int) Mod(m *Int) *Int
- func (i *Int) Mul(y *Int) *Int
- func (i *Int) MulMod(y *Int, m *Int) *Int
- func (i *Int) Not(y *Int) *Int
- func (i *Int) Or(y *Int) *Int
- func (i *Int) SAR(n uint64) *Int
- func (i *Int) SDiv(y *Int) *Int
- func (i *Int) SGT(y *Int) bool
- func (i *Int) SHL(n uint64) *Int
- func (i *Int) SHR(n uint64) *Int
- func (i *Int) SLT(y *Int) bool
- func (i *Int) SMod(m *Int) *Int
- func (i *Int) SignExtend(baseBytes *Int) *Int
- func (i *Int) Sub(y *Int) *Int
- func (i *Int) XOr(y *Int) *Int
Constants ¶
const ( ZXAddressLength = 22 ZXAddrPrefixLength = 2 ZXAddrSuffixLength = 20 ZXAddrPrefix = "ZX" )
const (
AddressLength = 20
)
Variables ¶
Functions ¶
func EVMIntToHashBytes ¶
EVMIntToHashBytes returns the absolute value of x as a big-endian fixed length byte slice.
func FromHex ¶
FromHex convert hex string to bytes @param s @return []byte @return error
func GetDataFrom ¶
GetDataFrom get data from src @param src @param offset @param size @return []byte
func Has0xPrefix ¶
Has0xPrefix check if the string has 0x prefix @param str @return bool
func Keccak256 ¶
Keccak256 keccak256 hash @param data @return []byte
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func LeftPaddingSlice ¶
LeftPaddingSlice left padding @param src @param toSize @return []byte
func MarshalPublicKey ¶ added in v2.3.0
MarshalPublicKey serialize pk to bytes
func MinI ¶
MinI returns the minimum of i and j. @param i @param j @return int64
func RightPaddingSlice ¶
RightPaddingSlice right padding @param src @param toSize @return []byte
func ZXAddress ¶ added in v2.2.0
ZXAddress computes the address of the given public key in Zhi Xin Lian format @param data @return string @return error
func ZXAddressFromCertificatePEM ¶ added in v2.1.1
ZXAddressFromCertificatePEM computes the address in Zhi Xin Lian format from a certificate PEM
func ZXAddressFromCertificatePath ¶ added in v2.1.1
ZXAddressFromCertificatePath computes the address in Zhi Xin Lian format from a certificate file path
func ZXAddressFromPublicKey ¶ added in v2.1.1
ZXAddressFromPublicKey computes the address of the given public key object in Zhi Xin Lian format
func ZXAddressFromPublicKeyDER ¶ added in v2.1.1
ZXAddressFromPublicKeyDER computes the address in Zhi Xin Lian format from a public key DER
Types ¶
type Address ¶
type Address [AddressLength]byte
Address is the 20 byte address of an Ethereum account.
func BytesToAddress ¶
BytesToAddress any byte set to an evm address
func HexToAddress ¶
HexToAddress direct convert hex to an evm address,直接将十六进制字符串转换为Address类型
func MakeHexToAddress ¶ added in v2.3.0
MakeHexToAddress 基于十六进制数据,经过Hash计算获得一个EVM地址 @param s @return Address @return error
func StringToAddress ¶
StringToAddress any string make an evm address
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. @param b
type Int ¶
Int is a 256-bit integer.
func BytesDataToEVMIntHash ¶
BytesDataToEVMIntHash fixed length bytes
func EthHashBytesToEVMInt ¶
EthHashBytesToEVMInt EVMIntToHashBytes reverse
func FromBigInt ¶
FromBigInt returns a new Int. @param i @return *Int
func FromDecimalString ¶
FromDecimalString from fmt data Int.String()
func FromHexString ¶
FromHexString from fmt data hex.encodeToString([]byte(Int.AsStringKey))
func HashBytesToEVMInt ¶
HashBytesToEVMInt byte to bigInt
func MakeAddressFromHex ¶
MakeAddressFromHex any hex str make an evm.Int
func MakeAddressFromString ¶
MakeAddressFromString any str make an evm.Int
func MinInt ¶
MinInt returns the minimum of i and j. @param i @param j @return *Int
func (*Int) Add ¶
Add adds y to i and returns i. @param y @return *Int
func (*Int) AddMod ¶
AddMod adds y to i and returns i. @param y @param m @return *Int
func (*Int) And ¶
And returns the bitwise AND of i and y. @param y @return *Int
func (*Int) AsStringKey ¶
AsStringKey returns the string key of the Int. @return string
func (*Int) ByteAt ¶
ByteAt returns the nth byte of i. @param n @return byte
func (*Int) Div ¶
Div divides i by y and returns i. @param y @return *Int
func (*Int) Exp ¶
Exp calculates i**e mod m and returns i. @param e @return *Int
func (*Int) GetSigned ¶
GetSigned returns the signed value of the Int. @return *Int
func (*Int) Mod ¶
Mod returns the unsigned remainder of i/y. @param m @return *Int
func (*Int) Mul ¶
Mul multiplies i by y and returns i. @param y @return *Int
func (*Int) MulMod ¶
MulMod multiplies i by y and returns i. @param y @param m @return *Int
func (*Int) Not ¶
Not returns the bitwise NOT of i. @param y @return *Int
func (*Int) Or ¶
Or returns the bitwise OR of i and y. @param y @return *Int
func (*Int) SAR ¶
SAR shifts i right by n bits. @param n @return *Int
func (*Int) SDiv ¶
SDiv divides i by y and returns i. @param y @return *Int
func (*Int) SHL ¶
SHL shifts i left by n bits. @param n @return *Int
func (*Int) SHR ¶
SHR shifts i right by n bits. @param n @return *Int
func (*Int) SMod ¶
SMod returns the signed remainder of i/y. @param m @return *Int
func (*Int) SignExtend ¶
SignExtend extends the length of the signed integer i by given number of bytes. @param baseBytes @return *Int
func (*Int) Sub ¶
Sub subtracts y from i and returns i. @param y @return *Int