Documentation
¶
Index ¶
- Constants
- Variables
- func FromBytes[F FeltLike](value []byte) F
- func FromString[F FeltLike](value string) (F, error)
- func FromUint64[F FeltLike](num uint64) F
- func NewFromBytes[F FeltLike](val []byte) *F
- func NewFromString[F FeltLike](val string) (*F, error)
- func NewFromUint64[F FeltLike](num uint64) *F
- func NewRandom[F FeltLike]() (*F, error)
- func UnsafeFromString[F FeltLike](value string) F
- type Address
- type ClassHash
- type Felt
- func (z *Felt) Add(x, y *Felt) *Felt
- func (z *Felt) BigInt(res *big.Int) *big.Int
- func (z *Felt) Bits() [4]uint64
- func (z *Felt) Bytes() [32]byte
- func (z *Felt) Clone() *Felt
- func (z *Felt) Cmp(x *Felt) int
- func (z *Felt) Div(x, y *Felt) *Felt
- func (z *Felt) Double(x *Felt) *Felt
- func (z *Felt) Equal(x *Felt) bool
- func (z *Felt) Exp(x *Felt, y *big.Int) *Felt
- func (z *Felt) Halve()
- func (z *Felt) Impl() *fp.Element
- func (z *Felt) IsOne() bool
- func (z *Felt) IsZero() bool
- func (z *Felt) Marshal() []byte
- func (z *Felt) MarshalCBOR() ([]byte, error)
- func (z *Felt) MarshalJSON() ([]byte, error)
- func (z *Felt) Mul(x, y *Felt) *Felt
- func (z *Felt) Neg(x *Felt) *Felt
- func (z *Felt) Set(x *Felt) *Felt
- func (z *Felt) SetBigInt(v *big.Int) *Felt
- func (z *Felt) SetBytes(e []byte) *Felt
- func (z *Felt) SetBytesCanonical(e []byte) error
- func (z *Felt) SetRandom() (*Felt, error)
- func (z *Felt) SetString(number string) (*Felt, error)
- func (z *Felt) SetUint64(v uint64) *Felt
- func (z *Felt) ShortString() string
- func (z *Felt) String() string
- func (z *Felt) Sub(x, y *Felt) *Felt
- func (z *Felt) Text(base int) string
- func (z *Felt) Uint64() uint64
- func (z *Felt) Unmarshal(e []byte)
- func (z *Felt) UnmarshalCBOR(data []byte) error
- func (z *Felt) UnmarshalJSON(data []byte) error
- type FeltLike
- type Hash
- type TransactionHash
Constants ¶
const ( Base16 = 16 Base10 = 10 )
Variables ¶
var One = Felt(fp.Element( [4]uint64{ 18446744073709551585, 18446744073709551615, 18446744073709551615, 576460752303422960, }, ))
var Zero = Felt{}
Functions ¶
func FromString ¶ added in v0.15.7
FromString crates a new Felt based type given a any string
func FromUint64 ¶ added in v0.14.3
FromUint64 creates a new Felt based type given an uint64
func NewFromBytes ¶ added in v0.15.7
NewFromBytes crates a new Felt based type given a byte array. Use this function with care since it forces a heap allocation. For efficient code use `FromBytes`
func NewFromString ¶ added in v0.15.7
NewFromString crates a new Felt based type given a string. Use this function with care since it forces a heap allocation. For efficient code use `FromString`
func NewFromUint64 ¶ added in v0.15.7
NewFromUint64 crates a new Felt based type given a uint64. Use this function with care since it forces a heap allocation. For efficient code use `FromUint64`
func NewRandom ¶ added in v0.15.7
NewRandom creates a new random Felt based type. It returns an error if "rand/Reader" errors
func UnsafeFromString ¶ added in v0.15.7
UnsafeFromString crates a new Felt based type given a any string. It panics if the string is not valid.
Types ¶
type Felt ¶
func (*Felt) Clone ¶ added in v0.9.3
TODO: look where this is used, the clone shouldn't return a pointer
func (*Felt) Double ¶ added in v0.2.1
Double forwards the call to underlying field element implementation
func (*Felt) Halve ¶
func (z *Felt) Halve()
Halve forwards the call to underlying field element implementation
func (*Felt) MarshalCBOR ¶
MarshalCBOR lets Felt be encoded in CBOR format with private `val`
func (*Felt) MarshalJSON ¶
MarshalJSON forwards the call to underlying field element implementation
func (*Felt) SetBigInt ¶ added in v0.4.0
SetBigInt forwards the call to underlying field element implementation
func (*Felt) SetBytesCanonical ¶ added in v0.14.7
SetBytesCanonical forwards the call to underlying field element implementation
func (*Felt) ShortString ¶
ShortString prints the felt to a string in a shortened format
func (*Felt) Uint64 ¶ added in v0.4.0
Uint64 forwards the call to underlying field element implementation
func (*Felt) Unmarshal ¶ added in v0.13.0
Unmarshal forwards the call to underlying field element implementation
func (*Felt) UnmarshalCBOR ¶
UnmarshalCBOR lets Felt be decoded from CBOR format with private `val`
func (*Felt) UnmarshalJSON ¶
UnmarshalJSON accepts numbers and strings as input. See Element.SetString for valid prefixes (0x, 0b, ...). If there is an error, we try to explicitly unmarshal from hex before returning an error. This implementation is based on gnark-crypto's UnmarshalJSON.
type FeltLike ¶ added in v0.15.7
type FeltLike interface {
~[4]uint64
}
Interface that represents all types that implement Felt as a sublying type E.g: Hash and Address
type TransactionHash ¶ added in v0.15.7
type TransactionHash Hash
func (*TransactionHash) String ¶ added in v0.15.7
func (h *TransactionHash) String() string