Documentation
¶
Index ¶
- Constants
- Variables
- func Equal[F FeltLike](a, b *F) bool
- func FromBytes[F FeltLike](value []byte) F
- func FromString[F FeltLike](value string) (F, error)
- func FromUint64[F FeltLike](num uint64) F
- func IsZero[F FeltLike](v *F) bool
- 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
- func NewUnsafeFromString[F FeltLike](val string) *F
- func Random[F FeltLike]() F
- func UnsafeFromString[F FeltLike](value string) F
- type Address
- type CasmClassHash
- 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
- 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 SierraClassHash
- func (h *SierraClassHash) Marshal() []byte
- func (h SierraClassHash) MarshalJSON() ([]byte, error)
- func (h *SierraClassHash) SetBytesCanonical(data []byte) error
- func (h *SierraClassHash) String() string
- func (h *SierraClassHash) Unmarshal(e []byte)
- func (h *SierraClassHash) UnmarshalJSON(data []byte) error
- type StateRootHash
- type TransactionHash
- func (h *TransactionHash) Marshal() []byte
- func (h TransactionHash) MarshalJSON() ([]byte, error)
- func (h *TransactionHash) SetBytesCanonical(data []byte) error
- func (h *TransactionHash) String() string
- func (h *TransactionHash) Unmarshal(e []byte)
- func (h *TransactionHash) UnmarshalJSON(data []byte) error
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
func NewRandom[F FeltLike]() *F
NewRandom creates a new random Felt based type. It also forces a heap allocation. For efficient code use `Random`
func NewUnsafeFromString ¶ added in v0.15.8
NewUnsafeFromString is similar to `NewFromString` but it panics instead of returning an error.
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 Address ¶ added in v0.15.7
type Address Felt
func (Address) MarshalJSON ¶ added in v0.15.11
func (*Address) SetBytesCanonical ¶ added in v0.15.13
func (*Address) UnmarshalJSON ¶ added in v0.15.11
type CasmClassHash ¶ added in v0.15.10
type CasmClassHash ClassHash
func (*CasmClassHash) Marshal ¶ added in v0.15.11
func (h *CasmClassHash) Marshal() []byte
func (CasmClassHash) MarshalJSON ¶ added in v0.15.11
func (h CasmClassHash) MarshalJSON() ([]byte, error)
func (*CasmClassHash) SetBytesCanonical ¶ added in v0.15.13
func (h *CasmClassHash) SetBytesCanonical(data []byte) error
func (*CasmClassHash) String ¶ added in v0.15.10
func (h *CasmClassHash) String() string
func (*CasmClassHash) Unmarshal ¶ added in v0.15.11
func (h *CasmClassHash) Unmarshal(e []byte)
func (*CasmClassHash) UnmarshalJSON ¶ added in v0.15.11
func (h *CasmClassHash) UnmarshalJSON(data []byte) error
type ClassHash ¶ added in v0.15.7
type ClassHash Hash
func (ClassHash) MarshalJSON ¶ added in v0.15.11
func (*ClassHash) SetBytesCanonical ¶ added in v0.15.13
func (*ClassHash) UnmarshalJSON ¶ added in v0.15.11
type Felt ¶
func (*Felt) Bits ¶
Bits forwards the call to underlying field element implementation. Provides access to z by returning its value as a little-endian [4]uint64 array.
func (*Felt) Bytes ¶
Bytes forwards the call to underlying field element implementation. Returns the value of z as a big-endian byte array
func (*Felt) Clone ¶ added in v0.9.3
TODO: look where this is used, the clone shouldn't return a pointer
func (*Felt) Cmp ¶ added in v0.2.1
Cmp forwards the call to underlying field element implementation. Returns:
-1 if z < x 0 if z == x +1 if z > x
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. Uses a value receiver so encoding/json can call it on non-addressable values (e.g. struct fields inside a value stored in an `any` interface).
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 only 0x-prefixed hexadecimal strings.
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 Hash ¶ added in v0.15.7
type Hash Felt
func (Hash) MarshalJSON ¶ added in v0.15.11
func (*Hash) SetBytesCanonical ¶ added in v0.15.13
func (*Hash) UnmarshalJSON ¶ added in v0.15.11
type SierraClassHash ¶ added in v0.15.10
type SierraClassHash ClassHash
func (*SierraClassHash) Marshal ¶ added in v0.15.11
func (h *SierraClassHash) Marshal() []byte
func (SierraClassHash) MarshalJSON ¶ added in v0.15.11
func (h SierraClassHash) MarshalJSON() ([]byte, error)
func (*SierraClassHash) SetBytesCanonical ¶ added in v0.15.13
func (h *SierraClassHash) SetBytesCanonical(data []byte) error
func (*SierraClassHash) String ¶ added in v0.15.10
func (h *SierraClassHash) String() string
func (*SierraClassHash) Unmarshal ¶ added in v0.15.11
func (h *SierraClassHash) Unmarshal(e []byte)
func (*SierraClassHash) UnmarshalJSON ¶ added in v0.15.11
func (h *SierraClassHash) UnmarshalJSON(data []byte) error
type StateRootHash ¶ added in v0.15.17
type StateRootHash Hash
func (*StateRootHash) Marshal ¶ added in v0.15.17
func (h *StateRootHash) Marshal() []byte
func (StateRootHash) MarshalJSON ¶ added in v0.15.17
func (h StateRootHash) MarshalJSON() ([]byte, error)
func (*StateRootHash) SetBytesCanonical ¶ added in v0.15.17
func (h *StateRootHash) SetBytesCanonical(data []byte) error
func (*StateRootHash) String ¶ added in v0.15.17
func (h *StateRootHash) String() string
func (*StateRootHash) Unmarshal ¶ added in v0.15.17
func (h *StateRootHash) Unmarshal(e []byte)
func (*StateRootHash) UnmarshalJSON ¶ added in v0.15.17
func (h *StateRootHash) UnmarshalJSON(data []byte) error
type TransactionHash ¶ added in v0.15.7
type TransactionHash Hash
func (*TransactionHash) Marshal ¶ added in v0.15.13
func (h *TransactionHash) Marshal() []byte
func (TransactionHash) MarshalJSON ¶ added in v0.15.11
func (h TransactionHash) MarshalJSON() ([]byte, error)
func (*TransactionHash) SetBytesCanonical ¶ added in v0.15.13
func (h *TransactionHash) SetBytesCanonical(data []byte) error
func (*TransactionHash) String ¶ added in v0.15.7
func (h *TransactionHash) String() string
func (*TransactionHash) Unmarshal ¶ added in v0.15.13
func (h *TransactionHash) Unmarshal(e []byte)
func (*TransactionHash) UnmarshalJSON ¶ added in v0.15.11
func (h *TransactionHash) UnmarshalJSON(data []byte) error