Skip to content

Commit

Permalink
chore: remove hardcoded constants from function that computes the van…
Browse files Browse the repository at this point in the history
…ishing_poly
  • Loading branch information
kevaundray committed May 27, 2024
1 parent 958727c commit a2e1ebd
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions erasure_codes/src/reed_solomon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ fn construct_vanishing_poly_from_erasures(
erasures: Erasures,
domain_extended: &Domain,
) -> Vec<Scalar> {
// Encode the data by doing an fft
const CELLS_PER_EXT_BLOB: usize = 128;
const FIELD_ELEMENTS_PER_EXT_BLOB: usize = 8192;
const FIELD_ELEMENTS_PER_CELL: usize = 64;

match erasures {
Erasures::Indices(indices) => {
let z_x_missing_indices_roots: Vec<_> = indices
Expand All @@ -122,15 +117,17 @@ fn construct_vanishing_poly_from_erasures(
vanishing_poly(&z_x_missing_indices_roots)
}
Erasures::Cells { cell_size, cells } => {
let domain = Domain::new(CELLS_PER_EXT_BLOB);
let domain_extended_size = domain_extended.roots.len();
let num_cells_per_extended_polynomial = domain_extended_size / cell_size;
let domain = Domain::new(num_cells_per_extended_polynomial);

let z_x_missing_indices_roots: Vec<_> =
cells.iter().map(|index| domain.roots[*index]).collect();
let short_zero_poly = vanishing_poly(&z_x_missing_indices_roots);

let mut z_x = vec![Scalar::ZERO; FIELD_ELEMENTS_PER_EXT_BLOB];
let mut z_x = vec![Scalar::ZERO; domain_extended_size];
for (i, coeff) in short_zero_poly.into_iter().enumerate() {
z_x[i * FIELD_ELEMENTS_PER_CELL] = coeff;
z_x[i * cell_size] = coeff;
}
z_x
}
Expand Down

0 comments on commit a2e1ebd

Please sign in to comment.