Skip to content

Commit

Permalink
refac: rename fri to config for FRIConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
chokobole committed Sep 12, 2024
1 parent 12ee7bb commit b3c722f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions tachyon/c/crypto/commitments/fri/two_adic_fri_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class TwoAdicFRIImpl
template <typename Derived>
absl::Span<F> CosetLDEBatch(Eigen::MatrixBase<Derived>& matrix, F shift) {
Domain coset = this->GetNaturalDomainForDegree(matrix.rows());
tachyon::math::RowMajorMatrix<F> lde(matrix.rows() << this->fri_.log_blowup,
matrix.cols());
coset.domain()->CosetLDEBatch(matrix, this->fri_.log_blowup, shift, lde,
tachyon::math::RowMajorMatrix<F> lde(
matrix.rows() << this->config_.log_blowup, matrix.cols());
coset.domain()->CosetLDEBatch(matrix, this->config_.log_blowup, shift, lde,
/*reverse_at_last=*/false);
absl::Span<F> ret(lde.data(), lde.size());
ldes_.push_back(std::move(lde));
Expand Down
23 changes: 12 additions & 11 deletions tachyon/crypto/commitments/fri/two_adic_fri.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class TwoAdicFRI {
using OpenedValues = std::vector<OpenedValuesForRound>;

TwoAdicFRI() = default;
TwoAdicFRI(InputMMCS&& mmcs, FRIConfig<ChallengeMMCS>&& fri)
: mmcs_(std::move(mmcs)), fri_(std::move(fri)) {}
TwoAdicFRI(InputMMCS&& mmcs, FRIConfig<ChallengeMMCS>&& config)
: mmcs_(std::move(mmcs)), config_(std::move(config)) {}

Domain GetNaturalDomainForDegree(size_t size) {
uint32_t log_n = base::bits::CheckedLog2(size);
Expand All @@ -79,10 +79,10 @@ class TwoAdicFRI {
base::Map(cosets, [this, &matrices](size_t i, const Domain& coset) {
math::RowMajorMatrix<F>& mat = matrices[i];
CHECK_EQ(coset.domain()->size(), static_cast<size_t>(mat.rows()));
math::RowMajorMatrix<F> lde(mat.rows() << fri_.log_blowup,
math::RowMajorMatrix<F> lde(mat.rows() << config_.log_blowup,
mat.cols());
coset.domain()->CosetLDEBatch(
mat, fri_.log_blowup,
mat, config_.log_blowup,
F::FromMontgomery(F::Config::kSubgroupGenerator) *
coset.domain()->offset_inv(),
lde, /*reverse_at_last=*/false);
Expand Down Expand Up @@ -147,7 +147,7 @@ class TwoAdicFRI {
CHECK_EQ(reduced_opening_for_log_num_rows.size(), num_rows);

math::RowMajorMatrix<F> block =
mat.topRows(num_rows >> fri_.log_blowup);
mat.topRows(num_rows >> config_.log_blowup);
ReverseMatrixIndexBits(block);
std::vector<ExtF> reduced_rows = DotExtPowers(mat, alpha);

Expand Down Expand Up @@ -192,7 +192,7 @@ class TwoAdicFRI {

*opened_values_out = std::move(opened_values);
*proof = fri::Prove<TwoAdicFRI>(
fri_, std::move(fri_input), challenger,
config_, std::move(fri_input), challenger,
[this, log_global_max_num_rows, &prover_data_by_round](size_t index) {
size_t num_rounds = prover_data_by_round.size();
return base::CreateVector(
Expand Down Expand Up @@ -227,9 +227,9 @@ class TwoAdicFRI {
const ExtF alpha = challenger.template SampleExtElement<ExtF>();
VLOG(2) << "FRI(alpha): " << alpha.ToHexString(true);
uint32_t log_global_max_num_rows =
proof.commit_phase_commits.size() + fri_.log_blowup;
proof.commit_phase_commits.size() + config_.log_blowup;
return fri::Verify(
fri_, proof, challenger,
config_, proof, challenger,
[this, alpha, log_global_max_num_rows, &commits_by_round,
&domains_by_round, &points_by_round, &opened_values_by_round](
size_t index, const InputProof& input_proof,
Expand Down Expand Up @@ -259,7 +259,8 @@ class TwoAdicFRI {
vals_size,
[this, &batch_max_num_rows, &domains](size_t batch_idx) {
const Domain& domain = domains[batch_idx];
size_t num_rows = domain.domain()->size() << fri_.log_blowup;
size_t num_rows = domain.domain()->size()
<< config_.log_blowup;
batch_max_num_rows = std::max(batch_max_num_rows, num_rows);
return math::Dimensions{0, num_rows};
});
Expand All @@ -281,7 +282,7 @@ class TwoAdicFRI {
const std::vector<ExtF> cur_values_in = base::Map(
opened_values_in[batch_idx], [](F f) { return ExtF(f); });
uint32_t log_num_rows =
domain.domain()->log_size_of_group() + fri_.log_blowup;
domain.domain()->log_size_of_group() + config_.log_blowup;
uint32_t bits_reduced = log_global_max_num_rows - log_num_rows;
uint32_t rev_reduced_index = base::bits::ReverseBitsLen(
index >> bits_reduced, log_num_rows);
Expand Down Expand Up @@ -433,7 +434,7 @@ class TwoAdicFRI {
}

InputMMCS mmcs_;
FRIConfig<ChallengeMMCS> fri_;
FRIConfig<ChallengeMMCS> config_;
};

} // namespace crypto
Expand Down

0 comments on commit b3c722f

Please sign in to comment.