Documentation ¶
Index ¶
- Constants
- Variables
- func AddPaddingBigInt(numInt *big.Int, fixedSize int) []byte
- func B2ImN(bytes []byte) *big.Int
- func BytesToInt(bytesArr []byte) int
- func BytesToUint32(b []byte) (uint32, error)
- func FromHex(s string) []byte
- func GetShardIDFromLastByte(b byte) byte
- func Has0xPrefix(str string) bool
- func Hash4Bls(data []byte) []byte
- func HashB(b []byte) []byte
- func Hex2Bytes(str string) []byte
- func IntToBytes(n int) []byte
- func RandBigIntMaxRange(max *big.Int) (*big.Int, error)
- func RandBytes(l int) []byte
- func RandChars(l int) string
- func RandInt() int
- func RandInt64() int64
- func RandIntInterval(L, R int) int
- func RandUint64() uint64
- func SHA256(b []byte) []byte
- func SliceExists(slice interface{}, item interface{}) (bool, error)
- func Uint32ToBytes(value uint32) []byte
- type AES
- type Hash
- func (hashObj *Hash) Cmp(target *Hash) (int, error)
- func (hashObj *Hash) Decode(dst *Hash, src string) error
- func (hashObj *Hash) GetBytes() []byte
- func (hashObj *Hash) IsEqual(target *Hash) bool
- func (hashObj Hash) MarshalText() ([]byte, error)
- func (hashObj Hash) NewHash(newHash []byte) (*Hash, error)
- func (hashObj Hash) NewHashFromStr(hash string) (*Hash, error)
- func (hashObj *Hash) SetBytes(newHash []byte) error
- func (hashObj Hash) String() string
- func (hashObj *Hash) UnmarshalJSON(data []byte) error
- func (hashObj Hash) UnmarshalText(text []byte) error
Constants ¶
const ( EmptyString = "" ZeroByte = byte(0x00) DateOutputFormat = "2006-01-02T15:04:05.999999" BigIntSize = 32 // bytes CheckSumLen = 4 // bytes AESKeySize = 32 // bytes Int32Size = 4 // bytes Uint32Size = 4 // bytes Uint64Size = 8 // bytes HashSize = 32 // bytes MaxHashStringSize = HashSize * 2 Base58Version = 0 )
for common
const ( PrivateKeySize = 32 // bytes PublicKeySize = 32 // bytes BLSPublicKeySize = 128 // bytes BriPublicKeySize = 33 // bytes )
const ( TxNormalType = "n" // normal tx TxRewardType = "s" // reward tx TxReturnStakingType = "rs" // return-staking tx TxConversionType = "cv" // Convert 1 - 2 normal tx TxTokenConversionType = "tcv" // Convert 1 - 2 token tx TxCustomTokenPrivacyType = "tp" // token tx with supporting privacy )
For all Transaction information
const ( BlsConsensus = "bls" BridgeConsensus = "dsa" IncKeyType = "inc" )
const ( BurningAddress = "15pABFiJVeh9D5uiQEhQX4SVibGGbdAVipQxBdxkmDqAJaoG1EdFKHBrNfs" BurningAddress2 = "12RxahVABnAVCGP3LGwCn8jkQxgw7z1x14wztHzn455TTVpi1wBq9YGwkRMQg3J4e657AbAnCvYCJSdA9czBUNuCKwGSRQt55Xwz8WA" )
const PRVIDStr = "0000000000000000000000000000000000000000000000000000000000000004"
const (
SalaryVerFixHash = 1
)
Variables ¶
var ( PRVCoinID = Hash{4} ConfidentialAssetID = Hash{5} MaxShardNumber = 8 //programmatically config based on networkID AddressVersion = 1 )
var (
MaxTxSize = uint64(100) // unit KB = 100KB
)
Functions ¶
func AddPaddingBigInt ¶
AddPaddingBigInt adds padding to big int to it is fixed size.
func BytesToInt ¶
BytesToInt reverts an integer number from 2-byte array.
func BytesToUint32 ¶
BytesToUint32 converts big endian 4-byte array to uint32 number.
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GetShardIDFromLastByte ¶
GetShardIDFromLastByte returns the shardID from the last byte b of a public key. The shardID is calculated by taking the remainder of b % MaxShardNumber.
func Has0xPrefix ¶
Has0xPrefix validates str begins with '0x' or '0X'.
func Hash4Bls ¶
Hash4Bls is Hash function for calculate block hash this is different from hash function for calculate transaction hash
func IntToBytes ¶
IntToBytes converts an integer number to 2-byte array in big endian.
func RandBigIntMaxRange ¶
RandBigIntMaxRange generates a random big.Int whose value is less than a given max value.
func RandIntInterval ¶
RandIntInterval returns a random int in range [L; R]
func RandUint64 ¶
func RandUint64() uint64
func SHA256 ¶
SHA256 calculates SHA256-256 hashing of input b and returns the result in bytes array.
func SliceExists ¶
SliceExists checks if an item exists in a slice.
func Uint32ToBytes ¶
Uint32ToBytes converts uint32 number to big endian 4-byte array.
Types ¶
type AES ¶
type AES struct {
Key []byte
}
AES consists of the symmetric key used in the aes encryption scheme.
type Hash ¶
Hash is a 32-byte long array wrapping a hashed value.
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
func (*Hash) Cmp ¶
Cmp compare two hashes, if - hash = target: return 0. - hash > target: return 1. - hash < target: return -1.
func (*Hash) Decode ¶
Decode decodes the byte-reversed hexadecimal string encoding of a Hash to a destination.
func (Hash) MarshalText ¶
MarshalText converts hashObj string to bytes array.
func (Hash) NewHashFromStr ¶
NewHashFromStr creates a Hash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the Hash.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON unmarshal json data to hashObj.
func (Hash) UnmarshalText ¶
UnmarshalText reverts bytes array to hashObj.