mirror of
https://github.com/codex-storage/proof-aggregation.git
synced 2025-02-19 01:58:35 +00:00
add select hash helper fn
This commit is contained in:
parent
e5985184df
commit
b280a5252c
@ -90,3 +90,19 @@ pub fn add_assign_hash_out_target<
|
|||||||
pub fn read_bytes_from_file<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
pub fn read_bytes_from_file<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
||||||
fs::read(path)
|
fs::read(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// select hash helper method
|
||||||
|
/// Computes `if b { h0 } else { h1 }`.
|
||||||
|
pub fn select_hash<
|
||||||
|
F: RichField + Extendable<D> + Poseidon2,
|
||||||
|
const D: usize,
|
||||||
|
>(
|
||||||
|
builder: &mut CircuitBuilder<F, D>,
|
||||||
|
b: BoolTarget,
|
||||||
|
h0: HashOutTarget,
|
||||||
|
h1: HashOutTarget,
|
||||||
|
) -> HashOutTarget {
|
||||||
|
HashOutTarget {
|
||||||
|
elements: core::array::from_fn(|i| builder.select(b, h0.elements[i], h1.elements[i])),
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user