Skip to content

Commit

Permalink
refactor: Update constants in consts.rs for G1 and G2 points
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOLAND committed Jun 19, 2024
1 parent 3bfea99 commit 85667eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub const BYTES_PER_FIELD_ELEMENT: usize = 32;
pub const FIELD_ELEMENTS_PER_BLOB: usize = 4096;
pub const BYTES_PER_G1: usize = 48;
pub const BYTES_PER_G2: usize = 96;
pub const BYTES_PER_G1_POINT: usize = 48;
pub const BYTES_PER_G2_POINT: usize = 96;
18 changes: 9 additions & 9 deletions src/trusted_setup.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bls12_381::{G1Affine, G2Affine};

use crate::{
consts::{BYTES_PER_G1, BYTES_PER_G2},
consts::{BYTES_PER_G1_POINT, BYTES_PER_G2_POINT},
enums::KzgError,
hex_to_bytes,
};
Expand All @@ -27,22 +27,22 @@ pub fn load_trusted_setup_file() -> Result<KzgSettings, KzgError> {
let g1_points_idx = num_g1_points + 2;
let g2_points_idx = g1_points_idx + num_g2_points;

let g1_points: Vec<[u8; BYTES_PER_G1]> =
let g1_points: Vec<[u8; BYTES_PER_G1_POINT]> =
hex_to_bytes(&trusted_setup_file[2..g1_points_idx].join(""))
.unwrap()
.chunks_exact(BYTES_PER_G1)
.chunks_exact(BYTES_PER_G1_POINT)
.map(|chunk| {
let mut array = [0u8; BYTES_PER_G1];
let mut array = [0u8; BYTES_PER_G1_POINT];
array.copy_from_slice(chunk);
array
})
.collect();
let g2_points: Vec<[u8; BYTES_PER_G2]> =
let g2_points: Vec<[u8; BYTES_PER_G2_POINT]> =
hex_to_bytes(&trusted_setup_file[g1_points_idx..g2_points_idx].join(""))
.unwrap()
.chunks_exact(BYTES_PER_G2)
.chunks_exact(BYTES_PER_G2_POINT)
.map(|chunk| {
let mut array = [0u8; BYTES_PER_G2];
let mut array = [0u8; BYTES_PER_G2_POINT];
array.copy_from_slice(chunk);
array
})
Expand All @@ -55,8 +55,8 @@ pub fn load_trusted_setup_file() -> Result<KzgSettings, KzgError> {
}

fn load_trusted_setup(
g1_points: Vec<[u8; BYTES_PER_G1]>,
g2_points: Vec<[u8; BYTES_PER_G2]>,
g1_points: Vec<[u8; BYTES_PER_G1_POINT]>,
g2_points: Vec<[u8; BYTES_PER_G2_POINT]>,
) -> Result<KzgSettings, KzgError> {
let mut kzg_settings = KzgSettings::default();

Expand Down

0 comments on commit 85667eb

Please sign in to comment.