chore: Da kzgrs unit tests update (#676)
* test: blst error conversions * test: compute roots of unity * test: variant with Toeplitz1Cache value * test: verify_column error cases * test: add DaEncoderParams::new case * fix: reduce code duplicity for test_verify_column * test: build_certificate error cases * test: Certificate related methods * test: VidCertificate related methods - Index * fix: revert changes for kzgrs-backend
This commit is contained in:
parent
9ad4ee7a3c
commit
4150c6514d
|
@ -130,10 +130,13 @@ pub fn compute_roots_of_unity(size: usize) -> Vec<Fr> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::{bytes_to_evaluations, bytes_to_polynomial, KzgRsError};
|
use super::{
|
||||||
|
bytes_to_evaluations, bytes_to_polynomial, compute_roots_of_unity, BlstError, KzgRsError,
|
||||||
|
};
|
||||||
use ark_bls12_381::fr::Fr;
|
use ark_bls12_381::fr::Fr;
|
||||||
use ark_ff::{BigInteger, PrimeField};
|
use ark_ff::{BigInteger, PrimeField};
|
||||||
use ark_poly::{EvaluationDomain, GeneralEvaluationDomain, Polynomial};
|
use ark_poly::{EvaluationDomain, GeneralEvaluationDomain, Polynomial};
|
||||||
|
use blst::BLST_ERROR;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use rand::{thread_rng, Fill};
|
use rand::{thread_rng, Fill};
|
||||||
|
|
||||||
|
@ -179,4 +182,55 @@ mod test {
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn blst_error_conversions() {
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_SUCCESS)),
|
||||||
|
"Operation successful"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_BAD_ENCODING)),
|
||||||
|
"Bad encoding"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_POINT_NOT_ON_CURVE)),
|
||||||
|
"Point not on curve"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_POINT_NOT_IN_GROUP)),
|
||||||
|
"Point not in group"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_AGGR_TYPE_MISMATCH)),
|
||||||
|
"Aggregate type mismatch"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_VERIFY_FAIL)),
|
||||||
|
"Verification failed"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_PK_IS_INFINITY)),
|
||||||
|
"Public key is infinity"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", BlstError(BLST_ERROR::BLST_BAD_SCALAR)),
|
||||||
|
"Bad scalar value"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
format!("{}", KzgRsError::from(BLST_ERROR::BLST_SUCCESS)),
|
||||||
|
"BLST error: Operation successful"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_compute_roots_of_unity() {
|
||||||
|
let roots = compute_roots_of_unity(10);
|
||||||
|
|
||||||
|
let domain: GeneralEvaluationDomain<Fr> = GeneralEvaluationDomain::new(10).unwrap();
|
||||||
|
let frs: Vec<Fr> = domain.elements().take(10).collect();
|
||||||
|
|
||||||
|
assert_eq!(roots, frs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl Toeplitz1Cache {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::fk20::fk20_batch_generate_elements_proofs;
|
use crate::fk20::{fk20_batch_generate_elements_proofs, Toeplitz1Cache};
|
||||||
use crate::{
|
use crate::{
|
||||||
common::bytes_to_polynomial, kzg::generate_element_proof, GlobalParameters, Proof,
|
common::bytes_to_polynomial, kzg::generate_element_proof, GlobalParameters, Proof,
|
||||||
BYTES_PER_FIELD_ELEMENT,
|
BYTES_PER_FIELD_ELEMENT,
|
||||||
|
@ -133,6 +133,12 @@ mod test {
|
||||||
.collect();
|
.collect();
|
||||||
let fk20_proofs = fk20_batch_generate_elements_proofs(&poly, &GLOBAL_PARAMETERS, None);
|
let fk20_proofs = fk20_batch_generate_elements_proofs(&poly, &GLOBAL_PARAMETERS, None);
|
||||||
assert_eq!(slow_proofs, fk20_proofs);
|
assert_eq!(slow_proofs, fk20_proofs);
|
||||||
|
|
||||||
|
// Test variant with Toeplitz1Cache param
|
||||||
|
let tc = Toeplitz1Cache::with_size(&GLOBAL_PARAMETERS.clone(), size);
|
||||||
|
let fk20_proofs =
|
||||||
|
fk20_batch_generate_elements_proofs(&poly, &GLOBAL_PARAMETERS, Some(&tc));
|
||||||
|
assert_eq!(slow_proofs, fk20_proofs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue