mirror of
https://github.com/codex-storage/proof-aggregation.git
synced 2025-02-13 15:16:58 +00:00
add select hash helper fn
This commit is contained in:
parent
e5985184df
commit
b280a5252c
@ -89,4 +89,20 @@ pub fn add_assign_hash_out_target<
|
||||
/// Reads the contents of the specified file and returns them as a vector of bytes using `std::fs::read`.
|
||||
pub fn read_bytes_from_file<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
||||
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