Skip to content

Commit

Permalink
remove completely blst dependency (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
aratz-lasa authored Jun 15, 2023
1 parent a2425ab commit e221f97
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
13 changes: 10 additions & 3 deletions blstools/blstools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
)

func GenerateNewKeypair() (sk *bls.SecretKey, pubKey types.PublicKey, err error) {

sk, pk, err := bls.GenerateNewKeypair()
if err != nil {
return nil, pubKey, err
}
err = pubKey.FromSlice(pk.Compress()) //nolint

pkBytes := pk.Bytes()
err = pubKey.FromSlice(pkBytes[:]) //nolint

return sk, pubKey, err
}
Expand All @@ -22,7 +23,13 @@ func SecretKeyFromBytes(skBytes []byte) (sk *bls.SecretKey, pk types.PublicKey,
return nil, types.PublicKey{}, err
}

err = pk.FromSlice(bls.PublicKeyFromSecretKey(sk).Compress()) //nolint
pubkey, err := bls.PublicKeyFromSecretKey(sk)
if err != nil {
return nil, types.PublicKey{}, err
}

pubkeyBytes := pubkey.Bytes()
err = pk.FromSlice(pubkeyBytes[:]) //nolint

return sk, pk, err
}
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/blocknative/dreamboat
go 1.20

require (
github.com/consensys/gnark-crypto v0.9.1-0.20230105202408-1a7a29904a7c
github.com/consensys/gnark-crypto v0.11.0
github.com/dgraph-io/badger/v2 v2.2007.4
github.com/ethereum/go-ethereum v1.11.6
github.com/ferranbt/fastssz v0.1.3
Expand Down Expand Up @@ -31,6 +31,7 @@ require (
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.5.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down Expand Up @@ -78,7 +79,6 @@ require (
github.com/rivo/uniseg v0.3.4 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/supranational/blst v0.3.10 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
Expand All @@ -97,11 +97,9 @@ require (
)

require (
github.com/flashbots/go-boost-utils v1.2.2
github.com/flashbots/go-boost-utils v1.6.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/r3labs/sse/v2 v2.8.1
golang.org/x/sys v0.8.0 // indirect
)

replace github.com/supranational/blst => github.com/lukanus/blst v0.0.0-20221108180119-1ce3e6f62936
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8=
github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
Expand Down Expand Up @@ -252,8 +254,8 @@ github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.9.1-0.20230105202408-1a7a29904a7c h1:llSLg4o9EgH3SrXky+Q5BqEYqV76NGKo07K5Ps2pIKo=
github.com/consensys/gnark-crypto v0.9.1-0.20230105202408-1a7a29904a7c/go.mod h1:CkbdF9hbRidRJYMRzmfX8TMOr95I2pYXRHF18MzRrvA=
github.com/consensys/gnark-crypto v0.11.0 h1:QqzHQlwEqlQr5jfWblGDkwlKHpT+4QodYqqExkAtyks=
github.com/consensys/gnark-crypto v0.11.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU=
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU=
Expand Down Expand Up @@ -462,8 +464,8 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/ferranbt/fastssz v0.1.3 h1:ZI+z3JH05h4kgmFXdHuR1aWYsgrg7o+Fw7/NCzM16Mo=
github.com/ferranbt/fastssz v0.1.3/go.mod h1:0Y9TEd/9XuFlh7mskMPfXiI2Dkw4Ddg9EyXt1W7MRvE=
github.com/flashbots/go-boost-utils v1.2.2 h1:KoIQHAveSwzJQceZLMBdxPwM/IAOmDZ30E6xQz37MEA=
github.com/flashbots/go-boost-utils v1.2.2/go.mod h1:XxZ1vM0bwnHTGyqmzjrXcBbNbGXBxmVdeyglOCcC+/E=
github.com/flashbots/go-boost-utils v1.6.0 h1:XIcPDG6q0Tesh3kcCXyv61ncD/WVYOMCO2OVzPznvMA=
github.com/flashbots/go-boost-utils v1.6.0/go.mod h1:fL9Jc738zFENkbn5HNnVzIfuRcvCO1djlT/ylyT34Zw=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down Expand Up @@ -918,8 +920,6 @@ github.com/lib/pq v1.10.8/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo=
github.com/lthibault/log v1.2.3 h1:6RVcEA7BhlNIxTaxhfNP5JJVxwFuwNCR8U4b+bQPk1Y=
github.com/lthibault/log v1.2.3/go.mod h1:uHlA0dSn/l30OLMOyauHFhwnNXt8LY56tDpzljuU21U=
github.com/lukanus/blst v0.0.0-20221108180119-1ce3e6f62936 h1:++wcCGHcWBfe/dj3aAuAL5l8YEedavuAQeAz7n5gBrU=
github.com/lukanus/blst v0.0.0-20221108180119-1ce3e6f62936/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
Expand Down
6 changes: 4 additions & 2 deletions verify/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package verify

import (
"context"
"errors"
"fmt"

"github.com/flashbots/go-boost-utils/bls"
"github.com/lthibault/log"
"github.com/prometheus/client_golang/prometheus"
)

var ErrInvalidSignature = errors.New("invalid signature")

type VerificationManager struct {
VerifySubmitBlockCh chan Request
VerifyRegisterValidatorCh chan Request
Expand Down Expand Up @@ -121,7 +123,7 @@ func verifyCheck(o prometheus.Observer, v Request) (err error) {
func verifyUnit(id int, msg [32]byte, sigBytes [96]byte, pkBytes [48]byte) Resp {
ok, err := VerifySignatureBytes(msg, sigBytes[:], pkBytes[:])
if err == nil && !ok {
err = bls.ErrInvalidSignature
err = ErrInvalidSignature
}
return Resp{Err: err, ID: id}
}

0 comments on commit e221f97

Please sign in to comment.