utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

* The MIT License (MIT)

Copyright (c) 2018 SmartContract ChainLink, Ltd.

* The MIT License (MIT)

Copyright (c) 2018 SmartContract ChainLink, Ltd.

Package utils is used for common functions and tools used across the codebase.

Index

Constants

View Source
const (
	// DefaultSecretSize is the entropy in bytes to generate a base64 string of 64 characters.
	DefaultSecretSize = 48
	// EVMWordByteLen the length of an EVM Word Byte
	EVMWordByteLen = 32
)

Variables

View Source
var (
	Zero  = big.NewInt(0)
	One   = big.NewInt(1)
	Two   = big.NewInt(2)
	Three = big.NewInt(3)
	Four  = big.NewInt(4)
	Seven = big.NewInt(7)
)

nolint

Functions

func Accumulate

func Accumulate(s []interface{}) (r *big.Int)

Accumulate returns the sum of the given slice after coercing all elements to a big.Int, or panics if it cannot.

func Add

func Add(addend1, addend2 interface{}) *big.Int

Add performs addition with the given values after coercing them to big.Int, or panics if it cannot.

func Div

func Div(dividend, divisor interface{}) *big.Int

Div performs division with the given values after coercing them to big.Int, or panics if it cannot.

func Equal

func Equal(left, right interface{}) bool

Equal compares the given values after coercing them to big.Int, or panics if it cannot.

func Exp

func Exp(base, exponent, modulus interface{}) *big.Int

Exp performs modular eponentiation with the given values after coercing them to big.Int, or panics if it cannot.

func HexToBig

func HexToBig(s string) *big.Int

HexToBig parses the given hex string or panics if it is invalid.

func I

func I() *big.Int

I returns a new big.Int.

func Keccak256

func Keccak256(in []byte) ([]byte, error)

Keccak256 is a simplified interface for the legacy SHA3 implementation that Ethereum uses.

func Max

func Max(x, y interface{}) *big.Int

Max returns the maximum of the two given values after coercing them to big.Int, or panics if it cannot.

func Min

func Min(x, y interface{}) *big.Int

Min returns the min of the two given values after coercing them to big.Int, or panics if it cannot.

func Mod

func Mod(dividend, divisor interface{}) *big.Int

Mod performs modulus with the given values after coercing them to big.Int, or panics if it cannot.

func Mul

func Mul(multiplicand, multiplier interface{}) *big.Int

Mul performs multiplication with the given values after coercing them to big.Int, or panics if it cannot.

func MustHash

func MustHash(in string) common.Hash

MustHash returns the keccak256 hash, or panics on failure.

func Sub

func Sub(minuend, subtrahend interface{}) *big.Int

Sub performs subtraction with the given values after coercing them to big.Int, or panics if it cannot.

func Uint256ToBytes

func Uint256ToBytes(x *big.Int) (uint256 []byte, err error)

Uint256ToBytes is x represented as the bytes of a uint256

func Uint256ToBytes32

func Uint256ToBytes32(n *big.Int) []byte

Uint256ToBytes32 returns the bytes32 encoding of the big int provided

Types

type ToIntable

type ToIntable interface {
	ToInt() *big.Int
}

ToIntable represents a type that is convertable to a big.Int, ex utils.Big

Jump to

Keyboard shortcuts

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