Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
57f7e16
refactor: remove bn_helpers.hpp as workaround for gmp / relic datastr…
knst Sep 11, 2026
43a953d
refactor: removed helper PrivateKey::RandomPrivateKey because it used…
knst Sep 11, 2026
158592f
refactor: drop fLegacy flag from private's key serialization
knst Sep 11, 2026
796a158
fix: silence -Wunused-parameter in LegacySchemeMPL stubs and Aggregat…
knst Sep 30, 2026
3a7f027
doc: repair license header text mangled by the MPL-stripping sed
knst Sep 11, 2026
7ecb920
test: order boundary tests, blst cross-check and the consensus vector…
knst Sep 11, 2026
f683a06
Adapt to the most recent version of emsdk. (#362)
AmineKhaldi Apr 22, 2023
73eb5bb
catchup: into main from long_lived/blastwjb @ 95c2f65073c366a3621e30…
wallentx Jun 20, 2023
e79d284
no avx not for EMSCRIPTEN (#428)
wjblanke Aug 24, 2023
69cce7e
fix: adopt dash specific files chaincode, threshold for blst library
knst Sep 11, 2026
6cb99c4
fix: adopt extendedprivatekey extendendpublickey for blst's library
knst Sep 11, 2026
4f8b4e5
fix: adopt legacy signing for blst library [ep2_map_legacy]
knst Sep 11, 2026
ecbb1dc
fix: adopt elements.cpp for blst library usages
knst Sep 11, 2026
81e22c0
fix: blst's validation assumes a point on the curve while relic's is-…
knst Sep 24, 2026
330f75b
fix: adopt privatekey.cpp for blst library usage
knst Sep 11, 2026
a021900
fix: adopt util.hpp for blst library usages
knst Sep 11, 2026
18a9a6b
fix: adopt schemes.hpp/cpp for blst library
knst Sep 11, 2026
c42c4dd
fix: scalar byte order in point multiplication
knst Sep 11, 2026
e2d734f
fix: keep relic's verification semantics instead of blst_core_verify
knst Sep 15, 2026
d48d45f
perf: serialize PrivateKey without blst's temporary limb conversion
knst Sep 11, 2026
49450c5
test: extra blst boundary checks tests
knst Sep 11, 2026
3c521b3
build: include blst headers as "blst.h"
knst Sep 13, 2026
6f3d09f
binds: restore G1Element/G2Element multiplication by PrivateKey in Py…
knst Sep 15, 2026
48307a8
binds: build the Go and Rust bindings against blst
knst Sep 15, 2026
45ad338
binds: build the Apple Rust dependencies with CMake
knst Sep 15, 2026
d59a414
build: link vectorgen with emmalloc under Emscripten
knst Sep 15, 2026
1079b7f
fix: legacy signing and verification require a 32-byte message hash
knst Sep 15, 2026
1d142fd
fix: keep md_hmac's key-derived buffers in secure memory
knst Sep 15, 2026
d26e546
fix: GTElement::Unity() returned a default element
knst Sep 21, 2026
32de4b2
test: fixed invalid point, secure-aggregation case; fuzzgen argument …
knst Sep 21, 2026
a9cc2d3
refactor: pass the message length to blst hash-to-group as size_t
knst Oct 1, 2026
36b2a13
fix: relic's zeros-only check for basic G1 decoding
knst Oct 1, 2026
e3fa624
ci: drop the relic backend matrix and the GMP installs
knst Oct 1, 2026
3c92123
build: use blst's portable C code on 64-bit targets without assembly
knst Oct 31, 2026
1d0724e
build: apply -fno-builtin to blst's server.c only
knst Oct 31, 2026
eef98c6
build: drop the relic leftovers from Python packaging
knst Oct 31, 2026
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
7 changes: 1 addition & 6 deletions .github/workflows/binds-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -qq --yes valgrind libgmp-dev cmake
sudo apt-get install -qq --yes valgrind cmake
hash -r
cmake --version

- name: Prepare build system for macOS
if: startsWith(matrix.os, 'macos')
run: |
brew install gmp

- name: Build library using CMake
run: |
cores=$(getconf _NPROCESSORS_ONLN)
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/binds-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ jobs:
- name: Build the sdist
run: uv build --sdist --out-dir dist

- name: Prepare build system
run: |
sudo apt-get update
sudo apt-get install -qq --yes libgmp-dev

- name: Install from the sdist and run the unit tests
run: |
uv venv .venv-sdist
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/binds-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -qq --yes valgrind libgmp-dev cmake
sudo apt-get install -qq --yes valgrind cmake
hash -r
cmake --version

- name: Prepare build system for macOS
if: startsWith(matrix.os, 'macos')
run: |
brew install gmp

- name: Install Rust
run: |
rustup toolchain install ${{ matrix.rust }}
Expand All @@ -47,3 +42,5 @@ jobs:
run: |
cd rust-bindings/bls-dash-sys
cargo test
cd ../bls-signatures
cargo test
10 changes: 4 additions & 6 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:

jobs:
build:
name: ${{ matrix.os }}, ${{ matrix.compiler.cc }}, ${{ matrix.backend }} backend
name: ${{ matrix.os }}, ${{ matrix.compiler.cc }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -28,7 +28,6 @@ jobs:
cxx: g++
- cc: clang
cxx: clang++
backend: [ easy, gmp ]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -37,21 +36,20 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -qq --yes valgrind libgmp-dev cmake
sudo apt-get install -qq --yes valgrind cmake
hash -r
cmake --version

- name: Prepare build system for macOS
if: startsWith(matrix.os, 'macos')
run: |
ls -l
export MACOSX_DEPLOYMENT_TARGET=10.14
brew install gmp pkg-config
brew install pkg-config

- name: Build library using CMake
run: |
mkdir -p build && cd build
CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} cmake .. -DARITH=${{ matrix.backend }} -DBUILD_BLS_PYTHON_BINDINGS=0 -DCMAKE_BUILD_TYPE=Debug
CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} cmake .. -DBUILD_BLS_PYTHON_BINDINGS=0 -DCMAKE_BUILD_TYPE=Debug
cmake --build . -- -j 6
mv src/runtest ..

Expand Down
Empty file modified .github/workflows/stale-issue.yml
100755 → 100644
Empty file.
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ main
.o
obj/
src/*.o
depends/relic/CTestTestfile.cmake
depends/relic/bench/CTestTestfile.cmake
depends/relic/bin
depends/relic/include/relic_conf.h
depends/relic/include/relic_conf.h.in
depends/relic/include/relic_conf.h.old
depends/relic/include/stamp-h1
depends/relic/test/CTestTestfile.cmake
contrib/gmp-6.1.2/

.idea
.vscode
Expand Down
108 changes: 20 additions & 88 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ endif()

project(BLS)

if(MSVC)
enable_language(ASM_MASM)
else()
enable_language(ASM)
endif()

set(BUILD_BLS_JS_BINDINGS "1" CACHE STRING "")
set(BUILD_BLS_PYTHON_BINDINGS "1" CACHE STRING "")
set(BUILD_BLS_TESTS "1" CACHE STRING "")
Expand All @@ -29,94 +35,27 @@ set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
)

# Relic related options

set(STBIN "off" CACHE STRING "Relic - Build static binaries")

find_package(gmp)
if (GMP_FOUND)
message(STATUS "Found libgmp")
set(ARITH "gmp" CACHE STRING "")
else()
set(ARITH "easy" CACHE STRING "")
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(WSIZE "32" CACHE STRING "Relic - Processor word size")
else()
set(WSIZE "64" CACHE STRING "Relic - Processor word size")
endif()

if(EMSCRIPTEN)
# emscripten needs arch set to be none since it can't compile assembly
set(ARCH "" CACHE STRING "")
# emscripten is a 32 bit compiler
set(WSIZE "32" CACHE STRING "Relic - Processor word size")
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(TIMER "ANSI" CACHE STRING "")
set(MULTI "OPENMP" CACHE STRING "")
else()
set(TIMER "CYCLE" CACHE STRING "")
set(MULTI "PTHREAD" CACHE STRING "")
endif()

set(CHECK "off" CACHE STRING "")
set(VERBS "off" CACHE STRING "")
set(ALLOC "AUTO" CACHE STRING "")
set(SHLIB "off" CACHE STRING "")
set(DOCUM "off" CACHE STRING "")
set(FP_PRIME "381" CACHE STRING "Relic - Prime modulus size")

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SEED "UDEV" CACHE STRING "")
set(FP_QNRES "off" CACHE STRING "")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(SEED "WCGR" CACHE STRING "")
set(FP_QNRES "on" CACHE STRING "")
else()
set(SEED "UDEV" CACHE STRING "")
set(FP_QNRES "on" CACHE STRING "")
endif()

set(FP_METHD "INTEG;INTEG;INTEG;MONTY;LOWER;SLIDE" CACHE STRING "")

if(MSVC)
set(COMP_FLAGS "" CACHE STRING "")
else()
set(COMP_FLAGS "-O3 -funroll-loops -fomit-frame-pointer" CACHE STRING "")
endif()

set(FP_PMERS "off" CACHE STRING "")
set(FPX_METHD "INTEG;INTEG;LAZYR" CACHE STRING "")
set(EP_PLAIN "off" CACHE STRING "")
set(EP_SUPER "off" CACHE STRING "")
# Disable relic tests and benchmarks
set(TESTS "0" CACHE STRING "Relic - Number of times each test is ran")
set(BENCH "0" CACHE STRING "Relic - Number of times each benchmark is ran")

set(QUIET "on" CACHE STRING "Relic - Build with printing disabled")

set(PP_EXT "LAZYR" CACHE STRING "")
set(PP_METHD "LAZYR;OATEP" CACHE STRING "")

# Disable mimalloc shared libraries and tests, enable secure mode
set(MI_SECURE "on" CACHE STRING "")

set(MI_BUILD_SHARED "off" CACHE STRING "")
set(MI_BUILD_TESTS "off" CACHE STRING "")
set(MI_OVERRIDE "off" CACHE STRING "")

add_subdirectory(depends/relic)
add_subdirectory(depends/mimalloc)

#message(STATUS "Patching Relic to make setjmp.h inclusion conditional")
#
#execute_process(
# COMMAND bash -c "git apply ${CMAKE_SOURCE_DIR}/setjmp_patch.diff"
# WORKING_DIRECTORY ${RELIC_SRC}
#)
include(FetchContent)

set(BLST_GIT_TAG "a8cd361c9f671577aeab3f074098443af92a53fc")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently used tag is three years old (source), against latest release, the API changes don't seem too drastic.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, I backported https://github.com/Chia-Network/bls-signatures/pull/409/files and tried to keep diff minimal as possible and changeset close as possible to original PR.
It would be easy to bump version any time in the future

@kwvg kwvg Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would rather the bump happen now, can be in a separate commit if desire to distinguish it from Chia's diffset but right off the bat we should try to at least use a tagged release. There are (even if minor) API changes so better to do it now.

set(BLST_REPOSITORY "https://github.com/supranational/blst")

message(STATUS "blst will be built from: ${BLST_GIT_TAG} and repository ${BLST_REPOSITORY}")

FetchContent_Declare(
Comment thread
kwvg marked this conversation as resolved.
Resolved
blst
GIT_REPOSITORY ${BLST_REPOSITORY}
GIT_TAG ${BLST_GIT_TAG}
)
FetchContent_MakeAvailable(blst)
Comment thread
kwvg marked this conversation as resolved.
Resolved
Comment thread
kwvg marked this conversation as resolved.
Resolved
Comment thread
kwvg marked this conversation as resolved.
Resolved

add_subdirectory(src)

Expand All @@ -128,14 +67,7 @@ endif()

file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES};")

if(GMP_INCLUDES)
file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${GMP_INCLUDES};")
endif()

# Write gmp library path for rust binding
if(GMP_LIBRARIES)
file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/gmp_libraries.txt" "${GMP_LIBRARIES}")
endif()
file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${blst_SOURCE_DIR}/bindings;")

if(EMSCRIPTEN)
if(BUILD_BLS_JS_BINDINGS)
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
> **This library has not undergone a formal security review.**

`bls-signatures` is a cross-platform library implementing BLS12-381 primitives for Dash built on
the [`relic`](https://github.com/relic-toolkit/relic) toolkit with bindings available in
the [`blst library`](https://github.com/supranational/blst.git) toolkit with bindings available in
[Python](./binds/python), [Rust](./rust-bindings/), [Go](./go-bindings/) and [Javascript](./js-bindings).

## Dependencies

* A C++17 capable compiler (GCC 9, Clang 7 or higher)
* CMake 3.18 or higher
* [`libgmp`](https://gmplib.org/) (for fast arithmetic, **optional**)

Additionally, the following dependencies are supplied by the codebase

* [`catch2`](https://github.com/catchorg/Catch2) (for tests)
* [`mimalloc`](https://github.com/microsoft/mimalloc) (for secure memory operations)
* [`relic`](https://github.com/relic-toolkit/relic) (for cryptographic operations)
* [`blst`](https://github.com/supranational/blst.git) (for cryptographic operations)

## Build library

Expand Down Expand Up @@ -100,6 +99,11 @@ uv run pytest -v binds/python/test_unit.py
uv run pytest -v binds/python/test_bench.py --benchmark-only
```

## BLST license

BLST is used with the
[Apache 2.0 license](https://github.com/supranational/blst/blob/master/LICENSE)

## License

```text
Expand Down
Loading
Loading