Skip to content

Commit

Permalink
Handle empty input for g1_array_poseidon (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltea authored Mar 11, 2024
1 parent 1627403 commit e0ab176
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lightclient-circuits/src/poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const R_F: usize = 8;
///
/// Each Poseidon sponge absorbs `POSEIDON_SIZE`-2 elements and previos sponge output if it's not the first batch, ie. onion commitment.
///
/// Assumes that LIMB_BITS * 2 < 254 (BN254).
/// Assumes that:
/// - `LIMB_BITS` * 2 < 254 (BN254)
/// - `x_coords` and `y_signs_packed` are not zero length
pub fn g1_array_poseidon<F: Field>(
ctx: &mut Context<F>,
fp_chip: &FpChip<F>,
Expand Down Expand Up @@ -69,6 +71,8 @@ pub fn g1_array_poseidon<F: Field>(
})
.collect_vec();

assert!(!limbs.is_empty(), "No G1 affines to hash");

let mut poseidon = PoseidonSponge::<F, T, POSEIDON_SIZE>::new::<R_F, R_P, 0>(ctx);

let mut current_poseidon_hash = None;
Expand Down

0 comments on commit e0ab176

Please sign in to comment.