# Notes on Ferveo & SCRAPE papers ![](https://i.imgur.com/rLkejT6.png) ![](https://i.imgur.com/tqCB87W.png) ![](https://i.imgur.com/7DFpjD9.png) ![](https://i.imgur.com/5PkaDUR.png) ![](https://i.imgur.com/sg5MyeJ.png) Doing now: ![](https://i.imgur.com/O4LcVzE.png) Try calculating this "Lagrange polynomial" in `prepare_combine_simple` Extra notes on "lambda" Simple variant of Ferveo uses SCRAPE/Pi protocol calculations, straight up: ![](https://i.imgur.com/8YJr7p4.png) ![](https://i.imgur.com/sh5J0UB.png) Notice how the "fast" decryption variant is using different kind of lambda ![](https://i.imgur.com/MdArgFu.png) There is no exponentiation! And also, the thing is indexed by omega. What does it mean? Looking at Lagrange interpolation from Ferveo docs: https://nikkolasg.github.io/ferveo/lagrange.html ![](https://i.imgur.com/hwmk0oh.png) They are using some "subproduct domain" technique to calculate "lambda" (?). Notice the use of omega, which is the domain. We've already established that Lagrange coefficients are "partiotioned" by domain, which has to do with how multiple entities have multiple shares. So apparently this is what `prepare_combine` is doing Is this how the Li is calculated? ```Rust let s = SubproductDomain::<E::Fr>::new(domain); let mut lagrange = s.inverse_lagrange_coefficients(); // L ark_ff::batch_inversion_and_mul(&mut lagrange, &n_0); // ... // L_i * [b] Z_{i,omega_i} blinded_key_share.mul(*lambda) ``` Earlier in the `setup` function: ``` blinded_key_shares.multiply_by_omega_inv(domain_inv); ``` So from this: ![](https://i.imgur.com/fkPiMCN.png) We have to reverse engineer how to reverse engineer L_{i}(0) ![](https://i.imgur.com/qBIrynF.png) Ideas for next steps: - Read how the original, "improper", L_i is calculated - Actually read the implementation of the whole things, line-by-line and underneath, the function impls. etc - Figure out how to rewrite it - Or maybe replace it with different evaluations method from arkworks - Also take note of the setup function and any additional pre-processing you may find there Use this `LagrangeInterpolate` construction? https://github.com/arkworks-rs/r1cs-std/blob/6d64f379a27011b3629cf4c9cb38b7b7b695d5a0/src/poly/evaluations/univariate/lagrange_interpolator.rs#L111-L143 https://github.com/arkworks-rs/algebra/blob/402e7f9603fca7a68b86baf296b6feaf904939f5/poly/src/domain/general.rs#L100 https://github.com/arkworks-rs/r1cs-std/blob/6d64f379a27011b3629cf4c9cb38b7b7b695d5a0/src/poly/evaluations/univariate/mod.rs#L90 https://github.com/arkworks-rs/algebra/blob/402e7f9603fca7a68b86baf296b6feaf904939f5/poly/src/domain/mixed_radix.rs#L441 https://github.com/arkworks-rs/algebra/blob/3ef9864dd3afd44ff5be432c8bfdafa201c58749/poly/src/domain/mod.rs#L149 https://github.com/arkworks-rs/algebra/blob/d3e888d9a7489a89bdc278618899c4604da26dbd/poly/README.md#evaluations