Skip to content

Commit 4e32bd2

Browse files
committed
move crate level tensor-code-iop based PCS to trait.rs
1 parent cdeb0ec commit 4e32bd2

File tree

5 files changed

+44
-46
lines changed

5 files changed

+44
-46
lines changed

pcs/src/orion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use transcript::Transcript;
1010
use crate::PolynomialCommitmentScheme;
1111

1212
mod utils;
13-
pub use utils::{OrionPCSError, OrionResult, SubsetSumLUTs, TensorIOPPCS};
13+
pub use utils::{OrionPCSError, OrionResult, SubsetSumLUTs};
1414

1515
mod linear_code;
1616
pub use linear_code::{OrionCodeParameter, ORION_CODE_PARAMETER_INSTANCE};

pcs/src/orion/pcs_impl.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use arith::{Field, FieldSerde, SimdField};
44
use polynomials::{EqPolynomial, MultiLinearPoly};
55
use transcript::Transcript;
66

7-
use crate::{orion::utils::SubsetSumLUTs, PCS_SOUNDNESS_BITS};
7+
use crate::{traits::TensorCodeIOPPCS, PCS_SOUNDNESS_BITS};
88

99
use super::{
1010
linear_code::{OrionCode, OrionCodeParameter},
11-
utils::{transpose_in_place, OrionPCSError, OrionResult, TensorIOPPCS},
11+
utils::{transpose_in_place, OrionPCSError, OrionResult, SubsetSumLUTs},
1212
};
1313

1414
/**********************************************************
@@ -21,7 +21,7 @@ pub struct OrionPublicParams {
2121
pub code_instance: OrionCode,
2222
}
2323

24-
impl TensorIOPPCS for OrionPublicParams {
24+
impl TensorCodeIOPPCS for OrionPublicParams {
2525
fn codeword_len(&self) -> usize {
2626
self.code_instance.code_len()
2727
}
@@ -38,7 +38,6 @@ where
3838
ComPackF: SimdField<Scalar = F>,
3939
{
4040
pub interleaved_alphabet_tree: tree::Tree,
41-
4241
pub _phantom: PhantomData<ComPackF>,
4342
}
4443

pcs/src/orion/tests.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ use ark_std::test_rng;
55
use gf2::{GF2x128, GF2x512, GF2x64, GF2x8, GF2};
66
use polynomials::MultiLinearPoly;
77

8-
use crate::orion::{
9-
linear_code::{OrionCode, ORION_CODE_PARAMETER_INSTANCE},
10-
pcs_impl::{OrionCommitment, OrionCommitmentWithData, OrionPublicParams},
11-
utils::{transpose_in_place, SubsetSumLUTs, TensorIOPPCS},
8+
use crate::{
9+
orion::{
10+
linear_code::{OrionCode, ORION_CODE_PARAMETER_INSTANCE},
11+
pcs_impl::{OrionCommitment, OrionCommitmentWithData, OrionPublicParams},
12+
utils::{transpose_in_place, SubsetSumLUTs},
13+
},
14+
traits::TensorCodeIOPPCS,
1215
};
1316

1417
fn column_combination<F, PackF>(mat: &[F], combination: &[F]) -> Vec<F>

pcs/src/orion/utils.rs

-37
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,6 @@ pub(crate) fn transpose_in_place<F: Field>(mat: &mut [F], scratch: &mut [F], row
4646
mat.copy_from_slice(scratch);
4747
}
4848

49-
/**********************************
50-
* TENSOR IOP BASED PCS UTILITIES *
51-
**********************************/
52-
53-
pub trait TensorIOPPCS {
54-
fn codeword_len(&self) -> usize;
55-
56-
fn hamming_weight(&self) -> f64;
57-
58-
fn row_col_from_variables<F: Field>(num_vars: usize) -> (usize, usize) {
59-
let elems_for_smallest_tree = tree::leaf_adic::<F>() * 2;
60-
61-
let row_num: usize = elems_for_smallest_tree;
62-
let msg_size: usize = (1 << num_vars) / row_num;
63-
64-
(row_num, msg_size)
65-
}
66-
67-
fn query_complexity(&self, soundness_bits: usize) -> usize {
68-
// NOTE: use Ligero (AHIV22) or Avg-case dist to a code (BKS18)
69-
// version of avg case dist in unique decoding technique.
70-
let avg_case_dist = self.hamming_weight() / 3f64;
71-
let sec_bits = -(1f64 - avg_case_dist).log2();
72-
73-
(soundness_bits as f64 / sec_bits).ceil() as usize
74-
}
75-
76-
fn proximity_repetitions<F: Field>(&self, soundness_bits: usize) -> usize {
77-
// NOTE: use Ligero (AHIV22) or Avg-case dist to a code (BKS18)
78-
// version of avg case dist in unique decoding technique.
79-
// Here is the probability union bound
80-
let single_run_soundness_bits = F::FIELD_SIZE - self.codeword_len().ilog2() as usize;
81-
82-
(soundness_bits as f64 / single_run_soundness_bits as f64).ceil() as usize
83-
}
84-
}
85-
8649
/*********************
8750
* LINEAR OPERATIONS *
8851
*********************/

pcs/src/traits.rs

+33
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,36 @@ pub trait PolynomialCommitmentScheme {
4141
transcript: &mut Self::FiatShamirTranscript,
4242
) -> bool;
4343
}
44+
45+
pub(crate) trait TensorCodeIOPPCS {
46+
fn codeword_len(&self) -> usize;
47+
48+
fn hamming_weight(&self) -> f64;
49+
50+
fn row_col_from_variables<F: Field>(num_vars: usize) -> (usize, usize) {
51+
let elems_for_smallest_tree = tree::leaf_adic::<F>() * 2;
52+
53+
let row_num: usize = elems_for_smallest_tree;
54+
let msg_size: usize = (1 << num_vars) / row_num;
55+
56+
(row_num, msg_size)
57+
}
58+
59+
fn query_complexity(&self, soundness_bits: usize) -> usize {
60+
// NOTE: use Ligero (AHIV22) or Avg-case dist to a code (BKS18)
61+
// version of avg case dist in unique decoding technique.
62+
let avg_case_dist = self.hamming_weight() / 3f64;
63+
let sec_bits = -(1f64 - avg_case_dist).log2();
64+
65+
(soundness_bits as f64 / sec_bits).ceil() as usize
66+
}
67+
68+
fn proximity_repetitions<F: Field>(&self, soundness_bits: usize) -> usize {
69+
// NOTE: use Ligero (AHIV22) or Avg-case dist to a code (BKS18)
70+
// version of avg case dist in unique decoding technique.
71+
// Here is the probability union bound
72+
let single_run_soundness_bits = F::FIELD_SIZE - self.codeword_len().ilog2() as usize;
73+
74+
(soundness_bits as f64 / single_run_soundness_bits as f64).ceil() as usize
75+
}
76+
}

0 commit comments

Comments
 (0)