diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e2f5bf..57c3b9d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,17 +30,55 @@ jobs: - name: Run cargo test run: cargo test --verbose - - name: Run cargo bench - run: cargo bench --verbose - - name: Run cargo clippy (default) run: cargo clippy -- -D warnings - name: Run cargo clippy (tests) run: cargo clippy --tests -- -D warnings + bench: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + - name: Run cargo bench + run: cargo bench --verbose + - name: Run cargo clippy (bench bls381_benches) run: cargo clippy --bench bls381_benches -- -D warnings - name: Run cargo clippy (bench multi_verify_benches) run: cargo clippy --bench multi_verify_benches -- -D warnings + + build-and-test-windows: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + targets: x86_64-pc-windows-gnu + + - name: Add MinGW to PATH + shell: pwsh + run: echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Run cargo test + run: cargo test --target x86_64-pc-windows-gnu --verbose + + - name: Run cargo clippy (tests) + run: cargo clippy --tests --target x86_64-pc-windows-gnu -- -D warnings diff --git a/.gitignore b/.gitignore index dfcb38c..b9c86d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target Cargo.lock CVS +.DS_Store diff --git a/Cargo.toml b/Cargo.toml index 00cda22..c639b75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,9 @@ categories = ["cryptography"] [lib] path = "src/lib.rs" -[dependencies] -criterion = "0.7.0" -hex = "0.4.0" +[dev-dependencies] +criterion = "0.8" +hex = "0.4" [[bench]] name = "bls381_benches" diff --git a/README.md b/README.md index 4791c0d..f2249c9 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ let buffer = [0; 96]; let mut public_key = G2::default(); -if !public_key.deserialize_g2(buffer) { +if !public_key.deserialize_g2(&buffer) { return Err(BlsError::InvalidData); } ``` @@ -174,7 +174,7 @@ let buffer = [0; 48]; let mut sign = G1::default(); -if !sign.deserialize(buffer) { +if !sign.deserialize(&buffer) { return Err(BlsError::InvalidData); } ``` @@ -186,3 +186,9 @@ fn verify_signature(signature: G1, public_key: G2, message: &[u8]) { signature.verify(public_key, message) } ``` + +## Acknowledgements + +This repository originated as a fork of [herumi/bls-eth-rust](https://github.com/herumi/bls-eth-rust) by MITSUNARI Shigeo, a Rust wrapper around the [herumi/bls](https://github.com/herumi/bls) C library. The original implementation provided the foundational FFI bindings and BLS primitives that this library builds upon. + +The codebase has since been substantially rewritten — Ethereum-specific logic was removed, the API was restructured into dedicated modules, and the library was tailored to MultiversX's requirements. The fork has been detached from the upstream repository to reflect this divergence. diff --git a/build.rs b/build.rs index eed8a5d..7b253ba 100644 --- a/build.rs +++ b/build.rs @@ -23,9 +23,18 @@ fn main() { println!("cargo:rustc-link-lib=static=bls384_256_arm_macos"); println!("cargo:rustc-link-lib=c++"); } - (_, "windows") => { + ("x86_64", "windows") => { + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); + if env == "msvc" { + panic!( + "The x86_64-pc-windows-msvc target is not supported: only a MinGW/GNU-compatible \ + static archive is provided. Use the x86_64-pc-windows-gnu target instead, or \ + supply an MSVC-compatible import/static library." + ); + } println!("cargo:rustc-link-search=native=./executors"); - println!("cargo:rustc-link-lib=static=bls384_256_arm_macos"); + println!("cargo:rustc-link-lib=static=bls384_256_amd_windows"); + println!("cargo:rustc-link-lib=advapi32"); println!("cargo:rustc-link-lib=stdc++"); } _ => panic!("Unsupported target: {os}-{target}"),