pub enum ZkStateChange {
Show 13 variants
StartComputation {
function_shortname: ShortnameZkComputation,
output_variable_metadata: Vec<Vec<u8>>,
input_arguments: Vec<Vec<u8>>,
on_complete_function_shortname: Option<ShortnameZkComputeComplete>,
},
DeletePendingInput {
variable: SecretVarId,
},
TransferVariable {
variable: SecretVarId,
new_owner: Address,
},
DeleteVariable {
variable: SecretVarId,
},
DeleteVariables {
variables_to_delete: Vec<SecretVarId>,
},
OpenVariables {
variables: Vec<SecretVarId>,
},
OutputComplete {},
ContractDone,
Attest {
data_to_attest: Vec<u8>,
},
SubscribeToEvmEvents {
chain_id: EvmChainId,
filter: EvmEventFilter,
},
UnsubscribeFromEvmEvents {
subscription_id: EventSubscriptionId,
},
DeleteEvmEvent {
event_id: ExternalEventId,
},
DeleteEvmEvents {
events_to_delete: Vec<ExternalEventId>,
},
}
Expand description
Represents individual state changes in the ZkState.
Variants§
StartComputation
Starts Zk computation.
The direct constructor is cumbersome, use ZkStateChange::start_computation
instead.
§Invariants
- Must only occur when
ZkState::calculation_state
isCalculationStatus::Waiting
. - Only one
StartComputation
is allowed per transaction.
Fields
function_shortname: ShortnameZkComputation
Id of the Zk function to call initially. Function must be declared as pub
.
output_variable_metadata: Vec<Vec<u8>>
Metadata associated which each output variable. Assumes each piece of metadata have been serialized manually.
input_arguments: Vec<Vec<u8>>
Public variables to be given to the ZK computation, as function inputs. Assumes each piece of metadata have been serialized manually.
on_complete_function_shortname: Option<ShortnameZkComputeComplete>
Shortname of function to call when the computation completes. A None
value
indicates that no function should be called; this prevents the contract from
reacting to the completion of the computation.
DeletePendingInput
Deletes pending input for the given user. If the variable is confirmed by the nodes before this state change is executed, the variable is not deleted.
§Invariants
- Can occur in any
ZkState::calculation_state
.
Fields
variable: SecretVarId
Input that should be deleted.
TransferVariable
Transfers ownership of variable
to new_owner
.
§Invariants
- Can occur in any
ZkState::calculation_state
.
DeleteVariable
Fields
variable: SecretVarId
Variable to delete
DeleteVariables
Fields
variables_to_delete: Vec<SecretVarId>
Variables to delete
OpenVariables
Reveals the values of the given secret variables.
§Invariants
- Can occur in any
ZkState::calculation_state
.
Fields
variables: Vec<SecretVarId>
Variables to open
OutputComplete
Deprecated state ZkStateChange
that changed ZkState::calculation_state
from CalculationStatus::Output
back to CalculationStatus::Waiting
, and deleted the specified variables.
§Deprecation
Removed variables_to_delete
field in order to trigger a hard error.
ContractDone
Closes ZK computation; no further zero-knowledge can be done.
§Invariants
Must only occur when ZkState::calculation_state
is CalculationStatus::Waiting
.
Attest
Requests ZK nodes to sign/attest this piece of data.
§Invariants
- Can occur in any
ZkState::calculation_state
.
SubscribeToEvmEvents
Subscribe to events emitted by an EVM chain.
Fields
chain_id: EvmChainId
Identification of the chain to subscribe to events from.
filter: EvmEventFilter
Event filter to specify which events to receive.
UnsubscribeFromEvmEvents
Unsubscribe from events emitted by an EVM chain.
Fields
subscription_id: EventSubscriptionId
Identifier for the subscription to cancel.
DeleteEvmEvent
Delete an EVM event.
Fields
event_id: ExternalEventId
Identifier for the event to delete.
DeleteEvmEvents
Delete EVM events.
Fields
events_to_delete: Vec<ExternalEventId>
List of subscription and event ids.
Implementations§
source§impl ZkStateChange
impl ZkStateChange
sourcepub fn start_computation<T: ReadWriteState>(
function_shortname: ShortnameZkComputation,
output_variable_metadata: Vec<T>,
on_complete_function_shortname: Option<ShortnameZkComputeComplete>,
) -> Self
pub fn start_computation<T: ReadWriteState>( function_shortname: ShortnameZkComputation, output_variable_metadata: Vec<T>, on_complete_function_shortname: Option<ShortnameZkComputeComplete>, ) -> Self
Convenience function for creating instances of Self::StartComputation
, automatically
serializing metadata.
Arguments:
output_variable_metadata
: Vector of pieces of metadata to associate with each output variable.
§Invariants
- The argument
output_variable_metadata
must have the same number of elements as is outputted by the zk computation.
sourcepub fn start_computation_with_inputs<T: ReadWriteState, A: ReadWriteState>(
function_shortname: ShortnameZkComputation,
output_variable_metadata: Vec<T>,
input_arguments: Vec<A>,
on_complete_function_shortname: Option<ShortnameZkComputeComplete>,
) -> Self
pub fn start_computation_with_inputs<T: ReadWriteState, A: ReadWriteState>( function_shortname: ShortnameZkComputation, output_variable_metadata: Vec<T>, input_arguments: Vec<A>, on_complete_function_shortname: Option<ShortnameZkComputeComplete>, ) -> Self
Convenience function for creating instances of Self::StartComputation
, automatically
serializing metadata.
Arguments:
output_variable_metadata
: Vector of pieces of metadata to associate with each output variable.input_arguments
: Vector of pieces of public input to be given to the ZK computation.
§Invariants
- The argument
output_variable_metadata
must have the same number of elements as is outputted by the zk computation. - The argument
input_arguments
must have the same number of elements as the ZK computation have input arguments, and these must be of the same types.
Trait Implementations§
source§impl Clone for ZkStateChange
impl Clone for ZkStateChange
source§fn clone(&self) -> ZkStateChange
fn clone(&self) -> ZkStateChange
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ZkStateChange
impl Debug for ZkStateChange
Auto Trait Implementations§
impl Freeze for ZkStateChange
impl RefUnwindSafe for ZkStateChange
impl Send for ZkStateChange
impl Sync for ZkStateChange
impl Unpin for ZkStateChange
impl UnwindSafe for ZkStateChange
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)