1#![deny(unreachable_pub)]
15#![deny(warnings)]
16#![allow(unused_imports)]
17
18#[macro_use]
19extern crate tracing;
20#[macro_use]
21extern crate lazy_static;
22
23pub const ZSWAP_TREE_HEIGHT: u8 = 32;
24
25pub(crate) fn ciphertext_to_field(c: &CoinCiphertext) -> transient_crypto::curve::Fr {
26 use transient_crypto::hash::{transient_commit, transient_hash};
27 transient_commit(
28 &c.ciph[..],
29 transient_hash(&[
30 transient_crypto::curve::Fr::from_le_bytes(b"midnight:zswap-ciphertext")
31 .expect("Domain sep should be in range for field"),
32 c.c.x().unwrap_or(0.into()),
33 c.c.y().unwrap_or(0.into()),
34 ]),
35 )
36}
37
38pub(crate) mod compact_slots;
39mod construct;
40pub mod error;
41pub mod keys;
42pub mod ledger;
43pub mod local;
44pub mod prove;
45mod structure;
46pub mod verify;
47
48use midnight_onchain_runtime::{ops::Op, result_mode::ResultMode};
49use storage::db::DB;
50
51pub(crate) fn filter_invalid<M: ResultMode<D>, I: Iterator<Item = Op<M, D>>, D: DB>(
52 iter: I,
53) -> impl Iterator<Item = Op<M, D>> {
54 iter.filter(|op| match op {
55 Op::Idx { path, .. } => !path.is_empty(),
56 Op::Ins { n, .. } => *n != 0,
57 _ => true,
58 })
59}
60
61pub use structure::*;