binary

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Word160Length = 20
View Source
const Word256Length = 32
View Source
const Word256Word160Delta = 12

Variables

View Source
var (
	Zero256 = Word256{}
	One256  = LeftPadWord256([]byte{1})
)
View Source
var Big256 = big.NewInt(256)
View Source
var BigWord256Length = big.NewInt(Word256Length)
View Source
var Zero160 = Word160{}

Functions

func Fingerprint

func Fingerprint(slice []byte) []byte

func GetInt64BE

func GetInt64BE(src []byte) int64

func GetInt64LE

func GetInt64LE(src []byte) int64

func GetUint64BE

func GetUint64BE(src []byte) uint64

func GetUint64LE

func GetUint64LE(src []byte) uint64

func Int64FromWord256

func Int64FromWord256(word Word256) int64

func IsUint64SumOverflow

func IsUint64SumOverflow(a, b uint64) bool

Returns whether a + b would be a uint64 overflow

func IsZeros

func IsZeros(slice []byte) bool

func LeftPadBytes

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

func PutInt64BE

func PutInt64BE(dest []byte, i int64)

func PutInt64LE

func PutInt64LE(dest []byte, i int64)

func PutUint64BE

func PutUint64BE(dest []byte, i uint64)

func PutUint64LE

func PutUint64LE(dest []byte, i uint64)

func RightPadBytes

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

func S256

func S256(x *big.Int) *big.Int

Interprets a positive big.Int as a 256-bit two's complement signed integer

func SignExtend

func SignExtend(back uint64, x *big.Int) *big.Int

Treats the positive big int x as if it contains an embedded a back + 1 byte signed integer in its least significant bits and extends that sign

func Tuple256Split

func Tuple256Split(t Tuple256) (Word256, Word256)

func U256

func U256(x *big.Int) *big.Int

Converts a possibly negative big int x into a positive big int encoding a twos complement representation of x truncated to 32 bytes

func Uint64FromWord256

func Uint64FromWord256(word Word256) uint64

Types

type HexBytes added in v0.19.0

type HexBytes []byte

func (HexBytes) Bytes added in v0.20.0

func (hb HexBytes) Bytes() []byte

func (HexBytes) Marshal added in v0.20.0

func (hb HexBytes) Marshal() ([]byte, error)

Protobuf support

func (HexBytes) MarshalText added in v0.19.0

func (hb HexBytes) MarshalText() ([]byte, error)

func (HexBytes) MarshalTo added in v0.20.0

func (hb HexBytes) MarshalTo(data []byte) (int, error)

func (HexBytes) Size added in v0.20.0

func (hb HexBytes) Size() int

func (HexBytes) String added in v0.19.0

func (hb HexBytes) String() string

func (*HexBytes) Unmarshal added in v0.20.0

func (hb *HexBytes) Unmarshal(data []byte) error

func (*HexBytes) UnmarshalText added in v0.19.0

func (hb *HexBytes) UnmarshalText(hexBytes []byte) error

type Tuple256

type Tuple256 struct {
	First  Word256
	Second Word256
}

func (Tuple256) Compare

func (tuple Tuple256) Compare(other Tuple256) int

type Tuple256Slice

type Tuple256Slice []Tuple256

func (Tuple256Slice) Len

func (p Tuple256Slice) Len() int

func (Tuple256Slice) Less

func (p Tuple256Slice) Less(i, j int) bool

func (Tuple256Slice) Sort

func (p Tuple256Slice) Sort()

func (Tuple256Slice) Swap

func (p Tuple256Slice) Swap(i, j int)

type Word160

type Word160 [Word160Length]byte

func (Word160) Bytes

func (w Word160) Bytes() []byte

func (Word160) Word256

func (w Word160) Word256() (word256 Word256)

Pad a Word160 on the left and embed it in a Word256 (as it is for account addresses in EVM)

type Word256

type Word256 [Word256Length]byte

func Int64ToWord256

func Int64ToWord256(i int64) (word Word256)

func LeftPadWord256

func LeftPadWord256(bz []byte) (word Word256)

func RightPadWord256

func RightPadWord256(bz []byte) (word Word256)

func Uint64ToWord256

func Uint64ToWord256(i uint64) (word Word256)

func (Word256) Bytes

func (w Word256) Bytes() []byte

func (Word256) Compare

func (w Word256) Compare(other Word256) int

func (Word256) Copy

func (w Word256) Copy() Word256

func (Word256) IsZero

func (w Word256) IsZero() bool

func (*Word256) Marshal added in v0.20.0

func (w *Word256) Marshal() ([]byte, error)

Gogo proto support

func (Word256) MarshalText added in v0.19.0

func (w Word256) MarshalText() ([]byte, error)

func (*Word256) MarshalTo added in v0.20.0

func (w *Word256) MarshalTo(data []byte) (int, error)

func (Word256) Postfix

func (w Word256) Postfix(n int) []byte

func (Word256) Prefix

func (w Word256) Prefix(n int) []byte

copied.

func (Word256) Size added in v0.20.0

func (w Word256) Size() int

func (Word256) String

func (w Word256) String() string

func (*Word256) Unmarshal added in v0.20.0

func (w *Word256) Unmarshal(data []byte) error

func (*Word256) UnmarshalText added in v0.19.0

func (w *Word256) UnmarshalText(hexBytes []byte) error

func (Word256) UnpadLeft

func (w Word256) UnpadLeft() []byte

func (Word256) UnpadRight

func (w Word256) UnpadRight() []byte

func (Word256) Word160

func (w Word256) Word160() (w160 Word160)

Get a Word160 embedded a Word256 and padded on the left (as it is for account addresses in EVM)

type Words256

type Words256 []Word256

func (Words256) Len

func (ws Words256) Len() int

func (Words256) Less

func (ws Words256) Less(i, j int) bool

func (Words256) Swap

func (ws Words256) Swap(i, j int)

Jump to

Keyboard shortcuts

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