Skip to content

Commit

Permalink
chore: document magic numbers in bytes_length (#304)
Browse files Browse the repository at this point in the history
* fix: correct the constant "10" as "6" in "VerifyingKey::bytes_length"

* doc: add the comment for "VerifyingKey::bytes_length"

* doc: add the comment for "ProvingKey::bytes_length"
  • Loading branch information
duguorong009 authored Mar 29, 2024
1 parent 62bf22c commit 720ba51
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions halo2_backend/src/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ impl<C: CurveAffine> VerifyingKey<C> {
where
C: SerdeCurveAffine,
{
10 + (self.fixed_commitments.len() * C::byte_length(format))
+ self.permutation.bytes_length(format)
6 // bytes used for encoding VERSION(u8), "domain.k"(u8) & num_fixed_columns(u32)
+ (self.fixed_commitments.len() * C::byte_length(format))
+ self.permutation.bytes_length(format)
}

fn from_parts(
Expand Down Expand Up @@ -293,7 +294,7 @@ where
{
let scalar_len = C::Scalar::default().to_repr().as_ref().len();
self.vk.bytes_length(format)
+ 12
+ 12 // bytes used for encoding the length(u32) of "l0", "l_last" & "l_active_row" polys
+ scalar_len * (self.l0.len() + self.l_last.len() + self.l_active_row.len())
+ polynomial_slice_byte_length(&self.fixed_values)
+ polynomial_slice_byte_length(&self.fixed_polys)
Expand Down

0 comments on commit 720ba51

Please sign in to comment.