Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
anupsv committed May 31, 2024
1 parent 40b4868 commit 36983d5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
3 changes: 0 additions & 3 deletions tests/blob_test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

#[cfg(test)]
mod tests {
use rust_kzg_bn254::{blob::Blob, errors::BlobError};
const GETTYSBURG_ADDRESS_BYTES: &[u8] = "Fourscore and seven years ago our fathers brought forth, on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived, and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting-place for those who here gave their lives, that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate—we cannot hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.".as_bytes();


#[test]
fn test_already_padded() {
let mut blob = Blob::from_bytes_and_pad("hi".as_bytes());
Expand All @@ -18,7 +16,6 @@ mod tests {

#[test]
fn test_convert_by_padding_empty_byte() {

let mut blob = Blob::from_bytes_and_pad("hi".as_bytes());
assert_eq!(
blob.get_blob_data(),
Expand Down
20 changes: 13 additions & 7 deletions tests/helpers_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use ark_bn254::{Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective};
use ark_ff::{UniformRand, PrimeField};
use rust_kzg_bn254::{consts::{BYTES_PER_FIELD_ELEMENT, SIZE_OF_G1_AFFINE_COMPRESSED}, helpers::{blob_to_polynomial, convert_by_padding_empty_byte, get_num_element, is_on_curve_g1, is_on_curve_g2, remove_empty_byte_from_padded_bytes, set_bytes_canonical, set_bytes_canonical_manual, to_byte_array, to_fr_array}};
use ark_std::{
str::FromStr,
One,
use ark_ff::{PrimeField, UniformRand};
use ark_std::{str::FromStr, One};
use rust_kzg_bn254::{
consts::{BYTES_PER_FIELD_ELEMENT, SIZE_OF_G1_AFFINE_COMPRESSED},
helpers::{
blob_to_polynomial, convert_by_padding_empty_byte, get_num_element, is_on_curve_g1,
is_on_curve_g2, remove_empty_byte_from_padded_bytes, set_bytes_canonical,
set_bytes_canonical_manual, to_byte_array, to_fr_array,
},
};

const GETTYSBURG_ADDRESS_BYTES: &[u8] = "Fourscore and seven years ago our fathers brought forth, on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived, and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting-place for those who here gave their lives, that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate—we cannot hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.".as_bytes();
Expand Down Expand Up @@ -225,14 +229,16 @@ fn test_convert_by_padding_empty_byte() {

unpadded_data = remove_empty_byte_from_padded_bytes(&padded_data);

assert_eq!(unpadded_data, GETTYSBURG_ADDRESS_BYTES, "testing adding padding");
assert_eq!(
unpadded_data, GETTYSBURG_ADDRESS_BYTES,
"testing adding padding"
);
}

#[cfg(test)]
mod tests {
use rust_kzg_bn254::helpers::{is_zeroed, read_g2_point_from_bytes_be};


#[test]
fn test_is_zeroed_all_zeroes() {
// Case where the first byte and the buffer are all zeroes
Expand Down
31 changes: 15 additions & 16 deletions tests/kzg_test.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@


#[cfg(test)]
mod tests {
use ark_bn254::{Fr, G1Affine, G2Affine};
use lazy_static::lazy_static;
use rust_kzg_bn254::{blob::Blob, errors::KzgError, helpers, kzg::Kzg, polynomial::Polynomial};
use std::{env, fs::File, io::{BufRead, BufReader}};
const GETTYSBURG_ADDRESS_BYTES: &[u8] = "Fourscore and seven years ago our fathers brought forth, on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived, and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting-place for those who here gave their lives, that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate—we cannot hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.".as_bytes();
use ark_std::{
str::FromStr,
One,
use std::{
env,
fs::File,
io::{BufRead, BufReader},
};
const GETTYSBURG_ADDRESS_BYTES: &[u8] = "Fourscore and seven years ago our fathers brought forth, on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived, and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting-place for those who here gave their lives, that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate—we cannot hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.".as_bytes();
use ark_std::{str::FromStr, One};

// Function to determine the setup based on an environment variable
fn determine_setup() -> Kzg {
Expand Down Expand Up @@ -109,8 +108,8 @@ mod tests {

#[test]
fn test_g2_power_of_2_readin() {
use rust_kzg_bn254::helpers::is_on_curve_g2;
use ark_bn254::{Fq, Fq2, G2Projective};
use rust_kzg_bn254::helpers::is_on_curve_g2;
use std::io::BufRead;

let kzg = Kzg::setup(
Expand Down Expand Up @@ -172,13 +171,14 @@ mod tests {
.unwrap();

let polynomial_input = input.to_polynomial().unwrap();
let expanded_roots_of_unity_vec_1: Vec<&Fr> = (0..polynomial_input.len()).map(|i| { kzg_clone1.get_nth_root_of_unity(i).unwrap() }).collect();
let expanded_roots_of_unity_vec_2: Vec<&Fr> = (0..polynomial_input.len()).map(|i| { kzg_clone2.get_nth_root_of_unity(i).unwrap() }).collect();
let expanded_roots_of_unity_vec_1: Vec<&Fr> = (0..polynomial_input.len())
.map(|i| kzg_clone1.get_nth_root_of_unity(i).unwrap())
.collect();
let expanded_roots_of_unity_vec_2: Vec<&Fr> = (0..polynomial_input.len())
.map(|i| kzg_clone2.get_nth_root_of_unity(i).unwrap())
.collect();

assert_eq!(
expanded_roots_of_unity_vec_1,
expanded_roots_of_unity_vec_2
);
assert_eq!(expanded_roots_of_unity_vec_1, expanded_roots_of_unity_vec_2);
});
}

Expand Down Expand Up @@ -292,8 +292,8 @@ mod tests {

#[test]
fn test_compute_kzg_proof_output_from_da() {
use rust_kzg_bn254::helpers::str_vec_to_fr_vec;
use ark_bn254::Fq;
use rust_kzg_bn254::helpers::str_vec_to_fr_vec;
let mut kzg = KZG_3000.clone();

let padded_input_fr_elements_raw: Vec<&str> = vec![
Expand Down Expand Up @@ -542,7 +542,6 @@ mod tests {

#[test]
fn test_compute_quotient_eval_on_domain() {

let z_fr = Fr::from_str(
"18272962628503604941710624384101461447671738503426463821117705461905178580283",
)
Expand Down
2 changes: 0 additions & 2 deletions tests/polynomial_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#[cfg(test)]
mod tests {
use ark_bn254::Fr;
Expand Down

0 comments on commit 36983d5

Please sign in to comment.