From 80b059d68125ba8fa7c501dd134b9e5043c15093 Mon Sep 17 00:00:00 2001 From: jacobkaufmann Date: Thu, 7 Mar 2024 13:53:32 -0700 Subject: [PATCH] use Compress::COMPRESSED const in favor of group element const --- benches/kzg.rs | 4 ++-- src/blob.rs | 2 +- src/bls.rs | 2 +- src/kzg/setup.rs | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/benches/kzg.rs b/benches/kzg.rs index 22c4b19..4e7d28a 100644 --- a/benches/kzg.rs +++ b/benches/kzg.rs @@ -22,12 +22,12 @@ pub fn benchmark(c: &mut Criterion) { let mut proofs = Vec::with_capacity(blobs.len()); for blob in &blobs { let commitment = kzg.blob_to_commitment(blob).unwrap(); - let mut bytes = [0u8; Commitment::BYTES]; + let mut bytes = [0u8; Commitment::COMPRESSED]; commitment.compress(&mut bytes).unwrap(); commitments.push(bytes); let proof = kzg.blob_proof(blob, &bytes).unwrap(); - let mut bytes = [0u8; Proof::BYTES]; + let mut bytes = [0u8; Proof::COMPRESSED]; proof.compress(&mut bytes).unwrap(); proofs.push(bytes); } diff --git a/src/blob.rs b/src/blob.rs index c05ab01..dc05f80 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -79,7 +79,7 @@ impl Blob { const DOMAIN: &[u8; 16] = b"FSBLOBVERIFY_V1_"; let degree = (N as u128).to_be_bytes(); - let mut comm = [0u8; Commitment::BYTES]; + let mut comm = [0u8; Commitment::COMPRESSED]; commitment .compress(comm.as_mut_slice()) .expect("sufficient buffer len"); diff --git a/src/bls.rs b/src/bls.rs index ccabdc1..82b7090 100644 --- a/src/bls.rs +++ b/src/bls.rs @@ -626,7 +626,7 @@ impl Compress for P2 { const COMPRESSED: usize = Self::BYTES; fn compress(&self, mut buf: impl AsMut<[u8]>) -> Result<(), &'static str> { - if buf.as_mut().len() < Self::BYTES { + if buf.as_mut().len() < Self::COMPRESSED { return Err("insufficient buffer length"); } unsafe { diff --git a/src/kzg/setup.rs b/src/kzg/setup.rs index 8167b7d..2e97e99 100644 --- a/src/kzg/setup.rs +++ b/src/kzg/setup.rs @@ -345,7 +345,7 @@ mod tests { continue; }; let (expected_proof, expected_y) = expected.unwrap(); - let mut proof_bytes = [0u8; Proof::BYTES]; + let mut proof_bytes = [0u8; Proof::COMPRESSED]; proof.compress(&mut proof_bytes).unwrap(); assert_eq!(proof_bytes, expected_proof); assert_eq!(y.to_be_bytes(), expected_y); @@ -371,7 +371,7 @@ mod tests { continue; }; let expected = expected.unwrap(); - let mut proof_bytes = [0u8; Proof::BYTES]; + let mut proof_bytes = [0u8; Proof::COMPRESSED]; proof.compress(&mut proof_bytes).unwrap(); assert_eq!(proof_bytes, expected); } @@ -393,7 +393,7 @@ mod tests { continue; }; let expected = expected.unwrap(); - let mut commitment_bytes = [0u8; Commitment::BYTES]; + let mut commitment_bytes = [0u8; Commitment::COMPRESSED]; commitment.compress(&mut commitment_bytes).unwrap(); assert_eq!(commitment_bytes, expected); }