Skip to content

Commit

Permalink
use Compress::COMPRESSED const in favor of group element const
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobkaufmann committed Mar 7, 2024
1 parent 32f21ec commit 80b059d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions benches/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<const N: usize> Blob<N> {
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");
Expand Down
2 changes: 1 addition & 1 deletion src/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/kzg/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 80b059d

Please sign in to comment.