//! VM stack type abstractions use halo2_gadgets::ecc::{chip::EccChip, FixedPoint, FixedPointBaseField, FixedPointShort, Point}; use halo2_proofs::circuit::AssignedCell; use pasta_curves::{pallas, EpAffine}; use crate::crypto::{constants::OrchardFixedBases, merkle_node::MerkleNode}; /// These represent the witness types outside of the circuit #[allow(clippy::large_enum_variant)] #[derive(Clone)] pub enum Witness { EcPoint(Option), EcFixedPoint(Option), Base(Option), Scalar(Option), MerklePath(Option<[MerkleNode; 32]>), Uint32(Option), Uint64(Option), } /// These represent the witness types inside the circuit #[allow(clippy::large_enum_variant)] #[derive(Clone)] pub enum StackVar { EcPoint(Point>), EcFixedPoint(FixedPoint>), EcFixedPointBase(FixedPointBaseField>), Base(AssignedCell), Scalar(Option), MerklePath(Option<[pallas::Base; 32]>), Uint32(Option), Uint64(Option), FixedPointShort(FixedPointShort>), } impl From for Point> { fn from(value: StackVar) -> Self { match value { StackVar::EcPoint(v) => v, _ => unimplemented!(), } } } impl From for FixedPoint> { fn from(value: StackVar) -> Self { match value { StackVar::EcFixedPoint(v) => v, _ => unimplemented!(), } } } impl From for std::option::Option { fn from(value: StackVar) -> Self { match value { StackVar::Scalar(v) => v, _ => unimplemented!(), } } } impl From for AssignedCell { fn from(value: StackVar) -> Self { match value { StackVar::Base(v) => v, _ => unimplemented!(), } } } impl From for std::option::Option { fn from(value: StackVar) -> Self { match value { StackVar::Uint32(v) => v, _ => unimplemented!(), } } } impl From for std::option::Option<[pallas::Base; 32]> { fn from(value: StackVar) -> Self { match value { StackVar::MerklePath(v) => v, _ => unimplemented!(), } } } impl From for FixedPointShort> { fn from(value: StackVar) -> Self { match value { StackVar::FixedPointShort(v) => v, _ => unimplemented!(), } } }