2021-02-09 21:25:21 -08:00
|
|
|
use crate::circuit_data::CircuitConfig;
|
|
|
|
|
use crate::wire::Wire;
|
2021-06-09 10:51:50 +02:00
|
|
|
use std::ops::Range;
|
2021-02-09 21:25:21 -08:00
|
|
|
|
|
|
|
|
/// 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 })
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 11:30:03 +02:00
|
|
|
pub fn is_routable(&self, config: &CircuitConfig) -> bool {
|
2021-02-09 21:25:21 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
2021-06-09 10:51:50 +02:00
|
|
|
|
|
|
|
|
pub fn wires_from_range(gate: usize, range: Range<usize>) -> Vec<Self> {
|
|
|
|
|
range.map(|i| Self::wire(gate, i)).collect()
|
|
|
|
|
}
|
2021-02-09 21:25:21 -08:00
|
|
|
}
|