Documentation ¶
Index ¶
- Constants
- Variables
- func BigIntFromLittleEndianBytes(bs []byte) *big.Int
- func BigIntFromWord256(word Word256) *big.Int
- func BigIntToLittleEndianBytes(x *big.Int) []byte
- func Fingerprint(slice []byte) []byte
- func FromTwosComplement(x *big.Int, n uint) *big.Int
- func Int64FromWord256(word Word256) int64
- func IsUint64SumOverflow(a, b uint64) bool
- func IsZeros(slice []byte) bool
- func LeftPadBytes(slice []byte, l int) []byte
- func RightPadBytes(slice []byte, l int) []byte
- func S256(x *big.Int) *big.Int
- func SignExtend(x *big.Int, n uint) *big.Int
- func ToTwosComplement(x *big.Int, n uint) *big.Int
- func Tuple256Split(t Tuple256) (Word256, Word256)
- func U256(x *big.Int) *big.Int
- func Uint64FromWord256(word Word256) uint64
- type HexBytes
- func (hb HexBytes) Bytes() []byte
- func (hb HexBytes) Marshal() ([]byte, error)
- func (hb HexBytes) MarshalText() ([]byte, error)
- func (hb HexBytes) MarshalTo(data []byte) (int, error)
- func (hb HexBytes) Size() int
- func (hb HexBytes) String() string
- func (hb *HexBytes) Unmarshal(data []byte) error
- func (hb *HexBytes) UnmarshalText(hexBytes []byte) error
- type Tuple256
- type Tuple256Slice
- type Word160
- type Word256
- func (w Word256) Bytes() []byte
- func (w Word256) Compare(other Word256) int
- func (w Word256) Copy() Word256
- func (w Word256) IsZero() bool
- func (w *Word256) Marshal() ([]byte, error)
- func (w Word256) MarshalText() ([]byte, error)
- func (w *Word256) MarshalTo(data []byte) (int, error)
- func (w Word256) Postfix(n int) []byte
- func (w Word256) Prefix(n int) []byte
- func (w Word256) Size() int
- func (w Word256) String() string
- func (w *Word256) Unmarshal(data []byte) error
- func (w *Word256) UnmarshalText(hexBytes []byte) error
- func (w Word256) UnpadLeft() []byte
- func (w Word256) UnpadRight() []byte
- func (w Word256) Word160() (w160 Word160)
- type Words256
Constants ¶
View Source
const Word160Length = 20
View Source
const Word256Bits = Word256Bytes * 8
View Source
const Word256Bytes = 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 BigWord256Bytes = big.NewInt(Word256Bytes)
View Source
var Zero160 = Word160{}
Functions ¶
func BigIntFromLittleEndianBytes ¶
Note: this function destructively reverses its input slice - pass a copy if the original is used elsewhere
func BigIntFromWord256 ¶
func Fingerprint ¶
func FromTwosComplement ¶
Interprets a positive big.Int as a n-bit two's complement signed integer
func Int64FromWord256 ¶
func IsUint64SumOverflow ¶
Returns whether a + b would be a uint64 overflow
func LeftPadBytes ¶
func RightPadBytes ¶
func SignExtend ¶
Treats the positive big int x as if it contains an embedded n bit signed integer in its least significant bits and extends that sign
func ToTwosComplement ¶
Convert a possibly negative big.Int x to a positive big.Int encoded in two's complement
func Tuple256Split ¶
func U256 ¶
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 ¶
Types ¶
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
type Word256 ¶
type Word256 [Word256Bytes]byte
func BigIntToWord256 ¶
func Int64ToWord256 ¶
func LeftPadWord256 ¶
func RightPadWord256 ¶
func Uint64ToWord256 ¶
func (Word256) MarshalText ¶
func (*Word256) UnmarshalText ¶
func (Word256) UnpadRight ¶
Click to show internal directories.
Click to hide internal directories.