pub enum Value {
Show 13 variants
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,
UnsynchronizedBools {
count: usize,
},
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
MFloat
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 u32Scalar { size_in_bits: 64, kind: ScalarKind::Signed }represents i64
Float
Bool
Ciphertext
ArcisX25519Pubkey
Point
UnsynchronizedBools
Bits supplied per node rather than read from the agreed public inputs – fetched from a
URL, say. Nodes may hold different values for these until a ConstrainPlaintextBits gate
reconciles them, which is why they are a distinct type rather than [Bool; N]: keeping it
in the interface is what stops unsynchronized data being handed to a circuit that assumed
every node reads the same bytes.
count is the number of bits, and maps to one
Parameter::UnsynchronizedPlaintextBools(count) on chain.
Array(Vec<Value>)
Tuple(Vec<Value>)
Struct(Vec<Value>)
Implementations§
Source§impl Value
impl Value
Sourcepub fn size_in_scalars(&self) -> usize
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);Sourcepub fn flatten(&self) -> Vec<Value>
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