arcium-core-utils 0.4.5

Arcium core utils
Documentation
#![allow(dead_code)] // avoid clippy warnings about unused fields in Gate enum

use primitives::algebra::{
    elliptic_curve::{Curve, Point, Scalar},
    BoxedUint,
};
use serde::Deserialize;

use crate::circuit::v1::{
    circuit::GateIndex,
    ops::{
        Batched,
        BitShareBinaryOp,
        BitShareUnaryOp,
        FieldPlaintextBinaryOp,
        FieldPlaintextUnaryOp,
        FieldShareBinaryOp,
        FieldShareUnaryOp,
        Input,
        PointPlaintextBinaryOp,
        PointPlaintextUnaryOp,
        PointShareBinaryOp,
        PointShareUnaryOp,
    },
    AlgebraicType,
    FieldType,
    ShareOrPlaintext,
};

/// Gate operations, where the operation arguments correspond to _wire_ label.
#[derive(Deserialize)]
#[serde(bound(deserialize = "Scalar<C>: Deserialize<'de>, Point<C>: Deserialize<'de>"))]
#[repr(C)]
pub enum Gate<C: Curve> {
    /// Input a wire
    Input {
        input_type: Input<C>,
    },
    /// Field share unary operations
    FieldShareUnaryOp {
        x: GateIndex,
        op: FieldShareUnaryOp,
        field_type: FieldType,
    },
    /// Field share binary operations, where the second wire may be a plaintext.
    FieldShareBinaryOp {
        x: GateIndex,
        y: GateIndex,
        y_form: ShareOrPlaintext,
        op: FieldShareBinaryOp,
        field_type: FieldType,
    },
    BatchSummation {
        x: GateIndex,
        x_form: ShareOrPlaintext,
        algebraic_type: AlgebraicType,
    },
    BitShareUnaryOp {
        x: GateIndex,
        op: BitShareUnaryOp,
    },
    BitShareBinaryOp {
        x: GateIndex,
        y: GateIndex,
        y_form: ShareOrPlaintext,
        op: BitShareBinaryOp,
    },
    /// Operations with elliptic curve points
    PointShareUnaryOp {
        p: GateIndex,
        op: PointShareUnaryOp,
    },
    PointShareBinaryOp {
        p: GateIndex,
        y: GateIndex,
        p_form: ShareOrPlaintext,
        y_form: ShareOrPlaintext,
        op: PointShareBinaryOp,
    },
    /// Field plaintext unary operations
    FieldPlaintextUnaryOp {
        x: GateIndex,
        op: FieldPlaintextUnaryOp,
        field_type: FieldType,
    },
    /// Field plaintext binary operations
    FieldPlaintextBinaryOp {
        x: GateIndex,
        y: GateIndex,
        op: FieldPlaintextBinaryOp,
        field_type: FieldType,
    },
    BitPlaintextUnaryOp {
        x: GateIndex,
        op: FieldPlaintextUnaryOp,
    },
    BitPlaintextBinaryOp {
        x: GateIndex,
        y: GateIndex,
        op: FieldPlaintextBinaryOp,
    },
    PointPlaintextUnaryOp {
        p: GateIndex,
        op: PointPlaintextUnaryOp,
    },
    PointPlaintextBinaryOp {
        p: GateIndex,
        y: GateIndex,
        op: PointPlaintextBinaryOp,
    },
    /// Request a daBit
    DaBit {
        field_type: FieldType,
        batched: Batched,
    },
    GetDaBitFieldShare {
        x: GateIndex,
        field_type: FieldType,
    },
    GetDaBitSharedBit {
        x: GateIndex,
        field_type: FieldType,
    },
    /// Base field exponentiation operation
    BaseFieldPow {
        x: GateIndex,
        exp: BoxedUint,
    },
    /// Bit plaintext conversion operations
    BitPlaintextToField {
        x: GateIndex,
        field_type: FieldType,
    },
    FieldPlaintextToBit {
        x: GateIndex,
        field_type: FieldType,
    },
    /// Get the element at a certain index of a batched wire
    BatchGetIndex {
        x: GateIndex,
        x_type: AlgebraicType,
        x_form: ShareOrPlaintext,
        index: usize,
    },
    CollectToBatch {
        wires: Vec<GateIndex>,
        x_type: AlgebraicType,
        x_form: ShareOrPlaintext,
    },
    PointFromPlaintextExtendedEdwards {
        wires: Vec<GateIndex>,
    },
    PlaintextPointToExtendedEdwards {
        point: GateIndex,
    },
    PlaintextKeccakF1600 {
        wires: Vec<GateIndex>,
    },
    CompressPlaintextPoint {
        point: GateIndex,
    },
    KeyRecoveryPlaintextComputeErrors {
        d_minus_one: GateIndex,
        syndromes: GateIndex,
    },
}