Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLS12-381 bindings #266

Merged
merged 67 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
43a88bb
BLS12-381 bindings
tdammers Feb 28, 2022
f3c1c83
Refactoring
tdammers Mar 14, 2022
ab5ee7e
Reduce public API and expose Integer instead of Scalar
tdammers Mar 15, 2022
7a2eaa3
Fix failing tests
tdammers Mar 16, 2022
0903c2d
Remove unnecessary FFI bindings
tdammers Mar 16, 2022
c56b0fc
Some documentation
tdammers Mar 17, 2022
a44cd9e
PT type and operations
tdammers Apr 5, 2022
4f94ee6
PT tests
tdammers Apr 5, 2022
61630d1
BLS Changes as requested
tdammers Apr 6, 2022
d350fbe
Remove ptInv
tdammers Apr 6, 2022
ef32b02
Pairing tests (failing)
tdammers Apr 6, 2022
e8c3a2d
Reinstate other pairing tests
tdammers Apr 6, 2022
18e7e6b
Fix argument order for blst_miller_loop
tdammers Apr 6, 2022
ed4e413
Remove unused test function
tdammers Aug 30, 2022
f2fb07c
Fix incorrect size_fp calculation
tdammers Aug 30, 2022
cc82400
Remove unused integerAsCStr function
tdammers Aug 30, 2022
3e9fc94
Use CSize when appropriate
tdammers Aug 30, 2022
1e1d5d5
Use type aliases for consistency
tdammers Aug 30, 2022
1e446ef
Use add_or_double() rather than add()
tdammers Aug 30, 2022
c3c607f
Remove onCurve function (not used)
tdammers Aug 30, 2022
3a588c5
Cleanup
tdammers Aug 30, 2022
373107d
Check exact size of serialised points
iquerejeta Nov 24, 2022
d34ba83
Trailing white spaces
iquerejeta Nov 24, 2022
ea62c3e
Activate windows CI
iquerejeta Nov 24, 2022
4e8bf0b
Use CSize to marshall size_t
iquerejeta Nov 29, 2022
c10c042
Length check for scalarFromBS
iquerejeta Nov 29, 2022
a2b34f2
Rewrite scalarFromBS fn
iquerejeta Nov 30, 2022
f324559
Remove ghc-prim from dependencies
iquerejeta Nov 30, 2022
dff81dc
Check length before calling c function
iquerejeta Dec 15, 2022
e677cc1
Explicit check on Points serialisation size
iquerejeta Dec 19, 2022
debf4cd
Try new GITHUB_PATH variable
iquerejeta Dec 30, 2022
5be0f93
testing - building win
iquerejeta Dec 30, 2022
a54ec95
typo in yml
iquerejeta Dec 30, 2022
88e7a43
typo in yml
iquerejeta Dec 30, 2022
11f4d79
Missed if
iquerejeta Dec 30, 2022
2ddda77
Typo
iquerejeta Dec 30, 2022
afdb57e
explictly set MSYSTEM as mingw
iquerejeta Dec 30, 2022
3c1f813
Update haskell.yml
angerman Jan 11, 2023
6221ec1
Update haskell.yml
angerman Jan 11, 2023
4790e6e
Create build-blst.bash
angerman Jan 11, 2023
3eaac9c
Update build-blst.bash
angerman Jan 11, 2023
4d744a4
Update haskell.yml
angerman Jan 11, 2023
9e968c4
additional test to check intermediate structure
iquerejeta Jan 12, 2023
7161d33
editorial nits
iquerejeta Feb 23, 2023
8081a28
Apply suggestions from code review
iquerejeta Mar 9, 2023
9ae1175
Bump bytestring and use correct imports
iquerejeta Mar 10, 2023
efa4181
Enforce that Points are part of the prime order subgroup
iquerejeta Mar 10, 2023
d4e8f5c
Improve docs of scalar mult
iquerejeta Mar 10, 2023
e57a905
use build-blst.bash for non-windows blst installs
iquerejeta Mar 10, 2023
a31978f
Update permissions
iquerejeta Mar 10, 2023
f061b19
Review comments
iquerejeta Mar 17, 2023
f572d87
bls prefix for bindings functions
iquerejeta Mar 17, 2023
18a0d00
Merge BLSPoint and BLSCurve typeclasses
tdammers Mar 20, 2023
c41c920
Make BLS `Point` nominal to avoid incorrect `Coercible` instances
tdammers Mar 20, 2023
1b872a9
Merge branch 'master' into bls12-381
iquerejeta Mar 24, 2023
66662d4
Update haskell.yml (fix indentation)
angerman Mar 24, 2023
327883a
Enable ssh for debugging
iquerejeta Mar 27, 2023
bea40a0
Activate tmate session if failure
iquerejeta Mar 27, 2023
128dc9c
Debugging windows CI
iquerejeta Mar 27, 2023
2b5bd23
cygpath var
iquerejeta Mar 27, 2023
caef6cf
Reactivate tmate
iquerejeta Mar 28, 2023
056b281
No tmate for now
angerman Mar 29, 2023
5d443ac
Update build-blst.bash
angerman Mar 29, 2023
9a5014a
Add tmate again
angerman Mar 29, 2023
3049b5a
:facepalm:
angerman Mar 29, 2023
2f57926
Cleanup
angerman Mar 29, 2023
7ead184
miller loop always succeeds
iquerejeta Mar 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build-blst.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# I don't understand why this just vanishes.
export PATH=/usr/bin:$PATH

mkdir blst-sources && cd blst-sources
git clone https://github.com/supranational/blst
cd blst
git reset --hard $BLST_REF
./build.sh
cd ../..
41 changes: 32 additions & 9 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:

# current ref from: 27.02.2022
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
# current ref from: 25.11.2022
BLST_REF: 03b5124029979755c752eec45f3c29674b558446

# Modify this value to "invalidate" the secp cache.
SECP_CACHE_VERSION: "2023-03-22"
Expand Down Expand Up @@ -96,6 +98,17 @@ jobs:
if: runner.os == 'macOS'
run: brew install autoconf automake libtool

- name: "WINDOWS: Install blst"
if: runner.os == 'Windows'
env:
MSYS2_PATH_TYPE: inherit
MSYSTEM: MINGW64
run: C:\\msys64\\usr\\bin\\bash.exe .github/workflows/build-blst.bash

- name: "NON-WINDOWS: Install blst"
if: runner.os != 'Windows'
run: .github/workflows/build-blst.bash

- name: Install secp256k1
uses: input-output-hk/setup-secp256k1@v1
with:
Expand Down Expand Up @@ -140,21 +153,30 @@ jobs:
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cabal build all --enable-tests --only-dependencies
cabal build all --enable-tests --only-dependencies -j --ghc-option=-j4

- name: Build
run: |
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cabal build all --enable-tests
- name: Build [WIN - testing]
if: runner.os == 'Windows'
run: cabal build all --enable-tests --extra-lib-dirs ${env:GITHUB_WORKSPACE}/blst-sources/blst -j --ghc-option=-j4

- name: Build [non-WIN - testing]
if: runner.os != 'Windows'
run: cabal build all --enable-tests --extra-lib-dirs ${GITHUB_WORKSPACE}/blst-sources/blst -j

- name: Run tests
- name: Run tests [WIN]
if: runner.os == 'Windows'
env:
MSYS2_PATH_TYPE: inherit
MSYSTEM: MINGW64
run: |
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cabal test all --enable-tests --test-show-details=direct -j1 -v3
cabal test all --enable-tests --test-show-details=direct -j1 --extra-lib-dirs ${env:GITHUB_WORKSPACE}/blst-sources/blst

- name: Run tests [non-WIN]
if: runner.os != 'Windows'
run: cabal test all --enable-tests --test-show-details=direct -j1 --extra-lib-dirs ${GITHUB_WORKSPACE}/blst-sources/blst

- uses: actions/upload-artifact@v3
with:
Expand All @@ -177,6 +199,7 @@ jobs:
# and will silently fail if msys2 is not in path. See the "Run tests" step.
#
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ test-show-details: direct

program-options
ghc-options: -Werror

3 changes: 3 additions & 0 deletions cardano-crypto-class/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.1.1.0
* Included bindings to `blst` library to enable operations over curve BLS12-381

## 2.1.0.1

* Remove `development` flag: #372
Expand Down
11 changes: 9 additions & 2 deletions cardano-crypto-class/cardano-crypto-class.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: cardano-crypto-class
version: 2.1.0.1
version: 2.1.1.0
synopsis:
Type classes abstracting over cryptography primitives for Cardano

Expand All @@ -19,6 +19,8 @@ category: Currency
build-type: Simple
extra-source-files: README.md
CHANGELOG.md
extra-source-files: cbits/blst.h
, cbits/blst_aux.h

flag secp256k1-support
description: Enable support for functions from libsecp256k1. Requires
Expand All @@ -45,6 +47,8 @@ library
Cardano.Crypto.DSIGN.Ed448
Cardano.Crypto.DSIGN.Mock
Cardano.Crypto.DSIGN.NeverUsed
Cardano.Crypto.EllipticCurve.BLS12_381
Cardano.Crypto.EllipticCurve.BLS12_381.Internal
Cardano.Crypto.Hash
Cardano.Crypto.Hash.Blake2b
Cardano.Crypto.Hash.Class
Expand Down Expand Up @@ -90,7 +94,7 @@ library
, aeson
, base
, base16-bytestring >=1
, bytestring
, bytestring >= 0.11
, cardano-binary >= 1.6
, cardano-strict-containers
, cryptonite
Expand Down Expand Up @@ -121,6 +125,9 @@ library
pkgconfig-depends: libsecp256k1 -any
cpp-options: -DSECP256K1_ENABLED

extra-libraries: blst
c-sources: cbits/blst_util.c

test-suite test-memory-example
import: base, project-config
-- Temporarily removing this as it is breaking the CI, and
Expand Down
Loading