move transcript to trait (#46)

This commit is contained in:
zhenfei
2022-07-26 11:34:47 -04:00
committed by GitHub
parent 17cff52765
commit 229148eb5a
19 changed files with 122 additions and 72 deletions

View File

@@ -3,7 +3,7 @@
use ark_serialize::SerializationError;
use ark_std::string::String;
use displaydoc::Display;
use poly_iop::PolyIOPErrors;
use transcript::TranscriptErrors;
/// A `enum` specifying the possible failure modes of the PCS.
#[derive(Display, Debug)]
@@ -18,8 +18,8 @@ pub enum PCSErrors {
InvalidParameters(String),
/// An error during (de)serialization: {0}
SerializationError(SerializationError),
/// PolyIOP error {0}
PolyIOPErrors(PolyIOPErrors),
/// Transcript error {0}
TranscriptError(TranscriptErrors),
}
impl From<SerializationError> for PCSErrors {
@@ -28,8 +28,8 @@ impl From<SerializationError> for PCSErrors {
}
}
impl From<PolyIOPErrors> for PCSErrors {
fn from(e: PolyIOPErrors) -> Self {
Self::PolyIOPErrors(e)
impl From<TranscriptErrors> for PCSErrors {
fn from(e: TranscriptErrors) -> Self {
Self::TranscriptError(e)
}
}

View File

@@ -13,7 +13,7 @@ use crate::{
use ark_ec::PairingEngine;
use ark_poly::{DenseMultilinearExtension, EvaluationDomain, MultilinearExtension, Polynomial};
use ark_std::{end_timer, start_timer, vec::Vec};
use poly_iop::IOPTranscript;
use transcript::IOPTranscript;
/// Input
/// - the prover parameters for univariate KZG,
@@ -237,12 +237,12 @@ pub(super) fn batch_verify_internal<E: PairingEngine>(
// 3. check `q(r) == batch_proof.q_x_value.last` and `q(omega^i) =
// batch_proof.q_x_value[i]`
for i in 0..points_len {
for (i, value) in values.iter().enumerate().take(points_len) {
if !KZGUnivariatePCS::verify(
uni_verifier_param,
&batch_proof.q_x_commit,
&domain.element(i),
&values[i],
&value,
&batch_proof.q_x_opens[i],
)? {
#[cfg(debug_assertion)]

View File

@@ -7,9 +7,20 @@ use ark_poly::{
MultilinearExtension, Polynomial, Radix2EvaluationDomain,
};
use ark_std::{end_timer, log2, start_timer};
use poly_iop::bit_decompose;
use std::cmp::max;
/// Decompose an integer into a binary vector in little endian.
#[allow(dead_code)]
pub(crate) fn bit_decompose(input: u64, num_var: usize) -> Vec<bool> {
let mut res = Vec::with_capacity(num_var);
let mut i = input;
for _ in 0..num_var {
res.push(i & 1 == 1);
i >>= 1;
}
res
}
/// For an MLE w with `mle_num_vars` variables, and `point_len` number of
/// points, compute the degree of the univariate polynomial `q(x):= w(l(x))`
/// where l(x) is a list of polynomials that go through all points.