utils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigIntArrayToElementArray

func BigIntArrayToElementArray(bi []*big.Int) []*ff.Element

BigIntArrayToElementArray converts an array of *big.Int into an array of *ff.Element

func BigIntLEBytes

func BigIntLEBytes(v *big.Int) [32]byte

BigIntLEBytes encodes a big.Int into an array in Little-Endian.

func CheckBigIntArrayInField

func CheckBigIntArrayInField(arr []*big.Int) bool

CheckBigIntArrayInField checks if given *big.Int fits in a Field Q element

func CheckBigIntInField

func CheckBigIntInField(a *big.Int) bool

CheckBigIntInField checks if given *big.Int fits in a Field Q element

func ElementArrayToBigIntArray

func ElementArrayToBigIntArray(e []*ff.Element) []*big.Int

ElementArrayToBigIntArray converts an array of *ff.Element into an array of *big.Int

func HexDecode

func HexDecode(h string) ([]byte, error)

HexDecode decodes a hex string into an array of bytes.

func HexDecodeInto

func HexDecodeInto(dst, h []byte) error

HexDecodeInto decodes a hex string into an array of bytes (dst), verifying that the decoded array has the same length as dst.

func HexEncode

func HexEncode(bs []byte) string

HexEncode encodes an array of bytes into a string in hex.

func NewIntFromString

func NewIntFromString(s string) *big.Int

NewIntFromString creates a new big.Int from a decimal integer encoded as a string. It will panic if the string is not a decimal integer.

func SetBigIntFromLEBytes

func SetBigIntFromLEBytes(v *big.Int, leBuf []byte) *big.Int

SetBigIntFromLEBytes sets the value of a big.Int from a Little-Endian encoded value.

func SwapEndianness

func SwapEndianness(xs []byte) []byte

SwapEndianness swaps the endianness of the value encoded in xs. If xs is Big-Endian, the result will be Little-Endian and viceversa.

Types

type Hex

type Hex []byte

Hex is a byte slice type that can be marshaled and unmarshaled in hex

func (Hex) MarshalText

func (buf Hex) MarshalText() ([]byte, error)

MarshalText encodes buf as hex

func (Hex) String

func (buf Hex) String() string

String encodes buf as hex

Jump to

Keyboard shortcuts

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