arcium-core-utils 0.8.1

Arcium core utils
Documentation
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,
};

/// Gate operations, where the operation arguments correspond to _wire_ label.
#[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 a wire
    Input(Input),
    /// Input a constant value
    Constant(Constant<C>),
    /// Generate random shares
    Random {
        algebraic_type: AlgebraicType,
        batch_size: BatchSize,
    },
    /// Field share unary operations
    FieldShareUnaryOp {
        x: GateIndex,
        op: FieldShareUnaryOp,
    },
    /// Field share binary operations, where the second wire may be a plaintext.
    FieldShareBinaryOp {
        x: GateIndex,
        y: GateIndex,
        op: FieldShareBinaryOp,
    },
    BatchSummation {
        x: GateIndex,
    },
    BitShareUnaryOp {
        x: GateIndex,
        op: BitShareUnaryOp,
    },
    BitShareBinaryOp {
        x: GateIndex,
        y: GateIndex,
        op: BitShareBinaryOp,
    },
    /// Operations with elliptic curve points
    PointShareUnaryOp {
        p: GateIndex,
        op: PointShareUnaryOp,
    },
    PointShareBinaryOp {
        p: GateIndex,
        y: GateIndex,
        op: PointShareBinaryOp,
    },
    /// Field plaintext unary operations
    FieldPlaintextUnaryOp {
        x: GateIndex,
        op: FieldPlaintextUnaryOp,
    },
    /// Field plaintext binary operations
    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,
    },
    /// Request a daBit
    DaBit {
        field_type: FieldType,
        batch_size: BatchSize,
    },
    GetDaBitFieldShare {
        x: GateIndex,
    },
    GetDaBitSharedBit {
        x: GateIndex,
    },
    /// Base field exponentiation operation
    BaseFieldPow {
        x: GateIndex,
        exp: BoxedUint,
    },
    /// Bit plaintext conversion operations
    BitPlaintextToField {
        x: GateIndex,
        field_type: FieldType,
    },
    FieldPlaintextToBit {
        x: GateIndex,
    },
    /// Get a slice of elements from a batched wire
    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,
    },
}