Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bn254 sqrt and decompression #905

Merged
merged 25 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
serde = { version = "1.0", default-features = false, features = [
"derive",
], optional = true }
serde_json = { version = "1.0", default-features = false, features = [
"alloc",
], optional = true }
proptest = { version = "1.1.0", optional = true }
winter-math = { package = "winter-math", version = "0.6.4", default-features = false, optional = true }
miden-core = { package = "miden-core" , version = "0.7", default-features = false, optional = true }
miden-core = { package = "miden-core", version = "0.7", default-features = false, optional = true }

# rayon
rayon = { version = "1.7", optional = true }
Expand All @@ -28,13 +32,13 @@ cudarc = { version = "0.9.7", optional = true }
lambdaworks-gpu = { workspace = true, optional = true }

[dev-dependencies]
rand = { version = "0.8.5", default-features = false }
rand = { version = "0.8.5", features = ["std"] }
rand_chacha = "0.3.1"
criterion = "0.5.1"
const-random = "0.1.15"
iai-callgrind.workspace = true
proptest = "1.1.0"
pprof = { version = "0.13.0", features = ["criterion","flamegraph"] }
pprof = { version = "0.13.0", features = ["criterion", "flamegraph"] }

[features]
default = ["parallel", "std"]
Expand Down Expand Up @@ -97,4 +101,3 @@ harness = false
name = "criterion_metal"
harness = false
required-features = ["metal"]

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ impl Compress for BLS12381Curve {
}
}

fn decompress_g1_point(input_bytes: &mut [u8; 48]) -> Result<Self::G1Point, Self::Error> {
fn decompress_g1_point(input_bytes: &mut [u8]) -> Result<Self::G1Point, Self::Error> {
nicole-graus marked this conversation as resolved.
Show resolved Hide resolved
if !input_bytes.len() == 48 {
return Err(ByteConversionError::InvalidValue);
}
let first_byte = input_bytes.first().unwrap();
// We get the 3 most significant bits
let prefix_bits = first_byte >> 5;
Expand Down Expand Up @@ -150,7 +153,11 @@ impl Compress for BLS12381Curve {
}
}

fn decompress_g2_point(input_bytes: &mut [u8; 96]) -> Result<Self::G2Point, Self::Error> {
fn decompress_g2_point(input_bytes: &mut [u8]) -> Result<Self::G2Point, Self::Error> {
if !input_bytes.len() == 96 {
return Err(ByteConversionError::InvalidValue);
}

let first_byte = input_bytes.first().unwrap();
nicole-graus marked this conversation as resolved.
Show resolved Hide resolved

// We get the first 3 bits
Expand Down
Loading
Loading