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

Function equation_test_template

poly-commit/src/lib.rs:902–1081  ·  view source on GitHub ↗
(info: TestInfo<F, P, S>)

Source from the content-addressed store, hash-verified

900 }
901
902 fn equation_test_template<F, P, PC, S>(info: TestInfo<F, P, S>) -> Result<(), PC::Error>
903 where
904 F: PrimeField,
905 P: Polynomial<F>,
906 PC: PolynomialCommitment<F, P>,
907 S: CryptographicSponge,
908 {
909 let TestInfo {
910 num_iters,
911 max_degree,
912 supported_degree,
913 num_vars,
914 num_polynomials,
915 enforce_degree_bounds,
916 max_num_queries,
917 num_equations,
918 rand_poly,
919 rand_point,
920 sponge,
921 } = info;
922
923 let sponge = sponge();
924
925 let rng = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
926 // If testing multivariate polynomials, make the max degree lower
927 let max_degree = match num_vars {
928 Some(_) => max_degree.unwrap_or(Uniform::from(2..=10).sample(rng)),
929 None => max_degree.unwrap_or(Uniform::from(2..=64).sample(rng)),
930 };
931 let pp = PC::setup(max_degree, num_vars, rng)?;
932
933 for _ in 0..num_iters {
934 let supported_degree =
935 supported_degree.unwrap_or(Uniform::from(1..=max_degree).sample(rng));
936 assert!(
937 max_degree >= supported_degree,
938 "max_degree < supported_degree"
939 );
940 let mut polynomials = Vec::new();
941 let mut degree_bounds = if enforce_degree_bounds {
942 Some(Vec::new())
943 } else {
944 None
945 };
946
947 let mut labels = Vec::new();
948 println!("Sampled supported degree");
949
950 // Generate polynomials
951 let num_points_in_query_set = Uniform::from(1..=max_num_queries).sample(rng);
952 for i in 0..num_polynomials {
953 let label = format!("Test{}", i);
954 labels.push(label.clone());
955 let degree = Uniform::from(1..=supported_degree).sample(rng);
956 let degree_bound = if let Some(degree_bounds) = &mut degree_bounds {
957 if rng.gen() {
958 let range = Uniform::from(degree..=supported_degree);
959 let degree_bound = range.sample(rng);

Callers

nothing calls this directly

Calls 9

commitFunction · 0.85
pushMethod · 0.80
iterMethod · 0.80
degree_boundMethod · 0.80
insertMethod · 0.80
is_emptyMethod · 0.80
rand_polyFunction · 0.50
rand_pointFunction · 0.50
evaluateMethod · 0.45

Tested by

no test coverage detected