diff --git a/ipa-multipoint/src/crs.rs b/ipa-multipoint/src/crs.rs index d11938c..2e31c00 100644 --- a/ipa-multipoint/src/crs.rs +++ b/ipa-multipoint/src/crs.rs @@ -46,6 +46,7 @@ impl CRS { .iter() .map(|bytes| Element::from_bytes_unchecked_uncompressed(*bytes)) .collect(); + CRS::assert_dedup(&G); let n = G.len(); CRS { G, Q, n } } @@ -162,3 +163,15 @@ fn load_from_bytes_to_bytes() { assert_eq!(bytes, bytes2, "bytes should be the same"); } + +#[test] +#[should_panic(expected = "crs has duplicated points")] +fn load_from_bytes_should_panic_with_duplicates() { + let crs = CRS::new(256, b"eth_verkle_oct_2021"); + let mut bytes = crs.to_bytes(); + // Introduce a duplicate + bytes[1] = bytes[0]; + + // the following line should panic + CRS::from_bytes(&bytes); +}