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

bls12_381-bls: Initial commit #1

Merged
merged 1 commit into from
Jan 8, 2024
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
116 changes: 22 additions & 94 deletions .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
@@ -1,101 +1,29 @@
on: [pull_request]

name: Continuous integration
name: Dusk CI

jobs:
analyze:
name: Dusk Analyzer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: install
args: --git https://github.com/dusk-network/cargo-dusk-analyzer
- uses: actions-rs/cargo@v1
with:
command: dusk-analyzer
args: --manifest-path rust/Cargo.toml

check_nightly_no_std:
name: Nightly check no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
target: thumbv6m-none-eabi
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: check
args: --manifest-path rust/bls12_381-sign/Cargo.toml --no-default-features --target thumbv6m-none-eabi
code_analysis:
name: Code Analysis
uses: dusk-network/.github/.github/workflows/code-analysis.yml@main
with:
clippy_default: false
clippy_args: --release --features=rkyv-impl,rkyv/size_16 -- -D warnings

test_nightly:
name: Nightly tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path rust/Cargo.toml --workspace --release

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path rust/Cargo.toml --all -- --check
dusk_analysis:
name: Dusk Analyzer
uses: dusk-network/.github/.github/workflows/dusk-analysis.yml@main

test:
strategy:
matrix:
go-version: [ 1.17.x ]
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
check_no_std:
name: check no_std
runs-on: core
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Change toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Rustfmt
run: rustup component add rustfmt
- name: Generate Rust FFI and IPC binaries
run: make lib
- name: Upload binaries for platform
uses: actions/upload-artifact@v2
with:
name: bls12_381_sign_${{ matrix.os }}
path: |
go/cgo/bls/libdusk_bls12_381_sign_ffi_${{ matrix.os }}.a
- name: Build Go Stuff
run: make build
- name: Test Go Stuff
run: make test
- name: Run all bls12-381 benches for Cgo, IPC
run: make bench
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- run: cargo check --no-default-features --target thumbv6m-none-eabi

test_std:
name: Nightly std tests
uses: dusk-network/.github/.github/workflows/run-tests.yml@main
with:
test_flags: --features=rkyv-impl,rkyv/size_16
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.DS_Store
/target
/rust/target
Cargo.lock
.idea
/.idea
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0] - 2024-01-08

### Added

- Add initial commit, this package continues the development of [dusk-bls12_381-sign](https://github.com/dusk-network/bls12_381-sign/) at version `0.6.0` under the new name: `bls12_381-bls` and without the go related code.

<!-- ISSUES -->

<!-- VERSIONS -->
[Unreleased]: https://github.com/dusk-network/bls12_381-bls/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/dusk-network/bls12_381-bls/releases/tag/v0.1.0
4 changes: 2 additions & 2 deletions rust/bls12_381-sign/Cargo.toml → Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dusk-bls12_381-sign"
version = "0.6.0"
name = "bls12_381-bls"
version = "0.1.0"
edition = "2021"
description = "Implementation of BLS signatures using the BLS12-381 curve"
license = "MPL-2.0"
Expand Down
64 changes: 0 additions & 64 deletions Makefile

This file was deleted.

48 changes: 19 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
# BLS12-381 Curve Signature
# Implementation of [BLS signatures](https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html) using the BLS12-381 curve.

This repo contains Dusk Network's [implementation](/rust/bls12_381-sign) of the BLS Signatures using the BLS12-381 curve. This implementation currently only supports rogue-key attack resistant batching, and does not support distinct message verification.

## Rust

The [library](/rust/bls12_381-sign) is written in rust.

We also provide a sample IPC [micro-service](/rust/grpc-server) that provides a synchronous gRPC interface to the library for third-party clients.

## Go

We provide a couple options to work with the library using Go:

1. [Using CGo](/go/cgo/bls) to build and link directly to the lib binaries.
1. [Using gRPC](/go/grpc/bls) to communicate with our simple lib IPC server.
This implementation currently only supports rogue-key attack resistant batching, and does not support distinct message verification.

## Benchmarks

We've found the CGo version to perform faster with `Go 1.17+`
### Machine specs

Recent benchmarks are attached for reference:
The benchmarks were ran on a 2020 13.3" MacBook Pro.

### CGo
CPU:
```
cpu: Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
BenchmarkSign 1264 4416508 ns/op 48 B/op 1 allocs/op
BenchmarkVerify 706 8568588 ns/op 0 B/op 0 allocs/op
BenchmarkAggregatePk 864 6687951 ns/op 216 B/op 3 allocs/op
BenchmarkAggregateSig 4274 1443901 ns/op 120 B/op 3 allocs/op
$ lscpu
Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
```

### gRPC
RAM:
```
16 GB 3733 MHz LPDDR4X
```

### Results

```
test benches::bench_aggregate_pk ... bench: 1,654,552 ns/iter (+/- 107,025)
test benches::bench_aggregate_sig ... bench: 36,893 ns/iter (+/- 3,399)
test benches::bench_sign ... bench: 1,480,169 ns/iter (+/- 106,151)
test benches::bench_sign_vulnerable ... bench: 1,024,052 ns/iter (+/- 111,395)
test benches::bench_verify ... bench: 4,740,114 ns/iter (+/- 336,036)
```
BenchmarkSign 1317 4507956 ns/op 5317 B/op 95 allocs/op
BenchmarkVerify 693 8767921 ns/op 5207 B/op 94 allocs/op
BenchmarkAggregatePk 656 9209897 ns/op 5385 B/op 96 allocs/op
BenchmarkAggregateSig 3651 1645111 ns/op 5194 B/op 96 allocs/op
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extern crate test;

mod benches {
use dusk_bls12_381_sign::{PublicKey, SecretKey, APK};
use bls12_381_bls::{PublicKey, SecretKey, APK};
use dusk_bytes::Serializable;
use rand_core::{OsRng, RngCore};
use test::Bencher;
Expand Down
29 changes: 0 additions & 29 deletions go/cgo/bls/README.md

This file was deleted.

Loading