Use the new BLST no assembly fallback on 32-bit (#96)

* Use the new BLST no assembly fallback on 32-bit

* Update the tests as well

* Revert "Use the new BLST no assembly fallback on 32-bit"

This reverts commit c8b061958e.

* Keep the fallback to Miracl for PowerPC / IBM Z / MIPS / Itanium ...

* typo

* Skip BLST in PowerPC CI
This commit is contained in:
Mamy Ratsimbazafy 2020-12-04 19:02:23 +01:00 committed by GitHub
parent 8a5fc68fc3
commit 282d1f6831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -31,14 +31,15 @@ task test, "Run all tests":
# Internal BLS API - IETF standard
# test "", "tests/hash_to_curve_v7.nim"
# Public BLS API - IETF standard / Ethereum2.0 v0.12.x
# Public BLS API - IETF standard / Ethereum2.0 v1.0.0
test "-d:BLS_FORCE_BACKEND=miracl", "tests/eth2_vectors.nim"
# key Derivation - EIP 2333
test "-d:BLS_FORCE_BACKEND=miracl", "tests/eip2333_key_derivation.nim"
# Secret key to pubkey
test "-d:BLS_FORCE_BACKEND=miracl", "tests/priv_to_pub.nim"
when sizeof(int) == 8 and (defined(arm64) or defined(amd64)):
when defined(arm64) or defined(arm) or
defined(amd64) or defined(i386):
test "-d:BLS_FORCE_BACKEND=blst", "tests/eth2_vectors.nim"
test "-d:BLS_FORCE_BACKEND=blst", "tests/eip2333_key_derivation.nim"
test "-d:BLS_FORCE_BACKEND=blst", "tests/priv_to_pub.nim"

View File

@ -20,18 +20,23 @@ type BlsBackendKind* = enum
BLST
Miracl
when BLS_FORCE_BACKEND == "blst" or (
BLS_FORCE_BACKEND == "auto" and
sizeof(int) == 8 and
(defined(arm64) or (
defined(amd64) and
gorgeEx(getEnv("CC", "gcc") & " -march=native -dM -E -x c /dev/null | grep -q SSSE3").exitCode == 0))
const AutoSelectBLST = BLS_FORCE_BACKEND == "auto" and (
defined(arm64) or defined(arm) or
defined(amd64) or defined(i386)
)
# Theoretically the BLST library has a fallback for any platform
# but it is missing https://github.com/supranational/blst/issues/46
when (BLS_FORCE_BACKEND == "blst" or AutoSelectBLST) and (
gorgeEx(getEnv("CC", "gcc") & " -march=native -dM -E -x c /dev/null | grep -q SSSE3").exitCode == 0
):
# BLST supports: x86_64 and ARM64
# BLST supports: x86 and ARM 32 and 64 bits
# and has optimized SHA256 routines for x86_64 CPU with SSE3
# It also assumes that all ARM CPUs are Neon instructions capable for SHA256
const BLS_BACKEND* = BLST
elif BLS_FORCE_BACKEND == "auto" and defined(amd64):
elif BLS_FORCE_BACKEND == "blst" or AutoSelectBLST:
# CPU doesn't support SSE3 which is used in optimized SHA256
# BLST_PORTABLE is a no-op on ARM
const BLS_BACKEND* = BLST
{.passC: "-D__BLST_PORTABLE__".}
else: