Skip to main content

DynamicRecord

Struct DynamicRecord 

Source
pub struct DynamicRecord<A: Aleo> { /* private fields */ }
Expand description

A dynamic record is a fixed-size representation of a record. Like static Records, a dynamic record contains an owner, nonce, and a version. However, instead of storing the full data, it only stores the Merkle root of the data. This ensures that all dynamic records have a constant size, regardless of the amount of data they contain.

Suppose we have the following record with two data entries:

record foo:
    owner as address.private;
    microcredits as u64.private;
    memo as [u8; 32u32].public;

The leaves of its Merkle tree are computed as follows:

L_0 := HashPSD8(ToField(name_0) || ToFields(entry_0))
L_1 := HashPSD8(ToField(name_1) || ToFields(entry_1))

where name_i is the field encoding of the entry identifier (e.g. "microcredits"Field), and ToFields encodes the entry’s mode and plaintext variant.

The tree has depth RECORD_DATA_TREE_DEPTH = 5 and is constructed with path hasher HashPSD2 and the padding scheme outlined in snarkVM’s MerkleTree.

Implementations§

Source§

impl<A: Aleo> DynamicRecord<A>

Source

pub fn find<A0: Into<Access<A>> + Clone + Debug>( &self, path: &[A0], ) -> Result<Value<A>>

Returns the entry from the given path.

Source§

impl<A: Aleo> DynamicRecord<A>

Source

pub const fn owner(&self) -> &Address<A>

Returns the owner of the record.

Source

pub const fn root(&self) -> &Field<A>

Returns the Merkle root of the record data.

Source

pub const fn nonce(&self) -> &Group<A>

Returns the nonce of the record.

Source

pub const fn version(&self) -> &U8<A>

Returns the version of the record.

Source

pub const fn data(&self) -> Option<&RecordData<A::Network>>

Returns the console record data.

Source§

impl<A: Aleo> DynamicRecord<A>

Source

pub fn from_record(record: &Record<A, Plaintext<A>>) -> Result<Self>

Creates a dynamic record from a static one.

Source

pub fn merkleize_data( data: &IndexMap<Identifier<A>, Entry<A, Plaintext<A>>>, ) -> Result<RecordDataTree<A>>

Serializes the given (ordered) entries to field elements, prepends an identifier tag per entry, and computes the Merkle tree over the resulting leaves. More details on the structure of the tree can be found in DynamicRecord.

Trait Implementations§

Source§

impl<A: Clone + Aleo> Clone for DynamicRecord<A>
where A::Network: Clone,

Source§

fn clone(&self) -> DynamicRecord<A>

Returns a duplicate 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<A: Aleo> Eject for DynamicRecord<A>

Source§

fn eject_mode(&self) -> Mode

Ejects the mode of the dynamic record.

Source§

fn eject_value(&self) -> Self::Primitive

Ejects the dynamic record.

Source§

type Primitive = DynamicRecord<<A as Environment>::Network>

Source§

fn eject(&self) -> (Mode, Self::Primitive)

Ejects the mode and primitive value of the circuit type.
Source§

fn is_constant(&self) -> bool

Returns true if the circuit is a constant.
Source§

fn is_public(&self) -> bool

Returns true if the circuit is a public.
Source§

fn is_private(&self) -> bool

Returns true if the circuit is a private.
Source§

impl<A: Aleo> Equal for DynamicRecord<A>

Source§

fn is_equal(&self, other: &Self) -> Self::Output

Returns true if self and other are equal.

Source§

fn is_not_equal(&self, other: &Self) -> Self::Output

Returns true if self and other are not equal.

Source§

type Output = Boolean<A>

Source§

impl<A: Aleo> From<DynamicRecord<A>> for Value<A>

Source§

fn from(dynamic_record: DynamicRecord<A>) -> Self

Initializes the value from a dynamic record.

Source§

impl<A: Aleo> Inject for DynamicRecord<A>

Source§

fn new(_: Mode, record: Self::Primitive) -> Self

Initializes a plaintext record from a primitive.

Source§

type Primitive = DynamicRecord<<A as Environment>::Network>

Source§

fn constant(value: Self::Primitive) -> Self
where Self: Sized,

Initializes a constant of the given primitive value.
Source§

impl<A: Aleo> ToBits for DynamicRecord<A>

Source§

fn write_bits_le(&self, vec: &mut Vec<Self::Boolean>)

Returns the circuit dynamic record as a list of little-endian bits.

Source§

fn write_bits_be(&self, vec: &mut Vec<Self::Boolean>)

Returns the circuit dynamic record as a list of big-endian bits.

Source§

type Boolean = Boolean<A>

Source§

fn to_bits_le(&self) -> Vec<Self::Boolean>

Returns the little-endian bits of the circuit.
Source§

fn to_bits_be(&self) -> Vec<Self::Boolean>

Returns the big-endian bits of the circuit.
Source§

impl<A: Aleo> ToFields for DynamicRecord<A>

Source§

fn to_fields(&self) -> Vec<Self::Field>

Returns this circuit dynamic record as a list of field elements.

Source§

type Field = Field<A>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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