Skip to content
This repository was archived by the owner on Jun 13, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
155 changes: 53 additions & 102 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,64 @@ name: Python package

on:
push:
branches: [master]
branches: [main]
tags:
- v1.*
pull_request:
branches: [master]
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install Rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
default: true
components: rustfmt, clippy
- name: Lint with rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt

- name: Lint with clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features
- run: cargo fmt --check
- run: cargo clippy --all-targets --all-features

build:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v2
- name: rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
- name: Set up Python 3.x
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- name: Test with pytest
run: pytest
- name: Benchmarks
run: pytest benchmark.py --benchmark-json output.json
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
with:
tool: 'pytest'
output-file-path: output.json
comment-on-alert: true
github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically
auto-push: true
- run: pytest

macos:
runs-on: macos-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
toolchain: nightly
profile: minimal
default: true
python-version: '3.x'
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels - x86_64
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
target: x86_64
# We do source distribution here too
args: --release --out dist
- name: Install built wheel - x86_64
run: |
pip install milagro_bls_binding --no-index --find-links dist --force-reinstall
python -c "import milagro_bls_binding"
- name: Build wheels - universal2
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
args: --release --universal2 --out dist --no-sdist
- name: Install built wheel - universal2
target: universal2-apple-darwin
args: --release --out dist
- name: Install and test universal2 wheel
run: |
pip install milagro_bls_binding --no-index --find-links dist --force-reinstall
python -c "import milagro_bls_binding"
- name: Upload wheels
uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-macos
path: dist

windows:
Expand All @@ -110,30 +69,24 @@ jobs:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.7
python-version: '3.x'
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
default: true
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --no-sdist
args: --release --out dist
- name: Install built wheel
run: |
pip install milagro_bls_binding --no-index --find-links dist --force-reinstall
python -c "import milagro_bls_binding"
- name: Upload wheels
uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-windows-${{ matrix.target }}
path: dist

linux:
Expand All @@ -143,42 +96,40 @@ jobs:
matrix:
target: [x86_64, i686, aarch64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
architecture: x64
- name: Build Wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist --no-sdist
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install milagro_bls_binding --no-index --find-links dist --force-reinstall
python -c "import milagro_bls_binding"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install milagro_bls_binding --no-index --find-links dist --force-reinstall
python -c "import milagro_bls_binding"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, windows, linux ]
needs: [macos, windows, linux]
steps:
- uses: actions/download-artifact@v4.1.7
- uses: actions/download-artifact@v4
with:
name: wheels
pattern: wheels-*
merge-multiple: true
- name: PyPi publish
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_PASSWORD }}
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
command: upload
args: --skip-existing *
13 changes: 0 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@ edition = "2018"
authors = ["chihchengliang@gmail.com"]
readme = "README.md"

[package.metadata.maturin]
classifier = [
"Development Status :: 7 - Inactive",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.8",
]
maintainer = "Chih-Cheng Liang"
maintainer-email = "chihchengliang@gmail.com"
requires-python = ">=3.8"
project-url = { Source = "https://github.com/ChihChengLiang/milagro_bls_binding/" }

[lib]
name = "milagro_bls_binding"
crate-type = ["cdylib"]
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
[project]
name = "milagro-bls-binding"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 7 - Inactive",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.8",
]

[[project.maintainers]]
name = "Chih-Cheng Liang"
email = "chihchengliang@gmail.com"

[project.urls]
Source = "https://github.com/ChihChengLiang/milagro_bls_binding/"

[build-system]
requires = ["maturin>=1.0,<2.0"]
Expand Down
29 changes: 24 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ fn SkToPk(py: Python<'_>, SK: &Bound<'_, PyBytes>) -> PyResult<Py<PyBytes>> {
}

#[pyfunction]
fn Sign(py: Python<'_>, SK: &Bound<'_, PyBytes>, message: &Bound<'_, PyBytes>) -> PyResult<Py<PyBytes>> {
fn Sign(
py: Python<'_>,
SK: &Bound<'_, PyBytes>,
message: &Bound<'_, PyBytes>,
) -> PyResult<Py<PyBytes>> {
SecretKey::from_bytes(SK.as_bytes())
.map_err(to_py_err)
.and_then(|sk| Ok(Signature::new(message.as_bytes(), &sk).as_bytes()))
.map(|sk| Signature::new(message.as_bytes(), &sk).as_bytes())
.map(|sig| PyBytes::new(py, &sig).unbind())
}

#[pyfunction]
fn Verify(_py: Python<'_>, PK: &Bound<'_, PyBytes>, message: &Bound<'_, PyBytes>, signature: &Bound<'_, PyBytes>) -> bool {
fn Verify(
_py: Python<'_>,
PK: &Bound<'_, PyBytes>,
message: &Bound<'_, PyBytes>,
signature: &Bound<'_, PyBytes>,
) -> bool {
PublicKey::from_bytes(PK.as_bytes())
.map_err(to_py_err)
.and_then(|pk| {
Expand Down Expand Up @@ -70,7 +79,12 @@ fn _AggregatePKs(py: Python<'_>, PKs: &Bound<'_, PyList>) -> PyResult<Py<PyBytes
}

#[pyfunction]
fn FastAggregateVerify(_py: Python<'_>, PKs: &Bound<'_, PyList>, message: &Bound<'_, PyBytes>, signature: &Bound<'_, PyBytes>) -> bool {
fn FastAggregateVerify(
_py: Python<'_>,
PKs: &Bound<'_, PyList>,
message: &Bound<'_, PyBytes>,
signature: &Bound<'_, PyBytes>,
) -> bool {
PKs.iter()
.map(|pubkey| {
let bytes: Vec<u8> = pubkey.extract()?;
Expand All @@ -89,7 +103,12 @@ fn FastAggregateVerify(_py: Python<'_>, PKs: &Bound<'_, PyList>, message: &Bound
}

#[pyfunction]
fn AggregateVerify(_py: Python<'_>, PKs: &Bound<'_, PyList>, messages: &Bound<'_, PyList>, signature: &Bound<'_, PyBytes>) -> bool {
fn AggregateVerify(
_py: Python<'_>,
PKs: &Bound<'_, PyList>,
messages: &Bound<'_, PyList>,
signature: &Bound<'_, PyBytes>,
) -> bool {
PKs.iter()
.map(|pubkey| {
let bytes: Vec<u8> = pubkey.extract()?;
Expand Down
Loading