use primitives::algebra::{
elliptic_curve::{Curve, Point, Scalar},
BoxedUint,
};
use serde::{Deserialize, Serialize};
use super::{
ops::{
BitPlaintextBinaryOp,
BitPlaintextUnaryOp,
BitShareBinaryOp,
BitShareUnaryOp,
Constant,
FieldPlaintextBinaryOp,
FieldPlaintextUnaryOp,
FieldShareBinaryOp,
FieldShareUnaryOp,
Input,
PointPlaintextBinaryOp,
PointPlaintextUnaryOp,
PointShareBinaryOp,
PointShareUnaryOp,
},
AlgebraicType,
BatchSize,
FieldType,
GateIndex,
Slice,
};
#[derive(Serialize, Deserialize)]
#[serde(bound(
serialize = "Scalar<C>: Serialize, Point<C>: Serialize",
deserialize = "Scalar<C>: Deserialize<'de>, Point<C>: Deserialize<'de>"
))]
#[repr(C)]
pub enum Gate<C: Curve> {
Input(Input),
Constant(Constant<C>),
Random {
algebraic_type: AlgebraicType,
batch_size: BatchSize,
},
FieldShareUnaryOp {
x: GateIndex,
op: FieldShareUnaryOp,
},
FieldShareBinaryOp {
x: GateIndex,
y: GateIndex,
op: FieldShareBinaryOp,
},
BatchSummation {
x: GateIndex,
},
BitShareUnaryOp {
x: GateIndex,
op: BitShareUnaryOp,
},
BitShareBinaryOp {
x: GateIndex,
y: GateIndex,
op: BitShareBinaryOp,
},
PointShareUnaryOp {
p: GateIndex,
op: PointShareUnaryOp,
},
PointShareBinaryOp {
p: GateIndex,
y: GateIndex,
op: PointShareBinaryOp,
},
FieldPlaintextUnaryOp {
x: GateIndex,
op: FieldPlaintextUnaryOp,
},
FieldPlaintextBinaryOp {
x: GateIndex,
y: GateIndex,
op: FieldPlaintextBinaryOp,
},
BitPlaintextUnaryOp {
x: GateIndex,
op: BitPlaintextUnaryOp,
},
BitPlaintextBinaryOp {
x: GateIndex,
y: GateIndex,
op: BitPlaintextBinaryOp,
},
PointPlaintextUnaryOp {
p: GateIndex,
op: PointPlaintextUnaryOp,
},
PointPlaintextBinaryOp {
p: GateIndex,
y: GateIndex,
op: PointPlaintextBinaryOp,
},
DaBit {
field_type: FieldType,
batch_size: BatchSize,
},
GetDaBitFieldShare {
x: GateIndex,
},
GetDaBitSharedBit {
x: GateIndex,
},
BaseFieldPow {
x: GateIndex,
exp: BoxedUint,
},
BitPlaintextToField {
x: GateIndex,
field_type: FieldType,
},
FieldPlaintextToBit {
x: GateIndex,
},
ExtractFromBatch {
x: GateIndex,
slice: Slice,
},
CollectToBatch {
wires: Vec<GateIndex>,
},
PointFromPlaintextCoordinates {
wires: Vec<GateIndex>,
},
PlaintextPointToCoordinates {
point: GateIndex,
},
PlaintextKeccakF1600 {
x: GateIndex,
},
CompressPlaintextPoint {
point: GateIndex,
},
KeyRecoveryPlaintextComputeErrors {
d_minus_one: GateIndex,
syndromes: GateIndex,
},
AesGcmKeyStream {
round_keys: GateIndex,
iv: GateIndex,
n_ciphertext_blocks: u32,
},
#[cfg(any(test, feature = "dev"))]
AesKeySchedule {
key: GateIndex,
},
GhashPowersOfH {
h: GateIndex,
n_ciphertext_blocks: u32,
},
Ghash {
x: GateIndex,
powers_of_h: GateIndex,
},
}