common

package
v0.0.0-...-e0cfe8b Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-3-Clause Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPositive

func IsPositive(b BigUInt) bool

func IsZero

func IsZero(b BigUInt) bool

Types

type BigUInt

type BigUInt struct {
	*big.Int
}

BigUInt is a simple wrapper on bigint to support marshaling to protobufs

func BigZero

func BigZero() *BigUInt

func (*BigUInt) Add

func (b *BigUInt) Add(x, y *BigUInt) *BigUInt

Add sets z to the sum x+y and returns z.

func (*BigUInt) Cmp

func (b *BigUInt) Cmp(i *BigUInt) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

func (*BigUInt) Div

func (b *BigUInt) Div(x, y *BigUInt) *BigUInt

Div sets z to the quotient x/y for y != 0 and returns z. If y == 0, a division-by-zero run-time panic occurs. Div implements Euclidean division (unlike Go); see DivMod for more details.

func (*BigUInt) Exp

func (b *BigUInt) Exp(x, y, m *BigUInt) *BigUInt

Exp sets z = x**y mod |m| (i.e. the sign of m is ignored), and returns z. If y <= 0, the result is 1 mod |m|; if m == nil or m == 0, z = x**y.

Modular exponentation of inputs of a particular size is not a cryptographically constant-time operation.

func (*BigUInt) Marshal

func (b *BigUInt) Marshal() ([]byte, error)

Marshal converts to a byte buffer for protobufs

func (*BigUInt) Mul

func (b *BigUInt) Mul(x, y *BigUInt) *BigUInt

Mul sets z to the product x*y and returns z.

func (*BigUInt) Size

func (b *BigUInt) Size() int

Size returns the length of the protobuf data

func (*BigUInt) Sub

func (b *BigUInt) Sub(x, y *BigUInt) *BigUInt

Sub sets z to the difference x-y and returns z.

func (*BigUInt) Uint64

func (b *BigUInt) Uint64() uint64

func (*BigUInt) Unmarshal

func (b *BigUInt) Unmarshal(by []byte) error

Unmarshal unmarshals protobuf data

type LocalAddress

type LocalAddress []byte

func (LocalAddress) Compare

func (a LocalAddress) Compare(other LocalAddress) int

func (LocalAddress) Hex

func (a LocalAddress) Hex() string

From ethereum with finalized sha3 Note: only works with addresses up to 256 bit

func (LocalAddress) Marshal

func (a LocalAddress) Marshal() ([]byte, error)

Marshal converts to a byte buffer for protobufs

func (LocalAddress) Size

func (a LocalAddress) Size() int

Size returns the number of bytes for deterministic marshaling

func (LocalAddress) String

func (a LocalAddress) String() string

func (*LocalAddress) Unmarshal

func (a *LocalAddress) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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