Skip to content

Commit 77c8da5

Browse files
Merge pull request #132 from knst/bump-chia-2.0
feat: bump library to mainstream Chia-Network#409 [blst library usage]
2 parents deebfcb + eef98c6 commit 77c8da5

59 files changed

Lines changed: 3456 additions & 2669 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/binds-go.yml‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,10 @@ jobs:
3232
if: startsWith(matrix.os, 'ubuntu')
3333
run: |
3434
sudo apt-get update
35-
sudo apt-get install -qq --yes valgrind libgmp-dev cmake
35+
sudo apt-get install -qq --yes valgrind cmake
3636
hash -r
3737
cmake --version
3838
39-
- name: Prepare build system for macOS
40-
if: startsWith(matrix.os, 'macos')
41-
run: |
42-
brew install gmp
43-
4439
- name: Build library using CMake
4540
run: |
4641
cores=$(getconf _NPROCESSORS_ONLN)

‎.github/workflows/binds-py.yml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ jobs:
9292
- name: Build the sdist
9393
run: uv build --sdist --out-dir dist
9494

95-
- name: Prepare build system
96-
run: |
97-
sudo apt-get update
98-
sudo apt-get install -qq --yes libgmp-dev
99-
10095
- name: Install from the sdist and run the unit tests
10196
run: |
10297
uv venv .venv-sdist

‎.github/workflows/binds-rs.yml‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,10 @@ jobs:
2727
if: startsWith(matrix.os, 'ubuntu')
2828
run: |
2929
sudo apt-get update
30-
sudo apt-get install -qq --yes valgrind libgmp-dev cmake
30+
sudo apt-get install -qq --yes valgrind cmake
3131
hash -r
3232
cmake --version
3333
34-
- name: Prepare build system for macOS
35-
if: startsWith(matrix.os, 'macos')
36-
run: |
37-
brew install gmp
38-
3934
- name: Install Rust
4035
run: |
4136
rustup toolchain install ${{ matrix.rust }}
@@ -47,3 +42,5 @@ jobs:
4742
run: |
4843
cd rust-bindings/bls-dash-sys
4944
cargo test
45+
cd ../bls-signatures
46+
cargo test

‎.github/workflows/build-test.yaml‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ concurrency:
1717

1818
jobs:
1919
build:
20-
name: ${{ matrix.os }}, ${{ matrix.compiler.cc }}, ${{ matrix.backend }} backend
20+
name: ${{ matrix.os }}, ${{ matrix.compiler.cc }}
2121
runs-on: ${{ matrix.os }}
2222
strategy:
2323
fail-fast: false
@@ -28,7 +28,6 @@ jobs:
2828
cxx: g++
2929
- cc: clang
3030
cxx: clang++
31-
backend: [ easy, gmp ]
3231
steps:
3332
- name: Checkout code
3433
uses: actions/checkout@v3
@@ -37,21 +36,20 @@ jobs:
3736
if: startsWith(matrix.os, 'ubuntu')
3837
run: |
3938
sudo apt-get update
40-
sudo apt-get install -qq --yes valgrind libgmp-dev cmake
39+
sudo apt-get install -qq --yes valgrind cmake
4140
hash -r
4241
cmake --version
4342
4443
- name: Prepare build system for macOS
4544
if: startsWith(matrix.os, 'macos')
4645
run: |
47-
ls -l
4846
export MACOSX_DEPLOYMENT_TARGET=10.14
49-
brew install gmp pkg-config
47+
brew install pkg-config
5048
5149
- name: Build library using CMake
5250
run: |
5351
mkdir -p build && cd build
54-
CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} cmake .. -DARITH=${{ matrix.backend }} -DBUILD_BLS_PYTHON_BINDINGS=0 -DCMAKE_BUILD_TYPE=Debug
52+
CC=${{ matrix.compiler.cc }} CXX=${{ matrix.compiler.cxx }} cmake .. -DBUILD_BLS_PYTHON_BINDINGS=0 -DCMAKE_BUILD_TYPE=Debug
5553
cmake --build . -- -j 6
5654
mv src/runtest ..
5755

‎.github/workflows/stale-issue.yml‎

100755100644
File mode changed.

‎.gitignore‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ main
1717
.o
1818
obj/
1919
src/*.o
20-
depends/relic/CTestTestfile.cmake
21-
depends/relic/bench/CTestTestfile.cmake
22-
depends/relic/bin
23-
depends/relic/include/relic_conf.h
24-
depends/relic/include/relic_conf.h.in
25-
depends/relic/include/relic_conf.h.old
26-
depends/relic/include/stamp-h1
27-
depends/relic/test/CTestTestfile.cmake
28-
contrib/gmp-6.1.2/
2920

3021
.idea
3122
.vscode

‎CMakeLists.txt‎

Lines changed: 20 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ endif()
1414

1515
project(BLS)
1616

17+
if(MSVC)
18+
enable_language(ASM_MASM)
19+
else()
20+
enable_language(ASM)
21+
endif()
22+
1723
set(BUILD_BLS_JS_BINDINGS "1" CACHE STRING "")
1824
set(BUILD_BLS_PYTHON_BINDINGS "1" CACHE STRING "")
1925
set(BUILD_BLS_TESTS "1" CACHE STRING "")
@@ -29,94 +35,27 @@ set(CMAKE_MODULE_PATH
2935
${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
3036
)
3137

32-
# Relic related options
33-
34-
set(STBIN "off" CACHE STRING "Relic - Build static binaries")
35-
36-
find_package(gmp)
37-
if (GMP_FOUND)
38-
message(STATUS "Found libgmp")
39-
set(ARITH "gmp" CACHE STRING "")
40-
else()
41-
set(ARITH "easy" CACHE STRING "")
42-
endif()
43-
44-
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
45-
set(WSIZE "32" CACHE STRING "Relic - Processor word size")
46-
else()
47-
set(WSIZE "64" CACHE STRING "Relic - Processor word size")
48-
endif()
49-
50-
if(EMSCRIPTEN)
51-
# emscripten needs arch set to be none since it can't compile assembly
52-
set(ARCH "" CACHE STRING "")
53-
# emscripten is a 32 bit compiler
54-
set(WSIZE "32" CACHE STRING "Relic - Processor word size")
55-
endif()
56-
57-
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
58-
set(TIMER "ANSI" CACHE STRING "")
59-
set(MULTI "OPENMP" CACHE STRING "")
60-
else()
61-
set(TIMER "CYCLE" CACHE STRING "")
62-
set(MULTI "PTHREAD" CACHE STRING "")
63-
endif()
64-
65-
set(CHECK "off" CACHE STRING "")
66-
set(VERBS "off" CACHE STRING "")
67-
set(ALLOC "AUTO" CACHE STRING "")
68-
set(SHLIB "off" CACHE STRING "")
69-
set(DOCUM "off" CACHE STRING "")
70-
set(FP_PRIME "381" CACHE STRING "Relic - Prime modulus size")
71-
72-
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
73-
set(SEED "UDEV" CACHE STRING "")
74-
set(FP_QNRES "off" CACHE STRING "")
75-
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
76-
set(SEED "WCGR" CACHE STRING "")
77-
set(FP_QNRES "on" CACHE STRING "")
78-
else()
79-
set(SEED "UDEV" CACHE STRING "")
80-
set(FP_QNRES "on" CACHE STRING "")
81-
endif()
82-
83-
set(FP_METHD "INTEG;INTEG;INTEG;MONTY;LOWER;SLIDE" CACHE STRING "")
84-
85-
if(MSVC)
86-
set(COMP_FLAGS "" CACHE STRING "")
87-
else()
88-
set(COMP_FLAGS "-O3 -funroll-loops -fomit-frame-pointer" CACHE STRING "")
89-
endif()
90-
91-
set(FP_PMERS "off" CACHE STRING "")
92-
set(FPX_METHD "INTEG;INTEG;LAZYR" CACHE STRING "")
93-
set(EP_PLAIN "off" CACHE STRING "")
94-
set(EP_SUPER "off" CACHE STRING "")
95-
# Disable relic tests and benchmarks
96-
set(TESTS "0" CACHE STRING "Relic - Number of times each test is ran")
97-
set(BENCH "0" CACHE STRING "Relic - Number of times each benchmark is ran")
98-
99-
set(QUIET "on" CACHE STRING "Relic - Build with printing disabled")
100-
101-
set(PP_EXT "LAZYR" CACHE STRING "")
102-
set(PP_METHD "LAZYR;OATEP" CACHE STRING "")
103-
10438
# Disable mimalloc shared libraries and tests, enable secure mode
10539
set(MI_SECURE "on" CACHE STRING "")
10640

10741
set(MI_BUILD_SHARED "off" CACHE STRING "")
10842
set(MI_BUILD_TESTS "off" CACHE STRING "")
10943
set(MI_OVERRIDE "off" CACHE STRING "")
110-
111-
add_subdirectory(depends/relic)
11244
add_subdirectory(depends/mimalloc)
11345

114-
#message(STATUS "Patching Relic to make setjmp.h inclusion conditional")
115-
#
116-
#execute_process(
117-
# COMMAND bash -c "git apply ${CMAKE_SOURCE_DIR}/setjmp_patch.diff"
118-
# WORKING_DIRECTORY ${RELIC_SRC}
119-
#)
46+
include(FetchContent)
47+
48+
set(BLST_GIT_TAG "a8cd361c9f671577aeab3f074098443af92a53fc")
49+
set(BLST_REPOSITORY "https://github.com/supranational/blst")
50+
51+
message(STATUS "blst will be built from: ${BLST_GIT_TAG} and repository ${BLST_REPOSITORY}")
52+
53+
FetchContent_Declare(
54+
blst
55+
GIT_REPOSITORY ${BLST_REPOSITORY}
56+
GIT_TAG ${BLST_GIT_TAG}
57+
)
58+
FetchContent_MakeAvailable(blst)
12059

12160
add_subdirectory(src)
12261

@@ -128,14 +67,7 @@ endif()
12867

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

131-
if(GMP_INCLUDES)
132-
file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${GMP_INCLUDES};")
133-
endif()
134-
135-
# Write gmp library path for rust binding
136-
if(GMP_LIBRARIES)
137-
file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/gmp_libraries.txt" "${GMP_LIBRARIES}")
138-
endif()
70+
file(APPEND "${CMAKE_CURRENT_LIST_DIR}/build/include_paths.txt" "${blst_SOURCE_DIR}/bindings;")
13971

14072
if(EMSCRIPTEN)
14173
if(BUILD_BLS_JS_BINDINGS)

‎README.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@
1111
> **This library has not undergone a formal security review.**
1212
1313
`bls-signatures` is a cross-platform library implementing BLS12-381 primitives for Dash built on
14-
the [`relic`](https://github.com/relic-toolkit/relic) toolkit with bindings available in
14+
the [`blst library`](https://github.com/supranational/blst.git) toolkit with bindings available in
1515
[Python](./binds/python), [Rust](./rust-bindings/), [Go](./go-bindings/) and [Javascript](./js-bindings).
1616

1717
## Dependencies
1818

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

2322
Additionally, the following dependencies are supplied by the codebase
2423

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

2928
## Build library
3029

@@ -100,6 +99,11 @@ uv run pytest -v binds/python/test_unit.py
10099
uv run pytest -v binds/python/test_bench.py --benchmark-only
101100
```
102101

102+
## BLST license
103+
104+
BLST is used with the
105+
[Apache 2.0 license](https://github.com/supranational/blst/blob/master/LICENSE)
106+
103107
## License
104108

105109
```text

0 commit comments

Comments
 (0)