snarkvm_synthesizer

Struct Stack

Source
pub struct Stack<N>
where N: Network,
{ /* private fields */ }

Implementations§

Source§

impl<N> Stack<N>
where N: Network,

Source

pub fn authorize<A, R>( &self, private_key: &PrivateKey<N>, function_name: impl TryInto<Identifier<N>>, inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, rng: &mut R, ) -> Result<Authorization<N>, Error>
where A: Aleo<Network = N>, R: Rng + CryptoRng,

Authorizes a call to the program function for the given inputs.

Source§

impl<N> Stack<N>
where N: Network,

Source

pub fn deploy<A, R>(&self, rng: &mut R) -> Result<Deployment<N>, Error>
where A: Aleo<Network = N>, R: Rng + CryptoRng,

Deploys the given program ID, if it does not exist.

Source

pub fn verify_deployment<A, R>( &self, deployment: &Deployment<N>, rng: &mut R, ) -> Result<(), Error>
where A: Aleo<Network = N>, R: Rng + CryptoRng,

Checks each function in the program on the given verifying key and certificate.

Source§

impl<N> Stack<N>
where N: Network,

Source

pub fn sample_plaintext<R>( &self, plaintext_type: &PlaintextType<N>, rng: &mut R, ) -> Result<Plaintext<N>, Error>
where R: Rng + CryptoRng,

Samples a plaintext value according to the given plaintext type.

Source

pub fn sample_future<R>( &self, locator: &Locator<N>, rng: &mut R, ) -> Result<Future<N>, Error>
where R: Rng + CryptoRng,

Samples a future value according to the given future type.

Source§

impl<N> Stack<N>
where N: Network,

Source

pub fn synthesize_key<A, R>( &self, function_name: &Identifier<N>, rng: &mut R, ) -> Result<(), Error>
where A: Aleo<Network = N>, R: Rng + CryptoRng,

Synthesizes the proving key and verifying key for the given function name.

Source

pub fn synthesize_from_assignment( &self, function_name: &Identifier<N>, assignment: &Assignment<<N as Environment>::Field>, ) -> Result<(), Error>

Synthesizes and stores the (proving_key, verifying_key) for the given function name and assignment.

Source§

impl<N> Stack<N>
where N: Network,

Source

pub fn new( process: &Process<N>, program: &ProgramCore<N, Instruction<N>, Command<N>>, ) -> Result<Stack<N>, Error>

Initializes a new stack, if it does not already exist, given the process and the program.

Source§

impl<N> Stack<N>
where N: Network,

Source

pub fn contains_proving_key(&self, function_name: &Identifier<N>) -> bool

Returns true if the proving key for the given function name exists.

Source

pub fn contains_verifying_key(&self, function_name: &Identifier<N>) -> bool

Returns true if the verifying key for the given function name exists.

Source

pub fn get_proving_key( &self, function_name: &Identifier<N>, ) -> Result<ProvingKey<N>, Error>

Returns the proving key for the given function name.

Source

pub fn get_verifying_key( &self, function_name: &Identifier<N>, ) -> Result<VerifyingKey<N>, Error>

Returns the verifying key for the given function name.

Source

pub fn insert_proving_key( &self, function_name: &Identifier<N>, proving_key: ProvingKey<N>, ) -> Result<(), Error>

Inserts the given proving key for the given function name.

Source

pub fn insert_verifying_key( &self, function_name: &Identifier<N>, verifying_key: VerifyingKey<N>, ) -> Result<(), Error>

Inserts the given verifying key for the given function name.

Source

pub fn remove_proving_key(&self, function_name: &Identifier<N>)

Removes the proving key for the given function name.

Source

pub fn remove_verifying_key(&self, function_name: &Identifier<N>)

Removes the verifying key for the given function name.

Trait Implementations§

Source§

impl<N> Clone for Stack<N>
where N: Clone + Network,

Source§

fn clone(&self) -> Stack<N>

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<N> PartialEq for Stack<N>
where N: Network,

Source§

fn eq(&self, other: &Stack<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N> StackEvaluate<N> for Stack<N>
where N: Network,

Source§

fn evaluate_closure<A>( &self, closure: &ClosureCore<N, Instruction<N>>, inputs: &[Value<N>], call_stack: CallStack<N>, signer: Address<N>, caller: Address<N>, tvk: Field<N>, ) -> Result<Vec<Value<N>>, Error>
where A: Aleo<Network = N>,

Evaluates a program closure on the given inputs.

§Errors

This method will halt if the given inputs are not the same length as the input statements.

Source§

fn evaluate_function<A>( &self, call_stack: CallStack<N>, caller: Option<ProgramID<N>>, ) -> Result<Response<N>, Error>
where A: Aleo<Network = N>,

Evaluates a program function on the given inputs.

§Errors

This method will halt if the given inputs are not the same length as the input statements.

Source§

impl<N> StackExecute<N> for Stack<N>
where N: Network,

Source§

fn execute_closure<A>( &self, closure: &ClosureCore<N, Instruction<N>>, inputs: &[Value<A>], call_stack: CallStack<N>, signer: Address<A>, caller: Address<A>, tvk: Field<A>, ) -> Result<Vec<Value<A>>, Error>
where A: Aleo<Network = N>,

Executes a program closure on the given inputs.

§Errors

This method will halt if the given inputs are not the same length as the input statements.

Source§

fn execute_function<A, R>( &self, call_stack: CallStack<N>, console_caller: Option<ProgramID<N>>, root_tvk: Option<Field<N>>, rng: &mut R, ) -> Result<Response<N>, Error>
where A: Aleo<Network = N>, R: CryptoRng + Rng,

Executes a program function on the given inputs.

Note: To execute a transition, do not call this method. Instead, call Process::execute.

§Errors

This method will halt if the given inputs are not the same length as the input statements.

Source§

impl<N> StackMatches<N> for Stack<N>
where N: Network,

Source§

fn matches_value_type( &self, value: &Value<N>, value_type: &ValueType<N>, ) -> Result<(), Error>

Checks that the given value matches the layout of the value type.

Source§

fn matches_register_type( &self, stack_value: &Value<N>, register_type: &RegisterType<N>, ) -> Result<(), Error>

Checks that the given stack value matches the layout of the register type.

Source§

fn matches_external_record( &self, record: &Record<N, Plaintext<N>>, locator: &Locator<N>, ) -> Result<(), Error>

Checks that the given record matches the layout of the external record type.

Source§

fn matches_record( &self, record: &Record<N, Plaintext<N>>, record_name: &Identifier<N>, ) -> Result<(), Error>

Checks that the given record matches the layout of the record type.

Source§

fn matches_plaintext( &self, plaintext: &Plaintext<N>, plaintext_type: &PlaintextType<N>, ) -> Result<(), Error>

Checks that the given plaintext matches the layout of the plaintext type.

Source§

fn matches_future( &self, future: &Future<N>, locator: &Locator<N>, ) -> Result<(), Error>

Checks that the given future matches the layout of the future type.

Source§

impl<N> StackProgram<N> for Stack<N>
where N: Network,

Source§

fn program(&self) -> &ProgramCore<N, Instruction<N>, Command<N>>

Returns the program.

Source§

fn program_id(&self) -> &ProgramID<N>

Returns the program ID.

Source§

fn program_depth(&self) -> usize

Returns the program depth.

Source§

fn program_address(&self) -> &Address<N>

Returns the program address.

Source§

fn contains_external_record(&self, locator: &Locator<N>) -> bool

Returns true if the stack contains the external record.

Source§

fn get_external_stack( &self, program_id: &ProgramID<N>, ) -> Result<&Arc<Stack<N>>, Error>

Returns the external stack for the given program ID.

Source§

fn get_external_program( &self, program_id: &ProgramID<N>, ) -> Result<&ProgramCore<N, Instruction<N>, Command<N>>, Error>

Returns the external program for the given program ID.

Source§

fn get_external_record( &self, locator: &Locator<N>, ) -> Result<&RecordType<N>, Error>

Returns the external record if the stack contains the external record.

Source§

fn get_finalize_cost(&self, function_name: &Identifier<N>) -> Result<u64, Error>

Returns the expected finalize cost for the given function name.

Source§

fn get_function( &self, function_name: &Identifier<N>, ) -> Result<FunctionCore<N, Instruction<N>, Command<N>>, Error>

Returns the function with the given function name.

Source§

fn get_function_ref( &self, function_name: &Identifier<N>, ) -> Result<&FunctionCore<N, Instruction<N>, Command<N>>, Error>

Returns a reference to the function with the given function name.

Source§

fn get_number_of_calls( &self, function_name: &Identifier<N>, ) -> Result<usize, Error>

Returns the expected number of calls for the given function name.

Source§

fn sample_value<R>( &self, burner_address: &Address<N>, value_type: &ValueType<N>, rng: &mut R, ) -> Result<Value<N>, Error>
where R: Rng + CryptoRng,

Returns a value for the given value type.

Source§

fn sample_record<R>( &self, burner_address: &Address<N>, record_name: &Identifier<N>, nonce: Group<N>, rng: &mut R, ) -> Result<Record<N, Plaintext<N>>, Error>
where R: Rng + CryptoRng,

Returns a record for the given record name, with the given burner address and nonce.

Source§

impl<N> StackProgramTypes<N> for Stack<N>
where N: Network,

Source§

fn get_register_types( &self, name: &Identifier<N>, ) -> Result<&RegisterTypes<N>, Error>

Returns the register types for the given closure or function name.

Source§

fn get_finalize_types( &self, name: &Identifier<N>, ) -> Result<&FinalizeTypes<N>, Error>

Returns the register types for the given finalize name.

Source§

impl<N> Eq for Stack<N>
where N: Network,

Auto Trait Implementations§

§

impl<N> Freeze for Stack<N>

§

impl<N> !RefUnwindSafe for Stack<N>

§

impl<N> Send for Stack<N>

§

impl<N> Sync for Stack<N>

§

impl<N> Unpin for Stack<N>

§

impl<N> !UnwindSafe for Stack<N>

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 u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T