plonky2/src/target.rs

25 lines
641 B
Rust
Raw Normal View History

2021-02-09 21:25:21 -08:00
use crate::circuit_data::CircuitConfig;
use crate::wire::Wire;
/// A location in the witness.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
2021-02-26 13:18:41 -08:00
pub enum Target {
2021-02-09 21:25:21 -08:00
Wire(Wire),
PublicInput { index: usize },
VirtualAdviceTarget { index: usize },
}
2021-02-26 13:18:41 -08:00
impl Target {
2021-02-09 21:25:21 -08:00
pub fn wire(gate: usize, input: usize) -> Self {
Self::Wire(Wire { gate, input })
}
pub fn is_routable(&self, config: CircuitConfig) -> bool {
match self {
2021-02-26 13:18:41 -08:00
Target::Wire(wire) => wire.is_routable(config),
Target::PublicInput { .. } => true,
Target::VirtualAdviceTarget { .. } => false,
2021-02-09 21:25:21 -08:00
}
}
}