Skip to content

Commit a6def66

Browse files
authored
Deprecate .size_in_bytes() in favor of .serialized_size() (#99)
1 parent 124a74f commit a6def66

File tree

4 files changed

+10
-29
lines changed

4 files changed

+10
-29
lines changed

src/data_structures.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ pub trait PCCommitment:
6666
fn has_degree_bound(&self) -> bool;
6767

6868
/// Size in bytes
69-
fn size_in_bytes(&self) -> usize;
69+
#[deprecated(since = "0.4.0", note = "Please use `.serialized_size()` instead.")]
70+
fn size_in_bytes(&self) -> usize {
71+
self.serialized_size()
72+
}
7073
}
7174

7275
/// Defines the minimal interface of prepared commitments for any polynomial
@@ -99,7 +102,10 @@ pub trait PCRandomness: Clone + CanonicalSerialize + CanonicalDeserialize {
99102
/// commitment scheme.
100103
pub trait PCProof: Clone + ark_ff::ToBytes + CanonicalSerialize + CanonicalDeserialize {
101104
/// Size in bytes
102-
fn size_in_bytes(&self) -> usize;
105+
#[deprecated(since = "0.4.0", note = "Please use `.serialized_size()` instead.")]
106+
fn size_in_bytes(&self) -> usize {
107+
self.serialized_size()
108+
}
103109
}
104110

105111
/// A proof of satisfaction of linear combinations.

src/ipa_pc/data_structures.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ impl<G: AffineCurve> PCCommitment for Commitment<G> {
119119
fn has_degree_bound(&self) -> bool {
120120
false
121121
}
122-
123-
fn size_in_bytes(&self) -> usize {
124-
ark_ff::to_bytes![G::zero()].unwrap().len() / 2
125-
}
126122
}
127123

128124
impl<G: AffineCurve> ToBytes for Commitment<G> {
@@ -216,11 +212,7 @@ pub struct Proof<G: AffineCurve> {
216212
pub rand: Option<G::ScalarField>,
217213
}
218214

219-
impl<G: AffineCurve> PCProof for Proof<G> {
220-
fn size_in_bytes(&self) -> usize {
221-
ark_ff::to_bytes![self].unwrap().len()
222-
}
223-
}
215+
impl<G: AffineCurve> PCProof for Proof<G> {}
224216

225217
impl<G: AffineCurve> ToBytes for Proof<G> {
226218
#[inline]

src/kzg10/data_structures.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,6 @@ impl<E: PairingEngine> PCCommitment for Commitment<E> {
440440
fn has_degree_bound(&self) -> bool {
441441
false
442442
}
443-
444-
fn size_in_bytes(&self) -> usize {
445-
ark_ff::to_bytes![E::G1Affine::zero()].unwrap().len() / 2
446-
}
447443
}
448444

449445
impl<E: PairingEngine> ToConstraintField<<E::Fq as Field>::BasePrimeField> for Commitment<E>
@@ -597,16 +593,7 @@ pub struct Proof<E: PairingEngine> {
597593
pub random_v: Option<E::Fr>,
598594
}
599595

600-
impl<E: PairingEngine> PCProof for Proof<E> {
601-
fn size_in_bytes(&self) -> usize {
602-
let hiding_size = if self.random_v.is_some() {
603-
ark_ff::to_bytes![E::Fr::zero()].unwrap().len()
604-
} else {
605-
0
606-
};
607-
ark_ff::to_bytes![E::G1Affine::zero()].unwrap().len() / 2 + hiding_size
608-
}
609-
}
596+
impl<E: PairingEngine> PCProof for Proof<E> {}
610597

611598
impl<E: PairingEngine> ToBytes for Proof<E> {
612599
#[inline]

src/marlin/marlin_pc/data_structures.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ impl<E: PairingEngine> PCCommitment for Commitment<E> {
290290
fn has_degree_bound(&self) -> bool {
291291
self.shifted_comm.is_some()
292292
}
293-
294-
fn size_in_bytes(&self) -> usize {
295-
self.comm.size_in_bytes() + self.shifted_comm.as_ref().map_or(0, |c| c.size_in_bytes())
296-
}
297293
}
298294

299295
/// Prepared commitment to a polynomial that optionally enforces a degree bound.

0 commit comments

Comments
 (0)