core_utils/circuit/
constants.rs1use enum_try_as_inner::EnumTryAsInner;
2use primitives::algebra::{
3 elliptic_curve::{BaseFieldElement, Point, Scalar},
4 field::{subfield_element::Mersenne107Element, Bit},
5};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Copy, Clone, EnumTryAsInner, PartialEq, Eq, Hash, Serialize, Deserialize)]
11pub enum Plaintext<T> {
12 Fixed(T),
13 Input(usize),
14}
15
16pub type ScalarPlaintext<C> = Plaintext<Scalar<C>>;
17pub type BaseFieldPlaintext<C> = Plaintext<BaseFieldElement<C>>;
18pub type Mersenne107Plaintext = Plaintext<Mersenne107Element>;
19pub type PointPlaintext<C> = Plaintext<Point<C>>;
20pub type BitPlaintext = Plaintext<Bit>;
21
22pub type ScalarPlaintextBatch<C> = Plaintext<Vec<Scalar<C>>>;
23pub type BaseFieldPlaintextBatch<C> = Plaintext<Vec<BaseFieldElement<C>>>;
24pub type Mersenne107PlaintextBatch = Plaintext<Vec<Mersenne107Element>>;
25pub type PointPlaintextBatch<C> = Plaintext<Vec<Point<C>>>;
26pub type BitPlaintextBatch = Plaintext<Vec<Bit>>;
27
28impl<T> Plaintext<Vec<T>> {
29 pub fn len(&self) -> usize {
31 match self {
32 Plaintext::Fixed(v) => v.len(),
33 Plaintext::Input(size) => *size,
34 }
35 }
36
37 pub fn is_empty(&self) -> bool {
38 self.len() == 0
39 }
40}