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

chore(bls): port markos bls changes to v0.38.x branch #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BUILDDIR?=$(CURDIR)/build
OUTPUT?=$(BUILDDIR)/cometbft

HTTPS_GIT := https://github.com/cometbft/cometbft.git
CGO_ENABLED ?= 0
CGO_ENABLED ?= 1

# Process Docker environment varible TARGETPLATFORM
# in order to build binary with correspondent ARCH
Expand Down
10 changes: 10 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ endif
ifeq (boltdb,$(findstring boltdb,$(COMETBFT_BUILD_OPTIONS)))
BUILD_TAGS += boltdb
endif

# handle pebbledb
ifeq (pebbledb,$(findstring pebbledb,$(COMETBFT_BUILD_OPTIONS)))
BUILD_TAGS += pebbledb
endif

# handle bls
ifeq (blst,$(findstring blst,$(COMETBFT_BUILD_OPTIONS)))
BUILD_TAGS += blst
endif
17 changes: 17 additions & 0 deletions crypto/encoding/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"fmt"

bls "github.com/berachain/comet-bls12-381"

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / Build (arm, linux)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / Build (amd64, linux)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (03)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (02)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (02)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (04)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (04)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (00)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (00)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (05)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (05)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / tests (01)

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist

Check failure on line 6 in crypto/encoding/codec.go

View workflow job for this annotation

GitHub Actions / govulncheck

github.com/berachain/[email protected]: replacement directory ../comet-bls12-381 does not exist
"github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/crypto/ed25519"
"github.com/cometbft/cometbft/crypto/secp256k1"
Expand All @@ -14,6 +15,7 @@
json.RegisterType((*pc.PublicKey)(nil), "tendermint.crypto.PublicKey")
json.RegisterType((*pc.PublicKey_Ed25519)(nil), "tendermint.crypto.PublicKey_Ed25519")
json.RegisterType((*pc.PublicKey_Secp256K1)(nil), "tendermint.crypto.PublicKey_Secp256K1")
json.RegisterType((*pc.PublicKey_Bls12381)(nil), "tendermint.crypto.PublicKey_Bls12381")
}

// PubKeyToProto takes crypto.PubKey and transforms it to a protobuf Pubkey
Expand All @@ -32,6 +34,12 @@
Secp256K1: k,
},
}
case bls.PubKey:
kp = pc.PublicKey{
Sum: &pc.PublicKey_Bls12381{
Bls12381: k,
},
}
default:
return kp, fmt.Errorf("toproto: key type %v is not supported", k)
}
Expand All @@ -57,6 +65,15 @@
pk := make(secp256k1.PubKey, secp256k1.PubKeySize)
copy(pk, k.Secp256K1)
return pk, nil

case *pc.PublicKey_Bls12381:
if len(k.Bls12381) != bls.PubKeySize {
return nil, fmt.Errorf("invalid size for PubKeyBLS12_381. Got %d, expected %d",
len(k.Bls12381), bls.PubKeySize)
}
pk := make(bls.PubKey, bls.PubKeySize)
copy(pk, k.Bls12381)
return pk, nil
default:
return nil, fmt.Errorf("fromproto: key type %v is not supported", k)
}
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cometbft/cometbft

go 1.21
go 1.22.0

require (
github.com/BurntSushi/toml v1.2.1
Expand Down Expand Up @@ -41,7 +41,8 @@ require (
)

require (
github.com/Masterminds/semver/v3 v3.2.0
github.com/Masterminds/semver/v3 v3.2.1
github.com/berachain/comet-bls12-381 v0.0.0-00010101000000-000000000000
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/cometbft/cometbft-db v0.7.0
Expand Down Expand Up @@ -253,6 +254,7 @@ require (
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
github.com/tdakkota/asciicheck v0.2.0 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
Expand Down Expand Up @@ -295,6 +297,8 @@ require (
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect
)

replace github.com/berachain/comet-bls12-381 => ../comet-bls12-381

retract (
// a regression was introduced
v0.38.4
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 h1:+r1rSv4gvYn0wmRjC8X7I
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0/go.mod h1:b3g59n2Y+T5xmcxJL+UEG2f8cQploZm1mR/v6BW0mU0=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
Expand Down Expand Up @@ -826,6 +826,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
Expand Down
Loading
Loading