From ba9bbb2a66fbceff64f17a7f4019490dca15e917 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 3 Dec 2021 14:30:16 -0500 Subject: [PATCH 01/30] Also build Python 3.10 wheels (#292) * Also build Python 3.10 wheels * Test all Python versions * Use cibuildwheel 2.2.2 * Skip musllinux for now * Add CPython $v to now-matrixed test jobs * add 3.10 builds to AARCH64 * break out testing of all pythons to another PR * Skip musllinux on aarch64 --- .github/workflows/build-aarch64.yml | 6 +++--- .github/workflows/build-wheels.yml | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml index 3f007a04d7e968..91f3bd32bf33dc 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-aarch64.yml @@ -30,7 +30,7 @@ jobs: python3 -m venv venv source venv/bin/activate python -m pip install --upgrade pip - python -m pip install cibuildwheel==1.10.0 + python -m pip install cibuildwheel==2.2.2 - name: Lint source with flake8 run: | @@ -49,8 +49,8 @@ jobs: source venv/bin/activate python -m cibuildwheel --output-dir dist env: - # build python 3.7 and 3.8 - CIBW_BUILD: cp37-* cp38-* cp39-* + CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* + CIBW_SKIP: '*-musllinux_*' CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 CIBW_BUILD_VERBOSITY_LINUX: 0 CIBW_BEFORE_BUILD_LINUX: > diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index ef38eebfc2fd70..e433605f4d4ddd 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -46,16 +46,15 @@ jobs: python -m build --sdist --outdir dist . - name: Build ${{ matrix.os }} wheels and test - uses: joerick/cibuildwheel@v1.10.0 + uses: joerick/cibuildwheel@v2.2.2 with: output-dir: dist env: CIBW_BUILD_VERBOSITY_MACOS: 0 CIBW_BUILD_VERBOSITY_LINUX: 0 CIBW_BUILD_VERBOSITY_WINDOWS: 0 - # Python 3.7 and 3.8 - CIBW_BUILD: cp37-* cp38-* cp39-* - CIBW_SKIP: '*-manylinux_i686 *-win32' + CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* + CIBW_SKIP: '*-manylinux_i686 *-win32 *-musllinux_*' CIBW_TEST_REQUIRES: pytest CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010 CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.17.3-Linux-`uname -m`/bin:$PATH" From 64d8d7eb7c8631ad30a815643c3e6b4073a5c7aa Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 3 Dec 2021 14:31:16 -0500 Subject: [PATCH 02/30] Build on main, tags, and PRs (#293) As is this builds on any push and also any PR. This results in double workflows on PRs. --- .github/workflows/build-aarch64.yml | 10 +++++++++- .github/workflows/build-m1-wheel.yml | 10 +++++++++- .github/workflows/build-test.yaml | 10 +++++++++- .github/workflows/build-wheels.yml | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml index 91f3bd32bf33dc..c309f1bab7b983 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-aarch64.yml @@ -1,6 +1,14 @@ name: Build ARM64 wheel -on: [push, pull_request] +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' jobs: build_wheels: diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index 34acf21318d39f..b178b71cf8416e 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -1,6 +1,14 @@ name: Build M1 Wheels -on: [push, pull_request] +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' jobs: build_wheels: diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 86f5e0ce8e07dd..fce51504c86649 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -1,6 +1,14 @@ name: Build and Test C++, Javascript, and Python -on: [push, pull_request] +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' jobs: build_wheels: diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index e433605f4d4ddd..9512680caec13c 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,6 +1,14 @@ name: Build wheels -on: [push, pull_request] +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' jobs: build_wheels: From cffc6462f916b5e1cbc095aaf0153bb8e6ce73f7 Mon Sep 17 00:00:00 2001 From: Gene Hoffman <30377676+hoffmang9@users.noreply.github.com> Date: Sat, 8 Jan 2022 14:50:24 -0800 Subject: [PATCH 03/30] Cancel-workflow to 0.9.1 - test Python 3.10 on Mac/Ubuntu (#303) * cancel-workflow to 0.9.1 - test Python 3.10 * Revert e73751e and change to single \ later --- .github/workflows/build-aarch64.yml | 2 +- .github/workflows/build-m1-wheel.yml | 2 +- .github/workflows/build-test.yaml | 4 ++-- .github/workflows/build-wheels.yml | 2 +- .github/workflows/relic-nightly.yml | 2 +- setup.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml index c309f1bab7b983..b33d845adbc8eb 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-aarch64.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Cancel previous runs on the same branch if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.7.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index b178b71cf8416e..06cc782dfe3ea1 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Cancel previous runs on the same branch if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.7.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index fce51504c86649..a9258194a07b09 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -18,12 +18,12 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest] - python: ['3.7', '3.8', '3.9'] + python: ['3.7', '3.8', '3.9', '3.10'] steps: - name: Cancel previous runs on the same branch if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.7.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 9512680caec13c..9f980600201724 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Cancel previous runs on the same branch if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.7.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} diff --git a/.github/workflows/relic-nightly.yml b/.github/workflows/relic-nightly.yml index c75972d313eaba..cc8c032a45acb3 100644 --- a/.github/workflows/relic-nightly.yml +++ b/.github/workflows/relic-nightly.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Cancel previous runs on the same branch if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.7.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} diff --git a/setup.py b/setup.py index 1b0d7b2b13b591..4d2482b9da0a6e 100644 --- a/setup.py +++ b/setup.py @@ -176,7 +176,7 @@ def build_extensions(self): opts.append("-fvisibility=hidden") elif ct == "msvc": if sys.version_info < (3, 9): - ver_flag = '/DVERSION_INFO=\\"%s\\"' + ver_flag = '/DVERSION_INFO=\"%s\"' else: ver_flag = '-DVERSION_INFO="%s"' opts.append(ver_flag % self.distribution.get_version()) From c009fa3c5fd84a2929b6072e4501409100e3d108 Mon Sep 17 00:00:00 2001 From: Gene Hoffman <30377676+hoffmang9@users.noreply.github.com> Date: Sat, 8 Jan 2022 16:28:16 -0800 Subject: [PATCH 04/30] Build Python 3.9 and 3.10 M1 wheels (#304) * Build Python 3.9 and 3.10 M1 wheels * Find brew-python paths * Cancel-workflow to 0.9.1 - test Python 3.10 on Mac/Ubuntu (#303) * cancel-workflow to 0.9.1 - test Python 3.10 * Revert e73751e and change to single \ later * python is in /opt/homebrew * source not found * no dash in cp39, cp310 * use brew install instead * pip install delocate-wheel * $(brew --prefix python@3.9) * shorten path * path is already full * Update path and correct delocate install --- .github/workflows/build-m1-wheel.yml | 45 +++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index 06cc782dfe3ea1..6700e8d34031d0 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -29,29 +29,46 @@ jobs: with: fetch-depth: 0 - - name: Lint source with flake8 + - name: Brew update Python run: | - arch -arm64 python -m pip install --upgrade pip - arch -arm64 pip install flake8 - arch -arm64 flake8 src setup.py python-bindings python-impl + arch -arm64 brew install python@3.9 + arch -arm64 brew install python@3.10 - - name: Lint source with mypy - run: | - arch -arm64 pip install mypy - arch -arm64 mypy --config-file mypi.ini python-bindings python-impl - - - name: Build m1 wheels + - name: Build m1 wheels for 3.9 and 3.10 run: | + rm -rf venv + arch -arm64 $(brew --prefix python@3.9)/libexec/bin/python -m venv venv + . venv/bin/activate + arch -arm64 pip wheel -w dist --no-deps . + arch -arm64 pip install delocate + arch -arm64 delocate-wheel -v dist/*cp39*.whl + deactivate + rm -rf venv + arch -arm64 $(brew --prefix python@3.10)/libexec/bin/python -m venv venv + . venv/bin/activate arch -arm64 pip wheel -w dist --no-deps . - arch -arm64 delocate-wheel -v dist/*.whl + arch -arm64 pip install delocate + arch -arm64 delocate-wheel -v dist/*cp310*.whl + deactivate + rm -rf venv - name: Test wheel run: | - arch -arm64 python3 -m venv venv - . ./venv/bin/activate - arch -arm64 pip install ./dist/*.whl + rm -rf venv + arch -arm64 $(brew --prefix python@3.9)/libexec/bin/python -m venv venv + . venv/bin/activate + arch -arm64 pip install ./dist/*cp39*.whl + arch -arm64 pip install pytest + arch -arm64 ./venv/bin/pytest -v ./python-bindings/test.py + deactivate + rm -rf venv + arch -arm64 $(brew --prefix python@3.10)/libexec/bin/python -m venv venv + . venv/bin/activate + arch -arm64 pip install ./dist/*cp310*.whl arch -arm64 pip install pytest arch -arm64 ./venv/bin/pytest -v ./python-bindings/test.py + deactivate + rm -rf venv - name: Create sha256 hash run: | From 802fd68caf8e79ba27cf763bd6f394fad0324bc1 Mon Sep 17 00:00:00 2001 From: Gene Hoffman <30377676+hoffmang9@users.noreply.github.com> Date: Sat, 8 Jan 2022 16:29:08 -0800 Subject: [PATCH 05/30] Update cibuildwheel to 2.3.1 (#302) * Update cibuildwheel to 2.3.1 * use single quotes in setup.py * Revert e73751e and change to single \ later --- .github/workflows/build-aarch64.yml | 2 +- .github/workflows/build-wheels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml index b33d845adbc8eb..e482cc03cf7567 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-aarch64.yml @@ -38,7 +38,7 @@ jobs: python3 -m venv venv source venv/bin/activate python -m pip install --upgrade pip - python -m pip install cibuildwheel==2.2.2 + python -m pip install cibuildwheel==2.3.1 - name: Lint source with flake8 run: | diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 9f980600201724..8bcd04b45a1b50 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -54,7 +54,7 @@ jobs: python -m build --sdist --outdir dist . - name: Build ${{ matrix.os }} wheels and test - uses: joerick/cibuildwheel@v2.2.2 + uses: joerick/cibuildwheel@v2.3.1 with: output-dir: dist env: From f0810fd5e2d9284382989f00c47fc022dca60175 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 15 Jan 2022 22:59:40 -0800 Subject: [PATCH 06/30] build(deps): bump follow-redirects from 1.14.1 to 1.14.7 in /js-bindings (#305) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.1 to 1.14.7. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.1...v1.14.7) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- js-bindings/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index a0d8af455b5aae..8830f2ba33ff47 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -1253,9 +1253,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", - "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==", + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", "dev": true }, "foreach": { From 41a1b44ab510a3c2e8f5f1e506e26a61523890be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 15 Jan 2022 23:00:07 -0800 Subject: [PATCH 07/30] build(deps): bump engine.io from 4.1.1 to 4.1.2 in /js-bindings (#306) Bumps [engine.io](https://github.com/socketio/engine.io) from 4.1.1 to 4.1.2. - [Release notes](https://github.com/socketio/engine.io/releases) - [Changelog](https://github.com/socketio/engine.io/blob/4.1.2/CHANGELOG.md) - [Commits](https://github.com/socketio/engine.io/compare/4.1.1...4.1.2) --- updated-dependencies: - dependency-name: engine.io dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- js-bindings/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index 8830f2ba33ff47..8eb72f042399cd 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -996,9 +996,9 @@ "dev": true }, "engine.io": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-4.1.1.tgz", - "integrity": "sha512-t2E9wLlssQjGw0nluF6aYyfX8LwYU8Jj0xct+pAhfWfv/YrBn6TSNtEYsgxHIfaMqfrLx07czcMg9bMN6di+3w==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-4.1.2.tgz", + "integrity": "sha512-t5z6zjXuVLhXDMiFJPYsPOWEER8B0tIsD3ETgw19S1yg9zryvUfY3Vhtk3Gf4sihw/bQGIqQ//gjvVlu+Ca0bQ==", "dev": true, "requires": { "accepts": "~1.3.4", @@ -1011,9 +1011,9 @@ }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" From 34a330183703afdbd4ff96c9b62ec8e424dcb091 Mon Sep 17 00:00:00 2001 From: Christian Paquin Date: Wed, 19 Jan 2022 13:52:27 -0500 Subject: [PATCH 08/30] Updated the pairings tutorial URL --- python-impl/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-impl/README.md b/python-impl/README.md index 861cfd38d6d4b0..4ee657903a2e56 100644 --- a/python-impl/README.md +++ b/python-impl/README.md @@ -5,7 +5,7 @@ as BLS signatures and aggregation. Use for reference / educational purposes only For an optimized implementation, use the [Python bindings](https://github.com/Chia-Network/bls-signatures/tree/main/python-bindings). -For a good introduction to pairings, read [Pairings for Beginners](http://www.craigcostello.com.au/pairings/PairingsForBeginners.pdf) by Craig Costello. +For a good introduction to pairings, read [Pairings for Beginners](https://static1.squarespace.com/static/5fdbb09f31d71c1227082339/t/5ff394720493bd28278889c6/1609798774687/PairingsForBeginners.pdf) by Craig Costello. Map to curve implementation from [Algorand](https://github.com/algorand/bls_sigs_ref/). From cdb16857b6a7e64e57b5ec0d557f1436afc51b7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jan 2022 14:10:33 -0800 Subject: [PATCH 09/30] build(deps): bump log4js from 6.3.0 to 6.4.0 in /js-bindings (#310) Bumps [log4js](https://github.com/log4js-node/log4js-node) from 6.3.0 to 6.4.0. - [Release notes](https://github.com/log4js-node/log4js-node/releases) - [Changelog](https://github.com/log4js-node/log4js-node/blob/master/CHANGELOG.md) - [Commits](https://github.com/log4js-node/log4js-node/compare/v6.3.0...v6.4.0) --- updated-dependencies: - dependency-name: log4js dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- js-bindings/package-lock.json | 144 ++++++++++++++-------------------- 1 file changed, 61 insertions(+), 83 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index 8eb72f042399cd..c20de0c72cf5be 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -859,12 +859,6 @@ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, - "date-format": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-3.0.0.tgz", - "integrity": "sha512-eyTcpKOcamdhWJXj56DpQMo1ylSQpcGtGKXcU0Tb97+K56/CF5amAqqqNj0+KvA0iw2ynxtHWFsPDSClCxe48w==", - "dev": true - }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1246,12 +1240,6 @@ "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", "dev": true }, - "flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", - "dev": true - }, "follow-redirects": { "version": "1.14.7", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", @@ -1264,17 +1252,6 @@ "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", "dev": true }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1715,15 +1692,6 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, "karma": { "version": "6.3.4", "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.4.tgz", @@ -1851,32 +1819,82 @@ } }, "log4js": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.3.0.tgz", - "integrity": "sha512-Mc8jNuSFImQUIateBFwdOQcmC6Q5maU0VVvdC2R6XMb66/VnT+7WS4D/0EeNMZu1YODmJe5NIn2XftCzEocUgw==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.0.tgz", + "integrity": "sha512-ysc/XUecZJuN8NoKOssk3V0cQ29xY4fra6fnigZa5VwxFsCsvdqsdnEuAxNN89LlHpbE4KUD3zGcn+kFqonSVQ==", "dev": true, "requires": { - "date-format": "^3.0.0", - "debug": "^4.1.1", - "flatted": "^2.0.1", - "rfdc": "^1.1.4", - "streamroller": "^2.2.4" + "date-format": "^4.0.3", + "debug": "^4.3.3", + "flatted": "^3.2.4", + "rfdc": "^1.3.0", + "streamroller": "^3.0.2" }, "dependencies": { + "date-format": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.3.tgz", + "integrity": "sha512-7P3FyqDcfeznLZp2b+OMitV9Sz2lUnsT87WaTat9nVwqsBkTzPG3lPLNwW3en6F4pHUiWzr6vb8CLhjdK9bcxQ==", + "dev": true + }, "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" } }, + "flatted": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.4.tgz", + "integrity": "sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==", + "dev": true + }, + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true + }, + "streamroller": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.0.2.tgz", + "integrity": "sha512-ur6y5S5dopOaRXBuRIZ1u6GC5bcEXHRZKgfBjfCglMhmIf+roVCECjvkEYzNQOXIN2/JPnkMPW/8B3CZoKaEPA==", + "dev": true, + "requires": { + "date-format": "^4.0.3", + "debug": "^4.1.1", + "fs-extra": "^10.0.0" + } + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true } } }, @@ -2621,40 +2639,6 @@ } } }, - "streamroller": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-2.2.4.tgz", - "integrity": "sha512-OG79qm3AujAM9ImoqgWEY1xG4HX+Lw+yY6qZj9R1K2mhF5bEmQ849wvrb+4vt4jLMLzwXttJlQbOdPOQVRv7DQ==", - "dev": true, - "requires": { - "date-format": "^2.1.0", - "debug": "^4.1.1", - "fs-extra": "^8.1.0" - }, - "dependencies": { - "date-format": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz", - "integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA==", - "dev": true - }, - "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } - } - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -2847,12 +2831,6 @@ } } }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true - }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", From 52fa4088043a6af21ee47bc0cbe6acd2087b288e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Feb 2022 22:09:49 -0800 Subject: [PATCH 10/30] build(deps-dev): bump karma from 6.3.4 to 6.3.14 in /js-bindings (#312) Bumps [karma](https://github.com/karma-runner/karma) from 6.3.4 to 6.3.14. - [Release notes](https://github.com/karma-runner/karma/releases) - [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md) - [Commits](https://github.com/karma-runner/karma/compare/v6.3.4...v6.3.14) --- updated-dependencies: - dependency-name: karma dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- js-bindings/package-lock.json | 374 +++++++++++++++++++--------------- 1 file changed, 208 insertions(+), 166 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index c20de0c72cf5be..1f036014792397 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -4,10 +4,16 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@socket.io/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ==", + "dev": true + }, "@types/component-emitter": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.10.tgz", - "integrity": "sha512-bsjleuRKWmGqajMerkzox19aGbscQX5rmmvvXl3wlIp5gMG1HgkiwPxsN5p070fBDKTNSPgojVbuY1+HWMbFhg==", + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.11.tgz", + "integrity": "sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ==", "dev": true }, "@types/cookie": { @@ -231,13 +237,30 @@ "dev": true }, "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "dev": true, "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "dependencies": { + "mime-db": { + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "dev": true + }, + "mime-types": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "dev": true, + "requires": { + "mime-db": "1.51.0" + } + } } }, "acorn": { @@ -374,12 +397,6 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base64-arraybuffer": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz", - "integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=", - "dev": true - }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -410,21 +427,21 @@ "dev": true }, "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", + "integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==", "dev": true, "requires": { - "bytes": "3.1.0", + "bytes": "3.1.1", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "1.7.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "qs": "6.9.6", + "raw-body": "2.4.2", + "type-is": "~1.6.18" } }, "brace-expansion": { @@ -572,9 +589,9 @@ "dev": true }, "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", + "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", "dev": true }, "call-bind": { @@ -616,9 +633,9 @@ } }, "chokidar": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", - "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, "requires": { "anymatch": "~3.1.2", @@ -768,9 +785,9 @@ "dev": true }, "cookie": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", "dev": true }, "core-js": { @@ -859,6 +876,12 @@ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, + "date-format": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.3.tgz", + "integrity": "sha512-7P3FyqDcfeznLZp2b+OMitV9Sz2lUnsT87WaTat9nVwqsBkTzPG3lPLNwW3en6F4pHUiWzr6vb8CLhjdK9bcxQ==", + "dev": true + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -990,18 +1013,21 @@ "dev": true }, "engine.io": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-4.1.2.tgz", - "integrity": "sha512-t5z6zjXuVLhXDMiFJPYsPOWEER8B0tIsD3ETgw19S1yg9zryvUfY3Vhtk3Gf4sihw/bQGIqQ//gjvVlu+Ca0bQ==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.2.tgz", + "integrity": "sha512-v/7eGHxPvO2AWsksyx2PUsQvBafuvqs0jJJQ0FdmJG1b9qIvgSbqDRGwNhfk2XHaTTbTXiC4quRE8Q9nRjsrQQ==", "dev": true, "requires": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "2.0.0", "cookie": "~0.4.1", "cors": "~2.8.5", "debug": "~4.3.1", - "engine.io-parser": "~4.0.0", - "ws": "~7.4.2" + "engine.io-parser": "~5.0.0", + "ws": "~8.2.3" }, "dependencies": { "debug": { @@ -1022,12 +1048,12 @@ } }, "engine.io-parser": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-4.0.2.tgz", - "integrity": "sha512-sHfEQv6nmtJrq6TKuIz5kyEKH/qSdK56H/A+7DnAuUPWosnIZAS2NHNcPLmyjtY3cGS/MqJdZbUjW97JU72iYg==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.3.tgz", + "integrity": "sha512-BtQxwF27XUNnSafQLvDi0dQ8s3i6VgzSoQMJacpIcGNrlUdfHSKbgm3jmjCVvQluGzqwujQMPAoMai3oYSTurg==", "dev": true, "requires": { - "base64-arraybuffer": "0.1.4" + "@socket.io/base64-arraybuffer": "~1.0.2" } }, "enhanced-resolve": { @@ -1240,10 +1266,16 @@ "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", "dev": true }, + "flatted": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", + "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "dev": true + }, "follow-redirects": { - "version": "1.14.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "version": "1.14.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", + "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==", "dev": true }, "foreach": { @@ -1252,6 +1284,17 @@ "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", "dev": true }, + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1411,16 +1454,24 @@ } }, "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", "dev": true, "requires": { "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "toidentifier": "1.0.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + } } }, "http-proxy": { @@ -1692,16 +1743,26 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, "karma": { - "version": "6.3.4", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.4.tgz", - "integrity": "sha512-hbhRogUYIulfkBTZT7xoPrCYhRBnBoqbbL4fszWD0ReFGUxU+LYBr3dwKdAluaDQ/ynT9/7C+Lf7pPNW4gSx4Q==", + "version": "6.3.14", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.14.tgz", + "integrity": "sha512-SDFoU5F4LdosEiUVWUDRPCV/C1zQRNtIakx7rWkigf7R4sxGADlSEeOma4S1f/js7YAzvqLW92ByoiQptg+8oQ==", "dev": true, "requires": { "body-parser": "^1.19.0", "braces": "^3.0.2", "chokidar": "^3.5.1", - "colors": "^1.4.0", + "colors": "1.4.0", "connect": "^3.7.0", "di": "^0.0.1", "dom-serialize": "^2.2.1", @@ -1710,23 +1771,23 @@ "http-proxy": "^1.18.1", "isbinaryfile": "^4.0.8", "lodash": "^4.17.21", - "log4js": "^6.3.0", + "log4js": "^6.4.1", "mime": "^2.5.2", "minimatch": "^3.0.4", "qjobs": "^1.2.0", "range-parser": "^1.2.1", "rimraf": "^3.0.2", - "socket.io": "^3.1.0", + "socket.io": "^4.2.0", "source-map": "^0.6.1", "tmp": "^0.2.1", - "ua-parser-js": "^0.7.28", + "ua-parser-js": "^0.7.30", "yargs": "^16.1.1" }, "dependencies": { "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -1738,21 +1799,15 @@ } }, "graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", + "version": "4.2.9", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", + "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", "dev": true }, "mime": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", - "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", - "dev": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", "dev": true } } @@ -1819,9 +1874,9 @@ } }, "log4js": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.0.tgz", - "integrity": "sha512-ysc/XUecZJuN8NoKOssk3V0cQ29xY4fra6fnigZa5VwxFsCsvdqsdnEuAxNN89LlHpbE4KUD3zGcn+kFqonSVQ==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.1.tgz", + "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", "dev": true, "requires": { "date-format": "^4.0.3", @@ -1831,12 +1886,6 @@ "streamroller": "^3.0.2" }, "dependencies": { - "date-format": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.3.tgz", - "integrity": "sha512-7P3FyqDcfeznLZp2b+OMitV9Sz2lUnsT87WaTat9nVwqsBkTzPG3lPLNwW3en6F4pHUiWzr6vb8CLhjdK9bcxQ==", - "dev": true - }, "debug": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", @@ -1846,55 +1895,11 @@ "ms": "2.1.2" } }, - "flatted": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.4.tgz", - "integrity": "sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==", - "dev": true - }, - "fs-extra": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", - "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true - }, - "streamroller": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.0.2.tgz", - "integrity": "sha512-ur6y5S5dopOaRXBuRIZ1u6GC5bcEXHRZKgfBjfCglMhmIf+roVCECjvkEYzNQOXIN2/JPnkMPW/8B3CZoKaEPA==", - "dev": true, - "requires": { - "date-format": "^4.0.3", - "debug": "^4.1.1", - "fs-extra": "^10.0.0" - } - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true } } }, @@ -2201,9 +2206,9 @@ "dev": true }, "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "dev": true }, "neo-async": { @@ -2370,9 +2375,9 @@ "dev": true }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "version": "6.9.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", + "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==", "dev": true }, "randombytes": { @@ -2401,13 +2406,13 @@ "dev": true }, "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", + "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", "dev": true, "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.1", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "unpipe": "1.0.0" } @@ -2508,9 +2513,9 @@ } }, "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "dev": true }, "sha.js": { @@ -2524,26 +2529,23 @@ } }, "socket.io": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-3.1.2.tgz", - "integrity": "sha512-JubKZnTQ4Z8G4IZWtaAZSiRP3I/inpy8c/Bsx2jrwGrTbKeVU5xd6qkKMHpChYeM3dWZSO0QACiGK+obhBNwYw==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.4.1.tgz", + "integrity": "sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==", "dev": true, "requires": { - "@types/cookie": "^0.4.0", - "@types/cors": "^2.8.8", - "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "~2.0.0", - "debug": "~4.3.1", - "engine.io": "~4.1.0", - "socket.io-adapter": "~2.1.0", - "socket.io-parser": "~4.0.3" + "debug": "~4.3.2", + "engine.io": "~6.1.0", + "socket.io-adapter": "~2.3.3", + "socket.io-parser": "~4.0.4" }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -2558,9 +2560,9 @@ } }, "socket.io-adapter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.1.0.tgz", - "integrity": "sha512-+vDov/aTsLjViYTwS9fPy5pEtTkrbEKsw2M+oVSoFGw6OD1IpvlV1VPhUzNbofCQ8oyMbdYJqDtGdmHQK6TdPg==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.3.3.tgz", + "integrity": "sha512-Qd/iwn3VskrpNO60BeRyCyr8ZWw9CPZyitW4AQwmRZ8zCiyDiL+znRnWX6tDHXnWn1sJrM1+b6Mn6wEDJJ4aYQ==", "dev": true }, "socket.io-parser": { @@ -2575,9 +2577,9 @@ }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -2597,6 +2599,12 @@ "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==", "dev": true }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, "source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -2639,6 +2647,34 @@ } } }, + "streamroller": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.0.2.tgz", + "integrity": "sha512-ur6y5S5dopOaRXBuRIZ1u6GC5bcEXHRZKgfBjfCglMhmIf+roVCECjvkEYzNQOXIN2/JPnkMPW/8B3CZoKaEPA==", + "dev": true, + "requires": { + "date-format": "^4.0.3", + "debug": "^4.1.1", + "fs-extra": "^10.0.0" + }, + "dependencies": { + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -2784,9 +2820,9 @@ } }, "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "dev": true }, "type-is": { @@ -2806,9 +2842,9 @@ "dev": true }, "ua-parser-js": { - "version": "0.7.28", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz", - "integrity": "sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==", + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.31.tgz", + "integrity": "sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ==", "dev": true }, "unbox-primitive": { @@ -2831,6 +2867,12 @@ } } }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -3088,9 +3130,9 @@ "dev": true }, "ws": { - "version": "7.4.6", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", - "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", + "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", "dev": true }, "yargs": { From 50438dfe9bba89fa75d46b6c7321e917ca707cd8 Mon Sep 17 00:00:00 2001 From: Nav Roudsari Date: Tue, 22 Feb 2022 17:06:04 +0000 Subject: [PATCH 11/30] test: Add augmented test vector --- python-impl/impl-test.py | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/python-impl/impl-test.py b/python-impl/impl-test.py index b4266f15ff299b..e7b1dd5461a8d1 100644 --- a/python-impl/impl-test.py +++ b/python-impl/impl-test.py @@ -371,6 +371,47 @@ def test_chia_vectors_1(): ) +def test_chia_vectors_2(): + msg1 = bytes([1, 2, 3, 40]) + msg2 = bytes([5, 6, 70, 201]) + msg3 = bytes([9, 10, 11, 12, 13]) + msg4 = bytes([15, 63, 244, 92, 0, 1]) + + seed1 = bytes([0x02] * 32) + seed2 = bytes([0x03] * 32) + + sk1 = AugSchemeMPL.key_gen(seed1) + sk2 = AugSchemeMPL.key_gen(seed2) + + pk1 = sk1.get_g1() + pk2 = sk2.get_g1() + + sig1 = AugSchemeMPL.sign(sk1, msg1) + sig2 = AugSchemeMPL.sign(sk2, msg2) + sig3 = AugSchemeMPL.sign(sk2, msg1) + sig4 = AugSchemeMPL.sign(sk1, msg3) + sig5 = AugSchemeMPL.sign(sk1, msg1) + sig6 = AugSchemeMPL.sign(sk1, msg4) + + agg_sig_l = AugSchemeMPL.aggregate([sig1, sig2]) + agg_sig_r = AugSchemeMPL.aggregate([sig3, sig4, sig5]) + agg_sig = AugSchemeMPL.aggregate([agg_sig_l, agg_sig_r, sig6]) + + assert ( + AugSchemeMPL.aggregate_verify( + [pk1, pk2, pk2, pk1, pk1, pk1], [msg1, msg2, msg1, msg3, msg1, msg4], agg_sig + ) + == True + ) + + assert ( + bytes(agg_sig).hex() + == "a1d5360dcb418d33b29b90b912b4accde535cf0e52caf467a005dc632d9f7af44b6c4e9acd4" + "6eac218b28cdb07a3e3bc087df1cd1e3213aa4e11322a3ff3847bbba0b2fd19ddc25ca964871" + "997b9bceeab37a4c2565876da19382ea32a962200" + ) + + def test_chia_vectors_3(): seed1: bytes = bytes([0x04] * 32) sk1 = PopSchemeMPL.key_gen(seed1) @@ -619,6 +660,7 @@ def test_readme(): test_edge_case_sign_Fq2() test_elements() test_chia_vectors_1() +test_chia_vectors_2() test_chia_vectors_3() test_pyecc_vectors() test_vectors_invalid() From 7a87417453f08c52018c8c1e03d5ff68a27edaff Mon Sep 17 00:00:00 2001 From: Nav Roudsari Date: Wed, 23 Feb 2022 11:17:57 +0000 Subject: [PATCH 12/30] test: fix lint issue --- python-impl/impl-test.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/python-impl/impl-test.py b/python-impl/impl-test.py index e7b1dd5461a8d1..0b514107567220 100644 --- a/python-impl/impl-test.py +++ b/python-impl/impl-test.py @@ -397,16 +397,12 @@ def test_chia_vectors_2(): agg_sig_r = AugSchemeMPL.aggregate([sig3, sig4, sig5]) agg_sig = AugSchemeMPL.aggregate([agg_sig_l, agg_sig_r, sig6]) - assert ( - AugSchemeMPL.aggregate_verify( - [pk1, pk2, pk2, pk1, pk1, pk1], [msg1, msg2, msg1, msg3, msg1, msg4], agg_sig - ) - == True + assert AugSchemeMPL.aggregate_verify( + [pk1, pk2, pk2, pk1, pk1, pk1], [msg1, msg2, msg1, msg3, msg1, msg4], agg_sig ) - assert ( - bytes(agg_sig).hex() - == "a1d5360dcb418d33b29b90b912b4accde535cf0e52caf467a005dc632d9f7af44b6c4e9acd4" + assert bytes(agg_sig).hex() == ( + "a1d5360dcb418d33b29b90b912b4accde535cf0e52caf467a005dc632d9f7af44b6c4e9acd4" "6eac218b28cdb07a3e3bc087df1cd1e3213aa4e11322a3ff3847bbba0b2fd19ddc25ca964871" "997b9bceeab37a4c2565876da19382ea32a962200" ) From 5a4204e3a6da3681dcd15c6636c2e49bc879c48b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 08:04:49 -0800 Subject: [PATCH 13/30] build(deps-dev): bump karma from 6.3.14 to 6.3.16 in /js-bindings (#314) --- js-bindings/package-lock.json | 68 ++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index 1f036014792397..8cac93585f7c00 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -427,20 +427,20 @@ "dev": true }, "body-parser": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", - "integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==", + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==", "dev": true, "requires": { - "bytes": "3.1.1", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", "http-errors": "1.8.1", "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.9.6", - "raw-body": "2.4.2", + "qs": "6.9.7", + "raw-body": "2.4.3", "type-is": "~1.6.18" } }, @@ -589,9 +589,9 @@ "dev": true }, "bytes": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", - "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "dev": true }, "call-bind": { @@ -1013,9 +1013,9 @@ "dev": true }, "engine.io": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.2.tgz", - "integrity": "sha512-v/7eGHxPvO2AWsksyx2PUsQvBafuvqs0jJJQ0FdmJG1b9qIvgSbqDRGwNhfk2XHaTTbTXiC4quRE8Q9nRjsrQQ==", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.3.tgz", + "integrity": "sha512-rqs60YwkvWTLLnfazqgZqLa/aKo+9cueVfEi/dZ8PyGyaf8TLOxj++4QMIgeG3Gn0AhrWiFXvghsoY9L9h25GA==", "dev": true, "requires": { "@types/cookie": "^0.4.1", @@ -1026,7 +1026,7 @@ "cookie": "~0.4.1", "cors": "~2.8.5", "debug": "~4.3.1", - "engine.io-parser": "~5.0.0", + "engine.io-parser": "~5.0.3", "ws": "~8.2.3" }, "dependencies": { @@ -1273,9 +1273,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.8", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", - "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==", + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", "dev": true }, "foreach": { @@ -1285,9 +1285,9 @@ "dev": true }, "fs-extra": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", - "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", + "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", "dev": true, "requires": { "graceful-fs": "^4.2.0", @@ -1754,9 +1754,9 @@ } }, "karma": { - "version": "6.3.14", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.14.tgz", - "integrity": "sha512-SDFoU5F4LdosEiUVWUDRPCV/C1zQRNtIakx7rWkigf7R4sxGADlSEeOma4S1f/js7YAzvqLW92ByoiQptg+8oQ==", + "version": "6.3.16", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.16.tgz", + "integrity": "sha512-nEU50jLvDe5yvXqkEJRf8IuvddUkOY2x5Xc4WXHz6dxINgGDrgD2uqQWeVrJs4hbfNaotn+HQ1LZJ4yOXrL7xQ==", "dev": true, "requires": { "body-parser": "^1.19.0", @@ -1774,6 +1774,7 @@ "log4js": "^6.4.1", "mime": "^2.5.2", "minimatch": "^3.0.4", + "mkdirp": "^0.5.5", "qjobs": "^1.2.0", "range-parser": "^1.2.1", "rimraf": "^3.0.2", @@ -1992,6 +1993,15 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "mocha": { "version": "8.4.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", @@ -2375,9 +2385,9 @@ "dev": true }, "qs": { - "version": "6.9.6", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", - "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==", + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", "dev": true }, "randombytes": { @@ -2406,12 +2416,12 @@ "dev": true }, "raw-body": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", - "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", + "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", "dev": true, "requires": { - "bytes": "3.1.1", + "bytes": "3.1.2", "http-errors": "1.8.1", "iconv-lite": "0.4.24", "unpipe": "1.0.0" From 84e19442bdd974fa0fbe05852b71420118cec073 Mon Sep 17 00:00:00 2001 From: dustinface <35775977+xdustinface@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:36:11 +0200 Subject: [PATCH 14/30] python-bindings: Release the python GIL whenever it makes sense (#311) * python-bindings: Release the python GIL where possible * python-bindings: Don't access `buffer_info::ptr` without the GIL --- python-bindings/pythonbindings.cpp | 190 +++++++++++++++++++---------- 1 file changed, 126 insertions(+), 64 deletions(-) diff --git a/python-bindings/pythonbindings.cpp b/python-bindings/pythonbindings.cpp index db2757d389ece6..59857f851a6b0e 100644 --- a/python-bindings/pythonbindings.cpp +++ b/python-bindings/pythonbindings.cpp @@ -27,16 +27,6 @@ using namespace bls; using std::vector; -/* This class releases the Python GIL until the end of the scope. - This is different from gil_scoped_release in that it can't be reacquired early. */ -// class PythonGIL { -// public: -// PythonGIL() { _save = PyEval_SaveThread(); } -// ~PythonGIL() { PyEval_RestoreThread(_save); } -// private: -// PyThreadState *_save; -// }; - PYBIND11_MODULE(blspy, m) { py::class_(m, "PrivateKey") @@ -56,16 +46,19 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to PrivateKey::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - // PythonGIL release_lock; - return PrivateKey::FromBytes(Bytes(data_ptr, PrivateKey::PRIVATE_KEY_SIZE)); + std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; + return PrivateKey::FromByteVector(data); }) .def( "__bytes__", [](const PrivateKey &k) { - // PythonGIL release_lock; uint8_t *output = Util::SecAlloc(PrivateKey::PRIVATE_KEY_SIZE); - k.Serialize(output); + { + py::gil_scoped_release release; + k.Serialize(output); + } py::bytes ret = py::bytes( reinterpret_cast(output), PrivateKey::PRIVATE_KEY_SIZE); @@ -78,15 +71,15 @@ PYBIND11_MODULE(blspy, m) return PrivateKey(k); }) .def("get_g1", [](const PrivateKey &k) { - // PythonGIL release_lock; + py::gil_scoped_release release; return k.GetG1Element(); }) - .def("aggregate", &PrivateKey::Aggregate) + .def("aggregate", &PrivateKey::Aggregate, py::call_guard()) .def(py::self == py::self) .def(py::self != py::self) .def("__repr__", [](const PrivateKey &k) { - uint8_t *output = - Util::SecAlloc(PrivateKey::PRIVATE_KEY_SIZE); + py::gil_scoped_release release; + uint8_t *output = Util::SecAlloc(PrivateKey::PRIVATE_KEY_SIZE); k.Serialize(output); std::string ret = "(str.data()); uint8_t output[BLS::MESSAGE_HASH_LEN]; - Util::Hash256(output, (const uint8_t *)str.data(), str.size()); + { + py::gil_scoped_release release; + Util::Hash256(output, (const uint8_t *)str.data(), str.size()); + } return py::bytes( reinterpret_cast(output), BLS::MESSAGE_HASH_LEN); }); py::class_(m, "BasicSchemeMPL") - .def("sk_to_g1", [](const PrivateKey &seckey){ return BasicSchemeMPL().SkToG1(seckey); }) + .def("sk_to_g1", [](const PrivateKey &seckey){ + py::gil_scoped_release release; + return BasicSchemeMPL().SkToG1(seckey); + }) .def( "key_gen", [](const py::bytes &b) { std::string str(b); - const uint8_t *input = - reinterpret_cast(str.data()); - const vector inputVec(input, input + len(b)); + py::gil_scoped_release release; + const vector inputVec(str.begin(), str.end()); return BasicSchemeMPL().KeyGen(inputVec); }) .def("derive_child_sk", [](const PrivateKey& sk, uint32_t index){ + py::gil_scoped_release release; return BasicSchemeMPL().DeriveChildSk(sk, index); }) .def("derive_child_sk_unhardened", [](const PrivateKey& sk, uint32_t index){ + py::gil_scoped_release release; return BasicSchemeMPL().DeriveChildSkUnhardened(sk, index); }) .def("derive_child_pk_unhardened", [](const G1Element& pk, uint32_t index){ + py::gil_scoped_release release; return BasicSchemeMPL().DeriveChildPkUnhardened(pk, index); }) .def("aggregate", [](const vector &signatures) { + py::gil_scoped_release release; return BasicSchemeMPL().Aggregate(signatures); }) .def( "sign", [](const PrivateKey &pk, const py::bytes &msg) { std::string s(msg); + py::gil_scoped_release release; vector v(s.begin(), s.end()); return BasicSchemeMPL().Sign(pk, v); }) @@ -140,7 +143,7 @@ PYBIND11_MODULE(blspy, m) const py::bytes &msg, const G2Element &sig) { std::string s(msg); - // PythonGIL release_lock; + py::gil_scoped_release release; vector v(s.begin(), s.end()); return BasicSchemeMPL().Verify(pk, v, sig); }) @@ -154,13 +157,14 @@ PYBIND11_MODULE(blspy, m) std::string s(msgs[i]); vecs[i] = vector(s.begin(), s.end()); } - // PythonGIL release_lock; + py::gil_scoped_release release; return BasicSchemeMPL().AggregateVerify(pks, vecs, sig); }) .def( "g2_from_message", [](const py::bytes &msg) { const auto msg_str = std::string(msg); + py::gil_scoped_release release; const auto msg_bytes = Bytes((const uint8_t *)msg_str.c_str(), msg_str.size()); return G2Element::FromMessage( msg_bytes, @@ -170,33 +174,39 @@ PYBIND11_MODULE(blspy, m) }); py::class_(m, "AugSchemeMPL") - .def("sk_to_g1", [](const PrivateKey &seckey){ return AugSchemeMPL().SkToG1(seckey); }) + .def("sk_to_g1", [](const PrivateKey &seckey){ + py::gil_scoped_release release; + return AugSchemeMPL().SkToG1(seckey); + }) .def( "key_gen", [](const py::bytes &b) { std::string str(b); - const uint8_t *input = - reinterpret_cast(str.data()); - const vector inputVec(input, input + len(b)); + py::gil_scoped_release release; + const vector inputVec(str.begin(), str.end()); return AugSchemeMPL().KeyGen(inputVec); }) .def("derive_child_sk", [](const PrivateKey& sk, uint32_t index){ - // PythonGIL release_lock; + py::gil_scoped_release release; return AugSchemeMPL().DeriveChildSk(sk, index); }) .def("derive_child_sk_unhardened", [](const PrivateKey& sk, uint32_t index){ + py::gil_scoped_release release; return AugSchemeMPL().DeriveChildSkUnhardened(sk, index); }) .def("derive_child_pk_unhardened", [](const G1Element& pk, uint32_t index){ + py::gil_scoped_release release; return AugSchemeMPL().DeriveChildPkUnhardened(pk, index); }) .def("aggregate", [](const vector& signatures) { + py::gil_scoped_release release; return AugSchemeMPL().Aggregate(signatures); }) .def( "sign", [](const PrivateKey &pk, const py::bytes &msg) { std::string s(msg); + py::gil_scoped_release release; vector v(s.begin(), s.end()); return AugSchemeMPL().Sign(pk, v); }) @@ -206,6 +216,7 @@ PYBIND11_MODULE(blspy, m) const py::bytes &msg, const G1Element &prepend_pk) { std::string s(msg); + py::gil_scoped_release release; vector v(s.begin(), s.end()); return AugSchemeMPL().Sign(pk, v, prepend_pk); }) @@ -215,7 +226,7 @@ PYBIND11_MODULE(blspy, m) const py::bytes &msg, const G2Element &sig) { std::string s(msg); - // PythonGIL release_lock; + py::gil_scoped_release release; vector v(s.begin(), s.end()); return AugSchemeMPL().Verify(pk, v, sig); }) @@ -229,13 +240,14 @@ PYBIND11_MODULE(blspy, m) std::string s(msgs[i]); vecs[i] = vector(s.begin(), s.end()); } - // PythonGIL release_lock; + py::gil_scoped_release release; return AugSchemeMPL().AggregateVerify(pks, vecs, sig); }) .def( "g2_from_message", [](const py::bytes &msg) { const auto msg_str = std::string(msg); + py::gil_scoped_release release; const auto msg_bytes = Bytes((const uint8_t *)msg_str.c_str(), msg_str.size()); return G2Element::FromMessage( msg_bytes, @@ -245,32 +257,39 @@ PYBIND11_MODULE(blspy, m) }); py::class_(m, "PopSchemeMPL") - .def("sk_to_g1", [](const PrivateKey &seckey){ return PopSchemeMPL().SkToG1(seckey); }) + .def("sk_to_g1", [](const PrivateKey &seckey){ + py::gil_scoped_release release; + return PopSchemeMPL().SkToG1(seckey); + }) .def( "key_gen", [](const py::bytes &b) { std::string str(b); - const uint8_t *input = - reinterpret_cast(str.data()); - const vector inputVec(input, input + len(b)); + py::gil_scoped_release release; + const vector inputVec(str.begin(), str.end()); return PopSchemeMPL().KeyGen(inputVec); }) .def("derive_child_sk", [](const PrivateKey& sk, uint32_t index){ + py::gil_scoped_release release; return PopSchemeMPL().DeriveChildSk(sk, index); }) .def("derive_child_sk_unhardened", [](const PrivateKey& sk, uint32_t index){ + py::gil_scoped_release release; return PopSchemeMPL().DeriveChildSkUnhardened(sk, index); }) .def("derive_child_pk_unhardened", [](const G1Element& pk, uint32_t index){ + py::gil_scoped_release release; return PopSchemeMPL().DeriveChildPkUnhardened(pk, index); }) .def("aggregate", [](const vector& signatures) { + py::gil_scoped_release release; return PopSchemeMPL().Aggregate(signatures); }) .def( "sign", [](const PrivateKey &pk, const py::bytes &msg) { std::string s(msg); + py::gil_scoped_release release; vector v(s.begin(), s.end()); return PopSchemeMPL().Sign(pk, v); }) @@ -280,7 +299,7 @@ PYBIND11_MODULE(blspy, m) const py::bytes &msg, const G2Element &sig) { std::string s(msg); - // PythonGIL release_lock; + py::gil_scoped_release release; vector v(s.begin(), s.end()); return PopSchemeMPL().Verify(pk, v, sig); }) @@ -294,13 +313,14 @@ PYBIND11_MODULE(blspy, m) std::string s(msgs[i]); vecs[i] = vector(s.begin(), s.end()); } - // PythonGIL release_lock; + py::gil_scoped_release release; return PopSchemeMPL().AggregateVerify(pks, vecs, sig); }) .def( "g2_from_message", [](const py::bytes &msg) { const auto msg_str = std::string(msg); + py::gil_scoped_release release; const auto msg_bytes = Bytes((const uint8_t *)msg_str.c_str(), msg_str.size()); return G2Element::FromMessage( msg_bytes, @@ -309,10 +329,11 @@ PYBIND11_MODULE(blspy, m) ); }) .def("pop_prove", [](const PrivateKey& privateKey){ + py::gil_scoped_release release; return PopSchemeMPL().PopProve(privateKey); }) .def("pop_verify", [](const G1Element& pubkey, const G2Element& signature){ - // PythonGIL release_lock; + py::gil_scoped_release release; return PopSchemeMPL().PopVerify(pubkey, signature); }) .def( @@ -321,7 +342,7 @@ PYBIND11_MODULE(blspy, m) const py::bytes &msg, const G2Element &sig) { std::string s(msg); - // PythonGIL release_lock; + py::gil_scoped_release release; vector v(s.begin(), s.end()); return PopSchemeMPL().FastAggregateVerify(pks, v, sig); }); @@ -329,8 +350,11 @@ PYBIND11_MODULE(blspy, m) py::class_(m, "G1Element") .def_property_readonly_static( "SIZE", [](py::object self) { return G1Element::SIZE; }) - .def(py::init([](){ return G1Element();})) - .def(py::init(&G1Element::FromByteVector)) + .def(py::init([](){ + py::gil_scoped_release release; + return G1Element(); + })) + .def(py::init(&G1Element::FromByteVector), py::call_guard()) .def(py::init([](py::int_ pyint) { std::vector buffer(G1Element::SIZE, 0); if (_PyLong_AsByteArray( @@ -341,6 +365,7 @@ PYBIND11_MODULE(blspy, m) 0) < 0) { throw std::invalid_argument("Failed to cast int to G1Element"); } + py::gil_scoped_release release; return G1Element::FromByteVector(buffer); })) .def(py::init([](py::buffer const b) { @@ -355,6 +380,7 @@ PYBIND11_MODULE(blspy, m) } auto data_ptr = static_cast(info.ptr); std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; return G1Element::FromByteVector(data); })) .def( @@ -370,14 +396,15 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G1Element::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - // PythonGIL release_lock; - return G1Element::FromBytes(Bytes(data_ptr, G1Element::SIZE)); + std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; + return G1Element::FromByteVector(data); }) .def("generator", &G1Element::Generator) - .def("from_message", py::overload_cast&, const uint8_t*, int>(&G1Element::FromMessage)) - .def("pair", &G1Element::Pair) - .def("negate", &G1Element::Negate) - .def("get_fingerprint", &G1Element::GetFingerprint) + .def("from_message", py::overload_cast&, const uint8_t*, int>(&G1Element::FromMessage), py::call_guard()) + .def("pair", &G1Element::Pair, py::call_guard()) + .def("negate", &G1Element::Negate, py::call_guard()) + .def("get_fingerprint", &G1Element::GetFingerprint, py::call_guard()) .def(py::self == py::self) .def(py::self != py::self) @@ -389,29 +416,35 @@ PYBIND11_MODULE(blspy, m) .def( "__add__", [](G1Element &self, G1Element &other) { - // PythonGIL release_lock; + py::gil_scoped_release release; return self + other; }, py::is_operator()) .def( "__mul__", [](G1Element &self, bn_t other) { + py::gil_scoped_release release; return self * (*(bn_t *)&other); }, py::is_operator()) .def( "__rmul__", [](G1Element &self, bn_t other) { + py::gil_scoped_release release; return self * (*(bn_t *)&other); }, py::is_operator()) .def( "__and__", - [](G1Element &self, G2Element &other) { return self & other; }, + [](G1Element &self, G2Element &other) { + py::gil_scoped_release release; + return self & other; + }, py::is_operator()) .def( "__repr__", [](const G1Element &ele) { + py::gil_scoped_release release; std::stringstream s; s << ele; return ""; @@ -419,6 +452,7 @@ PYBIND11_MODULE(blspy, m) .def( "__str__", [](const G1Element &ele) { + py::gil_scoped_release release; std::stringstream s; s << ele; return s.str(); @@ -427,9 +461,10 @@ PYBIND11_MODULE(blspy, m) "__bytes__", [](const G1Element &ele) { vector out; - // Py_BEGIN_ALLOW_THREADS - out = ele.Serialize(); - // Py_END_ALLOW_THREADS + { + py::gil_scoped_release release; + out = ele.Serialize(); + } py::bytes ans = py::bytes( reinterpret_cast(out.data()), G1Element::SIZE); return ans; @@ -441,8 +476,10 @@ PYBIND11_MODULE(blspy, m) py::class_(m, "G2Element") .def_property_readonly_static( "SIZE", [](py::object self) { return G2Element::SIZE; }) - .def(py::init([](){ return G2Element();})) - .def(py::init(&G2Element::FromByteVector)) + .def(py::init([](){ + return G2Element(); + })) + .def(py::init(&G2Element::FromByteVector), py::call_guard()) .def(py::init([](py::buffer const b) { py::buffer_info info = b.request(); if (info.format != py::format_descriptor::format() || @@ -455,6 +492,7 @@ PYBIND11_MODULE(blspy, m) } auto data_ptr = static_cast(info.ptr); std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; return G2Element::FromByteVector(data); })) .def(py::init([](py::int_ pyint) { @@ -467,6 +505,7 @@ PYBIND11_MODULE(blspy, m) 0) < 0) { throw std::invalid_argument("Failed to cast int to G2Element"); } + py::gil_scoped_release release; return G2Element::FromByteVector(buffer); })) .def( @@ -482,12 +521,14 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G2Element::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - return G2Element::FromBytes(Bytes(data_ptr, G2Element::SIZE)); + std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; + return G2Element::FromByteVector(data); }) .def("generator", &G2Element::Generator) - .def("from_message", py::overload_cast&, const uint8_t*, int, bool>(&G2Element::FromMessage)) - .def("pair", &G2Element::Pair) - .def("negate", &G2Element::Negate) + .def("from_message", py::overload_cast&, const uint8_t*, int, bool>(&G2Element::FromMessage), py::call_guard()) + .def("pair", &G2Element::Pair, py::call_guard()) + .def("negate", &G2Element::Negate, py::call_guard()) .def( "__deepcopy__", [](const G2Element &g2, const py::object &memo) { @@ -498,17 +539,22 @@ PYBIND11_MODULE(blspy, m) .def( "__add__", - [](G2Element &self, G2Element &other) { return self + other; }, + [](G2Element &self, G2Element &other) { + py::gil_scoped_release release; + return self + other; + }, py::is_operator()) .def( "__mul__", [](G2Element &self, bn_t other) { + py::gil_scoped_release release; return self * (*(bn_t *)&other); }, py::is_operator()) .def( "__rmul__", [](G2Element &self, bn_t other) { + py::gil_scoped_release release; return self * (*(bn_t *)&other); }, py::is_operator()) @@ -516,6 +562,7 @@ PYBIND11_MODULE(blspy, m) .def( "__repr__", [](const G2Element &ele) { + py::gil_scoped_release release; std::stringstream s; s << ele; return ""; @@ -523,6 +570,7 @@ PYBIND11_MODULE(blspy, m) .def( "__str__", [](const G2Element &ele) { + py::gil_scoped_release release; std::stringstream s; s << ele; return s.str(); @@ -530,7 +578,11 @@ PYBIND11_MODULE(blspy, m) .def( "__bytes__", [](const G2Element &ele) { - vector out = ele.Serialize(); + vector out; + { + py::gil_scoped_release release; + out = ele.Serialize(); + } py::bytes ans = py::bytes( reinterpret_cast(out.data()), G2Element::SIZE); return ans; @@ -542,7 +594,7 @@ PYBIND11_MODULE(blspy, m) py::class_(m, "GTElement") .def_property_readonly_static( "SIZE", [](py::object self) { return GTElement::SIZE; }) - .def(py::init(>Element::FromByteVector)) + .def(py::init(>Element::FromByteVector), py::call_guard()) .def(py::init([](py::buffer const b) { py::buffer_info info = b.request(); if (info.format != py::format_descriptor::format() || @@ -555,6 +607,7 @@ PYBIND11_MODULE(blspy, m) } auto data_ptr = static_cast(info.ptr); std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; return GTElement::FromByteVector(data); })) .def(py::init([](py::int_ pyint) { @@ -567,6 +620,7 @@ PYBIND11_MODULE(blspy, m) 0) < 0) { throw std::invalid_argument("Failed to cast int to GTElement"); } + py::gil_scoped_release release; return GTElement::FromByteVector(buffer); })) .def( @@ -582,7 +636,9 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to GTElement::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - return GTElement::FromBytes(Bytes(data_ptr, GTElement::SIZE)); + std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; + return GTElement::FromByteVector(data); }) .def("unity", >Element::Unity) .def(py::self == py::self) @@ -595,6 +651,7 @@ PYBIND11_MODULE(blspy, m) .def( "__repr__", [](const GTElement &ele) { + py::gil_scoped_release release; std::stringstream s; s << ele; return ""; @@ -602,6 +659,7 @@ PYBIND11_MODULE(blspy, m) .def( "__str__", [](const GTElement &ele) { + py::gil_scoped_release release; std::stringstream s; s << ele; return s.str(); @@ -610,7 +668,10 @@ PYBIND11_MODULE(blspy, m) "__bytes__", [](const GTElement &ele) { uint8_t *out = new uint8_t[GTElement::SIZE]; - ele.Serialize(out); + { + py::gil_scoped_release release; + ele.Serialize(out); + } py::bytes ans = py::bytes(reinterpret_cast(out), GTElement::SIZE); delete[] out; @@ -619,6 +680,7 @@ PYBIND11_MODULE(blspy, m) .def( "__mul__", [](GTElement &self, GTElement &other) { + py::gil_scoped_release release; return self * other; }, py::is_operator()) From 4787d21c3ae943c3d2016e8adefe560b7b1a13d0 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 4 Apr 2022 18:46:48 +0100 Subject: [PATCH 15/30] Link GMP dynamically in a consistent way. (#307) --- CMakeLists.txt | 5 ++--- cmake_modules/Findgmp.cmake | 13 ++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6922167b6909d3..a3f5a9e6613c03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,8 @@ FetchContent_Declare( # Relic related options -set(STBIN TRUE) +set(STBIN "off" CACHE STRING "Relic - Build static binaries") + find_package(gmp) if (GMP_FOUND) message(STATUS "Found libgmp") @@ -106,8 +107,6 @@ else() set(FP_QNRES "on" CACHE STRING "") endif() -set(STBIN "OFF" CACHE STRING "") - set(FP_METHD "INTEG;INTEG;INTEG;MONTY;LOWER;SLIDE" CACHE STRING "") if(MSVC) diff --git a/cmake_modules/Findgmp.cmake b/cmake_modules/Findgmp.cmake index 49e1aadabe8ba5..16f1f8b44c1799 100644 --- a/cmake_modules/Findgmp.cmake +++ b/cmake_modules/Findgmp.cmake @@ -68,7 +68,18 @@ if(GMP_INCLUDES) endif() endif() -find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) +if(STBIN) + set(_gmp_lib_name libgmp.a) +else() + set(_gmp_lib_name libgmp.so) +endif() + +find_library(GMP_LIBRARIES + NAMES + ${_gmp_lib_name} gmp.lib libgmp-10 libgmp gmp + PATHS + $ENV{GMPDIR} ${LIB_INSTALL_DIR} +) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(gmp DEFAULT_MSG From 0c37d868667268603c9fd5bdd5976a7a19bedd8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 08:27:30 -0700 Subject: [PATCH 16/30] build(deps): bump minimist from 1.2.5 to 1.2.6 in /js-bindings (#316) --- js-bindings/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index 8cac93585f7c00..a1ab9cfa77d42a 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -1988,9 +1988,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "mkdirp": { From 9c0d7d82798a4d3ee1d766a26d249eda2f982186 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 08:52:43 -0700 Subject: [PATCH 17/30] build(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /js-bindings (#317) --- js-bindings/package-lock.json | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/js-bindings/package-lock.json b/js-bindings/package-lock.json index a1ab9cfa77d42a..5d2a395f19033a 100644 --- a/js-bindings/package-lock.json +++ b/js-bindings/package-lock.json @@ -294,9 +294,9 @@ "dev": true }, "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { @@ -687,12 +687,6 @@ "wrap-ansi": "^7.0.0" }, "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2739,6 +2733,14 @@ "dev": true, "requires": { "ansi-regex": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true + } } }, "strip-json-comments": { @@ -3075,12 +3077,6 @@ "strip-ansi": "^6.0.0" }, "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -3160,12 +3156,6 @@ "yargs-parser": "^20.2.2" }, "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", From 7476dce55e34f9153ceca2c4360d9532e57817cf Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 24 Apr 2022 04:21:42 +0100 Subject: [PATCH 18/30] Fix and use OpenMP on Windows builds. (#324) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3f5a9e6613c03..79226528bb044d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ if (DEFINED ENV{RELIC_MAIN}) set(RELIC_GIT_TAG "origin/main") else () # This is currently anchored to upstream aecdcae7956f542fbee2392c1f0feb0a8ac41dc5 - set(RELIC_GIT_TAG "1d98e5abf3ca5b14fd729bd5bcced88ea70ecfd7") + set(RELIC_GIT_TAG "215c69966cb78b255995f0ee9c86bbbb41c3c42b") endif () message(STATUS "Relic will be built from: ${RELIC_GIT_TAG}") @@ -83,7 +83,7 @@ endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(TIMER "ANSI" CACHE STRING "") - set(MULTI "" CACHE STRING "") + set(MULTI "OPENMP" CACHE STRING "") else() set(TIMER "CYCLE" CACHE STRING "") set(MULTI "PTHREAD" CACHE STRING "") From 3a1489bbee8ec928c4839c69a7795bc7ee036abc Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 24 Apr 2022 04:22:21 +0100 Subject: [PATCH 19/30] Fix a typo that resulted in skipping the wheel build preparing command step for Linux. (#318) --- .github/workflows/build-wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 8bcd04b45a1b50..ae8ed403d2b1c6 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -82,8 +82,7 @@ jobs: && echo "Building GMP" && cd gmp-6.2.1 && ./configure --enable-fat && make && make install && cd .. && rm -rf gmp-6.2.1 - CIBW_BEFORE_BUID_LINUX: > - python -m pip install --upgrade pip + CIBW_BEFORE_BUILD_LINUX: python -m pip install --upgrade pip CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.14" # GH hosted MacOS runner has gmp natively # CIBW_ARCHS_MACOS: x86_64 arm64 universal2 From 1579662fa3843d47e653ebfe8dcca2343ce4ae24 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Mon, 25 Apr 2022 17:37:55 -0500 Subject: [PATCH 20/30] target arm64 linux runner (#325) * target arm64 linux runner * Fix nesting --- .github/workflows/build-aarch64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml index e482cc03cf7567..1bc059e35ed3ed 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-aarch64.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ARM64] + os: [[ARM64, Linux]] steps: - name: Cancel previous runs on the same branch From ffd1622aede13d1a44e179406caf19d4b04b9b9d Mon Sep 17 00:00:00 2001 From: Mariano Sorgente Date: Thu, 5 May 2022 09:35:01 -0400 Subject: [PATCH 21/30] Start working on from_bytes_unchecked --- src/elements.cpp | 31 +++++++++++++++++++++++++------ src/elements.hpp | 4 ++++ src/schemes.cpp | 4 ++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/elements.cpp b/src/elements.cpp index 503b59c1ebfb5c..9f4bee0505d0da 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -21,7 +21,13 @@ namespace bls { const size_t G1Element::SIZE; -G1Element G1Element::FromBytes(const Bytes& bytes, bool fLegacy) +G1Element G1Element::FromBytes(const Bytes& bytes, bool fLegacy) { + G1Element ele = G1Element::FromBytesUnchecked(bytes, fLegacy); + ele.CheckValid(); + return ele; +} + +G1Element G1Element::FromBytesUnchecked(const Bytes& bytes, bool fLegacy) { if (bytes.size() != SIZE) { throw std::invalid_argument("G1Element::FromBytes: Invalid size"); @@ -76,7 +82,6 @@ G1Element G1Element::FromBytes(const Bytes& bytes, bool fLegacy) g1_read_bin(ele.p, buffer, G1Element::SIZE + 1); if (!fLegacy) { BLS::CheckRelicErrors(); - ele.CheckValid(); } return ele; } @@ -86,11 +91,15 @@ G1Element G1Element::FromByteVector(const std::vector& bytevec, bool fL return G1Element::FromBytes(Bytes(bytevec), fLegacy); } +G1Element G1Element::FromByteVectorUnchecked(const std::vector& bytevec, bool fLegacy) +{ + return G1Element::FromBytesUnchecked(Bytes(bytevec), fLegacy); +} + G1Element G1Element::FromNative(const g1_t element) { G1Element ele; g1_copy(ele.p, element); - ele.CheckValid(); return ele; } @@ -223,7 +232,13 @@ G1Element operator*(const bn_t& k, const G1Element& a) { return a * k; } const size_t G2Element::SIZE; -G2Element G2Element::FromBytes(const Bytes& bytes, const bool fLegacy) +G2Element G2Element::FromBytes(const Bytes& bytes, const bool fLegacy) { + G2Element ele = G2Element::FromBytesUnchecked(bytes, fLegacy); + ele.CheckValid(); + return ele; +} + +G2Element G2Element::FromBytesUnchecked(const Bytes& bytes, const bool fLegacy) { if (bytes.size() != SIZE) { throw std::invalid_argument("G2Element::FromBytes: Invalid size"); @@ -281,7 +296,6 @@ G2Element G2Element::FromBytes(const Bytes& bytes, const bool fLegacy) g2_read_bin(ele.q, buffer, G2Element::SIZE + 1); if (!fLegacy) { BLS::CheckRelicErrors(); - ele.CheckValid(); } return ele; } @@ -291,11 +305,16 @@ G2Element G2Element::FromByteVector(const std::vector& bytevec, bool fL return G2Element::FromBytes(Bytes(bytevec), fLegacy); } +G2Element G2Element::FromByteVectorUnchecked(const std::vector& bytevec, bool fLegacy) +{ + return G2Element::FromBytesUnchecked(Bytes(bytevec), fLegacy); +} + + G2Element G2Element::FromNative(const g2_t element) { G2Element ele; g2_copy(ele.q, (g2_st*)element); - ele.CheckValid(); return ele; } diff --git a/src/elements.hpp b/src/elements.hpp index 320b17363f4724..3297318a727ffd 100644 --- a/src/elements.hpp +++ b/src/elements.hpp @@ -41,7 +41,9 @@ class G1Element { } static G1Element FromBytes(const Bytes& bytes, bool fLegacy = false); + static G1Element FromBytesUnchecked(const Bytes& bytes, bool fLegacy = false); static G1Element FromByteVector(const std::vector &bytevec, bool fLegacy = false); + static G1Element FromByteVectorUnchecked(const std::vector &bytevec, bool fLegacy = false); static G1Element FromNative(const g1_t element); static G1Element FromMessage(const std::vector &message, const uint8_t *dst, @@ -81,7 +83,9 @@ class G2Element { } static G2Element FromBytes(const Bytes& bytes, bool fLegacy = false); + static G2Element FromBytesUnchecked(const Bytes& bytes, bool fLegacy = false); static G2Element FromByteVector(const std::vector &bytevec, bool fLegacy = false); + static G2Element FromByteVectorUnchecked(const std::vector &bytevec, bool fLegacy = false); static G2Element FromNative(const g2_t element); static G2Element FromMessage(const std::vector& message, const uint8_t* dst, diff --git a/src/schemes.cpp b/src/schemes.cpp index 33bfa276e2b9fa..3d745ee1e0ac07 100644 --- a/src/schemes.cpp +++ b/src/schemes.cpp @@ -137,6 +137,8 @@ bool CoreMPL::Verify(const G1Element& pubkey, const Bytes& message, const G2Elem std::vector vecG2(2); G1Element::Generator().Negate().ToNative(&vecG1[0]); + pubkey.CheckValid(); + signature.CheckValid(); pubkey.ToNative(&vecG1[1]); signature.ToNative(&vecG2[0]); hashedPoint.ToNative(&vecG2[1]); @@ -313,9 +315,11 @@ bool CoreMPL::AggregateVerify(const vector& pubkeys, std::vector vecG1(nPubKeys + 1); std::vector vecG2(nPubKeys + 1); G1Element::Generator().Negate().ToNative(&vecG1[0]); + signature.CheckValid(); signature.ToNative(&vecG2[0]); for (size_t i = 0; i < nPubKeys; ++i) { + pubkeys[i].CheckValid(); pubkeys[i].ToNative(&vecG1[i + 1]); G2Element::FromMessage(messages[i], (const uint8_t*)strCiphersuiteId.c_str(), strCiphersuiteId.length()).ToNative(&vecG2[i + 1]); } From 235066da3d04a0e2bb5aae6bd74c851f686dfa31 Mon Sep 17 00:00:00 2001 From: Mariano Sorgente Date: Thu, 5 May 2022 09:42:52 -0400 Subject: [PATCH 22/30] Always CheckValid before NativeVerify --- src/schemes.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/schemes.cpp b/src/schemes.cpp index 3d745ee1e0ac07..9d0263b8935e11 100644 --- a/src/schemes.cpp +++ b/src/schemes.cpp @@ -577,6 +577,8 @@ bool PopSchemeMPL::PopVerify(const G1Element &pubkey, const G2Element &signature g1_t g1s[2]; g2_t g2s[2]; + pubkey.CheckValid(); + signature_proof.CheckValid(); G1Element::Generator().Negate().ToNative(g1s[0]); pubkey.ToNative(g1s[1]); signature_proof.ToNative(g2s[0]); From 3be4e9bb5ed971ec558e42216a64181ca5b695ac Mon Sep 17 00:00:00 2001 From: Mariano Sorgente Date: Fri, 6 May 2022 16:18:32 -0400 Subject: [PATCH 23/30] from_bytes_unchecked --- python-bindings/pythonbindings.cpp | 36 +++++++++++++++++++ python-bindings/test.py | 36 +++++++++++++++++++ src/schemes.cpp | 24 +++++++++---- src/test.cpp | 55 ++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 6 deletions(-) diff --git a/python-bindings/pythonbindings.cpp b/python-bindings/pythonbindings.cpp index 59857f851a6b0e..a560dbe0e42983 100644 --- a/python-bindings/pythonbindings.cpp +++ b/python-bindings/pythonbindings.cpp @@ -355,6 +355,7 @@ PYBIND11_MODULE(blspy, m) return G1Element(); })) .def(py::init(&G1Element::FromByteVector), py::call_guard()) + .def(py::init(&G1Element::FromByteVectorUnchecked), py::call_guard()) .def(py::init([](py::int_ pyint) { std::vector buffer(G1Element::SIZE, 0); if (_PyLong_AsByteArray( @@ -400,6 +401,23 @@ PYBIND11_MODULE(blspy, m) py::gil_scoped_release release; return G1Element::FromByteVector(data); }) + .def( + "from_bytes_unchecked", + [](py::buffer const b) { + py::buffer_info info = b.request(); + if (info.format != py::format_descriptor::format() || + info.ndim != 1) + throw std::runtime_error("Incompatible buffer format!"); + + if ((int)info.size != G1Element::SIZE) { + throw std::invalid_argument( + "Length of bytes object not equal to G1Element::SIZE"); + } + auto data_ptr = reinterpret_cast(info.ptr); + std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; + return G1Element::FromByteVectorUnchecked(data); + }) .def("generator", &G1Element::Generator) .def("from_message", py::overload_cast&, const uint8_t*, int>(&G1Element::FromMessage), py::call_guard()) .def("pair", &G1Element::Pair, py::call_guard()) @@ -480,6 +498,7 @@ PYBIND11_MODULE(blspy, m) return G2Element(); })) .def(py::init(&G2Element::FromByteVector), py::call_guard()) + .def(py::init(&G2Element::FromByteVectorUnchecked), py::call_guard()) .def(py::init([](py::buffer const b) { py::buffer_info info = b.request(); if (info.format != py::format_descriptor::format() || @@ -525,6 +544,23 @@ PYBIND11_MODULE(blspy, m) py::gil_scoped_release release; return G2Element::FromByteVector(data); }) + .def( + "from_bytes_unchecked", + [](py::buffer const b) { + py::buffer_info info = b.request(); + if (info.format != py::format_descriptor::format() || + info.ndim != 1) + throw std::runtime_error("Incompatible buffer format!"); + + if ((int)info.size != G2Element::SIZE) { + throw std::invalid_argument( + "Length of bytes object not equal to G2Element::SIZE"); + } + auto data_ptr = reinterpret_cast(info.ptr); + std::vector data(data_ptr, data_ptr + info.size); + py::gil_scoped_release release; + return G2Element::FromByteVector(data); + }) .def("generator", &G2Element::Generator) .def("from_message", py::overload_cast&, const uint8_t*, int, bool>(&G2Element::FromMessage), py::call_guard()) .def("pair", &G2Element::Pair, py::call_guard()) diff --git a/python-bindings/test.py b/python-bindings/test.py index 8fe58f0d123092..971d878591bbe8 100644 --- a/python-bindings/test.py +++ b/python-bindings/test.py @@ -1,5 +1,6 @@ # flake8: noqa: E501 import binascii +import time from copy import deepcopy from blspy import ( @@ -335,11 +336,46 @@ def test_aggregate_verify_zero_items(): assert AugSchemeMPL.aggregate_verify([], [], G2Element()) +def test_invalid_points(): + sk1 = BasicSchemeMPL.key_gen(b"1" *32) + good_point = sk1.get_g1() + good_point_bytes = bytes(good_point) + start = time.time() + for i in range(2000): + gp1 = G1Element.from_bytes(good_point_bytes) + print(f"from_bytes avg: {(time.time() - start) }") + + start = time.time() + for i in range(2000): + gp2 = G1Element.from_bytes_unchecked(good_point_bytes) + print(f"from_bytes_unchecked avg: {(time.time() - start) }") + assert gp1 == gp2 + + bad_point_hex: str = "8d5d0fb73b9c92df4eab4216e48c3e358578b4cc30f82c268bd6fef3bd34b558628daf1afef798d4c3b0fcd8b28c8973"; + try: + G1Element.from_bytes(bytes.fromhex(bad_point_hex)) + assert False + except ValueError: + pass + + p: G1Element = G1Element.from_bytes_unchecked(bytes.fromhex(bad_point_hex)) + + bad_g2_point_hex = "8f2886c94eaeac335c8414cbf14c16681b225380cfee3293becc4531d5b415984b4ea4050d9ecda11fbc21c60627e9d212dfcb17d2b5ae399aa3fbcb099e05baa496b852ad976fb633cc6766b02fca4da549dc063908463b2906ad64e8b310ad" + + try: + G2Element.from_bytes(bytes.fromhex(bad_g2_point_hex)) + assert False + except ValueError: + pass + + + test_schemes() test_vectors_invalid() test_vectors_valid() test_readme() test_aggregate_verify_zero_items() +test_invalid_points() print("\nAll tests passed.") diff --git a/src/schemes.cpp b/src/schemes.cpp index 9d0263b8935e11..003a44a467074b 100644 --- a/src/schemes.cpp +++ b/src/schemes.cpp @@ -137,8 +137,12 @@ bool CoreMPL::Verify(const G1Element& pubkey, const Bytes& message, const G2Elem std::vector vecG2(2); G1Element::Generator().Negate().ToNative(&vecG1[0]); - pubkey.CheckValid(); - signature.CheckValid(); + if (!pubkey.IsValid()) { + return false; + } + if (!signature.IsValid()) { + return false; + } pubkey.ToNative(&vecG1[1]); signature.ToNative(&vecG2[0]); hashedPoint.ToNative(&vecG2[1]); @@ -315,11 +319,15 @@ bool CoreMPL::AggregateVerify(const vector& pubkeys, std::vector vecG1(nPubKeys + 1); std::vector vecG2(nPubKeys + 1); G1Element::Generator().Negate().ToNative(&vecG1[0]); - signature.CheckValid(); + if (!signature.IsValid()) { + return false; + } signature.ToNative(&vecG2[0]); for (size_t i = 0; i < nPubKeys; ++i) { - pubkeys[i].CheckValid(); + if (!pubkeys[i].IsValid()) { + return false; + } pubkeys[i].ToNative(&vecG1[i + 1]); G2Element::FromMessage(messages[i], (const uint8_t*)strCiphersuiteId.c_str(), strCiphersuiteId.length()).ToNative(&vecG2[i + 1]); } @@ -577,8 +585,12 @@ bool PopSchemeMPL::PopVerify(const G1Element &pubkey, const G2Element &signature g1_t g1s[2]; g2_t g2s[2]; - pubkey.CheckValid(); - signature_proof.CheckValid(); + if (!pubkey.IsValid()) { + return false; + } + if (!signature_proof.IsValid()) { + return false; + } G1Element::Generator().Negate().ToNative(g1s[0]); pubkey.ToNative(g1s[1]); signature_proof.ToNative(g2s[0]); diff --git a/src/test.cpp b/src/test.cpp index 1ec7eef812cd76..8f1d296d78eed1 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1459,6 +1459,61 @@ TEST_CASE("Threshold Signatures") { } } +TEST_CASE("CheckValid") +{ + SECTION("Valid points should succeed") { + vector seed(32, 0x05); + vector msg1 = {10, 11, 12}; + + PrivateKey sk1 = BasicSchemeMPL().KeyGen(seed); + G1Element pk1 = BasicSchemeMPL().SkToG1(sk1); + pk1.CheckValid(); + + G2Element sig1 = AugSchemeMPL().Sign(sk1, msg1); + sig1.CheckValid(); + } + + SECTION("Invalid G1 points should not succeed") + { + string badPointHex = + "8d5d0fb73b9c92df4eab4216e48c3e358578b4cc30f82c268bd6fef3bd34b558628daf1afef798d4c3b0fcd8b28c8973"; + + // FromBytes throws + REQUIRE_THROWS( + G1Element::FromBytes(Bytes(Util::HexToBytes(badPointHex)))); + + // FromBytesUnchecked does not throw + G1Element pk = + G1Element::FromBytesUnchecked(Bytes(Util::HexToBytes(badPointHex))); + REQUIRE(pk.IsValid() == false); + REQUIRE_THROWS(pk.CheckValid()); + + vector seed(32, 0x05); + vector msg1 = {10, 11, 12}; + PrivateKey sk1 = BasicSchemeMPL().KeyGen(seed); + G1Element pk1 = BasicSchemeMPL().SkToG1(sk1); + G2Element sig1 = AugSchemeMPL().Sign(sk1, msg1); + REQUIRE(AugSchemeMPL().Verify(pk, msg1, sig1) == false); + } + + SECTION("Invalid G2 points should not succeed") { + g2_t point_native; + g2_set_infty(point_native); + fp2_rand(point_native->x); + fp2_rand(point_native->y); + fp2_rand(point_native->z); + + G2Element point = G2Element::FromNative(point_native); + REQUIRE(point.IsValid() == false); + REQUIRE_THROWS(point.CheckValid()); + + auto badSer = point.Serialize(); + std::cout < Date: Sat, 7 May 2022 11:09:20 +0200 Subject: [PATCH 24/30] lighter-weight buffer handling --- python-bindings/pythonbindings.cpp | 58 +++++++++++++++--------------- src/elements.cpp | 19 +++------- src/elements.hpp | 10 +++--- src/util.hpp | 10 ++++-- 4 files changed, 45 insertions(+), 52 deletions(-) diff --git a/python-bindings/pythonbindings.cpp b/python-bindings/pythonbindings.cpp index a560dbe0e42983..8a715fe2815703 100644 --- a/python-bindings/pythonbindings.cpp +++ b/python-bindings/pythonbindings.cpp @@ -24,7 +24,6 @@ namespace py = pybind11; using namespace bls; -using std::vector; PYBIND11_MODULE(blspy, m) @@ -46,9 +45,10 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to PrivateKey::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + PrivateKey::PRIVATE_KEY_SIZE, data.data()); py::gil_scoped_release release; - return PrivateKey::FromByteVector(data); + return PrivateKey::FromBytes(data); }) .def( "__bytes__", @@ -355,9 +355,8 @@ PYBIND11_MODULE(blspy, m) return G1Element(); })) .def(py::init(&G1Element::FromByteVector), py::call_guard()) - .def(py::init(&G1Element::FromByteVectorUnchecked), py::call_guard()) .def(py::init([](py::int_ pyint) { - std::vector buffer(G1Element::SIZE, 0); + std::array buffer{}; if (_PyLong_AsByteArray( (PyLongObject *)pyint.ptr(), buffer.data(), @@ -367,7 +366,7 @@ PYBIND11_MODULE(blspy, m) throw std::invalid_argument("Failed to cast int to G1Element"); } py::gil_scoped_release release; - return G1Element::FromByteVector(buffer); + return G1Element::FromBytes(buffer); })) .def(py::init([](py::buffer const b) { py::buffer_info info = b.request(); @@ -380,9 +379,10 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G1Element::SIZE"); } auto data_ptr = static_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + G1Element::SIZE, data.data()); py::gil_scoped_release release; - return G1Element::FromByteVector(data); + return G1Element::FromBytes(data); })) .def( "from_bytes", @@ -397,9 +397,10 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G1Element::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + G1Element::SIZE, data.data()); py::gil_scoped_release release; - return G1Element::FromByteVector(data); + return G1Element::FromBytes(data); }) .def( "from_bytes_unchecked", @@ -414,9 +415,7 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G1Element::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); - py::gil_scoped_release release; - return G1Element::FromByteVectorUnchecked(data); + return G1Element::FromBytesUnchecked({data_ptr, G1Element::SIZE}); }) .def("generator", &G1Element::Generator) .def("from_message", py::overload_cast&, const uint8_t*, int>(&G1Element::FromMessage), py::call_guard()) @@ -498,7 +497,6 @@ PYBIND11_MODULE(blspy, m) return G2Element(); })) .def(py::init(&G2Element::FromByteVector), py::call_guard()) - .def(py::init(&G2Element::FromByteVectorUnchecked), py::call_guard()) .def(py::init([](py::buffer const b) { py::buffer_info info = b.request(); if (info.format != py::format_descriptor::format() || @@ -510,12 +508,13 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G2Element::SIZE"); } auto data_ptr = static_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + G2Element::SIZE, data.data()); py::gil_scoped_release release; - return G2Element::FromByteVector(data); + return G2Element::FromBytes(data); })) .def(py::init([](py::int_ pyint) { - std::vector buffer(G2Element::SIZE, 0); + std::array buffer{}; if (_PyLong_AsByteArray( (PyLongObject *)pyint.ptr(), buffer.data(), @@ -525,7 +524,7 @@ PYBIND11_MODULE(blspy, m) throw std::invalid_argument("Failed to cast int to G2Element"); } py::gil_scoped_release release; - return G2Element::FromByteVector(buffer); + return G2Element::FromBytes(buffer); })) .def( "from_bytes", @@ -540,9 +539,10 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G2Element::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + G2Element::SIZE, data.data()); py::gil_scoped_release release; - return G2Element::FromByteVector(data); + return G2Element::FromBytes(data); }) .def( "from_bytes_unchecked", @@ -557,9 +557,7 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G2Element::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); - py::gil_scoped_release release; - return G2Element::FromByteVector(data); + return G2Element::FromBytesUnchecked({data_ptr, G2Element::SIZE}); }) .def("generator", &G2Element::Generator) .def("from_message", py::overload_cast&, const uint8_t*, int, bool>(&G2Element::FromMessage), py::call_guard()) @@ -642,12 +640,13 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to G2Element::SIZE"); } auto data_ptr = static_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + GTElement::SIZE, data.data()); py::gil_scoped_release release; - return GTElement::FromByteVector(data); + return GTElement::FromBytes(data); })) .def(py::init([](py::int_ pyint) { - std::vector buffer(GTElement::SIZE, 0); + std::array buffer{}; if (_PyLong_AsByteArray( (PyLongObject *)pyint.ptr(), buffer.data(), @@ -657,7 +656,7 @@ PYBIND11_MODULE(blspy, m) throw std::invalid_argument("Failed to cast int to GTElement"); } py::gil_scoped_release release; - return GTElement::FromByteVector(buffer); + return GTElement::FromBytes(buffer); })) .def( "from_bytes", @@ -672,9 +671,10 @@ PYBIND11_MODULE(blspy, m) "Length of bytes object not equal to GTElement::SIZE"); } auto data_ptr = reinterpret_cast(info.ptr); - std::vector data(data_ptr, data_ptr + info.size); + std::array data; + std::copy(data_ptr, data_ptr + GTElement::SIZE, data.data()); py::gil_scoped_release release; - return GTElement::FromByteVector(data); + return GTElement::FromBytes(data); }) .def("unity", >Element::Unity) .def(py::self == py::self) diff --git a/src/elements.cpp b/src/elements.cpp index 9f4bee0505d0da..020d25a6957d6c 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -21,13 +21,13 @@ namespace bls { const size_t G1Element::SIZE; -G1Element G1Element::FromBytes(const Bytes& bytes, bool fLegacy) { +G1Element G1Element::FromBytes(Bytes const bytes, bool fLegacy) { G1Element ele = G1Element::FromBytesUnchecked(bytes, fLegacy); ele.CheckValid(); return ele; } -G1Element G1Element::FromBytesUnchecked(const Bytes& bytes, bool fLegacy) +G1Element G1Element::FromBytesUnchecked(Bytes const bytes, bool fLegacy) { if (bytes.size() != SIZE) { throw std::invalid_argument("G1Element::FromBytes: Invalid size"); @@ -91,11 +91,6 @@ G1Element G1Element::FromByteVector(const std::vector& bytevec, bool fL return G1Element::FromBytes(Bytes(bytevec), fLegacy); } -G1Element G1Element::FromByteVectorUnchecked(const std::vector& bytevec, bool fLegacy) -{ - return G1Element::FromBytesUnchecked(Bytes(bytevec), fLegacy); -} - G1Element G1Element::FromNative(const g1_t element) { G1Element ele; @@ -232,13 +227,13 @@ G1Element operator*(const bn_t& k, const G1Element& a) { return a * k; } const size_t G2Element::SIZE; -G2Element G2Element::FromBytes(const Bytes& bytes, const bool fLegacy) { +G2Element G2Element::FromBytes(Bytes const bytes, const bool fLegacy) { G2Element ele = G2Element::FromBytesUnchecked(bytes, fLegacy); ele.CheckValid(); return ele; } -G2Element G2Element::FromBytesUnchecked(const Bytes& bytes, const bool fLegacy) +G2Element G2Element::FromBytesUnchecked(Bytes const bytes, const bool fLegacy) { if (bytes.size() != SIZE) { throw std::invalid_argument("G2Element::FromBytes: Invalid size"); @@ -305,12 +300,6 @@ G2Element G2Element::FromByteVector(const std::vector& bytevec, bool fL return G2Element::FromBytes(Bytes(bytevec), fLegacy); } -G2Element G2Element::FromByteVectorUnchecked(const std::vector& bytevec, bool fLegacy) -{ - return G2Element::FromBytesUnchecked(Bytes(bytevec), fLegacy); -} - - G2Element G2Element::FromNative(const g2_t element) { G2Element ele; diff --git a/src/elements.hpp b/src/elements.hpp index 3297318a727ffd..9b9839f02a5212 100644 --- a/src/elements.hpp +++ b/src/elements.hpp @@ -40,10 +40,9 @@ class G1Element { g1_set_infty(p); } - static G1Element FromBytes(const Bytes& bytes, bool fLegacy = false); - static G1Element FromBytesUnchecked(const Bytes& bytes, bool fLegacy = false); + static G1Element FromBytes(Bytes bytes, bool fLegacy = false); + static G1Element FromBytesUnchecked(Bytes bytes, bool fLegacy = false); static G1Element FromByteVector(const std::vector &bytevec, bool fLegacy = false); - static G1Element FromByteVectorUnchecked(const std::vector &bytevec, bool fLegacy = false); static G1Element FromNative(const g1_t element); static G1Element FromMessage(const std::vector &message, const uint8_t *dst, @@ -82,10 +81,9 @@ class G2Element { g2_set_infty(q); } - static G2Element FromBytes(const Bytes& bytes, bool fLegacy = false); - static G2Element FromBytesUnchecked(const Bytes& bytes, bool fLegacy = false); + static G2Element FromBytes(Bytes bytes, bool fLegacy = false); + static G2Element FromBytesUnchecked(Bytes bytes, bool fLegacy = false); static G2Element FromByteVector(const std::vector &bytevec, bool fLegacy = false); - static G2Element FromByteVectorUnchecked(const std::vector &bytevec, bool fLegacy = false); static G2Element FromNative(const g2_t element); static G2Element FromMessage(const std::vector& message, const uint8_t* dst, diff --git a/src/util.hpp b/src/util.hpp index 78e97eac2c4567..37fd8547a983ed 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace bls { @@ -30,14 +31,19 @@ class Bytes { const size_t nSize; public: - explicit Bytes(const uint8_t* pDataIn, const size_t nSizeIn) + Bytes(const uint8_t* pDataIn, const size_t nSizeIn) : pData(pDataIn), nSize(nSizeIn) { } - explicit Bytes(const std::vector& vecBytes) + Bytes(const std::vector& vecBytes) : pData(vecBytes.data()), nSize(vecBytes.size()) { } + template + Bytes(const std::array& a) + : pData(a.data()), nSize(N) + { + } inline const uint8_t* begin() const { return pData; } inline const uint8_t* end() const { return pData + nSize; } From bef701545714b135d9e22a01a29c182fef43f174 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 21 Jun 2022 08:06:28 -0500 Subject: [PATCH 25/30] NPM Publish (#335) * Use native job cancellation * Add start to js bindings workflow * Get the version info for a tag and replace in package.json * Add/update setup-emsdk action * Update artifact dir * Set NPM TOKEN in the publish step * Remove upload artifacts * Fix dir * publish packages as public * Actually use npm token * Fix cleanup file location --- .github/workflows/build-aarch64.yml | 13 +++--- .github/workflows/build-m1-wheel.yml | 13 +++--- .github/workflows/build-test.yaml | 15 ++++--- .github/workflows/build-wheels.yml | 13 +++--- .github/workflows/js-bindings.yml | 60 ++++++++++++++++++++++++++++ .github/workflows/relic-nightly.yml | 15 ++++--- 6 files changed, 92 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/js-bindings.yml diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml index 1bc059e35ed3ed..9b2d001f8ad77c 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-aarch64.yml @@ -10,6 +10,11 @@ on: branches: - '**' +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + cancel-in-progress: true + jobs: build_wheels: name: Build wheel on ${{ matrix.os }} @@ -20,14 +25,8 @@ jobs: os: [[ARM64, Linux]] steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index 6700e8d34031d0..1a7ecee595ca1e 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -10,6 +10,11 @@ on: branches: - '**' +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + cancel-in-progress: true + jobs: build_wheels: name: Build wheel on Mac M1 @@ -18,14 +23,8 @@ jobs: fail-fast: false steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index a9258194a07b09..e541b8e0be89f5 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -10,6 +10,11 @@ on: branches: - '**' +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + cancel-in-progress: true + jobs: build_wheels: name: Build and Test on ${{ matrix.os }} CPython ${{ matrix.python }} @@ -21,14 +26,8 @@ jobs: python: ['3.7', '3.8', '3.9', '3.10'] steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - uses: actions/setup-python@v2 name: Install Python @@ -70,7 +69,7 @@ jobs: python python-impl/impl-test.py - name: Install emsdk - uses: mymindstorm/setup-emsdk@v9 + uses: mymindstorm/setup-emsdk@v11 - name: Test javascript bindings run: | diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index ae8ed403d2b1c6..d125bc028da357 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -10,6 +10,11 @@ on: branches: - '**' +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + cancel-in-progress: true + jobs: build_wheels: name: Build wheel on ${{ matrix.os }} @@ -20,14 +25,8 @@ jobs: os: [macos-latest, ubuntu-latest, windows-latest] steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/js-bindings.yml b/.github/workflows/js-bindings.yml new file mode 100644 index 00000000000000..887c8df3d628a2 --- /dev/null +++ b/.github/workflows/js-bindings.yml @@ -0,0 +1,60 @@ +name: Build & Publish JS Bindings + +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' + +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + cancel-in-progress: true + +jobs: + js_bindings: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install emsdk + uses: mymindstorm/setup-emsdk@v11 + + - name: Get the version + id: version_info + run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} + + - name: Update version in package.json + if: startsWith(github.ref, 'refs/tags/') + working-directory: ${{ github.workspace }}/js-bindings + env: + SOURCE_TAG: ${{ steps.version_info.outputs.SOURCE_TAG }} + run: | + jq --arg VER "$SOURCE_TAG" '.version=$VER' package.json > temp.json && mv temp.json package.json + + - name: Build JS + run: ./js_build.sh + + - name: Publish + if: startsWith(github.ref, 'refs/tags/') + working-directory: ${{ github.workspace }}/js_build/js-bindings + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + npm publish --access public + + - name: Cleanup + if: always() + run: + rm ${{ github.workspace }}/js_build/js-bindings/.npmrc || true diff --git a/.github/workflows/relic-nightly.yml b/.github/workflows/relic-nightly.yml index cc8c032a45acb3..2a9ef67153cc03 100644 --- a/.github/workflows/relic-nightly.yml +++ b/.github/workflows/relic-nightly.yml @@ -5,6 +5,11 @@ on: - cron: "0 11 * * *" workflow_dispatch: +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + cancel-in-progress: true + jobs: build_wheels: name: Build and Test with Relic Nightly @@ -15,14 +20,8 @@ jobs: os: [macos-latest, ubuntu-latest] steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Ubuntu build C++ and test Relic at origin/main if: startsWith(matrix.os, 'ubuntu') @@ -69,7 +68,7 @@ jobs: python python-impl/impl-test.py - name: Install emsdk - uses: mymindstorm/setup-emsdk@v9 + uses: mymindstorm/setup-emsdk@v11 - name: Test javascript bindings run: | From dc5ee694e2fe4cc48ef6380a41fbc8ab1f08d351 Mon Sep 17 00:00:00 2001 From: Alessandro Guggino <42747219+alessandroguggino@users.noreply.github.com> Date: Tue, 31 May 2022 13:06:52 +0200 Subject: [PATCH 26/30] Fix bit getters in point deserialization --- python-impl/ec.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python-impl/ec.py b/python-impl/ec.py index 73ad9174127b24..36f573d11b1664 100644 --- a/python-impl/ec.py +++ b/python-impl/ec.py @@ -238,6 +238,7 @@ def sign_Fq2(element, ec=default_ec_twist) -> bool: def point_to_bytes(point_j: JacobianPoint, ec, FE) -> bytes: + # Zcash serialization described in https://datatracker.ietf.org/doc/draft-irtf-cfrg-pairing-friendly-curves/ point = point_j.to_affine() output = bytearray(bytes(point.x)) @@ -259,7 +260,7 @@ def point_to_bytes(point_j: JacobianPoint, ec, FE) -> bytes: def bytes_to_point(buffer: bytes, ec, FE) -> JacobianPoint: - # Zcash serialization described in https://datatracker.ietf.org/doc/draft-irtf-cfrg-pairing-friendly-curves/ + # Zcash deserialization described in https://datatracker.ietf.org/doc/draft-irtf-cfrg-pairing-friendly-curves/ if FE == Fq: if len(buffer) != 48: @@ -275,9 +276,9 @@ def bytes_to_point(buffer: bytes, ec, FE) -> JacobianPoint: if m_byte in [0x20, 0x60, 0xE0]: raise ValueError("Invalid first three bits") - C_bit = m_byte & 0x80 # First bit - I_bit = m_byte & 0x40 # Second bit - S_bit = m_byte & 0x20 # Third bit + C_bit = (m_byte & 0x80) >> 7 # First bit + I_bit = (m_byte & 0x40) >> 6 # Second bit + S_bit = (m_byte & 0x20) >> 5 # Third bit if C_bit == 0: raise ValueError("First bit must be 1 (only compressed points)") From 7c64d8ce65a119439973769ac648515dcadde99a Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 24 Jul 2022 13:06:31 +0100 Subject: [PATCH 27/30] Fix a typo. Addresses issue #336 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa88280050275c..26f854aa23b33a 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ vector message = {1, 2, 3, 4, 5}; // Message is passed in as a byte ve G2Element signature = AugSchemeMPL().Sign(sk, message); // Verify the signature -bool ok = AugSchemeMPL().Verify(pk, message, signature)); +bool ok = AugSchemeMPL().Verify(pk, message, signature); ``` ## Serializing keys and signatures to bytes From a9f9013db977ca5aad526d13adfcc13b15b214c6 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 4 Aug 2022 14:14:26 -0700 Subject: [PATCH 28/30] fix Bytes signatures. Byte is a span-type, it should be passed by value --- src/elements.cpp | 6 +++--- src/elements.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/elements.cpp b/src/elements.cpp index 020d25a6957d6c..b27a265974e76a 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -105,7 +105,7 @@ G1Element G1Element::FromMessage(const std::vector& message, return FromMessage(Bytes(message), dst, dst_len); } -G1Element G1Element::FromMessage(const Bytes& message, +G1Element G1Element::FromMessage(Bytes const message, const uint8_t* dst, int dst_len) { @@ -315,7 +315,7 @@ G2Element G2Element::FromMessage(const std::vector& message, return FromMessage(Bytes(message), dst, dst_len, fLegacy); } -G2Element G2Element::FromMessage(const Bytes& message, +G2Element G2Element::FromMessage(Bytes const message, const uint8_t* dst, int dst_len, const bool fLegacy) @@ -448,7 +448,7 @@ G2Element operator*(const bn_t& k, const G2Element& a) { return a * k; } const size_t GTElement::SIZE; -GTElement GTElement::FromBytes(const Bytes& bytes) +GTElement GTElement::FromBytes(Bytes const bytes) { if (bytes.size() != SIZE) { throw std::invalid_argument("GTElement::FromBytes: Invalid size"); diff --git a/src/elements.hpp b/src/elements.hpp index 9b9839f02a5212..5c0a203cddfdac 100644 --- a/src/elements.hpp +++ b/src/elements.hpp @@ -47,7 +47,7 @@ class G1Element { static G1Element FromMessage(const std::vector &message, const uint8_t *dst, int dst_len); - static G1Element FromMessage(const Bytes& message, + static G1Element FromMessage(Bytes message, const uint8_t* dst, int dst_len); static G1Element Generator(); @@ -89,7 +89,7 @@ class G2Element { const uint8_t* dst, int dst_len, bool fLegacy = false); - static G2Element FromMessage(const Bytes& message, + static G2Element FromMessage(Bytes message, const uint8_t* dst, int dst_len, bool fLegacy = false); @@ -117,7 +117,7 @@ class G2Element { class GTElement { public: static const size_t SIZE = 384; - static GTElement FromBytes(const Bytes& bytes); + static GTElement FromBytes(Bytes bytes); static GTElement FromByteVector(const std::vector &bytevec); static GTElement FromNative(const gt_t *element); static GTElement Unity(); // unity From d50917dfbc18070c0b43e13a888f9d4e8ce2bf8d Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 4 Aug 2022 14:19:42 -0700 Subject: [PATCH 29/30] add unchecked version of GTElement.from_bytes --- python-bindings/pythonbindings.cpp | 18 ++++++++++++++++++ src/elements.cpp | 10 ++++++++-- src/elements.hpp | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/python-bindings/pythonbindings.cpp b/python-bindings/pythonbindings.cpp index 8a715fe2815703..32d237080d3f96 100644 --- a/python-bindings/pythonbindings.cpp +++ b/python-bindings/pythonbindings.cpp @@ -676,6 +676,24 @@ PYBIND11_MODULE(blspy, m) py::gil_scoped_release release; return GTElement::FromBytes(data); }) + .def( + "from_bytes_unchecked", + [](py::buffer const b) { + py::buffer_info info = b.request(); + if (info.format != py::format_descriptor::format() || + info.ndim != 1) + throw std::runtime_error("Incompatible buffer format!"); + + if ((int)info.size != GTElement::SIZE) { + throw std::invalid_argument( + "Length of bytes object not equal to GTElement::SIZE"); + } + auto data_ptr = reinterpret_cast(info.ptr); + std::array data; + std::copy(data_ptr, data_ptr + GTElement::SIZE, data.data()); + py::gil_scoped_release release; + return GTElement::FromBytesUnchecked(data); + }) .def("unity", >Element::Unity) .def(py::self == py::self) .def(py::self != py::self) diff --git a/src/elements.cpp b/src/elements.cpp index b27a265974e76a..bf3d762646b107 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -449,14 +449,20 @@ G2Element operator*(const bn_t& k, const G2Element& a) { return a * k; } const size_t GTElement::SIZE; GTElement GTElement::FromBytes(Bytes const bytes) +{ + GTElement ele = GTElement::FromBytesUnchecked(bytes); + if (gt_is_valid(*(gt_t*)&ele) == 0) + throw std::invalid_argument("GTElement is invalid"); + return ele; +} + +GTElement GTElement::FromBytesUnchecked(Bytes const bytes) { if (bytes.size() != SIZE) { throw std::invalid_argument("GTElement::FromBytes: Invalid size"); } GTElement ele = GTElement(); gt_read_bin(ele.r, bytes.begin(), GTElement::SIZE); - if (gt_is_valid(*(gt_t*)&ele) == 0) - throw std::invalid_argument("GTElement is invalid"); BLS::CheckRelicErrors(); return ele; } diff --git a/src/elements.hpp b/src/elements.hpp index 5c0a203cddfdac..a147115907bf5e 100644 --- a/src/elements.hpp +++ b/src/elements.hpp @@ -118,6 +118,7 @@ class GTElement { public: static const size_t SIZE = 384; static GTElement FromBytes(Bytes bytes); + static GTElement FromBytesUnchecked(Bytes bytes); static GTElement FromByteVector(const std::vector &bytevec); static GTElement FromNative(const gt_t *element); static GTElement Unity(); // unity From 5f4f6ecbaa44c7f3c152a66dbefaf9afe9cc803b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Thu, 11 Aug 2022 10:05:08 -0400 Subject: [PATCH 30/30] rework build matrix to a single workflow (#338) * rework build matrix to a single workflow * rm the others * debug * drop the inp_raw.c patch * try dropping CIBW_ENVIRONMENT_WINDOWS * just remove it * Revert "debug" This reverts commit 7a2e1af12dac631fdc8f936d759abb75d0983880. --- .github/workflows/build-aarch64.yml | 137 ------------ .github/workflows/build-m1-wheel.yml | 119 ----------- .github/workflows/build-wheels.yml | 305 ++++++++++++++++++++------- 3 files changed, 233 insertions(+), 328 deletions(-) delete mode 100644 .github/workflows/build-aarch64.yml delete mode 100644 .github/workflows/build-m1-wheel.yml diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml deleted file mode 100644 index 9b2d001f8ad77c..00000000000000 --- a/.github/workflows/build-aarch64.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: Build ARM64 wheel - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} - cancel-in-progress: true - -jobs: - build_wheels: - name: Build wheel on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [[ARM64, Linux]] - - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Prepare cibuildwheel - run: | - if [ ! -f "venv" ]; then rm -rf venv; fi - sudo apt-get install python3-venv python3-pip -y - python3 -m venv venv - source venv/bin/activate - python -m pip install --upgrade pip - python -m pip install cibuildwheel==2.3.1 - - - name: Lint source with flake8 - run: | - source venv/bin/activate - pip install flake8 - flake8 src setup.py python-bindings python-impl - - - name: Lint source with mypy - run: | - source venv/bin/activate - pip install mypy - mypy --config-file mypi.ini python-bindings python-impl - - - name: Build wheels and test - run: | - source venv/bin/activate - python -m cibuildwheel --output-dir dist - env: - CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* - CIBW_SKIP: '*-musllinux_*' - CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 - CIBW_BUILD_VERBOSITY_LINUX: 0 - CIBW_BEFORE_BUILD_LINUX: > - python -m pip install --upgrade pip - CIBW_BEFORE_ALL_LINUX: > - yum -y install epel-release - && yum -y install lzip - && curl -L https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-aarch64.sh > cmake.sh - && yes | sh cmake.sh | cat - && rm -f /usr/bin/cmake && hash -r - && which cmake - && cmake --version - && curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x - && cd gmp-6.2.1 && ./configure --enable-fat - && make && make install && cd .. && rm -rf gmp-6.2.1 - CIBW_TEST_REQUIRES: pytest - CIBW_TEST_COMMAND: pytest -v {project}/python-bindings/test.py - - - name: Create sha256 wheel hashes - run: | - mkdir hashes - cd ./dist - shasum -a 256 * - shasum -a 256 * > ../hashes/blspy-arm64-wheels-sha256.txt - - - name: Upload hashes - uses: actions/upload-artifact@v2 - with: - name: blspy-arm64-hashes - path: ./hashes - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: wheels - path: ./dist - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo ::set-output name=HAS_SECRET::${HAS_SECRET} - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: Install twine - run: | - source venv/bin/activate - pip install twine - - - name: Publish distribution to PyPI - if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: | - source venv/bin/activate - twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Publish distribution to Test PyPI - if: steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.test_pypi_password }} - run: | - source venv/bin/activate - twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Clean up - run: | - rm -rf venv - rm -rf dist diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml deleted file mode 100644 index 1a7ecee595ca1e..00000000000000 --- a/.github/workflows/build-m1-wheel.yml +++ /dev/null @@ -1,119 +0,0 @@ -name: Build M1 Wheels - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} - cancel-in-progress: true - -jobs: - build_wheels: - name: Build wheel on Mac M1 - runs-on: [m1] - strategy: - fail-fast: false - - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Brew update Python - run: | - arch -arm64 brew install python@3.9 - arch -arm64 brew install python@3.10 - - - name: Build m1 wheels for 3.9 and 3.10 - run: | - rm -rf venv - arch -arm64 $(brew --prefix python@3.9)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip wheel -w dist --no-deps . - arch -arm64 pip install delocate - arch -arm64 delocate-wheel -v dist/*cp39*.whl - deactivate - rm -rf venv - arch -arm64 $(brew --prefix python@3.10)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip wheel -w dist --no-deps . - arch -arm64 pip install delocate - arch -arm64 delocate-wheel -v dist/*cp310*.whl - deactivate - rm -rf venv - - - name: Test wheel - run: | - rm -rf venv - arch -arm64 $(brew --prefix python@3.9)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip install ./dist/*cp39*.whl - arch -arm64 pip install pytest - arch -arm64 ./venv/bin/pytest -v ./python-bindings/test.py - deactivate - rm -rf venv - arch -arm64 $(brew --prefix python@3.10)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip install ./dist/*cp310*.whl - arch -arm64 pip install pytest - arch -arm64 ./venv/bin/pytest -v ./python-bindings/test.py - deactivate - rm -rf venv - - - name: Create sha256 hash - run: | - mkdir hashes - cd ./dist - shasum -a 256 * - shasum -a 256 * > ../hashes/blspy-wheel-m1-sha256.txt - - - name: Upload hashes - uses: actions/upload-artifact@v2 - with: - name: blspy-hashes - path: ./hashes - - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: ./dist - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo ::set-output name=HAS_SECRET::${HAS_SECRET} - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: Install twine - run: arch -arm64 pip install twine - - - name: Publish distribution to PyPI - if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Publish distribution to Test PyPI - if: steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.test_pypi_password }} - run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*' diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index d125bc028da357..d5c9680ca53b15 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,99 +1,158 @@ -name: Build wheels +name: build - check - upload on: push: branches: - - main + - main tags: - - '**' + - '**' pull_request: branches: - - '**' + - '**' concurrency: # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }} + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} cancel-in-progress: true jobs: - build_wheels: - name: Build wheel on ${{ matrix.os }} - runs-on: ${{ matrix.os }} + build-wheels: + name: Wheel - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: + - name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + cibw-archs-macos: + arm: arm64 + intel: x86_64 + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + - name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + python: + - major-dot-minor: '3.7' + cibw-build: 'cp37-*' + matrix: '3.7' + - major-dot-minor: '3.8' + cibw-build: 'cp38-*' + matrix: '3.8' + - major-dot-minor: '3.9' + cibw-build: 'cp39-*' + matrix: '3.9' + - major-dot-minor: '3.10' + cibw-build: 'cp310-*' + matrix: '3.10' + arch: + - name: ARM + matrix: arm + - name: Intel + matrix: intel + exclude: + # Only partial entries are required here by GitHub Actions so generally I + # only specify the `matrix:` entry. The super linter complains so for now + # all entries are included to avoid that. Reported at + # https://github.com/github/super-linter/issues/3016 + - os: + name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + arch: + name: ARM + matrix: arm + - os: + name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + python: + major-dot-minor: '3.7' + cibw-build: 'cp37-*' + matrix: '3.7' + arch: + name: ARM + matrix: arm + - os: + name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + python: + major-dot-minor: '3.8' + cibw-build: 'cp38-*' + matrix: '3.8' + arch: + name: ARM + matrix: arm steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-python@v2 - name: Install Python + - uses: chia-network/actions/setup-python@main with: - python-version: '3.8' - - - name: Lint source with flake8 - run: | - python -m pip install --upgrade pip - pip install flake8 - flake8 src setup.py python-bindings python-impl - - - name: Lint source with mypy - run: | - pip install mypy - mypy --config-file mypi.ini python-bindings python-impl + python-version: ${{ matrix.python.major-dot-minor }} - - name: Build source distribution with Ubuntu-latest - if: startsWith(matrix.os, 'ubuntu') + - name: Install pipx run: | - pip install build - python -m build --sdist --outdir dist . - - - name: Build ${{ matrix.os }} wheels and test - uses: joerick/cibuildwheel@v2.3.1 + pip install pipx + - name: Build and test + uses: pypa/cibuildwheel@v2.7.0 with: output-dir: dist env: CIBW_BUILD_VERBOSITY_MACOS: 0 CIBW_BUILD_VERBOSITY_LINUX: 0 CIBW_BUILD_VERBOSITY_WINDOWS: 0 - CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* + CIBW_BUILD: ${{ matrix.python.cibw-build }} CIBW_SKIP: '*-manylinux_i686 *-win32 *-musllinux_*' - CIBW_TEST_REQUIRES: pytest + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010 CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.17.3-Linux-`uname -m`/bin:$PATH" CIBW_BEFORE_ALL_LINUX: > yum -y install epel-release + && echo "epel-release installed" && yum -y install lzip + && echo "lzip installed" && curl -L https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-`uname -m`.sh > cmake.sh && yes | sh cmake.sh | cat - && rm -f /usr/bin/cmake && hash -r - && which cmake - && cmake --version - && echo "curling GMP 6.2.1" - && curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x - && echo "Patching GMP for lzcnt" + && rm -f /usr/bin/cmake + && curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | tar x --lzip && cp contrib/gmp-patch-6.2.1/longlong.h gmp-6.2.1/ && cp contrib/gmp-patch-6.2.1/compat.c gmp-6.2.1/ - && echo "Building GMP" && cd gmp-6.2.1 && ./configure --enable-fat && make && make install && cd .. && rm -rf gmp-6.2.1 - CIBW_BEFORE_BUILD_LINUX: python -m pip install --upgrade pip - CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.14" - # GH hosted MacOS runner has gmp natively - # CIBW_ARCHS_MACOS: x86_64 arm64 universal2 - CIBW_ARCHS_MACOS: x86_64 - CIBW_TEST_SKIP: '*_arm64 *_universal2:arm64' + && cmake --version + && uname -a + CIBW_BEFORE_BUILD_LINUX: > + python -m pip install --upgrade pip + CIBW_ARCHS_MACOS: ${{ matrix.os.cibw-archs-macos[matrix.arch.matrix] }} + CIBW_BEFORE_ALL_MACOS: > + brew install gmp boost cmake CIBW_BEFORE_BUILD_MACOS: > python -m pip install --upgrade pip + CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.14" CIBW_REPAIR_WHEEL_COMMAND_MACOS: > - pip uninstall -y delocate - && pip install git+https://github.com/Chia-Network/delocate.git - && delocate-listdeps {wheel} - && delocate-wheel -v {wheel} + pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git + && delocate-listdeps {wheel} && delocate-wheel -v {wheel} && cp {wheel} {dest_dir} CIBW_BEFORE_ALL_WINDOWS: > curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip > libsodium-1.0.18-stable-msvc.zip @@ -103,7 +162,7 @@ jobs: && git clone https://github.com/Chia-Network/mpir_gc_x64.git && ls -l mpir_gc_x64 CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > - pip uninstall -y delocate + ls -l mpir_gc_x64 && pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git && delocate-wheel -v -i mpir_gc_x64/mpir.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_gc.dll {wheel} @@ -114,36 +173,138 @@ jobs: && delocate-wheel -v -i mpir_gc_x64/mpir_piledriver.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_sandybridge.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_skylake_avx.dll {wheel} - && cp {wheel} {dest_dir} && ls -l {dest_dir} - # CIBW_ENVIRONMENT_WINDOWS: "" - CIBW_TEST_COMMAND: pytest -v {project}/python-bindings/test.py + && cp {wheel} {dest_dir} + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/python-bindings/test.py + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: packages + path: ./dist + + build-sdist: + name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - major-dot-minor: '3.9' + matrix: '3.9' + arch: + - name: Intel + matrix: intel + + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Create sha256 wheel hashes - if: startsWith(runner.os, 'linux') || startsWith(runner.os, 'windows') + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: Build source distribution run: | - mkdir hashes - cd ./dist - sha256sum * - sha256sum * > ../hashes/wheel-sha256.txt + pip install build + python -m build --sdist --outdir dist . + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: packages + path: ./dist + + check: + name: Check - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - major-dot-minor: '3.9' + matrix: '3.9' + arch: + - name: Intel + matrix: intel + + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Create sha256 wheel hashes - MacOS - if: startsWith(runner.os, 'macos') + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: flake8 + run: | + pip install flake8 + flake8 src setup.py python-bindings python-impl + - name: mypy run: | - mkdir hashes - cd ./dist - shasum -a 256 * - shasum -a 256 * > ../hashes/blspy-wheels-sha256.txt + pip install mypy + mypy --config-file mypi.ini python-bindings python-impl + upload: + name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + needs: + - build-wheels + - build-sdist + - check + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - major-dot-minor: '3.9' + matrix: '3.9' + arch: + - name: Intel + matrix: intel + + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Upload hashes - uses: actions/upload-artifact@v2 + - uses: Chia-Network/actions/setup-python@main with: - name: blspy-hashes - path: ./hashes + python-version: ${{ matrix.python.major-dot-minor }} - - name: Upload wheels - uses: actions/upload-artifact@v2 + - name: Download artifacts + uses: actions/download-artifact@v3 with: - name: wheels + name: packages path: ./dist - name: Test for secrets access