Documentation ¶
Index ¶
- Constants
- Variables
- func AllZero(b []byte) bool
- func BigMax(x, y *big.Int) *big.Int
- func BigMin(x, y *big.Int) *big.Int
- func BigPow(a, b int64) *big.Int
- func BigUint64(v *big.Int) (uint64, bool)
- func Byte(bigint *big.Int, padlength, n int) byte
- func BytesToString(data []byte) string
- func Exp(base, exponent *big.Int) *big.Int
- func GetDataBig(data []byte, start *big.Int, size *big.Int) []byte
- func HexToBytes(str string) []byte
- func JoinBytes(data ...[]byte) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func Max(x, y uint64) uint64
- func Min(x, y uint64) uint64
- func PaddedBigBytes(bigint *big.Int, n int) []byte
- func ReadBits(bigint *big.Int, buf []byte)
- func ReverseSlice(s interface{})
- func RightPadBytes(slice []byte, l int) []byte
- func S256(x *big.Int) *big.Int
- func SafeAdd(x, y uint64) (uint64, bool)
- func SafeMul(x, y uint64) (uint64, bool)
- func ToWordSize(size uint64) uint64
- func U256(x *big.Int) *big.Int
Constants ¶
Variables ¶
Functions ¶
func BigUint64 ¶
BigUint64 returns the integer casted to a uint64 and returns whether it overflowed in the process.
func Byte ¶
Byte returns the byte at position n, with the supplied padlength in Little-Endian encoding. n==0 returns the MSB Example: bigint '5', padlength 32, n=31 => 5
func Exp ¶
Exp implements exponentiation by squaring. Exp returns a newly-allocated big integer and does not change base or exponent. The result is truncated to 256 bits.
func GetDataBig ¶
GetDataBig returns a slice from the data based on the start and size and pads up to size with zero's. This function is overflow safe.
func LeftPadBytes ¶
leftPadBytes zero-pads slice to the left up to length l.
func PaddedBigBytes ¶
PaddedBigBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.
func ReadBits ¶
ReadBits encodes the absolute amount of bigint as big-endian bytes. Callers must ensure that buf has enough space. If buf is too short the result will be incomplete.
func ReverseSlice ¶
func ReverseSlice(s interface{})
func RightPadBytes ¶
rightPadBytes zero-pads slice to the right up to length l.
func S256 ¶
S256 interprets x as a two's complement number. x must not exceed 256 bits (the result is undefined if it does) and is not modified.
S256(0) = 0 S256(1) = 1 S256(2**255) = -2**255 S256(2**256-1) = -1
func SafeAdd ¶
SafeAdd returns the result and whether overflow occurred.
func SafeMul ¶
SafeMul returns multiplication result and whether overflow occurred.
func ToWordSize ¶
ToWordSize returns the ceiled word size required for memory expansion.
Types ¶
This section is empty.