utils

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 10 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigIntToFelt

func BigIntToFelt(big *big.Int) *felt.Felt

func BigToHex added in v0.4.6

func BigToHex(in *big.Int) string

convert big int to hexidecimal string

func BytesToBig added in v0.4.6

func BytesToBig(bytes []byte) *big.Int

func ComputeFact added in v0.4.6

func ComputeFact(programHash *big.Int, programOutputs []*big.Int) *big.Int

compute the keccack fact given the program hash and outputs

func FeltArrToBigIntArr added in v0.4.5

func FeltArrToBigIntArr(f []*felt.Felt) []*big.Int

func FeltToBigInt

func FeltToBigInt(f *felt.Felt) *big.Int

func FmtKecBytes added in v0.4.6

func FmtKecBytes(in *big.Int, rolen int) (buf []byte)

format the bytes in Keccak hash

func GetSelectorFromName added in v0.4.6

func GetSelectorFromName(funcName string) *big.Int

todo(): this is used by the signer. Should it return a felt?

func GetSelectorFromNameFelt added in v0.4.6

func GetSelectorFromNameFelt(funcName string) *felt.Felt

func HexArrToFelt

func HexArrToFelt(hexArr []string) ([]*felt.Felt, error)

func HexToBN added in v0.4.6

func HexToBN(hexString string) *big.Int

trim "0x" prefix(if exists) and converts hexidecimal string to big int

func HexToBytes added in v0.4.6

func HexToBytes(hexString string) ([]byte, error)

trim "0x" prefix(if exists) and converts hexidecimal string to byte slice

func HexToFelt

func HexToFelt(hex string) (*felt.Felt, error)

func HexToShortStr added in v0.4.6

func HexToShortStr(hexStr string) string

convert hex string to Starknet 'short string'

func Keccak256 added in v0.4.6

func Keccak256(data ...[]byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data. (ref: https://github.com/ethereum/go-ethereum/blob/master/crypto/crypto.go)

func MaskBits added in v0.4.6

func MaskBits(mask, wordSize int, slice []byte) (ret []byte)

mask excess bits

func SNValToBN added in v0.4.6

func SNValToBN(str string) *big.Int

used in string conversions when interfacing with the APIs

func SplitFactStr added in v0.4.6

func SplitFactStr(fact string) (fact_low, fact_high string)

split a fact into two felts

func StrToBig added in v0.4.6

func StrToBig(str string) *big.Int

convert decimal string to big int

func TestHexArrToFelt

func TestHexArrToFelt(t testing.TB, hexArr []string) []*felt.Felt

func TestHexToFelt

func TestHexToFelt(t testing.TB, hex string) *felt.Felt

func UTF8StrToBig added in v0.4.6

func UTF8StrToBig(str string) *big.Int

Convert utf8 string to big int

func Uint64ToFelt

func Uint64ToFelt(num uint64) *felt.Felt

Types

type KeccakState added in v0.4.6

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.

func NewKeccakState added in v0.4.6

func NewKeccakState() KeccakState

NewKeccakState creates a new KeccakState (ref: https://github.com/ethereum/go-ethereum/blob/master/crypto/crypto.go)

Jump to

Keyboard shortcuts

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