Skip to content

Commit c6010c8

Browse files
mariano54Alex Wicehoffmang9wjblanke
authored
* wip schemes * wip: all schemes tests pass * del relic in prep for submodule add * add relic submodule, major wip commit with basic functionality * manual merge hdkey, better logic for g1/g2 leading bits * fix compresspoint g2 * g1/g2 serialization correct * Get IETF branch building under MacOS and Linux (dashpay#120) * remove travis * bring the ci forward 2 months * bring setup.py forward * add flake8 ini * add mypi.ini * first attempt at FetchContent chia-relic-src * Final cmake fixes * Add lgtm.yml * explicit order of ops * clean up code for mypy/flake8 - black * enough to start looking at plotter * lgtm assignment operator * add 0x80 compression bit for 0 and 48 byte * reverted bit changes and commented out G2 tests * switch repos for relic * Remove Unknown distribution option: 'build_requires' warning * msvc fixes * Add libsodium to all platform wheels. README nit * Fix ARM, use nuget on Windows * Try libsodium-devel, bump verbosity to confirm sodium * ARM install epel first - Fix find sodium macos * no need for floor * add fingerprint, derive_child * fix __bytes__ * add n of n sigs in AugScheme, use MPL suffix * standardizing around __bytes__ * libsodium on linux (x86_64 & ARM) * allow agg sig of 0 msgs * alias g1/g2 element * Try find gmp from chiavdf * Build gmp and sodium from scratch * Fix ARM sodium and gmp - start debugging macos * delete dist dir on ARM shr's * Move all but Windows to build verbosity 0 * Changes required for chia-blockchain (deepcopy) * ADD hd keys tests * added gmp include folder to python-bindings cmake * pyecc tests * Move ci's to pytest * Add test vectors ietf * g2 elements start with 0b000 now * Use FromSeed * Revert bad test vectors Co-authored-by: Alex Wice <[email protected]> Co-authored-by: Gene Hoffman <[email protected]> Co-authored-by: Bill Blanke <[email protected]> Co-authored-by: Gene Hoffman <[email protected]>
1 parent f4ffccd commit c6010c8

File tree

677 files changed

+4651
-212176
lines changed

Some content is hidden

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

677 files changed

+4651
-212176
lines changed

.clang-format

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
BasedOnStyle: Google
2+
UseTab: Never
3+
ColumnLimit: 80
4+
IndentWidth: 4
5+
TabWidth: 4
6+
AllowShortIfStatementsOnASingleLine: false
7+
IndentCaseLabels: false
8+
AccessModifierOffset: -4
9+
BinPackArguments: false
10+
BinPackParameters: false
11+
AlignAfterOpenBracket: AlwaysBreak
12+
IndentCaseLabels: true
13+
AllowAllParametersOfDeclarationOnNextLine: false
14+
BreakBeforeBraces: Custom
15+
BraceWrapping:
16+
AfterFunction: true
17+
PenaltyReturnTypeOnItsOwnLine: 1000

.flake8

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[flake8]
22
max-line-length = 120
3-
exclude = ./typings/**/*
3+
exclude = ./typings/**/* python-impl/fields.py
44
ignore = E203,W503
5-

.github/workflows/build-aarch64.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
access_token: ${{ github.token }}
1919

2020
- name: Checkout code
21-
uses: actions/checkout@v1
21+
uses: actions/checkout@v2
2222
with:
2323
fetch-depth: 0
2424
# we need fetch-depth 0 so setuptools_scm can resolve tags
@@ -47,13 +47,13 @@ jobs:
4747
run: |
4848
source venv/bin/activate
4949
pip install flake8
50-
flake8 src setup.py
50+
flake8 src setup.py python-bindings python-impl
5151
5252
- name: Lint source with mypy
5353
run: |
5454
source venv/bin/activate
5555
pip install mypy
56-
mypy --config-file mypi.ini python-impl python-bindings
56+
mypy --config-file mypi.ini python-bindings python-impl
5757
5858
- name: Build wheel and test
5959
run: |
@@ -64,16 +64,22 @@ jobs:
6464
CIBW_BUILD: cp38-*
6565
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
6666
# we need boost
67+
CIBW_BUILD_VERBOSITY_LINUX: 0
6768
CIBW_BEFORE_BUILD_LINUX: >
6869
yum -y install epel-release
69-
&& yum -y install cmake3
70+
&& yum -y install cmake3 lzip
7071
&& ln -s /usr/bin/cmake3 /usr/local/bin/cmake
7172
&& python -m pip install --upgrade pip
7273
&& cmake --version
7374
&& uname -a
74-
CIBW_BUILD_VERBOSITY_LINUX: 0
75+
&& curl -L https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz | lzip -dc | tar x
76+
&& cd gmp-6.2.0 && ./configure --enable-fat
77+
&& make && make install && cd .. && rm -rf gmp-6.2.0
78+
&& curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz | tar xz
79+
&& cd libsodium-stable && ./configure
80+
&& make && make install && cd .. && rm -rf libsodium-stable
7581
CIBW_TEST_REQUIRES: pytest
76-
CIBW_TEST_COMMAND: python {project}/python-bindings/test.py
82+
CIBW_TEST_COMMAND: pytest -v {project}/python-bindings/test.py
7783

7884
- name: Upload artifacts
7985
uses: actions/upload-artifact@v1
@@ -107,6 +113,7 @@ jobs:
107113
source venv/bin/activate
108114
twine upload --non-interactive --skip-existing --verbose 'dist/*'
109115
110-
- name: Clean up venv
116+
- name: Clean up
111117
run: |
112118
rm -rf venv
119+
rm -rf dist

.github/workflows/build.yml

+36-15
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
with:
1818
access_token: ${{ github.token }}
1919

20-
- uses: actions/checkout@v1
20+
- name: Checkout code
21+
uses: actions/checkout@v2
2122
with:
2223
fetch-depth: 0
2324
# we need fetch-depth 0 so setuptools_scm can resolve tags
@@ -45,12 +46,12 @@ jobs:
4546
- name: Lint source with flake8
4647
run: |
4748
pip install flake8
48-
flake8 src setup.py
49+
flake8 src setup.py python-bindings python-impl
4950
5051
- name: Lint source with mypy
5152
run: |
5253
pip install mypy
53-
mypy --config-file mypi.ini python-impl python-bindings
54+
mypy --config-file mypi.ini python-bindings python-impl
5455
5556
- name: Build source distribution with MacOS
5657
if: startsWith(matrix.os, 'mac')
@@ -62,27 +63,42 @@ jobs:
6263
run: |
6364
python -m cibuildwheel --output-dir dist
6465
env:
66+
CIBW_BUILD_VERBOSITY_MACOS: 0
67+
CIBW_BUILD_VERBOSITY_LINUX: 0
68+
CIBW_BUILD_VERBOSITY_WINDOWS: 1
6569
# Python 3.7 and 3.8
6670
CIBW_BUILD: cp37-* cp38-*
6771
# don't build i686 targets, can't seem to find cmake for these
6872
CIBW_SKIP: '*-manylinux_i686 *-win32'
6973
# we need boost
7074
CIBW_TEST_REQUIRES: pytest
7175
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010
76+
CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.17.3-Linux-`uname -m`/bin:$PATH"
7277
CIBW_BEFORE_BUILD_LINUX: >
73-
curl -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-`uname -m`.sh > cmake.sh
78+
yum -y install lzip
79+
&& curl -L https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-`uname -m`.sh > cmake.sh
7480
&& yes | sh cmake.sh | cat
75-
&& rm -f /usr/bin/cmake
81+
&& rm -f /usr/bin/cmake && hash -r
7682
&& python -m pip install --upgrade pip
7783
&& which cmake
7884
&& cmake --version
79-
CIBW_BEFORE_BUILD_MACOS: python -m pip install --upgrade pip
85+
&& curl -L https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz | lzip -dc | tar x
86+
&& cd gmp-6.2.0 && ./configure --enable-fat
87+
&& make && make install && cd .. && rm -rf gmp-6.2.0
88+
&& curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz | tar xz
89+
&& cd libsodium-stable && ./configure
90+
&& make && make install && cd .. && rm -rf libsodium-stable
91+
# GH hosted runner has gmp and libsodium natively
92+
CIBW_BEFORE_BUILD_MACOS: >
93+
python -m pip install --upgrade pip
8094
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.14
81-
CIBW_BUILD_VERBOSITY_MACOS: 0
8295
CIBW_BEFORE_BUILD_WINDOWS: >
83-
python -m pip install --upgrade pip && pwd
84-
&& git clone https://github.com/Chia-Network/relic_gmp_64.git
85-
&& ls -l relic_gmp_64
96+
python -m pip install --upgrade pip
97+
&& pwd
98+
&& nuget install libsodium -Version 1.0.18
99+
&& ls -l libsodium.1.0.18/runtimes/win-x64/native/
100+
&& git clone https://github.com/Chia-Network/relic_ietf_64.git
101+
&& ls -l relic_ietf_64
86102
&& git clone https://github.com/Chia-Network/mpir_gc_x64.git
87103
&& ls -l mpir_gc_x64
88104
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
@@ -98,12 +114,11 @@ jobs:
98114
&& delocate-wheel -v -i mpir_gc_x64/mpir_skylake.dll {wheel}
99115
&& delocate-wheel -v -i mpir_gc_x64/mpir_skylake_avx.dll {wheel}
100116
&& cp {wheel} {dest_dir} && ls -l {dest_dir}
101-
&& rm -fr relic_gmp_64
117+
&& rm -fr relic_ietf_64
102118
&& rm -fr mpir_gc_x64
103119
# The pure python implementation, is not used anywhere and will be replaced
104120
# pytest {project}/python-impl/tests.py
105-
CIBW_TEST_COMMAND: python {project}/python-bindings/test.py
106-
CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.17.0-Linux-`uname -m`/bin:$PATH"
121+
CIBW_TEST_COMMAND: pytest -v {project}/python-bindings/test.py
107122
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
108123
pip uninstall -y delocate
109124
&& pip install git+https://github.com/Chia-Network/delocate.git
@@ -114,9 +129,10 @@ jobs:
114129
- name: Mac OS build C++ and test
115130
if: startsWith(matrix.os, 'macos')
116131
run: |
117-
brew install pkg-config
118-
132+
ls -l
133+
export MACOSX_DEPLOYMENT_TARGET=10.14
119134
mkdir -p build
135+
ls -l build
120136
cd build
121137
cmake ../
122138
cmake --build . -- -j 6
@@ -128,6 +144,11 @@ jobs:
128144
run: |
129145
sudo apt-get update
130146
sudo apt-get install valgrind libsodium-dev -y
147+
sudo apt-get install snap -y
148+
sudo apt-get remove --purge cmake -y
149+
sudo snap install cmake --classic
150+
hash -r
151+
cmake --version
131152
mkdir -p build
132153
cd build
133154
cmake ../

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ blsbench.*
5353
*.pb.h
5454

5555
**/.DS_Store
56+
57+
*.whl
58+
venv

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "contrib/pybind11"]
22
path = contrib/pybind11
33
url = https://github.com/pybind/pybind11.git
4+
[submodule "contrib/relic"]
5+
path = contrib/relic
6+
url = https://github.com/Chia-Network/relic

CMakeLists.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# add_compile_definitions() was introduced in cmake 3.12 but this compiles on 3.10
2-
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.0 FATAL_ERROR)
1+
CMAKE_MINIMUM_REQUIRED(VERSION 3.11.0 FATAL_ERROR)
32
set(CMAKE_CXX_STANDARD 11)
43
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
54

@@ -49,6 +48,7 @@ set(VERBS "off" CACHE STRING "")
4948
set(ALLOC "AUTO" CACHE STRING "")
5049
set(SHLIB "OFF" CACHE STRING "")
5150
set(MULTI "PTHREAD" CACHE STRING "")
51+
set(DOCUM "off" CACHE STRING "")
5252

5353
set(FP_PRIME 381 CACHE INTEGER "")
5454

@@ -78,12 +78,13 @@ set(QUIET 1 CACHE INTEGER "")
7878
set(PP_EXT "LAZYR" CACHE STRING "")
7979
set(PP_METHD "LAZYR;OATEP" CACHE STRING "")
8080

81-
add_subdirectory(contrib/relic)
81+
#add_subdirectory(contrib/relic)
8282
add_subdirectory(src)
8383

8484
if (EMSCRIPTEN)
8585
add_subdirectory(js-bindings)
8686
else()
8787
# emscripten can't build python bindings, it produces only javascript
88+
# add_subdirectory(contrib/pybind11)
8889
add_subdirectory(python-bindings)
8990
endif()

README.md

+11-15
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ Implements BLS signatures with aggregation as in
1717
, using [relic toolkit](https://github.com/relic-toolkit/relic)
1818
for cryptographic primitives (pairings, EC, hashing).
1919
The [BLS12-381](https://github.com/zkcrypto/pairing/tree/master/src/bls12_381)
20-
curve is used. The spec is
20+
curve is used. The original spec is
2121
[here](https://github.com/Chia-Network/bls-signatures/tree/master/SPEC.md).
22-
This library will be migrating to the
23-
[IETF BLS RFC](https://datatracker.ietf.org/doc/draft-irtf-cfrg-bls-signature/)
24-
shortly.
22+
This library now implements
23+
[IETF BLS RFC](https://datatracker.ietf.org/doc/draft-irtf-cfrg-bls-signature/).
2524

2625
Features:
2726
* Non-interactive signature aggregation on identical or distinct messages
@@ -266,15 +265,12 @@ function. Note: relic is used with the Apache 2.0 license.
266265
Libsodium and GMP are optional dependencies: libsodium gives secure memory
267266
allocation, and GMP speeds up the library by ~ 3x. To install them, either
268267
download them from github and follow the instructions for each repo, or use
269-
a package manager like APT or brew.
268+
a package manager like APT or brew. You can follow the recipe used to build
269+
python wheels for multiple platforms in `.github/workflows/`
270270

271271
### Discussion
272-
Discussion about this library and other Chia related development is on Keybase.
273-
Install Keybase, and run the following to join the Chia public channels:
274-
275-
```bash
276-
keybase team request-access chia_network.public
277-
```
272+
Discussion about this library and other Chia related development is in Chia's
273+
[public Keybase channels](https://keybase.io/team/chia_network.public).
278274

279275
### Code style
280276
* Always use uint8_t for bytes
@@ -296,10 +292,10 @@ build binary wheels for MacOS, Linux (x64 and aarch64), and Windows and publish
296292
them with a source wheel on PyPi. See `.github/workflows/build.yml`. CMake uses
297293
[FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html)
298294
to download [pybind11](https://github.com/pybind/pybind11) for the Python
299-
bindings. Building is then managed by
300-
[cibuildwheel](https://github.com/joerick/cibuildwheel). Further installation
301-
is then available via `pip install blspy` e.g. The ci builds include GMP and
302-
libsoduium.
295+
bindings and relic from a chia relic forked reporitory. Building is then
296+
managed by [cibuildwheel](https://github.com/joerick/cibuildwheel).
297+
Further installation is then available via `pip install blspy` e.g. The ci
298+
builds include GMP and soduium.
303299

304300
### Contributing and workflow
305301
Contributions are welcome and more details are available in chia-blockchain's

0 commit comments

Comments
 (0)