MCPcopy Create free account
hub / github.com/arkworks-rs/poly-commit / test_reed_solomon

Function test_reed_solomon

poly-commit/src/linear_codes/utils.rs:304–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

302
303 #[test]
304 fn test_reed_solomon() {
305 let rho_inv = 3;
306 // `i` is the min number of evaluations we need to interpolate a poly of degree `i - 1`
307 for i in 1..10 {
308 let deg = (1 << i) - 1;
309
310 let rand_chacha = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
311 let mut pol = DensePolynomial::rand(deg, rand_chacha);
312
313 while pol.degree() != deg {
314 pol = DensePolynomial::rand(deg, rand_chacha);
315 }
316
317 let coeffs = &pol.coeffs;
318
319 // size of evals might be larger than deg + 1 (the min. number of evals needed to interpolate): we could still do R-S encoding on smaller evals, but the resulting polynomial will differ, so for this test to work we should pass it in full
320 let m = deg + 1;
321
322 let encoded = reed_solomon(&coeffs, rho_inv);
323
324 let large_domain = GeneralEvaluationDomain::<Fr>::new(m * rho_inv).unwrap();
325
326 // the encoded elements should agree with the evaluations of the polynomial in the larger domain
327 for j in 0..(rho_inv * m) {
328 assert_eq!(pol.evaluate(&large_domain.element(j)), encoded[j]);
329 }
330 }
331 }
332
333 #[test]
334 fn test_get_num_bytes() {

Callers

nothing calls this directly

Calls 2

reed_solomonFunction · 0.85
degreeMethod · 0.80

Tested by

no test coverage detected