Skip to content

Commit

Permalink
add check_proof_multi to KZG
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkingLee committed Jul 18, 2023
1 parent d9ca13d commit 37c5b07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 16 additions & 0 deletions primitives/src/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,22 @@ impl KZG {
self.fs.max_width
}

pub fn get_expanded_roots_of_unity_at(&self, i: usize) -> FsFr {
self.fs.get_expanded_roots_of_unity_at(i)
}

pub fn check_proof_multi(
&self,
commitment: &KZGCommitment,
i: usize,
values: &[FsFr],
proof: &KZGProof,
) -> Result<bool, String> {
let x = self.fs.get_expanded_roots_of_unity_at(i);
self.ks
.check_proof_multi(&commitment.0,&proof.0, &x, values ,FIELD_ELEMENTS_PER_BLOB)
}

pub fn compute_proof(&self, poly: &FsPoly, point_index: usize) -> Result<KZGProof, String> {
let x = self.ks.get_expanded_roots_of_unity_at(point_index as usize);
self.ks.compute_proof_single(poly, &x).map(KZGProof)
Expand Down
10 changes: 4 additions & 6 deletions primitives/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ impl Segment {
let domain_stride = kzg.max_width() / (2 * FIELD_ELEMENTS_PER_BLOB);
let chunk_count = FIELD_ELEMENTS_PER_BLOB / SEGMENT_LENGTH;
let domain_pos = Self::reverse_bits_limited(chunk_count, self.position.x as usize);
let x = kzg.fs.get_expanded_roots_of_unity_at(domain_pos * domain_stride);
kzg.ks.check_proof_multi(
&commitment.0,
&self.proof,
&x,
kzg.check_proof_multi(
&commitment,
domain_pos * domain_stride,
&self.content,
FIELD_ELEMENTS_PER_BLOB,
&self.proof,
)
}

Expand Down

0 comments on commit 37c5b07

Please sign in to comment.