use noir_zk_backend::{ArtifactStore, Frozen};
pub use noir_zk_backend::DirStore;
pub const PACKS_URL: &str = "https://circuits.zk-eid.dev";
#[cfg(feature = "http")]
pub use noir_zk_backend::HttpStore;
#[allow(missing_docs, clippy::all)]
pub mod circuits {
include!(concat!(env!("OUT_DIR"), "/circuits.rs"));
}
#[cfg(feature = "bundled")]
pub mod bundled {
use noir_zk_backend::ArtifactStore;
use noir_zk_core::Error;
include!(concat!(env!("OUT_DIR"), "/bundled.rs"));
pub struct BundledStore;
impl ArtifactStore for BundledStore {
fn fetch(&self, asset: &str) -> Result<Vec<u8>, Error> {
ASSETS
.iter()
.find(|(name, _)| *name == asset)
.map(|(_, bytes)| bytes.to_vec())
.ok_or_else(|| Error::Artifact(format!("{asset} is not bundled")))
}
}
}
pub fn artifacts<S: ArtifactStore>(store: S) -> Frozen<S> {
Frozen::layered(circuits::REGISTRY, circuits::FAMILIES, store)
}
pub fn family(name: &str) -> Option<&'static noir_zk_core::FamilyEntry> {
circuits::FAMILIES
.iter()
.find(|f| f.id.layer == "eid" && f.id.family == name)
}
#[cfg(test)]
mod tests {
use super::*;
use noir_zk_core::registry::Status;
use noir_zk_core::{ChonkRole, ProofSystem};
#[cfg(feature = "bundled")]
#[test]
fn bundled_assets_match_their_pins() {
use noir_zk_core::Artifacts;
let frozen = artifacts(bundled::BundledStore);
for (asset, _) in bundled::ASSETS {
let label = asset.split('@').next().unwrap();
assert!(frozen.bytecode_b64(label).is_ok(), "{asset}");
}
}
#[test]
fn registry_is_the_three_families() {
let active: Vec<_> = circuits::REGISTRY
.iter()
.filter(|e| e.status == Status::Active)
.collect();
assert_eq!(active.len(), 296);
assert!(active
.iter()
.all(|e| e.system == ProofSystem::Chonk(ChonkRole::App)));
let members = |name: &str| family(name).unwrap().members.len();
assert_eq!(
(members("dsc"), members("sod"), members("document")),
(124, 124, 48)
);
assert_eq!(
(circuits::LIBRARY.name, circuits::LIBRARY.version),
("eid-circuits", "0.8.2")
);
for f in circuits::FAMILIES {
for (label, _) in f.members {
assert!(
label.starts_with(&format!("{}_", f.id.family)),
"{label} in {}",
f.id
);
}
}
let d = family("document").unwrap();
assert_eq!(d.link_in.unwrap().link, "CB");
assert_eq!(d.link_out.unwrap().link, "PayloadCommitment");
assert_eq!(d.slots, ["date", "scope", "nullifier"]);
}
}