From 06230aee41cbbd0c90a6b62c3a389e604ad0fa54 Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 2 Dec 2024 18:34:30 +0100 Subject: [PATCH] fix(crypto): bls compilation (#22717) (cherry picked from commit 9d9c19c0f854c203ba1a202846eb9067124d4eff) --- .github/workflows/build.yml | 6 ++++++ crypto/keys/bls12_381/key_cgo.go | 13 +------------ scripts/build/build.mk | 6 ------ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17fa601f64c5..aafbcbaee4e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,12 @@ jobs: - name: Build with rocksdb backend if: matrix.go-arch == 'amd64' run: GOARCH=${{ matrix.go-arch }} COSMOS_BUILD_OPTIONS="rocksdb" make build + - name: Build with BLS12381 + if: matrix.go-arch == 'amd64' + run: GOARCH=${{ matrix.go-arch }} COSMOS_BUILD_OPTIONS="bls12381" make build + - name: Build with Secp_cgo + if: matrix.go-arch == 'amd64' + run: GOARCH=${{ matrix.go-arch }} COSMOS_BUILD_OPTIONS="secp" make build ################### ## Build Tooling ## ################### diff --git a/crypto/keys/bls12_381/key_cgo.go b/crypto/keys/bls12_381/key_cgo.go index 2470e2c6ab6b..86c6a6644690 100644 --- a/crypto/keys/bls12_381/key_cgo.go +++ b/crypto/keys/bls12_381/key_cgo.go @@ -4,13 +4,12 @@ package bls12_381 import ( "bytes" - "crypto/sha256" "errors" "fmt" "github.com/cometbft/cometbft/crypto" - "github.com/cometbft/cometbft/crypto/tmhash" "github.com/cometbft/cometbft/crypto/bls12381" + "github.com/cometbft/cometbft/crypto/tmhash" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -84,11 +83,6 @@ func (privKey PrivKey) Sign(msg []byte) ([]byte, error) { return nil, err } - if len(msg) > bls12381.MaxMsgLen { - hash := sha256.Sum256(msg) - return secretKey.Sign(hash[:]) - } - return secretKey.Sign(msg) } @@ -151,11 +145,6 @@ func (pubKey PubKey) VerifySignature(msg, sig []byte) bool { return false } - if len(msg) > bls12381.MaxMsgLen { - hash := sha256.Sum256(msg) - msg = hash[:] - } - return pubK.VerifySignature(msg, sig) } diff --git a/scripts/build/build.mk b/scripts/build/build.mk index 34e76795046f..c39301f370c6 100644 --- a/scripts/build/build.mk +++ b/scripts/build/build.mk @@ -58,12 +58,6 @@ ifeq (v2,$(findstring v2,$(COSMOS_BUILD_OPTIONS))) endif # DB backend selection -ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS))) - build_tags += gcc -endif -ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS))) - build_tags += badgerdb -endif # handle rocksdb ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS))) CGO_ENABLED=1