sdk

package
v0.0.0-...-8cb95f7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 41 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Uint248Type = "Uint248"
	Uint521Type = "Uint521"
	Int248Type  = "Int248"
	Bytes32Type = "Bytes32"
)
View Source
const NumMaxDataPoints = 512

NumMaxDataPoints is the max amount of data points this circuit can handle at once. This couples tightly to the batch size of the aggregation circuit on Brevis' side

View Source
const NumMaxLogFields = 4

NumMaxLogFields is the max amount of log fields each Receipt can have. This couples tightly to the decoding capacity of the receipt decoder circuit on Brevis' side

Variables

View Source
var MaxBytes32 = ConstUint521(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
View Source
var MaxUint248 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 248), big.NewInt(1))

MaxUint248 is the largest safe number for uint248 type

Functions

func AssertEach

func AssertEach[T CircuitVariable](ds *DataStream[T], assertFunc AssertFunc[T])

AssertEach asserts on each valid element in the data stream

func AssertSorted

func AssertSorted[T CircuitVariable](ds *DataStream[T], sortFunc SortFunc[T])

AssertSorted Performs the sortFunc on each valid pair of data points and assert the result to be 1.

func Compile

func Compile(app AppCircuit, compileOutDir, srsDir string) (constraint.ConstraintSystem, plonk.ProvingKey, plonk.VerifyingKey, error)

func CompileOnly

func CompileOnly(app AppCircuit) (constraint.ConstraintSystem, error)

CompileOnly is like Compile, but it does not automatically save the compilation output

func GetHints

func GetHints() []solver.Hint

func GetUnderlying

func GetUnderlying[T CircuitVariable](ds *DataStream[T], index int) T

GetUnderlying gets an element from the DataStream. Performed on the underlying data directly. It also requires the underlying data slot is valid

func GroupValuesHint

func GroupValuesHint(_ *big.Int, inputs []*big.Int, outputs []*big.Int) error

func MaxGeneric

func MaxGeneric[T CircuitVariable](ds *DataStream[T], initialMax T, gt SortFunc[T]) T

MaxGeneric finds out the maximum value from the data stream with the user defined sort function. Uses Reduce under the hood. Note if the data stream is empty (all data points are toggled off), this function returns 0.

func MinGeneric

func MinGeneric[T CircuitVariable](ds *DataStream[T], initialMin T, lt SortFunc[T]) T

MinGeneric finds out the minimum value from the data stream with the user defined sort function. Uses Reduce under the hood. Note if the data stream is empty (all data points are toggled off), this function returns MaxUint248.

func NewFullWitness

func NewFullWitness(assign AppCircuit, in CircuitInput) (w, wpub witness.Witness, err error)

func QuoRemBigHint

func QuoRemBigHint(_ *big.Int, in []*big.Int, out []*big.Int) error

func QuoRemHint

func QuoRemHint(_ *big.Int, in, out []*big.Int) error

func ReadCircuitFrom

func ReadCircuitFrom(path string) (constraint.ConstraintSystem, error)

func ReadPkFrom

func ReadPkFrom(path string) (plonk.ProvingKey, error)

func ReadProofFrom

func ReadProofFrom(path string) (plonk.Proof, error)

func ReadVkFrom

func ReadVkFrom(path string) (plonk.VerifyingKey, error)

func Reduce

func Reduce[T, R CircuitVariable](ds *DataStream[T], initial R, reducer ReduceFunc[T, R]) R

Reduce reduces the data stream to another CircuitVariable with the given reducer and initial condition

func Select

func Select[T CircuitVariable](api *CircuitAPI, s Uint248, a, b T) T

func Setup

func Setup(ccs constraint.ConstraintSystem, cacheDir string) (pk plonk.ProvingKey, vk plonk.VerifyingKey, err error)

func SortHint

func SortHint(_ *big.Int, in, out []*big.Int) error

SortHint sorts the input in descending order

func SqrtHint

func SqrtHint(_ *big.Int, in, out []*big.Int) error

func Verify

func Verify(vk plonk.VerifyingKey, publicWitness witness.Witness, proof plonk.Proof) error

func WriteTo

func WriteTo(w io.WriterTo, path string) error

Types

type AppCircuit

type AppCircuit interface {
	Define(api *CircuitAPI, in DataInput) error
	Allocate() (maxReceipts, maxStorage, maxTransactions int)
}

type AssertFunc

type AssertFunc[T CircuitVariable] func(current T) Uint248

AssertFunc returns 1 if the assertion passes, and 0 otherwise

type BrevisApp

type BrevisApp struct {
	// contains filtered or unexported fields
}

func NewBrevisApp

func NewBrevisApp(gatewayUrlOverride ...string) (*BrevisApp, error)

func (*BrevisApp) AddReceipt

func (q *BrevisApp) AddReceipt(data ReceiptData, index ...int)

AddReceipt adds the ReceiptData to be queried. If an index is specified, the data will be assigned to the specified index of DataInput.Receipts.

func (*BrevisApp) AddStorage

func (q *BrevisApp) AddStorage(data StorageData, index ...int)

AddStorage adds the StorageData to be queried. If an index is specified, the data will be assigned to the specified index of DataInput.StorageSlots.

func (*BrevisApp) AddTransaction

func (q *BrevisApp) AddTransaction(data TransactionData, index ...int)

AddTransaction adds the TransactionData to be queried. If an index is specified, the data will be assigned to the specified index of DataInput.Transactions.

func (*BrevisApp) BuildCircuitInput

func (q *BrevisApp) BuildCircuitInput(app AppCircuit) (CircuitInput, error)

BuildCircuitInput executes all added queries and package the query results into circuit assignment (the DataInput struct) The provided ctx is used when performing network calls to the provided blockchain RPC.

func (*BrevisApp) PrepareRequest

func (q *BrevisApp) PrepareRequest(
	vk plonk.VerifyingKey,
	srcChainId, dstChainId uint64,
	refundee, appContract common.Address,
) (calldata []byte, requestId common.Hash, feeValue *big.Int, err error)

func (*BrevisApp) SubmitProof

func (q *BrevisApp) SubmitProof(proof plonk.Proof, options ...SubmitProofOption) error

func (*BrevisApp) SubmitProofWithQueryId

func (q *BrevisApp) SubmitProofWithQueryId(queryId string, dstChainId uint64, proof []byte) error

func (*BrevisApp) WaitFinalProofSubmitted

func (q *BrevisApp) WaitFinalProofSubmitted(ctx context.Context) (tx common.Hash, err error)

type Bytes32

type Bytes32 struct {
	Val [2]frontend.Variable
}

Bytes32 is an in-circuit representation of the solidity bytes32 type.

func ConstBytes32

func ConstBytes32(data []byte) Bytes32

ConstBytes32 initializes a constant Bytes32 circuit variable. Panics if the length of the supplied data bytes is larger than 32.

func (Bytes32) FromValues

func (v Bytes32) FromValues(vs ...frontend.Variable) CircuitVariable

func (Bytes32) NumVars

func (v Bytes32) NumVars() uint32

func (Bytes32) String

func (v Bytes32) String() string

func (Bytes32) Values

func (v Bytes32) Values() []frontend.Variable

type Bytes32API

type Bytes32API struct {
	// contains filtered or unexported fields
}

func (*Bytes32API) AssertIsDifferent

func (api *Bytes32API) AssertIsDifferent(a, b Bytes32)

AssertIsDifferent asserts a != b

func (*Bytes32API) AssertIsEqual

func (api *Bytes32API) AssertIsEqual(a, b Bytes32)

AssertIsEqual asserts a == b

func (*Bytes32API) FromBinary

func (api *Bytes32API) FromBinary(vs ...Uint248) Bytes32

FromBinary interprets the input vs as a list of little-endian binary digits and recomposes it to a Bytes32. Input size can be less than 256 bits, the input is padded on the MSB end with 0s.

func (*Bytes32API) IsEqual

func (api *Bytes32API) IsEqual(a, b Bytes32) Uint248

IsEqual returns 1 if a == b, and 0 otherwise

func (*Bytes32API) IsZero

func (api *Bytes32API) IsZero(a Bytes32) Uint248

IsZero returns 1 if a == 0, and 0 otherwise

func (*Bytes32API) Select

func (api *Bytes32API) Select(s Uint248, a, b Bytes32) Bytes32

Select returns a if s == 1, and b if s == 0

func (*Bytes32API) ToBinary

func (api *Bytes32API) ToBinary(v Bytes32) List[Uint248]

ToBinary decomposes the input v to a list (size 256) of little-endian binary digits

type CircuitAPI

type CircuitAPI struct {
	Uint248 *Uint248API
	Uint521 *Uint521API
	Int248  *Int248API
	Bytes32 *Bytes32API
	// contains filtered or unexported fields
}

CircuitAPI contains a set of APIs that can only be used in circuit to perform logical and arithmetic operations over circuit variables. It is an extension of g's frontend.API.

func NewCircuitAPI

func NewCircuitAPI(gapi frontend.API) *CircuitAPI

func (*CircuitAPI) AssertInputsAreUnique

func (api *CircuitAPI) AssertInputsAreUnique()

AssertInputsAreUnique Asserts that all input data (Transaction, Receipt, StorageSlot) are different from each other

func (*CircuitAPI) OutputAddress

func (api *CircuitAPI) OutputAddress(v Uint248)

OutputAddress adds an output of solidity address type.

func (*CircuitAPI) OutputBool

func (api *CircuitAPI) OutputBool(v Uint248)

OutputBool adds an output of solidity bool type

func (*CircuitAPI) OutputBytes32

func (api *CircuitAPI) OutputBytes32(v Bytes32)

OutputBytes32 adds an output of solidity bytes32/uint256 type

func (*CircuitAPI) OutputUint

func (api *CircuitAPI) OutputUint(bitSize int, v Uint248)

OutputUint adds an output of solidity uint_bitSize type where N is in range [8, 248] with a step size 8. e.g. uint8, uint16, ..., uint248. Panics if a bitSize of non-multiple of 8 is used. Panics if the bitSize exceeds 248. For outputting uint256, use OutputBytes32 instead

func (*CircuitAPI) SlotOfArrayElement

func (api *CircuitAPI) SlotOfArrayElement(arrSlot Bytes32, elementSize int, index, offset Uint248) Bytes32

SlotOfArrayElement computes the storage slot for an element in a solidity array state variable. arrSlot is the plain slot of the array variable. index determines the array index. offset determines the offset (in terms of bytes32) within each array element.

func (*CircuitAPI) SlotOfStructFieldInMapping

func (api *CircuitAPI) SlotOfStructFieldInMapping(
	slot, offset int, valueSlot Bytes32, nestedMappingSlots ...Bytes32) Bytes32

SlotOfStructFieldInMapping computes the slot for a struct field stored in a solidity mapping. Implements keccak256(h(k) | p) for computing mapping or nested mapping's slot where the value is a struct The mapping slots are of the order which you would access the solidity mapping. For example, to access nested mapping at slot 1 value with m[a][b] and subsequently the 4th index of the struct value, use SlotOfStructFieldInMapping(1, 4, a, b). If your a and b are not of Bytes32 type, cast them to Bytes32 first using api.ToBytes32.

https://docs.soliditylang.org/en/v0.8.24/internals/layout_in_storage.html#mappings-and-dynamic-arrays

func (*CircuitAPI) ToBytes32

func (api *CircuitAPI) ToBytes32(i interface{}) Bytes32

ToBytes32 casts the input to a Bytes32 type. Supports Bytes32, Int248, Uint521, and Uint248.

func (*CircuitAPI) ToInt248

func (api *CircuitAPI) ToInt248(i interface{}) Int248

ToInt248 casts the input to a Int248 type. Supports Int248, Uint248, and Bytes32

func (*CircuitAPI) ToUint248

func (api *CircuitAPI) ToUint248(i interface{}) Uint248

ToUint248 casts the input to a Uint248 type. Supports Uint248, Int248, Bytes32, and Uint521

func (*CircuitAPI) ToUint521

func (api *CircuitAPI) ToUint521(i interface{}) Uint521

ToUint521 casts the input to a Uint521 type. Supports Uint521, Bytes32, and Uint248

type CircuitInput

type CircuitInput struct {
	DataInput

	// InputCommitments is a list of hash commitment to each value of Raw. These
	// commitments must match sub-prover circuit's commitment to its rlp decoded
	// values
	InputCommitments  []frontend.Variable `gnark:",public"`
	TogglesCommitment frontend.Variable   `gnark:",public"`
	// OutputCommitment is a keccak256 commitment to the computation results of the
	// developer's circuit. The output of this commitment is revealed by the
	// developer in their application contract.
	OutputCommitment OutputCommitment `gnark:",public"`
	// contains filtered or unexported fields
}

func (CircuitInput) Clone

func (in CircuitInput) Clone() CircuitInput

func (CircuitInput) GetAbiPackedOutput

func (in CircuitInput) GetAbiPackedOutput() []byte

type CircuitVariable

type CircuitVariable interface {
	Values() []frontend.Variable
	FromValues(vs ...frontend.Variable) CircuitVariable
	NumVars() uint32
	String() string
}

type DataInput

type DataInput struct {
	Receipts     DataPoints[Receipt]
	StorageSlots DataPoints[StorageSlot]
	Transactions DataPoints[Transaction]
}

func (DataInput) Toggles

func (d DataInput) Toggles() []frontend.Variable

type DataPoints

type DataPoints[T any] struct {
	// Raw is the structured input data (receipts, txs, and slots).
	Raw []T
	// Toggles is a bitmap that toggles the effectiveness of each position of Raw.
	// len(Toggles) must equal len(Raw)
	Toggles []frontend.Variable
}

func NewDataPoints

func NewDataPoints[T any](maxCount int, newEmpty func() T) DataPoints[T]

func (DataPoints[T]) Clone

func (dp DataPoints[T]) Clone() DataPoints[T]

type DataStream

type DataStream[T CircuitVariable] struct {
	// contains filtered or unexported fields
}

func Filter

func Filter[T CircuitVariable](ds *DataStream[T], predicate FilterFunc[T]) *DataStream[T]

Filter filters the data stream with the given predicate

func GroupBy

func GroupBy[T, R CircuitVariable](
	ds *DataStream[T],
	reducer ReduceFunc[T, R],
	reducerInit R,
	field GetValueFunc[T],
	maxUniqueGroupValuesOptional ...int,
) (*DataStream[R], error)

GroupBy a given field (identified through the field func), call reducer on each group, and returns a data stream in which each element is an aggregation result of the group. The optional param maxUniqueGroupValuesOptional can be supplied to optimize performance. It assumes the worst case (all values in the data stream are unique) if no maxUniqueGroupValuesOptional is configured.

func Map

func Map[T, R CircuitVariable](ds *DataStream[T], mapFunc MapFunc[T, R]) *DataStream[R]

Map maps each valid element in the data stream by calling the user defined mapFunc

func NewDataStream

func NewDataStream[T CircuitVariable](api *CircuitAPI, in DataPoints[T]) *DataStream[T]

func RangeUnderlying

func RangeUnderlying[T CircuitVariable](ds *DataStream[T], start, end int) *DataStream[T]

RangeUnderlying selects a range of the data stream. Performed on the underlying data directly.

func WindowUnderlying

func WindowUnderlying[T CircuitVariable](ds *DataStream[T], size int, step ...int) *DataStream[List[T]]

WindowUnderlying splits a DataStream into many equal sized List. Performed on the underlying data directly. Panics if `size` does not divide the length of the underlying list. Use Range to cut the list length into a multiple of `size` first

func ZipMap2

func ZipMap2[T0, T1, R CircuitVariable](
	a *DataStream[T0], b List[T1],
	zipFunc ZipMap2Func[T0, T1, R],
) *DataStream[R]

ZipMap2 zips a data stream with a list and apply the map function over the zipped data. The underlying toggles of the result data stream depends on the toggles from the source data stream. Panics if the underlying data lengths mismatch Example: ZipMap2([1,2,3], [4,5,6], mySumFunc) -> [5,7,9]

func ZipMap3

func ZipMap3[T0, T1, T2, R CircuitVariable](
	a *DataStream[T0], b List[T1], c List[T2],
	zipFunc ZipMap3Func[T0, T1, T2, R],
) *DataStream[R]

ZipMap3 zips a data stream with two other lists and apply the map function over the zipped data. The underlying toggles of the result data stream depends on the toggles from the source data stream. Example: ZipMap3([1,2,3], [4,5,6], [7,8,9], mySumFunc) -> [12,15,18]

func (*DataStream[T]) Show

func (ds *DataStream[T]) Show()

Show pretty prints the data stream. Useful for debugging.

type FilterFunc

type FilterFunc[T CircuitVariable] func(current T) Uint248

FilterFunc must return 1/0 to include/exclude `current` in the filter result

type GatewayClient

type GatewayClient struct {
	// contains filtered or unexported fields
}

func NewGatewayClient

func NewGatewayClient(url ...string) (*GatewayClient, error)

func (*GatewayClient) GetQueryStatus

func (c *GatewayClient) GetQueryStatus(req *gwproto.GetQueryStatusRequest) (resp *gwproto.GetQueryStatusResponse, err error)

func (*GatewayClient) PrepareQuery

func (c *GatewayClient) PrepareQuery(req *gwproto.PrepareQueryRequest) (resp *gwproto.PrepareQueryResponse, err error)

func (*GatewayClient) SubmitProof

type GetValueFunc

type GetValueFunc[T any] func(current T) Uint248

type HostCircuit

type HostCircuit struct {
	Input CircuitInput
	Guest AppCircuit
	// contains filtered or unexported fields
}

func DefaultHostCircuit

func DefaultHostCircuit(app AppCircuit) *HostCircuit

func NewHostCircuit

func NewHostCircuit(in CircuitInput, guest AppCircuit) *HostCircuit

func (*HostCircuit) Define

func (c *HostCircuit) Define(gapi frontend.API) error

type Int248

type Int248 struct {
	// Val encodes the entire int248 including the sign bit as a uint
	Val frontend.Variable
	// SignBit caches the sign bit signal. 0 if positive, 1 if negative. It could be
	// uninitialized.
	SignBit frontend.Variable
	// contains filtered or unexported fields
}

func ConstInt248

func ConstInt248(v *big.Int) Int248

ConstInt248 initializes a constant Int248. This function does not generate circuit wires and should only be used outside of circuit. The input big int can be negative

func (Int248) FromValues

func (v Int248) FromValues(vs ...frontend.Variable) CircuitVariable

func (Int248) NumVars

func (v Int248) NumVars() uint32

func (Int248) String

func (v Int248) String() string

func (Int248) Values

func (v Int248) Values() []frontend.Variable

type Int248API

type Int248API struct {
	// contains filtered or unexported fields
}

func (*Int248API) ABS

func (api *Int248API) ABS(a Int248) Uint248

ABS returns the absolute value of a

func (*Int248API) AssertIsDifferent

func (api *Int248API) AssertIsDifferent(a, b Int248)

AssertIsDifferent asserts a != b

func (*Int248API) AssertIsEqual

func (api *Int248API) AssertIsEqual(a, b Int248)

AssertIsEqual asserts a == b

func (*Int248API) FromBinary

func (api *Int248API) FromBinary(vs ...Uint248) Int248

FromBinary interprets the input vs as a list of little-endian binary digits and recomposes it to an Int248. The MSB (most significant bit) of the input is interpreted as the sign bit

func (*Int248API) IsEqual

func (api *Int248API) IsEqual(a, b Int248) Uint248

IsEqual returns 1 if a == b, and 0 otherwise

func (*Int248API) IsGreaterThan

func (api *Int248API) IsGreaterThan(a, b Int248) Uint248

IsGreaterThan returns 1 if a > b, and 0 otherwise

func (*Int248API) IsLessThan

func (api *Int248API) IsLessThan(a, b Int248) Uint248

IsLessThan returns 1 if a < b, and 0 otherwise

func (*Int248API) IsZero

func (api *Int248API) IsZero(a Int248) Uint248

IsZero returns 1 if a == 0, and 0 otherwise

func (*Int248API) Select

func (api *Int248API) Select(s Uint248, a, b Int248) Int248

Select returns a if s == 1, and b if s == 0

func (*Int248API) ToBinary

func (api *Int248API) ToBinary(v Int248) List[Uint248]

ToBinary decomposes the input v to a list (size n) of little-endian binary digits

type List

type List[T CircuitVariable] []T

func (List[T]) FromValues

func (l List[T]) FromValues(vs ...frontend.Variable) CircuitVariable

func (List[T]) NumVars

func (l List[T]) NumVars() uint32

func (List[T]) String

func (l List[T]) String() string

func (List[T]) Values

func (l List[T]) Values() []frontend.Variable

type LogField

type LogField struct {
	// The contract from which the event is emitted
	Contract Uint248
	// The event ID of the event to which the field belong (aka topics[0])
	EventID Uint248
	// Whether the field is a topic (aka "indexed" as in solidity events)
	IsTopic Uint248
	// The index of the field. For example, if a field is the second topic of a log, then Index is 1; if a field is the
	// third field in the RLP decoded data, then Index is 2.
	Index Uint248
	// The value of the field in event, aka the actual thing we care about, only 32-byte fixed length values are supported.
	Value Bytes32
}

LogField represents a single field of an event.

func (LogField) FromValues

func (f LogField) FromValues(vs ...frontend.Variable) CircuitVariable

func (LogField) NumVars

func (f LogField) NumVars() uint32

func (LogField) String

func (f LogField) String() string

func (LogField) Values

func (f LogField) Values() []frontend.Variable

type LogFieldData

type LogFieldData struct {
	// The contract from which the event is emitted
	Contract common.Address `json:"contract,omitempty"`
	// the index of the log in the receipt
	LogIndex uint `json:"log_index,omitempty"`
	// The event ID of the event to which the field belong (aka topics[0])
	EventID common.Hash `json:"event_id,omitempty"`
	// Whether the field is a topic (aka "indexed" as in solidity events)
	IsTopic bool `json:"is_topic,omitempty"`
	// The index of the field in either a log's topics or data. For example, if a
	// field is the second topic of a log, then FieldIndex is 1; if a field is the
	// third field in the RLP decoded data, then FieldIndex is 2.
	FieldIndex uint `json:"field_index,omitempty"`
	// The value of the field in event, aka the actual thing we care about, only
	// 32-byte fixed length values are supported.
	Value common.Hash `json:"value,omitempty"`
}

LogFieldData represents a single field of an event.

type MapFunc

type MapFunc[T, R CircuitVariable] func(current T) R

type OutputCommitment

type OutputCommitment [2]frontend.Variable

OutputCommitment represents the value of a keccak256 hash H in the form of {H[:16], H[16:]}

func (OutputCommitment) Hash

func (c OutputCommitment) Hash() common.Hash

Hash returns the go hash representation of the commitment

type Receipt

type Receipt struct {
	BlockNum Uint248
	Fields   [NumMaxLogFields]LogField
}

Receipt is a collection of LogField.

func (Receipt) FromValues

func (r Receipt) FromValues(vs ...frontend.Variable) CircuitVariable

func (Receipt) NumVars

func (r Receipt) NumVars() uint32

func (Receipt) String

func (r Receipt) String() string

func (Receipt) Values

func (r Receipt) Values() []frontend.Variable

type ReceiptData

type ReceiptData struct {
	BlockNum *big.Int                      `json:"block_num,omitempty"`
	TxHash   common.Hash                   `json:"tx_hash,omitempty"`
	Fields   [NumMaxLogFields]LogFieldData `json:"fields,omitempty"`
}

type ReduceFunc

type ReduceFunc[T, R CircuitVariable] func(accumulator R, current T) (newAccumulator R)

type SortFunc

type SortFunc[T CircuitVariable] func(a, b T) Uint248

SortFunc returns 1 if a, b are sorted, 0 if not.

type StorageData

type StorageData struct {
	BlockNum *big.Int       `json:"block_num,omitempty"`
	Address  common.Address `json:"address,omitempty"`
	Slot     common.Hash    `json:"slot,omitempty"`
	Value    common.Hash    `json:"value,omitempty"`
}

type StorageSlot

type StorageSlot struct {
	BlockNum Uint248
	// The contract to which the storage slot belong
	Contract Uint248
	// The storage slot
	Slot Bytes32
	// The storage slot value
	Value Bytes32
}

func (StorageSlot) FromValues

func (s StorageSlot) FromValues(vs ...frontend.Variable) CircuitVariable

func (StorageSlot) NumVars

func (s StorageSlot) NumVars() uint32

func (StorageSlot) String

func (s StorageSlot) String() string

func (StorageSlot) Values

func (s StorageSlot) Values() []frontend.Variable

type SubmitProofOption

type SubmitProofOption func(option submitProofOptions)

func WithContext

func WithContext(ctx context.Context) SubmitProofOption

WithContext uses the input context as the context for waiting for final proof submission

func WithFinalProofSubmittedCallback

func WithFinalProofSubmittedCallback(onSubmitted func(txHash common.Hash), onError func(err error)) SubmitProofOption

WithFinalProofSubmittedCallback sets an async callback for final proof submission result

type Transaction

type Transaction struct {
	ChainId  Uint248
	BlockNum Uint248
	Nonce    Uint248
	// GasTipCapOrGasPrice is GasPrice for legacy tx (type 0) and GasTipCapOap for
	// dynamic-fee tx (type 2)
	GasTipCapOrGasPrice Uint248
	// GasFeeCap is always 0 for legacy tx
	GasFeeCap Uint248
	GasLimit  Uint248
	From      Uint248
	To        Uint248
	Value     Bytes32
}

func (Transaction) FromValues

func (t Transaction) FromValues(vs ...frontend.Variable) CircuitVariable

func (Transaction) NumVars

func (t Transaction) NumVars() uint32

func (Transaction) String

func (t Transaction) String() string

func (Transaction) Values

func (t Transaction) Values() []frontend.Variable

type TransactionData

type TransactionData struct {
	Hash     common.Hash `json:"hash,omitempty"`
	ChainId  *big.Int    `json:"chain_id,omitempty"`
	BlockNum *big.Int    `json:"block_num,omitempty"`
	Nonce    uint64      `json:"nonce,omitempty"`
	// GasTipCapOrGasPrice is GasPrice for legacy tx (type 0) and GasTipCapOap for
	// dynamic-fee tx (type 2)
	GasTipCapOrGasPrice *big.Int `json:"max_priority_fee_per_gas,omitempty"`
	// GasFeeCap is always 0 for legacy tx
	GasFeeCap *big.Int       `json:"gas_price_or_fee_cap,omitempty"`
	GasLimit  uint64         `json:"gas_limit,omitempty"`
	From      common.Address `json:"from,omitempty"`
	To        common.Address `json:"to,omitempty"`
	Value     *big.Int       `json:"value,omitempty"`
}

type Tuple2

type Tuple2[F0, F1 CircuitVariable] struct {
	F0 F0
	F1 F1
}

func (Tuple2[F0, F1]) FromValues

func (t Tuple2[F0, F1]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple2[F0, F1]) NumVars

func (t Tuple2[F0, F1]) NumVars() uint32

func (Tuple2[F0, F1]) String

func (t Tuple2[F0, F1]) String() string

func (Tuple2[F0, F1]) Values

func (t Tuple2[F0, F1]) Values() []frontend.Variable

type Tuple3

type Tuple3[F0, F1, F2 CircuitVariable] struct {
	F0 F0
	F1 F1
	F2 F2
}

func (Tuple3[F0, F1, F2]) FromValues

func (t Tuple3[F0, F1, F2]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple3[F0, F1, F2]) NumVars

func (t Tuple3[F0, F1, F2]) NumVars() uint32

func (Tuple3[F0, F1, F2]) String

func (t Tuple3[F0, F1, F2]) String() string

func (Tuple3[F0, F1, F2]) Values

func (t Tuple3[F0, F1, F2]) Values() []frontend.Variable

type Tuple4

type Tuple4[F0, F1, F2, F3 CircuitVariable] struct {
	F0 F0
	F1 F1
	F2 F2
	F3 F3
}

func (Tuple4[F0, F1, F2, F3]) FromValues

func (t Tuple4[F0, F1, F2, F3]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple4[F0, F1, F2, F3]) NumVars

func (t Tuple4[F0, F1, F2, F3]) NumVars() uint32

func (Tuple4[F0, F1, F2, F3]) String

func (t Tuple4[F0, F1, F2, F3]) String() string

func (Tuple4[F0, F1, F2, F3]) Values

func (t Tuple4[F0, F1, F2, F3]) Values() []frontend.Variable

type Tuple5

type Tuple5[F0, F1, F2, F3, F4 CircuitVariable] struct {
	F0 F0
	F1 F1
	F2 F2
	F3 F3
	F4 F4
}

func (Tuple5[F0, F1, F2, F3, F4]) FromValues

func (t Tuple5[F0, F1, F2, F3, F4]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple5[F0, F1, F2, F3, F4]) NumVars

func (t Tuple5[F0, F1, F2, F3, F4]) NumVars() uint32

func (Tuple5[F0, F1, F2, F3, F4]) String

func (t Tuple5[F0, F1, F2, F3, F4]) String() string

func (Tuple5[F0, F1, F2, F3, F4]) Values

func (t Tuple5[F0, F1, F2, F3, F4]) Values() []frontend.Variable

type Tuple6

type Tuple6[F0, F1, F2, F3, F4, F5 CircuitVariable] struct {
	F0 F0
	F1 F1
	F2 F2
	F3 F3
	F4 F4
	F5 F5
}

func (Tuple6[F0, F1, F2, F3, F4, F5]) FromValues

func (t Tuple6[F0, F1, F2, F3, F4, F5]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple6[F0, F1, F2, F3, F4, F5]) NumVars

func (t Tuple6[F0, F1, F2, F3, F4, F5]) NumVars() uint32

func (Tuple6[F0, F1, F2, F3, F4, F5]) String

func (t Tuple6[F0, F1, F2, F3, F4, F5]) String() string

func (Tuple6[F0, F1, F2, F3, F4, F5]) Values

func (t Tuple6[F0, F1, F2, F3, F4, F5]) Values() []frontend.Variable

type Tuple7

type Tuple7[F0, F1, F2, F3, F4, F5, F6 CircuitVariable] struct {
	F0 F0
	F1 F1
	F2 F2
	F3 F3
	F4 F4
	F5 F5
	F6 F6
}

func (Tuple7[F0, F1, F2, F3, F4, F5, F6]) FromValues

func (t Tuple7[F0, F1, F2, F3, F4, F5, F6]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple7[F0, F1, F2, F3, F4, F5, F6]) NumVars

func (t Tuple7[F0, F1, F2, F3, F4, F5, F6]) NumVars() uint32

func (Tuple7[F0, F1, F2, F3, F4, F5, F6]) String

func (t Tuple7[F0, F1, F2, F3, F4, F5, F6]) String() string

func (Tuple7[F0, F1, F2, F3, F4, F5, F6]) Values

func (t Tuple7[F0, F1, F2, F3, F4, F5, F6]) Values() []frontend.Variable

type Tuple8

type Tuple8[F0, F1, F2, F3, F4, F5, F6, F7 CircuitVariable] struct {
	F0 F0
	F1 F1
	F2 F2
	F3 F3
	F4 F4
	F5 F5
	F6 F6
	F7 F7
}

func (Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) FromValues

func (t Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) FromValues(vs ...frontend.Variable) CircuitVariable

func (Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) NumVars

func (t Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) NumVars() uint32

func (Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) String

func (t Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) String() string

func (Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) Values

func (t Tuple8[F0, F1, F2, F3, F4, F5, F6, F7]) Values() []frontend.Variable

type Uint248

type Uint248 struct {
	Val frontend.Variable
}

func ConstUint248

func ConstUint248(i interface{}) Uint248

ConstUint248 initializes a constant Uint248. This function does not generate circuit wires and should only be used outside of circuit. Supports all int and uint variants, bool, []byte (big-endian), *big.Int, and string inputs. If input is string, this function uses *big.Int SetString function to interpret the string

func Count

func Count[T CircuitVariable](ds *DataStream[T]) Uint248

Count returns the number of valid elements (i.e. toggled on) in the data stream.

func IsSorted

func IsSorted[T CircuitVariable](ds *DataStream[T], sortFunc SortFunc[T]) Uint248

IsSorted returns 1 if the data stream is sorted to the criteria of sortFunc, 0 if not.

func Max

func Max(ds *DataStream[Uint248]) Uint248

Max finds out the maximum value from the data stream. Uses MaxGeneric. Note if the data stream is empty (all data points are toggled off), this function returns 0.

func Mean

func Mean(ds *DataStream[Uint248]) Uint248

Mean calculates the arithmetic mean over the selected fields of the data stream. Uses Sum.

func Min

func Min(ds *DataStream[Uint248]) Uint248

Min finds out the minimum value from the data stream. Uses MinGeneric. Note if the data stream is empty (all data points are toggled off), this function returns MaxUint248.

func ParseEventID

func ParseEventID(b []byte) Uint248

ParseEventID initializes a circuit Uint248 from bytes. Only the first 6 bytes of the event id is used to save space. This function does not generate circuit wires and should only be used outside of circuit.

func Sum

func Sum(ds *DataStream[Uint248]) Uint248

Sum sums values of the selected field in the data stream. Uses Reduce

func (Uint248) FromValues

func (v Uint248) FromValues(vs ...frontend.Variable) CircuitVariable

func (Uint248) NumVars

func (v Uint248) NumVars() uint32

func (Uint248) String

func (v Uint248) String() string

func (Uint248) Values

func (v Uint248) Values() []frontend.Variable

type Uint248API

type Uint248API struct {
	// contains filtered or unexported fields
}

func (*Uint248API) Add

func (api *Uint248API) Add(a, b Uint248, other ...Uint248) Uint248

Add returns a + b. Overflow can happen if a + b > 2^248

func (*Uint248API) And

func (api *Uint248API) And(a, b Uint248, other ...Uint248) Uint248

And returns 1 if a && b [&& other[0] [&& other[1]...]] is true, and 0 otherwise

func (*Uint248API) AssertIsDifferent

func (api *Uint248API) AssertIsDifferent(a, b Uint248)

AssertIsDifferent asserts a != b

func (*Uint248API) AssertIsEqual

func (api *Uint248API) AssertIsEqual(a, b Uint248)

AssertIsEqual asserts a == b

func (*Uint248API) AssertIsLessOrEqual

func (api *Uint248API) AssertIsLessOrEqual(a, b Uint248)

AssertIsLessOrEqual asserts a <= b

func (*Uint248API) Div

func (api *Uint248API) Div(a, b Uint248) (quotient, remainder Uint248)

Div computes the standard unsigned integer division (like Go) and returns the quotient and remainder. Uses QuoRemHint

func (*Uint248API) FromBinary

func (api *Uint248API) FromBinary(vs ...Uint248) Uint248

FromBinary interprets the input vs as a list of little-endian binary digits and recomposes it to a Uint248

func (*Uint248API) IsEqual

func (api *Uint248API) IsEqual(a, b Uint248) Uint248

IsEqual returns 1 if a == b, and 0 otherwise

func (*Uint248API) IsGreaterThan

func (api *Uint248API) IsGreaterThan(a, b Uint248) Uint248

IsGreaterThan returns 1 if a > b, and 0 otherwise

func (*Uint248API) IsLessThan

func (api *Uint248API) IsLessThan(a, b Uint248) Uint248

IsLessThan returns 1 if a < b, and 0 otherwise

func (*Uint248API) IsZero

func (api *Uint248API) IsZero(a Uint248) Uint248

IsZero returns 1 if a == 0, and 0 otherwise

func (*Uint248API) Mul

func (api *Uint248API) Mul(a, b Uint248) Uint248

Mul returns a * b. Overflow can happen if a * b > 2^248

func (*Uint248API) Not

func (api *Uint248API) Not(a Uint248) Uint248

Not returns 1 if a is 0, and 0 if a is 1. The user must make sure a is either 0 or 1

func (*Uint248API) Or

func (api *Uint248API) Or(a, b Uint248, other ...Uint248) Uint248

Or returns 1 if a || b [|| other[0] [|| other[1]...]] is true, and 0 otherwise

func (*Uint248API) Select

func (api *Uint248API) Select(s Uint248, a, b Uint248) Uint248

Select returns a if s == 1, and b if s == 0

func (*Uint248API) Sqrt

func (api *Uint248API) Sqrt(a Uint248) Uint248

Sqrt returns √a. Uses SqrtHint

func (*Uint248API) Sub

func (api *Uint248API) Sub(a, b Uint248) Uint248

Sub returns a - b. Underflow can happen if b > a

func (*Uint248API) ToBinary

func (api *Uint248API) ToBinary(v Uint248, n int) List[Uint248]

ToBinary decomposes the input v to a list (size n) of little-endian binary digits

type Uint521

type Uint521 struct {
	*emulated.Element[Uint521Field]
}

func ConstUint521

func ConstUint521(i interface{}) Uint521

ConstUint521 initializes a constant Uint521. This function does not generate circuit wires and should only be used outside of circuit. Supports all int and uint variants, bool, []byte (big-endian), *big.Int, and string inputs. If input is string, this function uses *big.Int SetString function to interpret the string

func (Uint521) FromValues

func (v Uint521) FromValues(vs ...frontend.Variable) CircuitVariable

func (Uint521) NumVars

func (v Uint521) NumVars() uint32

func (Uint521) String

func (v Uint521) String() string

func (Uint521) Values

func (v Uint521) Values() []frontend.Variable

type Uint521API

type Uint521API struct {
	// contains filtered or unexported fields
}

func (*Uint521API) Add

func (api *Uint521API) Add(a, b Uint521) Uint521

Add returns a + b. Overflow can happen if a + b > 2^521

func (*Uint521API) AssertIsEqual

func (api *Uint521API) AssertIsEqual(a, b Uint521)

AssertIsEqual asserts a == b

func (*Uint521API) AssertIsLessOrEqual

func (api *Uint521API) AssertIsLessOrEqual(a, b Uint521)

AssertIsLessOrEqual asserts a <= b

func (*Uint521API) Div

func (api *Uint521API) Div(a, b Uint521) (quotient, remainder Uint521)

Div computes the standard unsigned integer division (like Go) and returns the quotient and remainder. Uses QuoRemHint

func (*Uint521API) FromBinary

func (api *Uint521API) FromBinary(vs ...Uint248) Uint521

FromBinary interprets the input vs as a list of little-endian binary digits and recomposes it to a Uint521

func (*Uint521API) IsEqual

func (api *Uint521API) IsEqual(a, b Uint521) Uint248

IsEqual returns 1 if a == b, and 0 otherwise

func (*Uint521API) Mul

func (api *Uint521API) Mul(a, b Uint521) Uint521

Mul returns a * b. Overflow can happen if a * b > 2^521

func (*Uint521API) Select

func (api *Uint521API) Select(s Uint248, a, b Uint521) Uint521

Select returns a if s == 1, and b if s == 0

func (*Uint521API) Sub

func (api *Uint521API) Sub(a, b Uint521) Uint521

Sub returns a - b. Underflow can happen if b > a

func (*Uint521API) ToBinary

func (api *Uint521API) ToBinary(v Uint521, n int) List[Uint248]

ToBinary decomposes the input v to a list (size n) of little-endian binary digits

type Uint521Field

type Uint521Field struct{}

func (Uint521Field) BitsPerLimb

func (f Uint521Field) BitsPerLimb() uint

func (Uint521Field) IsPrime

func (f Uint521Field) IsPrime() bool

func (Uint521Field) Modulus

func (f Uint521Field) Modulus() *big.Int

func (Uint521Field) NbLimbs

func (f Uint521Field) NbLimbs() uint

type ZipMap2Func

type ZipMap2Func[T0, T1, R CircuitVariable] func(a T0, b T1) R

type ZipMap3Func

type ZipMap3Func[T0, T1, T2, R CircuitVariable] func(a T0, b T1, c T2) R

Directories

Path Synopsis
proto
sdkproto
Package sdk is a reverse proxy.
Package sdk is a reverse proxy.

Jump to

Keyboard shortcuts

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