Value

Enum Value 

Source
pub enum Value {
    MScalar {
        size_in_bits: usize,
    },
    MFloat {
        size_in_bits: usize,
    },
    MBool,
    Scalar {
        size_in_bits: usize,
        kind: ScalarKind,
    },
    Float {
        size_in_bits: usize,
    },
    Bool,
    Ciphertext {
        size_in_bits: usize,
    },
    ArcisX25519Pubkey,
    Point,
    Array(Vec<Value>),
    Tuple(Vec<Value>),
    Struct(Vec<Value>),
}
Expand description

Circuit interface value types.

Represents all possible types that can be used as inputs or outputs in Arcium circuits.

Variants§

§

MScalar

Fields

§size_in_bits: usize
§

MFloat

Fields

§size_in_bits: usize
§

MBool

§

Scalar

Plaintext scalar value (integer).

§Fields

  • size_in_bits - Bit width of the scalar (8, 16, 32, 64, or 128)
  • kind - Whether the scalar is signed or unsigned

§Examples

  • Scalar { size_in_bits: 32, kind: ScalarKind::Unsigned } represents u32
  • Scalar { size_in_bits: 64, kind: ScalarKind::Signed } represents i64

Fields

§size_in_bits: usize
§

Float

Fields

§size_in_bits: usize
§

Bool

§

Ciphertext

Fields

§size_in_bits: usize
§

ArcisX25519Pubkey

§

Point

§

Array(Vec<Value>)

§

Tuple(Vec<Value>)

§

Struct(Vec<Value>)

Implementations§

Source§

impl Value

Source

pub fn size_in_scalars(&self) -> usize

Returns the number of scalar field elements this value occupies.

For primitive types (Scalar, Bool, Float, etc.), this returns 1. For composite types (Array, Tuple, Struct), this recursively counts all scalar fields.

§Examples
use arcis_interface::{Value, ScalarKind};

let scalar = Value::Scalar { size_in_bits: 32, kind: ScalarKind::Unsigned };
assert_eq!(scalar.size_in_scalars(), 1);

let tuple = Value::Tuple(vec![
    Value::Scalar { size_in_bits: 32, kind: ScalarKind::Unsigned },
    Value::Bool,
]);
assert_eq!(tuple.size_in_scalars(), 2);
Source

pub fn flatten(&self) -> Vec<Value>

Flattens composite types into a vector of primitive values.

For primitive types, returns a single-element vector containing self. For composite types (Array, Tuple, Struct), recursively flattens all nested values into a flat vector of primitives.

§Examples
use arcis_interface::{Value, ScalarKind};

let scalar = Value::Scalar { size_in_bits: 32, kind: ScalarKind::Unsigned };
assert_eq!(scalar.flatten().len(), 1);

let tuple = Value::Tuple(vec![
    Value::Scalar { size_in_bits: 32, kind: ScalarKind::Unsigned },
    Value::Tuple(vec![Value::Bool, Value::Bool]),
]);
assert_eq!(tuple.flatten().len(), 3); // u32, bool, bool

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl<'de> Deserialize<'de> for Value

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

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

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 Serialize for Value

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Value

Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,