Uint

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: Unlicense, Unlicense Imports: 3 Imported by: 0

Documentation

Overview

A library for 160 and 256 bit integers for use with EC keys, signatures and RIPEMD160, as well as very basic arithmetic functions built from big.Int

Index

Constants

View Source
const (
	// Bitwidth160 is the number of bits in a U160
	Bitwidth160 = 160
	// Bytewidth160 is the number of bytes in a U160
	Bytewidth160 = 20
)
View Source
const (
	// Bitwidth256 is the number of bits in a U256
	Bitwidth256 = 256
	// Bytewidth256 is the number of bytes in a U256
	Bytewidth256 = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type U160

type U160 struct {
	big.Int
}

U160 stores the 160 bit integer value in a big.Int

func RIPEMD160

func RIPEMD160(b ...[]byte) *U160

Returns the RIPEMD160 hash of a list of byte slices

func Zero160

func Zero160() *U160

Returns an empty uint256

func (*U160) Add

func (u *U160) Add(operand *U160) *U160

Returns the sum of the value in the receiver and the operand and stores it

func (*U160) And

func (u *U160) And(operand *U160) *U160

Returns the binary AND with the operand and stores it

func (*U160) Assign

func (u *U160) Assign(input *U160) *U160

Stores a new value in the current variable as well returning the value

func (*U160) EQ

func (u *U160) EQ(operand *U160) bool

Returns true if the operand is equal to the value in the receiver

func (*U160) FromBytes

func (u *U160) FromBytes(input []byte) *U160

Converts a byte slice into a U160, and returns the U160

func (*U160) FromString

func (u *U160) FromString(input string) *U160

Converts a string, attempting to autodetect base, into a U256, truncates if the number is too large for 160 bits

func (*U160) FromUint64

func (u *U160) FromUint64(input uint64) *U160

Puts a Uint64 value into the U256 and returns a U160

func (*U160) GT

func (u *U160) GT(operand *U160) bool

Returns true if the operand is greater than the value in the receiver

func (*U160) GToE

func (u *U160) GToE(operand *U160) bool

Returns true if the operand is greater than or equal to the value in the receiver

func (*U160) LT

func (u *U160) LT(operand *U160) bool

Returns true if the operand is less than the value in the receiver

func (*U160) LToE

func (u *U160) LToE(operand *U160) bool

Returns true if the operand is less than or equal to the value in the receiver

func (*U160) NEQ

func (u *U160) NEQ(operand *U160) bool

Returns true if the operand is not equal to the value in the receiver

func (*U160) Not

func (u *U160) Not() *U160

Returns the bitwise inversion of the value in the receiver and stores it

func (*U160) Or

func (u *U160) Or(operand *U160) *U160

Returns the binary OR with the operand and stores it

func (*U160) Sub

func (u *U160) Sub(operand *U160) *U160

Returns the difference of the value in the receiver and the operand and stores it

func (*U160) ToBytes

func (u *U160) ToBytes() []byte

Returns a byte slice containing the U256 raw binary data

func (*U160) ToString

func (u *U160) ToString() string

Converts a U256 into a string containing a decimal representing the value

func (*U160) Xor

func (u *U160) Xor(operand *U160) *U160

Returns the binary XOR with another U160 and stores it

type U256

type U256 struct {
	big.Int
}

U256 stores a 256 bit value in a big.Int

func SHA256

func SHA256(b ...[]byte) *U256

Returns the SHA256 hash of a one or more byte slices

func Zero256

func Zero256() *U256

Zero256 returns an empty uint256

func (*U256) Add

func (u *U256) Add(operand *U256) *U256

Adds a value to a 256 bit integer and stores the result in the receiver

func (*U256) And

func (u *U256) And(operand *U256) *U256

Performs a logical AND between one U256 and another and stores the value in the receiver

func (*U256) Assign

func (u *U256) Assign(input *U256) *U256

Stores a U256 in the receiver and returns it

func (*U256) EQ

func (u *U256) EQ(operand *U256) bool

Returns true if the operand is equal to the value in the receiver

func (*U256) FromBytes

func (u *U256) FromBytes(input []byte) *U256

Converts a byte slice to U256, truncating or padding as required, storing in the receiver, and returning the derived value

func (*U256) FromString

func (u *U256) FromString(input string) *U256

FromString converts a string, detecting hexadecimal or octal prefix as required and converting to U256 and returning to the caller

func (*U256) FromUint64

func (u *U256) FromUint64(input uint64) *U256

Converts a uint64 to U256, stores it and returns it

func (*U256) GT

func (u *U256) GT(operand *U256) bool

Returns true if the operand is greater than the value in the receiver

func (*U256) GToE

func (u *U256) GToE(operand *U256) bool

Returns true if the operand is greater than or equal to the value in the receiver

func (*U256) LT

func (u *U256) LT(operand *U256) bool

Returns true if the operand is lesser than the value in the receiver

func (*U256) LToE

func (u *U256) LToE(operand *U256) bool

Returns true if the operand is less than or equal to the value in the receiver

func (*U256) NEQ

func (u *U256) NEQ(operand *U256) bool

Returns true if the operand is not equal to the value in the receiver

func (*U256) Not

func (u *U256) Not() *U256

Returns the bit-inverse of a 256 bit integer and stores it in the receiver

func (*U256) Or

func (u *U256) Or(operand *U256) *U256

Returns the logical OR between one 256 bit value and another and stores the result in the receiver

func (*U256) Sub

func (u *U256) Sub(operand *U256) *U256

Subtracts a value from a 256 bit integer and stores the result in the receiver

func (*U256) ToBytes

func (u *U256) ToBytes() []byte

Returns the 256 bit integer in the receiver as a byte slice

func (*U256) ToString

func (u *U256) ToString() string

Returns a base 10 representation of the value in the receiver as a string

func (*U256) Xor

func (u *U256) Xor(operand *U256) *U256

Returns the logical Exclusive OR between one 256 value and another and stores the value in the receiver

Jump to

Keyboard shortcuts

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