pbc_contract_common::zk

Enum ZkStateChange

source
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

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

Fields

§variable: SecretVarId

Input that should be deleted.

§

TransferVariable

Transfers ownership of variable to new_owner.

§Invariants

Fields

§variable: SecretVarId

Variable to transfer

§new_owner: Address

New owner of variable

§

DeleteVariable

Deletes given secret variable.

§Invariants

Fields

§variable: SecretVarId

Variable to delete

§

DeleteVariables

Deletes given secret variables.

§Invariants

Fields

§variables_to_delete: Vec<SecretVarId>

Variables to delete

§

OpenVariables

Reveals the values of the given secret variables.

§Invariants

Fields

§variables: Vec<SecretVarId>

Variables to open

§

OutputComplete

👎Deprecated: OutputComplete state change is not supported. Either remove, or use DeleteVariables instead.

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

Fields

§data_to_attest: Vec<u8>

The piece of data to attest.

§

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

source

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.
source

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

source§

fn clone(&self) -> ZkStateChange

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ZkStateChange

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl WriteRPC for ZkStateChange

source§

fn rpc_write_to<T: Write>(&self, writer: &mut T) -> Result<()>

Serialization method for RPC arguments.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.