@@ -471,39 +471,27 @@ def verify_cell_proof_batch(row_commitments_bytes: Sequence[Bytes48],
471471
472472## Reconstruction
473473
474- ### ` recover_polynomial `
474+ ### ` construct_vanishing_polynomial `
475475
476476``` python
477- def recover_polynomial (cell_ids : Sequence[CellID],
478- cells_bytes : Sequence[Vector[Bytes32, FIELD_ELEMENTS_PER_CELL ]]) -> Polynomial:
479- """
480- Recovers a polynomial from 2 * FIELD_ELEMENTS_PER_CELL evaluations, half of which can be missing.
481-
482- This algorithm uses FFTs to recover cells faster than using Lagrange implementation. However,
483- a faster version thanks to Qi Zhou can be found here:
484- https://github.com/ethereum/research/blob/51b530a53bd4147d123ab3e390a9d08605c2cdb8/polynomial_reconstruction/polynomial_reconstruction_danksharding.py
485-
486- Public method.
487- """
488- assert len (cell_ids) == len (cells_bytes)
489-
490- cells = [bytes_to_cell(cell_bytes) for cell_bytes in cells_bytes]
491-
492- assert len (cells) >= CELLS_PER_BLOB // 2
477+ def construct_vanishing_polynomial (cell_ids : Sequence[CellID],
478+ cells : Sequence[Cell]) -> Tuple[
479+ Sequence[BLSFieldElement],
480+ Sequence[BLSFieldElement]]:
493481 missing_cell_ids = [cell_id for cell_id in range (CELLS_PER_BLOB ) if cell_id not in cell_ids]
494482 roots_of_unity_reduced = compute_roots_of_unity(CELLS_PER_BLOB )
495483 short_zero_poly = vanishing_polynomialcoeff([
496484 roots_of_unity_reduced[reverse_bits(cell_id, CELLS_PER_BLOB )]
497485 for cell_id in missing_cell_ids
498486 ])
499487
500- full_zero_poly = []
488+ zero_poly_coeff = []
501489 for i in short_zero_poly:
502- full_zero_poly .append(i)
503- full_zero_poly .extend([0 ] * (FIELD_ELEMENTS_PER_CELL - 1 ))
504- full_zero_poly = full_zero_poly + [0 ] * (2 * FIELD_ELEMENTS_PER_BLOB - len (full_zero_poly ))
490+ zero_poly_coeff .append(i)
491+ zero_poly_coeff .extend([0 ] * (FIELD_ELEMENTS_PER_CELL - 1 ))
492+ zero_poly_coeff = zero_poly_coeff + [0 ] * (2 * FIELD_ELEMENTS_PER_BLOB - len (zero_poly_coeff ))
505493
506- zero_poly_eval = fft_field(full_zero_poly ,
494+ zero_poly_eval = fft_field(zero_poly_coeff ,
507495 compute_roots_of_unity(2 * FIELD_ELEMENTS_PER_BLOB ))
508496 zero_poly_eval_brp = bit_reversal_permutation(zero_poly_eval)
509497 for cell_id in missing_cell_ids:
@@ -515,6 +503,34 @@ def recover_polynomial(cell_ids: Sequence[CellID],
515503 end = (cell_id + 1 ) * FIELD_ELEMENTS_PER_CELL
516504 assert all (a != 0 for a in zero_poly_eval_brp[start:end])
517505
506+ return zero_poly_coeff, zero_poly_eval, zero_poly_eval_brp
507+ ```
508+
509+ ### ` recover_shifted_data `
510+
511+ ### ` recover_original_data `
512+
513+ ### ` recover_polynomial `
514+
515+ ``` python
516+ def recover_polynomial (cell_ids : Sequence[CellID],
517+ cells_bytes : Sequence[Vector[Bytes32, FIELD_ELEMENTS_PER_CELL ]]) -> Polynomial:
518+ """
519+ Recovers a polynomial from 2 * FIELD_ELEMENTS_PER_CELL evaluations, half of which can be missing.
520+
521+ This algorithm uses FFTs to recover cells faster than using Lagrange implementation. However,
522+ a faster version thanks to Qi Zhou can be found here:
523+ https://github.com/ethereum/research/blob/51b530a53bd4147d123ab3e390a9d08605c2cdb8/polynomial_reconstruction/polynomial_reconstruction_danksharding.py
524+
525+ Public method.
526+ """
527+ assert len (cell_ids) == len (cells_bytes)
528+
529+ cells = [bytes_to_cell(cell_bytes) for cell_bytes in cells_bytes]
530+ assert len (cells) >= CELLS_PER_BLOB // 2
531+
532+ zero_poly_coeff, zero_poly_eval, zero_poly_eval_brp = construct_vanishing_polynomial(cell_ids, cells)
533+
518534 extended_evaluation_rbo = [0 ] * (FIELD_ELEMENTS_PER_BLOB * 2 )
519535 for cell_id, cell in zip (cell_ids, cells):
520536 start = cell_id * FIELD_ELEMENTS_PER_CELL
@@ -533,7 +549,7 @@ def recover_polynomial(cell_ids: Sequence[CellID],
533549 shift_inv = div(BLSFieldElement(1 ), shift_factor)
534550
535551 shifted_extended_evaluation = shift_polynomialcoeff(extended_evaluations_fft, shift_factor)
536- shifted_zero_poly = shift_polynomialcoeff(full_zero_poly , shift_factor)
552+ shifted_zero_poly = shift_polynomialcoeff(zero_poly_coeff , shift_factor)
537553
538554 eval_shifted_extended_evaluation = fft_field(shifted_extended_evaluation, roots_of_unity_extended)
539555 eval_shifted_zero_poly = fft_field(shifted_zero_poly, roots_of_unity_extended)
0 commit comments