Skip to content

Commit beee357

Browse files
Default, Clone, ToConstraintField impls
1 parent 37298ab commit beee357

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/data_structures.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{Rc, String, Vec};
2-
use ark_ff::Field;
2+
use ark_ff::{Field, ToConstraintField};
33
pub use ark_poly::DensePolynomial as Polynomial;
44
use core::borrow::Borrow;
55
use core::ops::{AddAssign, MulAssign, SubAssign};
@@ -184,6 +184,14 @@ impl<C: PCCommitment> LabeledCommitment<C> {
184184
}
185185
}
186186

187+
impl<F: Field, C: PCCommitment + ToConstraintField<F>> ToConstraintField<F>
188+
for LabeledCommitment<C>
189+
{
190+
fn to_field_elements(&self) -> Option<Vec<F>> {
191+
self.commitment.to_field_elements()
192+
}
193+
}
194+
187195
impl<C: PCCommitment> ark_ff::ToBytes for LabeledCommitment<C> {
188196
#[inline]
189197
fn write<W: ark_std::io::Write>(&self, writer: W) -> ark_std::io::Result<()> {

src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,22 @@ pub type QuerySet<'a, F> = BTreeSet<(String, (String, F))>;
9999
pub type Evaluations<'a, F> = BTreeMap<(String, F), F>;
100100

101101
/// A proof of satisfaction of linear combinations.
102-
#[derive(Clone)]
103102
pub struct BatchLCProof<F: Field, PC: PolynomialCommitment<F>> {
104103
/// Evaluation proof.
105104
pub proof: PC::BatchProof,
106105
/// Evaluations required to verify the proof.
107106
pub evals: Option<Vec<F>>,
108107
}
109108

109+
impl<F: Field, PC: PolynomialCommitment<F>> Clone for BatchLCProof<F, PC> {
110+
fn clone(&self) -> Self {
111+
BatchLCProof {
112+
proof: self.proof.clone(),
113+
evals: self.evals.clone(),
114+
}
115+
}
116+
}
117+
110118
/// Describes the interface for a polynomial commitment scheme that allows
111119
/// a sender to commit to multiple polynomials and later provide a succinct proof
112120
/// of evaluation for the corresponding commitments at a query set `Q`, while
@@ -119,9 +127,9 @@ pub trait PolynomialCommitment<F: Field>: Sized {
119127
/// open the commitment to produce an evaluation proof.
120128
type CommitterKey: PCCommitterKey;
121129
/// The verifier key for the scheme; used to check an evaluation proof.
122-
type VerifierKey: PCVerifierKey;
130+
type VerifierKey: PCVerifierKey + Default;
123131
/// The prepared verifier key for the scheme; used to check an evaluation proof.
124-
type PreparedVerifierKey: PCPreparedVerifierKey<Self::VerifierKey> + Clone;
132+
type PreparedVerifierKey: PCPreparedVerifierKey<Self::VerifierKey> + Default + Clone;
125133
/// The commitment to a polynomial.
126134
type Commitment: PCCommitment + Default;
127135
/// The prepared commitment to a polynomial.

src/marlin_pc/data_structures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<E: PairingEngine> ToBytes for VerifierKey<E> {
148148

149149
/// `PreparedVerifierKey` is used to check evaluation proofs for a given commitment.
150150
#[derive(Derivative)]
151-
#[derivative(Clone(bound = ""), Debug(bound = ""))]
151+
#[derivative(Default(bound = ""), Clone(bound = ""), Debug(bound = ""))]
152152
pub struct PreparedVerifierKey<E: PairingEngine> {
153153
/// The verification key for the underlying KZG10 scheme.
154154
pub prepared_vk: kzg10::PreparedVerifierKey<E>,

0 commit comments

Comments
 (0)