use primitives::algebra::{
elliptic_curve::{BaseFieldElement, Curve, Point, Scalar},
field::{mersenne::Mersenne107, subfield_element::Mersenne107Element, Bit},
};
use serde::{Deserialize, Serialize};
use crate::{
circuit::{latest, old::legacy_codec::legacy},
config::MpcConfig,
};
pub type FieldPlaintextUnaryOp = latest::FieldPlaintextUnaryOp;
pub type FieldPlaintextBinaryOp = latest::FieldPlaintextBinaryOp;
pub type FieldShareUnaryOp = latest::FieldShareUnaryOp;
pub type FieldShareBinaryOp = latest::FieldShareBinaryOp;
pub type BitShareUnaryOp = latest::BitShareUnaryOp;
pub type BitShareBinaryOp = latest::BitShareBinaryOp;
pub type BitPlaintextUnaryOp = latest::BitPlaintextUnaryOp;
pub type BitPlaintextBinaryOp = latest::BitPlaintextBinaryOp;
pub type PointPlaintextUnaryOp = latest::PointPlaintextUnaryOp;
pub type PointPlaintextBinaryOp = latest::PointPlaintextBinaryOp;
pub type PointShareUnaryOp = latest::PointShareUnaryOp;
pub type PointShareBinaryOp = latest::PointShareBinaryOp;
pub type Input = latest::Input;
#[derive(Serialize, Deserialize)]
#[repr(C)]
pub enum Constant<C: Curve> {
Scalar(#[serde(with = "legacy")] Scalar<C>),
ScalarBatch(#[serde(with = "legacy")] Vec<Scalar<C>>),
BaseField(#[serde(with = "legacy")] BaseFieldElement<C>),
BaseFieldBatch(#[serde(with = "legacy")] Vec<BaseFieldElement<C>>),
Mersenne107(#[serde(with = "legacy")] Mersenne107Element),
Mersenne107Batch(#[serde(with = "legacy")] Vec<Mersenne107Element>),
Bit(#[serde(with = "legacy")] Bit),
BitBatch(#[serde(with = "legacy")] Vec<Bit>),
Point(#[serde(with = "legacy")] Point<C>),
PointBatch(#[serde(with = "legacy")] Vec<Point<C>>),
}
impl<C: Curve, Cfg: MpcConfig<Curve = C, Field = Mersenne107>> From<Constant<C>>
for latest::Constant<Cfg>
{
fn from(value: Constant<C>) -> Self {
match value {
Constant::Scalar(value) => latest::Constant::Scalar(value),
Constant::ScalarBatch(value) => latest::Constant::ScalarBatch(value),
Constant::BaseField(value) => latest::Constant::BaseField(value),
Constant::BaseFieldBatch(value) => latest::Constant::BaseFieldBatch(value),
Constant::Mersenne107(value) => latest::Constant::MpcField(value),
Constant::Mersenne107Batch(value) => latest::Constant::MpcFieldBatch(value),
Constant::Bit(value) => latest::Constant::Bit(value),
Constant::BitBatch(value) => latest::Constant::BitBatch(value),
Constant::Point(value) => latest::Constant::Point(value),
Constant::PointBatch(value) => latest::Constant::PointBatch(value),
}
}
}