From 0a66445c834882fa636540cfb7c5bf1cb89e5a48 Mon Sep 17 00:00:00 2001 From: hanish gogada Date: Sun, 25 Feb 2024 01:20:32 +0100 Subject: [PATCH 01/13] feat(eddsa): Added EDDSA crypto module Added EDDSA(25519 curve) crypto module to the framework. Current design for eddsa module is messy, this PR is a starting point to take this activity. Need to discuss with others. --- .vscode/dict.txt | 1 + crypto/crypto_test.go | 3 + crypto/ecdsa/ecdsa.go | 92 ++-------- crypto/eddsa/eddsa.go | 179 +++++++++++++++++++ crypto/keygen/keygen.go | 40 ++++- crypto/multi_signature.go | 94 ++++++++++ internal/orchestration/orchestration_test.go | 3 + internal/orchestration/worker.go | 1 + internal/proto/hotstuffpb/convert.go | 53 ++++-- internal/proto/hotstuffpb/hotstuff.proto | 19 +- internal/testutil/testutil.go | 10 ++ 11 files changed, 389 insertions(+), 106 deletions(-) create mode 100644 crypto/eddsa/eddsa.go create mode 100644 crypto/multi_signature.go diff --git a/.vscode/dict.txt b/.vscode/dict.txt index e8ec8629..64194972 100644 --- a/.vscode/dict.txt +++ b/.vscode/dict.txt @@ -14,6 +14,7 @@ coverpkg coverprofile Debugf durationpb +eddsa emptypb Erevik Fangyu diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index 56814a4f..af216e79 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -10,6 +10,7 @@ import ( "github.com/relab/hotstuff/crypto" "github.com/relab/hotstuff/crypto/bls12" "github.com/relab/hotstuff/crypto/ecdsa" + "github.com/relab/hotstuff/crypto/eddsa" "github.com/relab/hotstuff/internal/testutil" ) @@ -167,6 +168,8 @@ func runAll(t *testing.T, run func(*testing.T, setupFunc)) { t.Helper() t.Run("Ecdsa", func(t *testing.T) { run(t, setup(NewBase(ecdsa.New), testutil.GenerateECDSAKey)) }) t.Run("Cache+Ecdsa", func(t *testing.T) { run(t, setup(NewCache(ecdsa.New), testutil.GenerateECDSAKey)) }) + t.Run("Eddsa", func(t *testing.T) { run(t, setup(NewBase(eddsa.New), testutil.GenerateEDDSAKey)) }) + t.Run("Cache+Eddsa", func(t *testing.T) { run(t, setup(NewCache(eddsa.New), testutil.GenerateEDDSAKey)) }) t.Run("BLS12-381", func(t *testing.T) { run(t, setup(NewBase(bls12.New), testutil.GenerateBLS12Key)) }) t.Run("Cache+BLS12-381", func(t *testing.T) { run(t, setup(NewCache(bls12.New), testutil.GenerateBLS12Key)) }) } diff --git a/crypto/ecdsa/ecdsa.go b/crypto/ecdsa/ecdsa.go index a67facc3..ff91b788 100644 --- a/crypto/ecdsa/ecdsa.go +++ b/crypto/ecdsa/ecdsa.go @@ -1,4 +1,4 @@ -// Package ecdsa provides a crypto implementation for HotStuff using Go's 'crypto/ecdsa' package. +// Package ecdsa supports spec-k256 curve signature package ecdsa import ( @@ -12,7 +12,6 @@ import ( "github.com/relab/hotstuff/crypto" "github.com/relab/hotstuff/logging" "github.com/relab/hotstuff/modules" - "golang.org/x/exp/slices" ) func init() { @@ -61,79 +60,6 @@ func (sig Signature) ToBytes() []byte { return b } -// MultiSignature is a set of (partial) signatures. -type MultiSignature map[hotstuff.ID]*Signature - -// RestoreMultiSignature should only be used to restore an existing threshold signature from a set of signatures. -func RestoreMultiSignature(signatures []*Signature) MultiSignature { - sig := make(MultiSignature, len(signatures)) - for _, s := range signatures { - sig[s.signer] = s - } - return sig -} - -// ToBytes returns the object as bytes. -func (sig MultiSignature) ToBytes() []byte { - var b []byte - // sort by ID to make it deterministic - order := make([]hotstuff.ID, 0, len(sig)) - for _, signature := range sig { - order = append(order, signature.signer) - } - slices.Sort(order) - for _, id := range order { - b = append(b, sig[id].ToBytes()...) - } - return b -} - -// Participants returns the IDs of replicas who participated in the threshold signature. -func (sig MultiSignature) Participants() hotstuff.IDSet { - return sig -} - -// Add adds an ID to the set. -func (sig MultiSignature) Add(_ hotstuff.ID) { - panic("not implemented") -} - -// Contains returns true if the set contains the ID. -func (sig MultiSignature) Contains(id hotstuff.ID) bool { - _, ok := sig[id] - return ok -} - -// ForEach calls f for each ID in the set. -func (sig MultiSignature) ForEach(f func(hotstuff.ID)) { - for id := range sig { - f(id) - } -} - -// RangeWhile calls f for each ID in the set until f returns false. -func (sig MultiSignature) RangeWhile(f func(hotstuff.ID) bool) { - for id := range sig { - if !f(id) { - break - } - } -} - -// Len returns the number of entries in the set. -func (sig MultiSignature) Len() int { - return len(sig) -} - -func (sig MultiSignature) String() string { - return hotstuff.IDSetToString(sig) -} - -var ( - _ hotstuff.QuorumSignature = (*MultiSignature)(nil) - _ hotstuff.IDSet = (*MultiSignature)(nil) -) - type ecdsaBase struct { configuration modules.Configuration logger logging.Logger @@ -166,7 +92,7 @@ func (ec *ecdsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, e if err != nil { return nil, fmt.Errorf("ecdsa: sign failed: %w", err) } - return MultiSignature{ec.opts.ID(): &Signature{ + return crypto.MultiSignature{ec.opts.ID(): &Signature{ r: r, s: s, signer: ec.opts.ID(), @@ -179,10 +105,10 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q return nil, crypto.ErrCombineMultiple } - ts := make(MultiSignature) + ts := make(crypto.MultiSignature) for _, sig1 := range signatures { - if sig2, ok := sig1.(MultiSignature); ok { + if sig2, ok := sig1.(crypto.MultiSignature); ok { for id, s := range sig2 { if _, ok := ts[id]; ok { return nil, crypto.ErrCombineOverlap @@ -199,7 +125,7 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q // Verify verifies the given quorum signature against the message. func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { - s, ok := signature.(MultiSignature) + s, ok := signature.(crypto.MultiSignature) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -215,7 +141,7 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) for _, sig := range s { go func(sig *Signature, hash hotstuff.Hash) { results <- ec.verifySingle(sig, hash) - }(sig, hash) + }(sig.(*Signature), hash) } valid := true @@ -230,7 +156,7 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) // BatchVerify verifies the given quorum signature against the batch of messages. func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { - s, ok := signature.(MultiSignature) + s, ok := signature.(crypto.MultiSignature) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -251,7 +177,7 @@ func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h set[hash] = struct{}{} go func(sig *Signature, hash hotstuff.Hash) { results <- ec.verifySingle(sig, hash) - }(sig, hash) + }(sig.(*Signature), hash) } valid := true @@ -274,3 +200,5 @@ func (ec *ecdsaBase) verifySingle(sig *Signature, hash hotstuff.Hash) bool { pk := replica.PublicKey().(*ecdsa.PublicKey) return ecdsa.Verify(pk, hash[:], sig.R(), sig.S()) } + +var _ crypto.Signature = (*Signature)(nil) diff --git a/crypto/eddsa/eddsa.go b/crypto/eddsa/eddsa.go new file mode 100644 index 00000000..5c59fb3c --- /dev/null +++ b/crypto/eddsa/eddsa.go @@ -0,0 +1,179 @@ +// Package eddsa implements 25519 curve signature +package eddsa + +import ( + "crypto/ed25519" + "crypto/sha256" + + "github.com/relab/hotstuff" + "github.com/relab/hotstuff/crypto" + "github.com/relab/hotstuff/logging" + "github.com/relab/hotstuff/modules" +) + +func init() { + modules.RegisterModule("eddsa", New) +} + +const ( + // PrivateKeyFileType is the PEM type for a private key. + PrivateKeyFileType = "EDDSA PRIVATE KEY" + + // PublicKeyFileType is the PEM type for a public key. + PublicKeyFileType = "EDDSA PUBLIC KEY" +) + +// Signature is an ECDSA signature +type Signature struct { + signer hotstuff.ID + sign []byte +} + +// RestoreSignature restores an existing signature. It should not be used to create new signatures, use Sign instead. +func RestoreSignature(sign []byte, signer hotstuff.ID) *Signature { + return &Signature{signer, sign} +} + +// Signer returns the ID of the replica that generated the signature. +func (sig Signature) Signer() hotstuff.ID { + return sig.signer +} + +// ToBytes returns a raw byte string representation of the signature +func (sig Signature) ToBytes() []byte { + var b []byte + b = append(b, sig.sign...) + return b +} + +type eddsaBase struct { + configuration modules.Configuration + logger logging.Logger + opts *modules.Options +} + +// New returns a new instance of the ECDSA CryptoBase implementation. +func New() modules.CryptoBase { + return &eddsaBase{} +} + +// InitModule gives the module a reference to the Core object. +// It also allows the module to set module options using the OptionsBuilder. +func (ed *eddsaBase) InitModule(mods *modules.Core) { + mods.Get( + &ed.configuration, + &ed.logger, + &ed.opts, + ) +} + +func (ed *eddsaBase) privateKey() ed25519.PrivateKey { + return ed.opts.PrivateKey().(ed25519.PrivateKey) +} + +func (ed *eddsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, err error) { + sign := ed25519.Sign(ed.privateKey(), message) + eddsaSign := &Signature{signer: ed.opts.ID(), sign: sign} + return crypto.MultiSignature{ed.opts.ID(): eddsaSign}, nil +} + +func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.QuorumSignature, error) { + if len(signatures) < 2 { + return nil, crypto.ErrCombineMultiple + } + + ts := make(crypto.MultiSignature) + + for _, sig1 := range signatures { + if sig2, ok := sig1.(crypto.MultiSignature); ok { + for id, s := range sig2 { + if _, ok := ts[id]; ok { + return nil, crypto.ErrCombineOverlap + } + ts[id] = s + } + } else { + ed.logger.Panicf("cannot combine signature of incompatible type %T (expected %T)", sig1, sig2) + } + } + return ts, nil +} + +func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { + s, ok := signature.(crypto.MultiSignature) + if !ok { + ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) + } + n := signature.Participants().Len() + if n == 0 { + return false + } + + results := make(chan bool, n) + + for _, sig := range s { + go func(sig *Signature, msg []byte) { + results <- ed.verifySingle(sig, msg) + }(sig.(*Signature), message) + } + + valid := true + for range s { + if !<-results { + valid = false + } + } + + return valid + +} +func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { + s, ok := signature.(crypto.MultiSignature) + if !ok { + ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) + } + + n := signature.Participants().Len() + if n == 0 { + return false + } + + results := make(chan bool, n) + set := make(map[hotstuff.Hash]struct{}) + for id, sig := range s { + message, ok := batch[id] + if !ok { + return false + } + hash := sha256.Sum256(message) + set[hash] = struct{}{} + go func(sig *Signature, msg []byte) { + results <- ed.verifySingle(sig, msg) + }(sig.(*Signature), message) + } + + valid := true + for range s { + if !<-results { + valid = false + } + } + + // valid if all partial signatures are valid and there are no duplicate messages + return valid && len(set) == len(batch) +} +func (ed *eddsaBase) verifySingle(sig *Signature, message []byte) bool { + replica, ok := ed.configuration.Replica(sig.Signer()) + if !ok { + ed.logger.Warnf("ecdsaBase: got signature from replica whose ID (%d) was not in the config.", sig.Signer()) + return false + } + pk, ok := replica.PublicKey().([]byte) + if !ok { + ed.logger.Infof("ecdsaBase: got public key from replica that was not of type []byte.") + pk = replica.PublicKey().(ed25519.PublicKey) + } + return ed25519.Verify(pk, message, sig.sign) +} + +var _ crypto.Signature = (*Signature)(nil) diff --git a/crypto/keygen/keygen.go b/crypto/keygen/keygen.go index 8ae4480c..211337e7 100644 --- a/crypto/keygen/keygen.go +++ b/crypto/keygen/keygen.go @@ -4,6 +4,7 @@ package keygen import ( "crypto/ecdsa" + "crypto/ed25519" "crypto/elliptic" "crypto/rand" "crypto/x509" @@ -18,6 +19,7 @@ import ( "github.com/relab/hotstuff" "github.com/relab/hotstuff/crypto/bls12" ecdsacrypto "github.com/relab/hotstuff/crypto/ecdsa" + "github.com/relab/hotstuff/crypto/eddsa" ) // GenerateECDSAPrivateKey returns a new ECDSA private key. @@ -29,6 +31,15 @@ func GenerateECDSAPrivateKey() (pk *ecdsa.PrivateKey, err error) { return pk, nil } +// GenerateED25519Key generates 25519 key +func GenerateED25519Key() (pub ed25519.PublicKey, pk ed25519.PrivateKey, err error) { + pub, pk, err = ed25519.GenerateKey(rand.Reader) + if err != nil { + return nil, nil, err + } + return pub, pk, nil +} + // GenerateRootCert generates a self-signed TLS certificate to act as a CA. func GenerateRootCert(privateKey *ecdsa.PrivateKey) (cert *x509.Certificate, err error) { sn, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) @@ -104,6 +115,10 @@ func PrivateKeyToPEM(key hotstuff.PrivateKey) ([]byte, error) { case *bls12.PrivateKey: marshalled = k.ToBytes() keyType = bls12.PrivateKeyFileType + case ed25519.PrivateKey: + marshalled = make([]byte, ed25519.PrivateKeySize) + copy(marshalled, k) + keyType = eddsa.PrivateKeyFileType } b := &pem.Block{ Type: keyType, @@ -150,6 +165,10 @@ func PublicKeyToPEM(key hotstuff.PublicKey) ([]byte, error) { case *bls12.PublicKey: marshalled = k.ToBytes() keyType = bls12.PublicKeyFileType + case ed25519.PublicKey: + marshalled = make([]byte, ed25519.PublicKeySize) + copy(marshalled, k) + keyType = eddsa.PublicKeyFileType } b := &pem.Block{ @@ -213,8 +232,11 @@ func ParsePrivateKey(buf []byte) (key hotstuff.PrivateKey, err error) { k := &bls12.PrivateKey{} k.FromBytes(b.Bytes) key = k + case eddsa.PrivateKeyFileType: + k := ed25519.NewKeyFromSeed(b.Bytes[:32]) + key = k default: - return nil, fmt.Errorf("file type did not match any known types") + return nil, fmt.Errorf("file type did not match any known types %v", b.Type) } if err != nil { return nil, fmt.Errorf("failed to parse key: %w", err) @@ -247,8 +269,12 @@ func ParsePublicKey(buf []byte) (key hotstuff.PublicKey, err error) { return nil, err } key = k + case eddsa.PublicKeyFileType: + k := make([]byte, ed25519.PublicKeySize) + copy(k, b.Bytes) + key = k default: - return nil, fmt.Errorf("file type did not match any known types") + return nil, fmt.Errorf("file type did not match any known types %v", b.Type) } if err != nil { return nil, fmt.Errorf("failed to parse key: %w", err) @@ -316,14 +342,22 @@ func GenerateKeyChain(id hotstuff.ID, validFor []string, crypto string, ca *x509 certPEM := CertToPEM(cert) var privateKey hotstuff.PrivateKey + var publicKey hotstuff.PublicKey switch crypto { case "ecdsa": privateKey = ecdsaKey + publicKey = privateKey.Public() case "bls12": privateKey, err = bls12.GeneratePrivateKey() if err != nil { return KeyChain{}, fmt.Errorf("failed to generate bls12-381 private key: %w", err) } + publicKey = privateKey.Public() + case "eddsa": + publicKey, privateKey, err = GenerateED25519Key() + if err != nil { + return KeyChain{}, fmt.Errorf("failed to generate ed25519 key: %w", err) + } default: return KeyChain{}, fmt.Errorf("unknown crypto implementation: %s", crypto) } @@ -333,7 +367,7 @@ func GenerateKeyChain(id hotstuff.ID, validFor []string, crypto string, ca *x509 return KeyChain{}, err } - publicKeyPEM, err := PublicKeyToPEM(privateKey.Public()) + publicKeyPEM, err := PublicKeyToPEM(publicKey) if err != nil { return KeyChain{}, err } diff --git a/crypto/multi_signature.go b/crypto/multi_signature.go new file mode 100644 index 00000000..c6c92069 --- /dev/null +++ b/crypto/multi_signature.go @@ -0,0 +1,94 @@ +package crypto + +import ( + "reflect" + + "github.com/relab/hotstuff" + "golang.org/x/exp/slices" +) + +// Signature is the individual component in MultiSignature +type Signature interface { + Signer() hotstuff.ID + ToBytes() []byte +} + +// MultiSignature is a set of (partial) signatures. +type MultiSignature map[hotstuff.ID]Signature + +// RestoreMultiSignature should only be used to restore an existing threshold signature from a set of signatures. +func RestoreMultiSignature(signatures []Signature) MultiSignature { + sig := make(MultiSignature, len(signatures)) + for _, s := range signatures { + sig[s.Signer()] = s + } + return sig +} + +// ToBytes returns the object as bytes. +func (sig MultiSignature) ToBytes() []byte { + var b []byte + // sort by ID to make it deterministic + order := make([]hotstuff.ID, 0, len(sig)) + for _, signature := range sig { + order = append(order, signature.Signer()) + } + slices.Sort(order) + for _, id := range order { + b = append(b, sig[id].ToBytes()...) + } + return b +} + +// Participants returns the IDs of replicas who participated in the threshold signature. +func (sig MultiSignature) Participants() hotstuff.IDSet { + return sig +} + +// Add adds an ID to the set. +func (sig MultiSignature) Add(_ hotstuff.ID) { + panic("not implemented") +} + +// Contains returns true if the set contains the ID. +func (sig MultiSignature) Contains(id hotstuff.ID) bool { + _, ok := sig[id] + return ok +} + +// ForEach calls f for each ID in the set. +func (sig MultiSignature) ForEach(f func(hotstuff.ID)) { + for id := range sig { + f(id) + } +} + +// RangeWhile calls f for each ID in the set until f returns false. +func (sig MultiSignature) RangeWhile(f func(hotstuff.ID) bool) { + for id := range sig { + if !f(id) { + break + } + } +} + +// Len returns the number of entries in the set. +func (sig MultiSignature) Len() int { + return len(sig) +} + +func (sig MultiSignature) String() string { + return hotstuff.IDSetToString(sig) +} + +func (sig MultiSignature) Type() reflect.Type { + for _, s := range sig { + return reflect.TypeOf(s) + } + return nil +} + +var ( + _ hotstuff.QuorumSignature = (*MultiSignature)(nil) + _ hotstuff.IDSet = (*MultiSignature)(nil) +) diff --git a/internal/orchestration/orchestration_test.go b/internal/orchestration/orchestration_test.go index 14ec5cae..2e17eb07 100644 --- a/internal/orchestration/orchestration_test.go +++ b/internal/orchestration/orchestration_test.go @@ -78,6 +78,9 @@ func TestOrchestration(t *testing.T) { t.Run("Fast-HotStuff+BLS12", func(t *testing.T) { run("fasthotstuff", "bls12", nil, "") }) t.Run("Simple-HotStuff+ECDSA", func(t *testing.T) { run("simplehotstuff", "ecdsa", nil, "") }) t.Run("Simple-HotStuff+BLS12", func(t *testing.T) { run("simplehotstuff", "bls12", nil, "") }) + t.Run("ChainedHotStuff+EDDSA", func(t *testing.T) { run("chainedhotstuff", "eddsa", nil, "") }) + t.Run("Fast-HotStuff+EDDSA", func(t *testing.T) { run("fasthotstuff", "eddsa", nil, "") }) + t.Run("Simple-HotStuff+EDDSA", func(t *testing.T) { run("simplehotstuff", "eddsa", nil, "") }) // handel mods := []string{"handel"} diff --git a/internal/orchestration/worker.go b/internal/orchestration/worker.go index 04183561..290d66d6 100644 --- a/internal/orchestration/worker.go +++ b/internal/orchestration/worker.go @@ -39,6 +39,7 @@ import ( _ "github.com/relab/hotstuff/consensus/simplehotstuff" _ "github.com/relab/hotstuff/crypto/bls12" _ "github.com/relab/hotstuff/crypto/ecdsa" + _ "github.com/relab/hotstuff/crypto/eddsa" _ "github.com/relab/hotstuff/handel" _ "github.com/relab/hotstuff/leaderrotation" ) diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 3f6124c7..3256dd79 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -8,28 +8,42 @@ import ( "github.com/relab/hotstuff/crypto" "github.com/relab/hotstuff/crypto/bls12" "github.com/relab/hotstuff/crypto/ecdsa" + "github.com/relab/hotstuff/crypto/eddsa" ) // QuorumSignatureToProto converts a threshold signature to a protocol buffers message. func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { signature := &QuorumSignature{} - switch s := sig.(type) { - case ecdsa.MultiSignature: - sigs := make([]*ECDSASignature, 0, len(s)) - for _, p := range s { - sigs = append(sigs, &ECDSASignature{ - Signer: uint32(p.Signer()), - R: p.R().Bytes(), - S: p.S().Bytes(), - }) + switch ms := sig.(type) { + case crypto.MultiSignature: + ECDSASigs := make([]*ECDSASignature, 0, sig.Participants().Len()) + EDDSASigs := make([]*EDDSASignature, 0, sig.Participants().Len()) + for _, p := range ms { + switch s := p.(type) { + case *ecdsa.Signature: + ECDSASigs = append(ECDSASigs, &ECDSASignature{ + Signer: uint32(s.Signer()), + R: s.R().Bytes(), + S: s.S().Bytes(), + }) + case *eddsa.Signature: + EDDSASigs = append(EDDSASigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) + } } - signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ - Sigs: sigs, - }} + if len(ECDSASigs) > 0 { + signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ + Sigs: ECDSASigs, + }} + } else { + signature.Sig = &QuorumSignature_EDDSASigs{EDDSASigs: &EDDSAMultiSignature{ + Sigs: EDDSASigs, + }} + } + case *bls12.AggregateSignature: signature.Sig = &QuorumSignature_BLS12Sig{BLS12Sig: &BLS12AggregateSignature{ - Sig: s.ToBytes(), - Participants: s.Bitfield().Bytes(), + Sig: ms.ToBytes(), + Participants: ms.Bitfield().Bytes(), }} } return signature @@ -38,7 +52,7 @@ func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { // QuorumSignatureFromProto converts a protocol buffers message to a threshold signature. func QuorumSignatureFromProto(sig *QuorumSignature) hotstuff.QuorumSignature { if signature := sig.GetECDSASigs(); signature != nil { - sigs := make([]*ecdsa.Signature, len(signature.GetSigs())) + sigs := make([]crypto.Signature, len(signature.GetSigs())) for i, sig := range signature.GetSigs() { r := new(big.Int) r.SetBytes(sig.GetR()) @@ -46,7 +60,14 @@ func QuorumSignatureFromProto(sig *QuorumSignature) hotstuff.QuorumSignature { s.SetBytes(sig.GetS()) sigs[i] = ecdsa.RestoreSignature(r, s, hotstuff.ID(sig.GetSigner())) } - return ecdsa.RestoreMultiSignature(sigs) + return crypto.RestoreMultiSignature(sigs) + } + if signature := sig.GetEDDSASigs(); signature != nil { + sigs := make([]crypto.Signature, len(signature.GetSigs())) + for i, sig := range signature.GetSigs() { + sigs[i] = eddsa.RestoreSignature(sig.Sig, hotstuff.ID(sig.GetSigner())) + } + return crypto.RestoreMultiSignature(sigs) } if signature := sig.GetBLS12Sig(); signature != nil { aggSig, err := bls12.RestoreAggregateSignature(signature.GetSig(), crypto.BitfieldFromBytes(signature.GetParticipants())) diff --git a/internal/proto/hotstuffpb/hotstuff.proto b/internal/proto/hotstuffpb/hotstuff.proto index 4d605c0b..27cc8739 100644 --- a/internal/proto/hotstuffpb/hotstuff.proto +++ b/internal/proto/hotstuffpb/hotstuff.proto @@ -30,7 +30,7 @@ service Hotstuff { message Proposal { Block Block = 1; - optional AggQC AggQC = 2; + AggQC AggQC = 2; } message BlockHash { bytes Hash = 1; } @@ -51,10 +51,16 @@ message ECDSASignature { message BLS12Signature { bytes Sig = 1; } +message EDDSASignature { + uint32 Signer = 1; + bytes Sig = 2; + } + message Signature { oneof Sig { ECDSASignature ECDSASig = 1; BLS12Signature BLS12Sig = 2; + EDDSASignature EDDSASig = 3; } } @@ -65,6 +71,8 @@ message PartialCert { message ECDSAMultiSignature { repeated ECDSASignature Sigs = 1; } +message EDDSAMultiSignature {repeated EDDSASignature Sigs = 1;} + message BLS12AggregateSignature { bytes Sig = 1; bytes participants = 2; @@ -74,6 +82,7 @@ message QuorumSignature { oneof Sig { ECDSAMultiSignature ECDSASigs = 1; BLS12AggregateSignature BLS12Sig = 2; + EDDSAMultiSignature EDDSASigs =3; } } @@ -92,13 +101,13 @@ message TimeoutMsg { uint64 View = 1; SyncInfo SyncInfo = 2; QuorumSignature ViewSig = 3; - optional QuorumSignature MsgSig = 4; + QuorumSignature MsgSig = 4; } message SyncInfo { - optional QuorumCert QC = 1; - optional TimeoutCert TC = 2; - optional AggQC AggQC = 3; + QuorumCert QC = 1; + TimeoutCert TC = 2; + AggQC AggQC = 3; } message AggQC { diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index ed0ecaf8..c42ea030 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -250,6 +250,16 @@ func GenerateECDSAKey(t *testing.T) hotstuff.PrivateKey { return key } +// GenerateEDDSAKey generates an ECDSA private key for use in tests. +func GenerateEDDSAKey(t *testing.T) hotstuff.PrivateKey { + t.Helper() + _, key, err := keygen.GenerateED25519Key() + if err != nil { + t.Fatalf("Failed to generate private key: %v", err) + } + return key +} + // GenerateBLS12Key generates a BLS12-381 private key for use in tests. func GenerateBLS12Key(t *testing.T) hotstuff.PrivateKey { t.Helper() From 6c6e63d6d18be91b5665cd5695e08d18d885c8e2 Mon Sep 17 00:00:00 2001 From: hanish gogada Date: Sun, 25 Feb 2024 01:30:05 +0100 Subject: [PATCH 02/13] fix: missed the proto files --- internal/proto/hotstuffpb/hotstuff.pb.go | 617 +++++++++++------- .../proto/hotstuffpb/hotstuff_gorums.pb.go | 12 +- 2 files changed, 399 insertions(+), 230 deletions(-) diff --git a/internal/proto/hotstuffpb/hotstuff.pb.go b/internal/proto/hotstuffpb/hotstuff.pb.go index e1226cab..b6cf4c5b 100644 --- a/internal/proto/hotstuffpb/hotstuff.pb.go +++ b/internal/proto/hotstuffpb/hotstuff.pb.go @@ -1,16 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 -// protoc v3.21.4 +// protoc-gen-go v1.32.0 +// protoc v3.12.4 // source: internal/proto/hotstuffpb/hotstuff.proto package hotstuffpb import ( + empty "github.com/golang/protobuf/ptypes/empty" _ "github.com/relab/gorums" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) @@ -28,7 +28,7 @@ type Proposal struct { unknownFields protoimpl.UnknownFields Block *Block `protobuf:"bytes,1,opt,name=Block,proto3" json:"Block,omitempty"` - AggQC *AggQC `protobuf:"bytes,2,opt,name=AggQC,proto3,oneof" json:"AggQC,omitempty"` + AggQC *AggQC `protobuf:"bytes,2,opt,name=AggQC,proto3" json:"AggQC,omitempty"` } func (x *Proposal) Reset() { @@ -313,6 +313,61 @@ func (x *BLS12Signature) GetSig() []byte { return nil } +type EDDSASignature struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Signer uint32 `protobuf:"varint,1,opt,name=Signer,proto3" json:"Signer,omitempty"` + Sig []byte `protobuf:"bytes,2,opt,name=Sig,proto3" json:"Sig,omitempty"` +} + +func (x *EDDSASignature) Reset() { + *x = EDDSASignature{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EDDSASignature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EDDSASignature) ProtoMessage() {} + +func (x *EDDSASignature) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EDDSASignature.ProtoReflect.Descriptor instead. +func (*EDDSASignature) Descriptor() ([]byte, []int) { + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{5} +} + +func (x *EDDSASignature) GetSigner() uint32 { + if x != nil { + return x.Signer + } + return 0 +} + +func (x *EDDSASignature) GetSig() []byte { + if x != nil { + return x.Sig + } + return nil +} + type Signature struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -321,13 +376,14 @@ type Signature struct { // Types that are assignable to Sig: // *Signature_ECDSASig // *Signature_BLS12Sig + // *Signature_EDDSASig Sig isSignature_Sig `protobuf_oneof:"Sig"` } func (x *Signature) Reset() { *x = Signature{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[5] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -340,7 +396,7 @@ func (x *Signature) String() string { func (*Signature) ProtoMessage() {} func (x *Signature) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[5] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -353,7 +409,7 @@ func (x *Signature) ProtoReflect() protoreflect.Message { // Deprecated: Use Signature.ProtoReflect.Descriptor instead. func (*Signature) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{5} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{6} } func (m *Signature) GetSig() isSignature_Sig { @@ -377,6 +433,13 @@ func (x *Signature) GetBLS12Sig() *BLS12Signature { return nil } +func (x *Signature) GetEDDSASig() *EDDSASignature { + if x, ok := x.GetSig().(*Signature_EDDSASig); ok { + return x.EDDSASig + } + return nil +} + type isSignature_Sig interface { isSignature_Sig() } @@ -389,10 +452,16 @@ type Signature_BLS12Sig struct { BLS12Sig *BLS12Signature `protobuf:"bytes,2,opt,name=BLS12Sig,proto3,oneof"` } +type Signature_EDDSASig struct { + EDDSASig *EDDSASignature `protobuf:"bytes,3,opt,name=EDDSASig,proto3,oneof"` +} + func (*Signature_ECDSASig) isSignature_Sig() {} func (*Signature_BLS12Sig) isSignature_Sig() {} +func (*Signature_EDDSASig) isSignature_Sig() {} + type PartialCert struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -405,7 +474,7 @@ type PartialCert struct { func (x *PartialCert) Reset() { *x = PartialCert{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[6] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -418,7 +487,7 @@ func (x *PartialCert) String() string { func (*PartialCert) ProtoMessage() {} func (x *PartialCert) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[6] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -431,7 +500,7 @@ func (x *PartialCert) ProtoReflect() protoreflect.Message { // Deprecated: Use PartialCert.ProtoReflect.Descriptor instead. func (*PartialCert) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{6} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{7} } func (x *PartialCert) GetSig() *QuorumSignature { @@ -459,7 +528,7 @@ type ECDSAMultiSignature struct { func (x *ECDSAMultiSignature) Reset() { *x = ECDSAMultiSignature{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[7] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -472,7 +541,7 @@ func (x *ECDSAMultiSignature) String() string { func (*ECDSAMultiSignature) ProtoMessage() {} func (x *ECDSAMultiSignature) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[7] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -485,7 +554,7 @@ func (x *ECDSAMultiSignature) ProtoReflect() protoreflect.Message { // Deprecated: Use ECDSAMultiSignature.ProtoReflect.Descriptor instead. func (*ECDSAMultiSignature) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{7} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{8} } func (x *ECDSAMultiSignature) GetSigs() []*ECDSASignature { @@ -495,6 +564,53 @@ func (x *ECDSAMultiSignature) GetSigs() []*ECDSASignature { return nil } +type EDDSAMultiSignature struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sigs []*EDDSASignature `protobuf:"bytes,1,rep,name=Sigs,proto3" json:"Sigs,omitempty"` +} + +func (x *EDDSAMultiSignature) Reset() { + *x = EDDSAMultiSignature{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EDDSAMultiSignature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EDDSAMultiSignature) ProtoMessage() {} + +func (x *EDDSAMultiSignature) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EDDSAMultiSignature.ProtoReflect.Descriptor instead. +func (*EDDSAMultiSignature) Descriptor() ([]byte, []int) { + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{9} +} + +func (x *EDDSAMultiSignature) GetSigs() []*EDDSASignature { + if x != nil { + return x.Sigs + } + return nil +} + type BLS12AggregateSignature struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -507,7 +623,7 @@ type BLS12AggregateSignature struct { func (x *BLS12AggregateSignature) Reset() { *x = BLS12AggregateSignature{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[8] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -520,7 +636,7 @@ func (x *BLS12AggregateSignature) String() string { func (*BLS12AggregateSignature) ProtoMessage() {} func (x *BLS12AggregateSignature) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[8] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -533,7 +649,7 @@ func (x *BLS12AggregateSignature) ProtoReflect() protoreflect.Message { // Deprecated: Use BLS12AggregateSignature.ProtoReflect.Descriptor instead. func (*BLS12AggregateSignature) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{8} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{10} } func (x *BLS12AggregateSignature) GetSig() []byte { @@ -558,13 +674,14 @@ type QuorumSignature struct { // Types that are assignable to Sig: // *QuorumSignature_ECDSASigs // *QuorumSignature_BLS12Sig + // *QuorumSignature_EDDSASigs Sig isQuorumSignature_Sig `protobuf_oneof:"Sig"` } func (x *QuorumSignature) Reset() { *x = QuorumSignature{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[9] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -577,7 +694,7 @@ func (x *QuorumSignature) String() string { func (*QuorumSignature) ProtoMessage() {} func (x *QuorumSignature) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[9] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -590,7 +707,7 @@ func (x *QuorumSignature) ProtoReflect() protoreflect.Message { // Deprecated: Use QuorumSignature.ProtoReflect.Descriptor instead. func (*QuorumSignature) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{9} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{11} } func (m *QuorumSignature) GetSig() isQuorumSignature_Sig { @@ -614,6 +731,13 @@ func (x *QuorumSignature) GetBLS12Sig() *BLS12AggregateSignature { return nil } +func (x *QuorumSignature) GetEDDSASigs() *EDDSAMultiSignature { + if x, ok := x.GetSig().(*QuorumSignature_EDDSASigs); ok { + return x.EDDSASigs + } + return nil +} + type isQuorumSignature_Sig interface { isQuorumSignature_Sig() } @@ -626,10 +750,16 @@ type QuorumSignature_BLS12Sig struct { BLS12Sig *BLS12AggregateSignature `protobuf:"bytes,2,opt,name=BLS12Sig,proto3,oneof"` } +type QuorumSignature_EDDSASigs struct { + EDDSASigs *EDDSAMultiSignature `protobuf:"bytes,3,opt,name=EDDSASigs,proto3,oneof"` +} + func (*QuorumSignature_ECDSASigs) isQuorumSignature_Sig() {} func (*QuorumSignature_BLS12Sig) isQuorumSignature_Sig() {} +func (*QuorumSignature_EDDSASigs) isQuorumSignature_Sig() {} + type QuorumCert struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -643,7 +773,7 @@ type QuorumCert struct { func (x *QuorumCert) Reset() { *x = QuorumCert{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[10] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -656,7 +786,7 @@ func (x *QuorumCert) String() string { func (*QuorumCert) ProtoMessage() {} func (x *QuorumCert) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[10] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -669,7 +799,7 @@ func (x *QuorumCert) ProtoReflect() protoreflect.Message { // Deprecated: Use QuorumCert.ProtoReflect.Descriptor instead. func (*QuorumCert) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{10} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{12} } func (x *QuorumCert) GetSig() *QuorumSignature { @@ -705,7 +835,7 @@ type TimeoutCert struct { func (x *TimeoutCert) Reset() { *x = TimeoutCert{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[11] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -718,7 +848,7 @@ func (x *TimeoutCert) String() string { func (*TimeoutCert) ProtoMessage() {} func (x *TimeoutCert) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[11] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -731,7 +861,7 @@ func (x *TimeoutCert) ProtoReflect() protoreflect.Message { // Deprecated: Use TimeoutCert.ProtoReflect.Descriptor instead. func (*TimeoutCert) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{11} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{13} } func (x *TimeoutCert) GetSig() *QuorumSignature { @@ -756,13 +886,13 @@ type TimeoutMsg struct { View uint64 `protobuf:"varint,1,opt,name=View,proto3" json:"View,omitempty"` SyncInfo *SyncInfo `protobuf:"bytes,2,opt,name=SyncInfo,proto3" json:"SyncInfo,omitempty"` ViewSig *QuorumSignature `protobuf:"bytes,3,opt,name=ViewSig,proto3" json:"ViewSig,omitempty"` - MsgSig *QuorumSignature `protobuf:"bytes,4,opt,name=MsgSig,proto3,oneof" json:"MsgSig,omitempty"` + MsgSig *QuorumSignature `protobuf:"bytes,4,opt,name=MsgSig,proto3" json:"MsgSig,omitempty"` } func (x *TimeoutMsg) Reset() { *x = TimeoutMsg{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[12] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -775,7 +905,7 @@ func (x *TimeoutMsg) String() string { func (*TimeoutMsg) ProtoMessage() {} func (x *TimeoutMsg) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[12] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -788,7 +918,7 @@ func (x *TimeoutMsg) ProtoReflect() protoreflect.Message { // Deprecated: Use TimeoutMsg.ProtoReflect.Descriptor instead. func (*TimeoutMsg) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{12} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{14} } func (x *TimeoutMsg) GetView() uint64 { @@ -824,15 +954,15 @@ type SyncInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - QC *QuorumCert `protobuf:"bytes,1,opt,name=QC,proto3,oneof" json:"QC,omitempty"` - TC *TimeoutCert `protobuf:"bytes,2,opt,name=TC,proto3,oneof" json:"TC,omitempty"` - AggQC *AggQC `protobuf:"bytes,3,opt,name=AggQC,proto3,oneof" json:"AggQC,omitempty"` + QC *QuorumCert `protobuf:"bytes,1,opt,name=QC,proto3" json:"QC,omitempty"` + TC *TimeoutCert `protobuf:"bytes,2,opt,name=TC,proto3" json:"TC,omitempty"` + AggQC *AggQC `protobuf:"bytes,3,opt,name=AggQC,proto3" json:"AggQC,omitempty"` } func (x *SyncInfo) Reset() { *x = SyncInfo{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[13] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -845,7 +975,7 @@ func (x *SyncInfo) String() string { func (*SyncInfo) ProtoMessage() {} func (x *SyncInfo) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[13] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -858,7 +988,7 @@ func (x *SyncInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncInfo.ProtoReflect.Descriptor instead. func (*SyncInfo) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{13} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{15} } func (x *SyncInfo) GetQC() *QuorumCert { @@ -895,7 +1025,7 @@ type AggQC struct { func (x *AggQC) Reset() { *x = AggQC{} if protoimpl.UnsafeEnabled { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[14] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -908,7 +1038,7 @@ func (x *AggQC) String() string { func (*AggQC) ProtoMessage() {} func (x *AggQC) ProtoReflect() protoreflect.Message { - mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[14] + mi := &file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -921,7 +1051,7 @@ func (x *AggQC) ProtoReflect() protoreflect.Message { // Deprecated: Use AggQC.ProtoReflect.Descriptor instead. func (*AggQC) Descriptor() ([]byte, []int) { - return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{14} + return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP(), []int{16} } func (x *AggQC) GetQCs() map[uint32]*QuorumCert { @@ -954,137 +1084,148 @@ var file_internal_proto_hotstuffpb_hotstuff_proto_rawDesc = []byte{ 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x6b, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x27, 0x0a, + 0x6f, 0x22, 0x5c, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x27, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2c, 0x0a, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x18, + 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x27, 0x0a, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, - 0x70, 0x62, 0x2e, 0x41, 0x67, 0x67, 0x51, 0x43, 0x48, 0x00, 0x52, 0x05, 0x41, 0x67, 0x67, 0x51, - 0x43, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x41, 0x67, 0x67, 0x51, 0x43, 0x22, 0x1f, - 0x0a, 0x09, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x48, - 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x48, 0x61, 0x73, 0x68, 0x22, - 0x91, 0x01, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, - 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x50, 0x61, 0x72, 0x65, 0x6e, - 0x74, 0x12, 0x26, 0x0a, 0x02, 0x51, 0x43, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, - 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, - 0x6d, 0x43, 0x65, 0x72, 0x74, 0x52, 0x02, 0x51, 0x43, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, 0x65, - 0x77, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x18, 0x0a, - 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x6f, - 0x73, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x6f, - 0x73, 0x65, 0x72, 0x22, 0x44, 0x0a, 0x0e, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x0c, 0x0a, - 0x01, 0x52, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x01, 0x52, 0x12, 0x0c, 0x0a, 0x01, 0x53, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x01, 0x53, 0x22, 0x22, 0x0a, 0x0e, 0x42, 0x4c, 0x53, - 0x31, 0x32, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x53, - 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x53, 0x69, 0x67, 0x22, 0x86, 0x01, - 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x38, 0x0a, 0x08, 0x45, - 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x43, 0x44, 0x53, 0x41, - 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x08, 0x45, 0x43, 0x44, - 0x53, 0x41, 0x53, 0x69, 0x67, 0x12, 0x38, 0x0a, 0x08, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, - 0x66, 0x66, 0x70, 0x62, 0x2e, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x08, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x42, - 0x05, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x22, 0x50, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, - 0x6c, 0x43, 0x65, 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x70, 0x62, 0x2e, 0x41, 0x67, 0x67, 0x51, 0x43, 0x52, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x22, + 0x1f, 0x0a, 0x09, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, + 0x48, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x48, 0x61, 0x73, 0x68, + 0x22, 0x91, 0x01, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, + 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x50, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x02, 0x51, 0x43, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, + 0x75, 0x6d, 0x43, 0x65, 0x72, 0x74, 0x52, 0x02, 0x51, 0x43, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, + 0x65, 0x77, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x18, + 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x65, 0x72, 0x22, 0x44, 0x0a, 0x0e, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x0c, + 0x0a, 0x01, 0x52, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x01, 0x52, 0x12, 0x0c, 0x0a, 0x01, + 0x53, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x01, 0x53, 0x22, 0x22, 0x0a, 0x0e, 0x42, 0x4c, + 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x53, 0x69, 0x67, 0x22, 0x3a, + 0x0a, 0x0e, 0x45, 0x44, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x53, 0x69, 0x67, 0x22, 0xc0, 0x01, 0x0a, 0x09, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x38, 0x0a, 0x08, 0x45, 0x43, 0x44, 0x53, + 0x41, 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, 0x6f, 0x74, + 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x08, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, + 0x69, 0x67, 0x12, 0x38, 0x0a, 0x08, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, + 0x62, 0x2e, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x48, 0x00, 0x52, 0x08, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x12, 0x38, 0x0a, 0x08, + 0x45, 0x44, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x44, 0x44, 0x53, + 0x41, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x08, 0x45, 0x44, + 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x42, 0x05, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x22, 0x50, 0x0a, + 0x0b, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x43, 0x65, 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x03, + 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, + 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x03, 0x53, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x48, + 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x48, 0x61, 0x73, 0x68, 0x22, + 0x45, 0x0a, 0x13, 0x45, 0x43, 0x44, 0x53, 0x41, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, + 0x62, 0x2e, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x52, 0x04, 0x53, 0x69, 0x67, 0x73, 0x22, 0x45, 0x0a, 0x13, 0x45, 0x44, 0x44, 0x53, 0x41, 0x4d, + 0x75, 0x6c, 0x74, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2e, 0x0a, + 0x04, 0x53, 0x69, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, 0x6f, + 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x44, 0x44, 0x53, 0x41, 0x53, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x04, 0x53, 0x69, 0x67, 0x73, 0x22, 0x4f, 0x0a, + 0x17, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x53, 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x61, + 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x22, 0xdd, + 0x01, 0x0a, 0x0f, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x12, 0x3f, 0x0a, 0x09, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, + 0x70, 0x62, 0x2e, 0x45, 0x43, 0x44, 0x53, 0x41, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x09, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, + 0x69, 0x67, 0x73, 0x12, 0x41, 0x0a, 0x08, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, + 0x70, 0x62, 0x2e, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x08, 0x42, 0x4c, + 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x12, 0x3f, 0x0a, 0x09, 0x45, 0x44, 0x44, 0x53, 0x41, 0x53, + 0x69, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x68, 0x6f, 0x74, 0x73, + 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x44, 0x44, 0x53, 0x41, 0x4d, 0x75, 0x6c, 0x74, + 0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x09, 0x45, 0x44, + 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, 0x73, 0x42, 0x05, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x22, 0x63, + 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x65, 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x03, + 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, + 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x03, 0x53, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x56, + 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, + 0x12, 0x0a, 0x04, 0x48, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x48, + 0x61, 0x73, 0x68, 0x22, 0x50, 0x0a, 0x0b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x43, 0x65, + 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, + 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x03, 0x53, 0x69, + 0x67, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x04, 0x56, 0x69, 0x65, 0x77, 0x22, 0xbe, 0x01, 0x0a, 0x0a, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, + 0x74, 0x4d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x30, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, + 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x68, 0x6f, 0x74, + 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x35, 0x0a, 0x07, 0x56, 0x69, + 0x65, 0x77, 0x53, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, + 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x07, 0x56, 0x69, 0x65, 0x77, 0x53, 0x69, + 0x67, 0x12, 0x33, 0x0a, 0x06, 0x4d, 0x73, 0x67, 0x53, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, + 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x06, + 0x4d, 0x73, 0x67, 0x53, 0x69, 0x67, 0x22, 0x84, 0x01, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x0a, 0x02, 0x51, 0x43, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x16, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, + 0x72, 0x75, 0x6d, 0x43, 0x65, 0x72, 0x74, 0x52, 0x02, 0x51, 0x43, 0x12, 0x27, 0x0a, 0x02, 0x54, + 0x43, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, + 0x66, 0x66, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x43, 0x65, 0x72, 0x74, + 0x52, 0x02, 0x54, 0x43, 0x12, 0x27, 0x0a, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, + 0x2e, 0x41, 0x67, 0x67, 0x51, 0x43, 0x52, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x22, 0xc8, 0x01, + 0x0a, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x12, 0x2c, 0x0a, 0x03, 0x51, 0x43, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, + 0x62, 0x2e, 0x41, 0x67, 0x67, 0x51, 0x43, 0x2e, 0x51, 0x43, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x03, 0x51, 0x43, 0x73, 0x12, 0x2d, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, - 0x03, 0x53, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x48, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x04, 0x48, 0x61, 0x73, 0x68, 0x22, 0x45, 0x0a, 0x13, 0x45, 0x43, 0x44, 0x53, - 0x41, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, - 0x2e, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x43, 0x44, 0x53, 0x41, - 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x04, 0x53, 0x69, 0x67, 0x73, 0x22, - 0x4f, 0x0a, 0x17, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, - 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, - 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x53, 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, - 0x22, 0x9c, 0x01, 0x0a, 0x0f, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x12, 0x3f, 0x0a, 0x09, 0x45, 0x43, 0x44, 0x53, 0x41, 0x53, 0x69, 0x67, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, - 0x66, 0x66, 0x70, 0x62, 0x2e, 0x45, 0x43, 0x44, 0x53, 0x41, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x09, 0x45, 0x43, 0x44, 0x53, - 0x41, 0x53, 0x69, 0x67, 0x73, 0x12, 0x41, 0x0a, 0x08, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, - 0x66, 0x66, 0x70, 0x62, 0x2e, 0x42, 0x4c, 0x53, 0x31, 0x32, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x08, - 0x42, 0x4c, 0x53, 0x31, 0x32, 0x53, 0x69, 0x67, 0x42, 0x05, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x22, - 0x63, 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x65, 0x72, 0x74, 0x12, 0x2d, 0x0a, - 0x03, 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, - 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x03, 0x53, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, - 0x56, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, - 0x12, 0x12, 0x0a, 0x04, 0x48, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x48, 0x61, 0x73, 0x68, 0x22, 0x50, 0x0a, 0x0b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x43, - 0x65, 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x03, 0x53, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, - 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x03, 0x53, - 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x22, 0xce, 0x01, 0x0a, 0x0a, 0x54, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x30, 0x0a, 0x08, 0x53, 0x79, 0x6e, - 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x68, 0x6f, - 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x35, 0x0a, 0x07, 0x56, - 0x69, 0x65, 0x77, 0x53, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, - 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, - 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x07, 0x56, 0x69, 0x65, 0x77, 0x53, - 0x69, 0x67, 0x12, 0x38, 0x0a, 0x06, 0x4d, 0x73, 0x67, 0x53, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, - 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, - 0x00, 0x52, 0x06, 0x4d, 0x73, 0x67, 0x53, 0x69, 0x67, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, - 0x5f, 0x4d, 0x73, 0x67, 0x53, 0x69, 0x67, 0x22, 0xab, 0x01, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2b, 0x0a, 0x02, 0x51, 0x43, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x16, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, - 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x02, 0x51, 0x43, 0x88, 0x01, - 0x01, 0x12, 0x2c, 0x0a, 0x02, 0x54, 0x43, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, - 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x43, 0x65, 0x72, 0x74, 0x48, 0x01, 0x52, 0x02, 0x54, 0x43, 0x88, 0x01, 0x01, 0x12, - 0x2c, 0x0a, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, - 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x41, 0x67, 0x67, 0x51, - 0x43, 0x48, 0x02, 0x52, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x88, 0x01, 0x01, 0x42, 0x05, 0x0a, - 0x03, 0x5f, 0x51, 0x43, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x54, 0x43, 0x42, 0x08, 0x0a, 0x06, 0x5f, - 0x41, 0x67, 0x67, 0x51, 0x43, 0x22, 0xc8, 0x01, 0x0a, 0x05, 0x41, 0x67, 0x67, 0x51, 0x43, 0x12, - 0x2c, 0x0a, 0x03, 0x51, 0x43, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x68, - 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x41, 0x67, 0x67, 0x51, 0x43, 0x2e, - 0x51, 0x43, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x51, 0x43, 0x73, 0x12, 0x2d, 0x0a, - 0x03, 0x53, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x68, 0x6f, 0x74, - 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x53, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x03, 0x53, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, - 0x56, 0x69, 0x65, 0x77, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, - 0x1a, 0x4e, 0x0a, 0x08, 0x51, 0x43, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, - 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, - 0x6d, 0x43, 0x65, 0x72, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x32, 0xc1, 0x02, 0x0a, 0x08, 0x48, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x12, 0x3d, 0x0a, - 0x07, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x14, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, - 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x1a, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3d, 0x0a, 0x04, - 0x56, 0x6f, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, - 0x62, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x43, 0x65, 0x72, 0x74, 0x1a, 0x16, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x90, 0xb5, 0x18, 0x01, 0x12, 0x3f, 0x0a, 0x07, 0x54, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, - 0x66, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3d, 0x0a, 0x07, - 0x4e, 0x65, 0x77, 0x56, 0x69, 0x65, 0x77, 0x12, 0x14, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, - 0x66, 0x66, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x16, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x90, 0xb5, 0x18, 0x01, 0x12, 0x37, 0x0a, 0x05, 0x46, - 0x65, 0x74, 0x63, 0x68, 0x12, 0x15, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, - 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x1a, 0x11, 0x2e, 0x68, 0x6f, - 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x04, - 0xa0, 0xb5, 0x18, 0x01, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, - 0x66, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x03, 0x53, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x56, 0x69, 0x65, 0x77, 0x1a, 0x4e, 0x0a, 0x08, 0x51, 0x43, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, + 0x70, 0x62, 0x2e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x65, 0x72, 0x74, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xc1, 0x02, 0x0a, 0x08, 0x48, 0x6f, 0x74, + 0x73, 0x74, 0x75, 0x66, 0x66, 0x12, 0x3d, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, + 0x12, 0x14, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x50, 0x72, + 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, + 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3d, 0x0a, 0x04, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x68, + 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, + 0x6c, 0x43, 0x65, 0x72, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x90, + 0xb5, 0x18, 0x01, 0x12, 0x3f, 0x0a, 0x07, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x16, + 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, + 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3d, 0x0a, 0x07, 0x4e, 0x65, 0x77, 0x56, 0x69, 0x65, 0x77, 0x12, + 0x14, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x90, + 0xb5, 0x18, 0x01, 0x12, 0x37, 0x0a, 0x05, 0x46, 0x65, 0x74, 0x63, 0x68, 0x12, 0x15, 0x2e, 0x68, + 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x61, 0x73, 0x68, 0x1a, 0x11, 0x2e, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x70, 0x62, + 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x42, 0x35, 0x5a, 0x33, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, + 0x2f, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, 0x66, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x68, 0x6f, 0x74, 0x73, 0x74, 0x75, 0x66, + 0x66, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1099,62 +1240,67 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_rawDescGZIP() []byte { return file_internal_proto_hotstuffpb_hotstuff_proto_rawDescData } -var file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_internal_proto_hotstuffpb_hotstuff_proto_goTypes = []interface{}{ (*Proposal)(nil), // 0: hotstuffpb.Proposal (*BlockHash)(nil), // 1: hotstuffpb.BlockHash (*Block)(nil), // 2: hotstuffpb.Block (*ECDSASignature)(nil), // 3: hotstuffpb.ECDSASignature (*BLS12Signature)(nil), // 4: hotstuffpb.BLS12Signature - (*Signature)(nil), // 5: hotstuffpb.Signature - (*PartialCert)(nil), // 6: hotstuffpb.PartialCert - (*ECDSAMultiSignature)(nil), // 7: hotstuffpb.ECDSAMultiSignature - (*BLS12AggregateSignature)(nil), // 8: hotstuffpb.BLS12AggregateSignature - (*QuorumSignature)(nil), // 9: hotstuffpb.QuorumSignature - (*QuorumCert)(nil), // 10: hotstuffpb.QuorumCert - (*TimeoutCert)(nil), // 11: hotstuffpb.TimeoutCert - (*TimeoutMsg)(nil), // 12: hotstuffpb.TimeoutMsg - (*SyncInfo)(nil), // 13: hotstuffpb.SyncInfo - (*AggQC)(nil), // 14: hotstuffpb.AggQC - nil, // 15: hotstuffpb.AggQC.QCsEntry - (*emptypb.Empty)(nil), // 16: google.protobuf.Empty + (*EDDSASignature)(nil), // 5: hotstuffpb.EDDSASignature + (*Signature)(nil), // 6: hotstuffpb.Signature + (*PartialCert)(nil), // 7: hotstuffpb.PartialCert + (*ECDSAMultiSignature)(nil), // 8: hotstuffpb.ECDSAMultiSignature + (*EDDSAMultiSignature)(nil), // 9: hotstuffpb.EDDSAMultiSignature + (*BLS12AggregateSignature)(nil), // 10: hotstuffpb.BLS12AggregateSignature + (*QuorumSignature)(nil), // 11: hotstuffpb.QuorumSignature + (*QuorumCert)(nil), // 12: hotstuffpb.QuorumCert + (*TimeoutCert)(nil), // 13: hotstuffpb.TimeoutCert + (*TimeoutMsg)(nil), // 14: hotstuffpb.TimeoutMsg + (*SyncInfo)(nil), // 15: hotstuffpb.SyncInfo + (*AggQC)(nil), // 16: hotstuffpb.AggQC + nil, // 17: hotstuffpb.AggQC.QCsEntry + (*empty.Empty)(nil), // 18: google.protobuf.Empty } var file_internal_proto_hotstuffpb_hotstuff_proto_depIdxs = []int32{ 2, // 0: hotstuffpb.Proposal.Block:type_name -> hotstuffpb.Block - 14, // 1: hotstuffpb.Proposal.AggQC:type_name -> hotstuffpb.AggQC - 10, // 2: hotstuffpb.Block.QC:type_name -> hotstuffpb.QuorumCert + 16, // 1: hotstuffpb.Proposal.AggQC:type_name -> hotstuffpb.AggQC + 12, // 2: hotstuffpb.Block.QC:type_name -> hotstuffpb.QuorumCert 3, // 3: hotstuffpb.Signature.ECDSASig:type_name -> hotstuffpb.ECDSASignature 4, // 4: hotstuffpb.Signature.BLS12Sig:type_name -> hotstuffpb.BLS12Signature - 9, // 5: hotstuffpb.PartialCert.Sig:type_name -> hotstuffpb.QuorumSignature - 3, // 6: hotstuffpb.ECDSAMultiSignature.Sigs:type_name -> hotstuffpb.ECDSASignature - 7, // 7: hotstuffpb.QuorumSignature.ECDSASigs:type_name -> hotstuffpb.ECDSAMultiSignature - 8, // 8: hotstuffpb.QuorumSignature.BLS12Sig:type_name -> hotstuffpb.BLS12AggregateSignature - 9, // 9: hotstuffpb.QuorumCert.Sig:type_name -> hotstuffpb.QuorumSignature - 9, // 10: hotstuffpb.TimeoutCert.Sig:type_name -> hotstuffpb.QuorumSignature - 13, // 11: hotstuffpb.TimeoutMsg.SyncInfo:type_name -> hotstuffpb.SyncInfo - 9, // 12: hotstuffpb.TimeoutMsg.ViewSig:type_name -> hotstuffpb.QuorumSignature - 9, // 13: hotstuffpb.TimeoutMsg.MsgSig:type_name -> hotstuffpb.QuorumSignature - 10, // 14: hotstuffpb.SyncInfo.QC:type_name -> hotstuffpb.QuorumCert - 11, // 15: hotstuffpb.SyncInfo.TC:type_name -> hotstuffpb.TimeoutCert - 14, // 16: hotstuffpb.SyncInfo.AggQC:type_name -> hotstuffpb.AggQC - 15, // 17: hotstuffpb.AggQC.QCs:type_name -> hotstuffpb.AggQC.QCsEntry - 9, // 18: hotstuffpb.AggQC.Sig:type_name -> hotstuffpb.QuorumSignature - 10, // 19: hotstuffpb.AggQC.QCsEntry.value:type_name -> hotstuffpb.QuorumCert - 0, // 20: hotstuffpb.Hotstuff.Propose:input_type -> hotstuffpb.Proposal - 6, // 21: hotstuffpb.Hotstuff.Vote:input_type -> hotstuffpb.PartialCert - 12, // 22: hotstuffpb.Hotstuff.Timeout:input_type -> hotstuffpb.TimeoutMsg - 13, // 23: hotstuffpb.Hotstuff.NewView:input_type -> hotstuffpb.SyncInfo - 1, // 24: hotstuffpb.Hotstuff.Fetch:input_type -> hotstuffpb.BlockHash - 16, // 25: hotstuffpb.Hotstuff.Propose:output_type -> google.protobuf.Empty - 16, // 26: hotstuffpb.Hotstuff.Vote:output_type -> google.protobuf.Empty - 16, // 27: hotstuffpb.Hotstuff.Timeout:output_type -> google.protobuf.Empty - 16, // 28: hotstuffpb.Hotstuff.NewView:output_type -> google.protobuf.Empty - 2, // 29: hotstuffpb.Hotstuff.Fetch:output_type -> hotstuffpb.Block - 25, // [25:30] is the sub-list for method output_type - 20, // [20:25] is the sub-list for method input_type - 20, // [20:20] is the sub-list for extension type_name - 20, // [20:20] is the sub-list for extension extendee - 0, // [0:20] is the sub-list for field type_name + 5, // 5: hotstuffpb.Signature.EDDSASig:type_name -> hotstuffpb.EDDSASignature + 11, // 6: hotstuffpb.PartialCert.Sig:type_name -> hotstuffpb.QuorumSignature + 3, // 7: hotstuffpb.ECDSAMultiSignature.Sigs:type_name -> hotstuffpb.ECDSASignature + 5, // 8: hotstuffpb.EDDSAMultiSignature.Sigs:type_name -> hotstuffpb.EDDSASignature + 8, // 9: hotstuffpb.QuorumSignature.ECDSASigs:type_name -> hotstuffpb.ECDSAMultiSignature + 10, // 10: hotstuffpb.QuorumSignature.BLS12Sig:type_name -> hotstuffpb.BLS12AggregateSignature + 9, // 11: hotstuffpb.QuorumSignature.EDDSASigs:type_name -> hotstuffpb.EDDSAMultiSignature + 11, // 12: hotstuffpb.QuorumCert.Sig:type_name -> hotstuffpb.QuorumSignature + 11, // 13: hotstuffpb.TimeoutCert.Sig:type_name -> hotstuffpb.QuorumSignature + 15, // 14: hotstuffpb.TimeoutMsg.SyncInfo:type_name -> hotstuffpb.SyncInfo + 11, // 15: hotstuffpb.TimeoutMsg.ViewSig:type_name -> hotstuffpb.QuorumSignature + 11, // 16: hotstuffpb.TimeoutMsg.MsgSig:type_name -> hotstuffpb.QuorumSignature + 12, // 17: hotstuffpb.SyncInfo.QC:type_name -> hotstuffpb.QuorumCert + 13, // 18: hotstuffpb.SyncInfo.TC:type_name -> hotstuffpb.TimeoutCert + 16, // 19: hotstuffpb.SyncInfo.AggQC:type_name -> hotstuffpb.AggQC + 17, // 20: hotstuffpb.AggQC.QCs:type_name -> hotstuffpb.AggQC.QCsEntry + 11, // 21: hotstuffpb.AggQC.Sig:type_name -> hotstuffpb.QuorumSignature + 12, // 22: hotstuffpb.AggQC.QCsEntry.value:type_name -> hotstuffpb.QuorumCert + 0, // 23: hotstuffpb.Hotstuff.Propose:input_type -> hotstuffpb.Proposal + 7, // 24: hotstuffpb.Hotstuff.Vote:input_type -> hotstuffpb.PartialCert + 14, // 25: hotstuffpb.Hotstuff.Timeout:input_type -> hotstuffpb.TimeoutMsg + 15, // 26: hotstuffpb.Hotstuff.NewView:input_type -> hotstuffpb.SyncInfo + 1, // 27: hotstuffpb.Hotstuff.Fetch:input_type -> hotstuffpb.BlockHash + 18, // 28: hotstuffpb.Hotstuff.Propose:output_type -> google.protobuf.Empty + 18, // 29: hotstuffpb.Hotstuff.Vote:output_type -> google.protobuf.Empty + 18, // 30: hotstuffpb.Hotstuff.Timeout:output_type -> google.protobuf.Empty + 18, // 31: hotstuffpb.Hotstuff.NewView:output_type -> google.protobuf.Empty + 2, // 32: hotstuffpb.Hotstuff.Fetch:output_type -> hotstuffpb.Block + 28, // [28:33] is the sub-list for method output_type + 23, // [23:28] is the sub-list for method input_type + 23, // [23:23] is the sub-list for extension type_name + 23, // [23:23] is the sub-list for extension extendee + 0, // [0:23] is the sub-list for field type_name } func init() { file_internal_proto_hotstuffpb_hotstuff_proto_init() } @@ -1224,7 +1370,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Signature); i { + switch v := v.(*EDDSASignature); i { case 0: return &v.state case 1: @@ -1236,7 +1382,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PartialCert); i { + switch v := v.(*Signature); i { case 0: return &v.state case 1: @@ -1248,7 +1394,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ECDSAMultiSignature); i { + switch v := v.(*PartialCert); i { case 0: return &v.state case 1: @@ -1260,7 +1406,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BLS12AggregateSignature); i { + switch v := v.(*ECDSAMultiSignature); i { case 0: return &v.state case 1: @@ -1272,7 +1418,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QuorumSignature); i { + switch v := v.(*EDDSAMultiSignature); i { case 0: return &v.state case 1: @@ -1284,7 +1430,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QuorumCert); i { + switch v := v.(*BLS12AggregateSignature); i { case 0: return &v.state case 1: @@ -1296,7 +1442,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TimeoutCert); i { + switch v := v.(*QuorumSignature); i { case 0: return &v.state case 1: @@ -1308,7 +1454,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TimeoutMsg); i { + switch v := v.(*QuorumCert); i { case 0: return &v.state case 1: @@ -1320,7 +1466,7 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SyncInfo); i { + switch v := v.(*TimeoutCert); i { case 0: return &v.state case 1: @@ -1332,6 +1478,30 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TimeoutMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AggQC); i { case 0: return &v.state @@ -1344,24 +1514,23 @@ func file_internal_proto_hotstuffpb_hotstuff_proto_init() { } } } - file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[0].OneofWrappers = []interface{}{} - file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[5].OneofWrappers = []interface{}{ + file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[6].OneofWrappers = []interface{}{ (*Signature_ECDSASig)(nil), (*Signature_BLS12Sig)(nil), + (*Signature_EDDSASig)(nil), } - file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[9].OneofWrappers = []interface{}{ + file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[11].OneofWrappers = []interface{}{ (*QuorumSignature_ECDSASigs)(nil), (*QuorumSignature_BLS12Sig)(nil), + (*QuorumSignature_EDDSASigs)(nil), } - file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[12].OneofWrappers = []interface{}{} - file_internal_proto_hotstuffpb_hotstuff_proto_msgTypes[13].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_internal_proto_hotstuffpb_hotstuff_proto_rawDesc, NumEnums: 0, - NumMessages: 16, + NumMessages: 18, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/proto/hotstuffpb/hotstuff_gorums.pb.go b/internal/proto/hotstuffpb/hotstuff_gorums.pb.go index fc82a827..59c5f38c 100644 --- a/internal/proto/hotstuffpb/hotstuff_gorums.pb.go +++ b/internal/proto/hotstuffpb/hotstuff_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.7.0-devel -// protoc v3.21.4 +// protoc v3.12.4 // source: internal/proto/hotstuffpb/hotstuff.proto package hotstuffpb @@ -9,10 +9,10 @@ package hotstuffpb import ( context "context" fmt "fmt" + empty "github.com/golang/protobuf/ptypes/empty" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" - emptypb "google.golang.org/protobuf/types/known/emptypb" ) const ( @@ -145,7 +145,7 @@ type Node struct { } // Reference imports to suppress errors if they are not otherwise used. -var _ emptypb.Empty +var _ empty.Empty // Propose is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. @@ -159,7 +159,7 @@ func (c *Configuration) Propose(ctx context.Context, in *Proposal, opts ...gorum } // Reference imports to suppress errors if they are not otherwise used. -var _ emptypb.Empty +var _ empty.Empty // Timeout is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. @@ -251,7 +251,7 @@ type internalBlock struct { } // Reference imports to suppress errors if they are not otherwise used. -var _ emptypb.Empty +var _ empty.Empty // Vote is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. @@ -265,7 +265,7 @@ func (n *Node) Vote(ctx context.Context, in *PartialCert, opts ...gorums.CallOpt } // Reference imports to suppress errors if they are not otherwise used. -var _ emptypb.Empty +var _ empty.Empty // NewView is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. From 975e03a572650fdad748c47ae8507c5eb4aa60df Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Mon, 26 Feb 2024 14:43:15 +0100 Subject: [PATCH 03/13] fix(crypto): made MultiSignature generic This is an attempt at making the MultiSignature type be generic so that impl can be switched at the top level instead of nested. --- crypto/ecdsa/ecdsa.go | 19 +++++++----- crypto/eddsa/eddsa.go | 19 +++++++----- crypto/multi_signature.go | 29 ++++++++---------- internal/proto/hotstuffpb/convert.go | 44 +++++++++++++++------------- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/crypto/ecdsa/ecdsa.go b/crypto/ecdsa/ecdsa.go index ff91b788..f2a60acd 100644 --- a/crypto/ecdsa/ecdsa.go +++ b/crypto/ecdsa/ecdsa.go @@ -26,6 +26,11 @@ const ( PublicKeyFileType = "ECDSA PUBLIC KEY" ) +var ( + _ hotstuff.QuorumSignature = (*crypto.MultiSignature[*Signature])(nil) + _ hotstuff.IDSet = (*crypto.MultiSignature[*Signature])(nil) +) + // Signature is an ECDSA signature type Signature struct { r, s *big.Int @@ -92,7 +97,7 @@ func (ec *ecdsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, e if err != nil { return nil, fmt.Errorf("ecdsa: sign failed: %w", err) } - return crypto.MultiSignature{ec.opts.ID(): &Signature{ + return crypto.MultiSignature[*Signature]{ec.opts.ID(): &Signature{ r: r, s: s, signer: ec.opts.ID(), @@ -105,10 +110,10 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q return nil, crypto.ErrCombineMultiple } - ts := make(crypto.MultiSignature) + ts := make(crypto.MultiSignature[*Signature]) for _, sig1 := range signatures { - if sig2, ok := sig1.(crypto.MultiSignature); ok { + if sig2, ok := sig1.(crypto.MultiSignature[*Signature]); ok { for id, s := range sig2 { if _, ok := ts[id]; ok { return nil, crypto.ErrCombineOverlap @@ -125,7 +130,7 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q // Verify verifies the given quorum signature against the message. func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { - s, ok := signature.(crypto.MultiSignature) + s, ok := signature.(crypto.MultiSignature[*Signature]) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -141,7 +146,7 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) for _, sig := range s { go func(sig *Signature, hash hotstuff.Hash) { results <- ec.verifySingle(sig, hash) - }(sig.(*Signature), hash) + }(sig, hash) } valid := true @@ -156,7 +161,7 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) // BatchVerify verifies the given quorum signature against the batch of messages. func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { - s, ok := signature.(crypto.MultiSignature) + s, ok := signature.(crypto.MultiSignature[*Signature]) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -177,7 +182,7 @@ func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h set[hash] = struct{}{} go func(sig *Signature, hash hotstuff.Hash) { results <- ec.verifySingle(sig, hash) - }(sig.(*Signature), hash) + }(sig, hash) } valid := true diff --git a/crypto/eddsa/eddsa.go b/crypto/eddsa/eddsa.go index 5c59fb3c..bd2b4975 100644 --- a/crypto/eddsa/eddsa.go +++ b/crypto/eddsa/eddsa.go @@ -23,6 +23,11 @@ const ( PublicKeyFileType = "EDDSA PUBLIC KEY" ) +var ( + _ hotstuff.QuorumSignature = (*crypto.MultiSignature[*Signature])(nil) + _ hotstuff.IDSet = (*crypto.MultiSignature[*Signature])(nil) +) + // Signature is an ECDSA signature type Signature struct { signer hotstuff.ID @@ -74,7 +79,7 @@ func (ed *eddsaBase) privateKey() ed25519.PrivateKey { func (ed *eddsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, err error) { sign := ed25519.Sign(ed.privateKey(), message) eddsaSign := &Signature{signer: ed.opts.ID(), sign: sign} - return crypto.MultiSignature{ed.opts.ID(): eddsaSign}, nil + return crypto.MultiSignature[*Signature]{ed.opts.ID(): eddsaSign}, nil } func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.QuorumSignature, error) { @@ -82,10 +87,10 @@ func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q return nil, crypto.ErrCombineMultiple } - ts := make(crypto.MultiSignature) + ts := make(crypto.MultiSignature[*Signature]) for _, sig1 := range signatures { - if sig2, ok := sig1.(crypto.MultiSignature); ok { + if sig2, ok := sig1.(crypto.MultiSignature[*Signature]); ok { for id, s := range sig2 { if _, ok := ts[id]; ok { return nil, crypto.ErrCombineOverlap @@ -100,7 +105,7 @@ func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q } func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { - s, ok := signature.(crypto.MultiSignature) + s, ok := signature.(crypto.MultiSignature[*Signature]) if !ok { ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -114,7 +119,7 @@ func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) for _, sig := range s { go func(sig *Signature, msg []byte) { results <- ed.verifySingle(sig, msg) - }(sig.(*Signature), message) + }(sig, message) } valid := true @@ -128,7 +133,7 @@ func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) } func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { - s, ok := signature.(crypto.MultiSignature) + s, ok := signature.(crypto.MultiSignature[*Signature]) if !ok { ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -149,7 +154,7 @@ func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h set[hash] = struct{}{} go func(sig *Signature, msg []byte) { results <- ed.verifySingle(sig, msg) - }(sig.(*Signature), message) + }(sig, message) } valid := true diff --git a/crypto/multi_signature.go b/crypto/multi_signature.go index c6c92069..3793a4a9 100644 --- a/crypto/multi_signature.go +++ b/crypto/multi_signature.go @@ -14,11 +14,11 @@ type Signature interface { } // MultiSignature is a set of (partial) signatures. -type MultiSignature map[hotstuff.ID]Signature +type MultiSignature[T Signature] map[hotstuff.ID]T // RestoreMultiSignature should only be used to restore an existing threshold signature from a set of signatures. -func RestoreMultiSignature(signatures []Signature) MultiSignature { - sig := make(MultiSignature, len(signatures)) +func RestoreMultiSignature[T Signature](signatures []T) MultiSignature[T] { + sig := make(MultiSignature[T], len(signatures)) for _, s := range signatures { sig[s.Signer()] = s } @@ -26,7 +26,7 @@ func RestoreMultiSignature(signatures []Signature) MultiSignature { } // ToBytes returns the object as bytes. -func (sig MultiSignature) ToBytes() []byte { +func (sig MultiSignature[T]) ToBytes() []byte { var b []byte // sort by ID to make it deterministic order := make([]hotstuff.ID, 0, len(sig)) @@ -41,30 +41,30 @@ func (sig MultiSignature) ToBytes() []byte { } // Participants returns the IDs of replicas who participated in the threshold signature. -func (sig MultiSignature) Participants() hotstuff.IDSet { +func (sig MultiSignature[T]) Participants() hotstuff.IDSet { return sig } // Add adds an ID to the set. -func (sig MultiSignature) Add(_ hotstuff.ID) { +func (sig MultiSignature[T]) Add(_ hotstuff.ID) { panic("not implemented") } // Contains returns true if the set contains the ID. -func (sig MultiSignature) Contains(id hotstuff.ID) bool { +func (sig MultiSignature[T]) Contains(id hotstuff.ID) bool { _, ok := sig[id] return ok } // ForEach calls f for each ID in the set. -func (sig MultiSignature) ForEach(f func(hotstuff.ID)) { +func (sig MultiSignature[T]) ForEach(f func(hotstuff.ID)) { for id := range sig { f(id) } } // RangeWhile calls f for each ID in the set until f returns false. -func (sig MultiSignature) RangeWhile(f func(hotstuff.ID) bool) { +func (sig MultiSignature[T]) RangeWhile(f func(hotstuff.ID) bool) { for id := range sig { if !f(id) { break @@ -73,22 +73,17 @@ func (sig MultiSignature) RangeWhile(f func(hotstuff.ID) bool) { } // Len returns the number of entries in the set. -func (sig MultiSignature) Len() int { +func (sig MultiSignature[T]) Len() int { return len(sig) } -func (sig MultiSignature) String() string { +func (sig MultiSignature[T]) String() string { return hotstuff.IDSetToString(sig) } -func (sig MultiSignature) Type() reflect.Type { +func (sig MultiSignature[T]) Type() reflect.Type { for _, s := range sig { return reflect.TypeOf(s) } return nil } - -var ( - _ hotstuff.QuorumSignature = (*MultiSignature)(nil) - _ hotstuff.IDSet = (*MultiSignature)(nil) -) diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 3256dd79..87291ebe 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -15,36 +15,38 @@ import ( func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { signature := &QuorumSignature{} switch ms := sig.(type) { - case crypto.MultiSignature: + case crypto.MultiSignature[ecdsa.Signature]: ECDSASigs := make([]*ECDSASignature, 0, sig.Participants().Len()) - EDDSASigs := make([]*EDDSASignature, 0, sig.Participants().Len()) - for _, p := range ms { - switch s := p.(type) { - case *ecdsa.Signature: - ECDSASigs = append(ECDSASigs, &ECDSASignature{ - Signer: uint32(s.Signer()), - R: s.R().Bytes(), - S: s.S().Bytes(), - }) - case *eddsa.Signature: - EDDSASigs = append(EDDSASigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) - } + for _, s := range ms { + ECDSASigs = append(ECDSASigs, &ECDSASignature{ + Signer: uint32(s.Signer()), + R: s.R().Bytes(), + S: s.S().Bytes(), + }) } - if len(ECDSASigs) > 0 { - signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ - Sigs: ECDSASigs, - }} - } else { - signature.Sig = &QuorumSignature_EDDSASigs{EDDSASigs: &EDDSAMultiSignature{ - Sigs: EDDSASigs, - }} + signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ + Sigs: ECDSASigs, + }} + + case crypto.MultiSignature[eddsa.Signature]: + EDDSASigs := make([]*EDDSASignature, 0, sig.Participants().Len()) + for _, s := range ms { + EDDSASigs = append(EDDSASigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) } + signature.Sig = &QuorumSignature_EDDSASigs{EDDSASigs: &EDDSAMultiSignature{ + Sigs: EDDSASigs, + }} case *bls12.AggregateSignature: signature.Sig = &QuorumSignature_BLS12Sig{BLS12Sig: &BLS12AggregateSignature{ Sig: ms.ToBytes(), Participants: ms.Bitfield().Bytes(), }} + + default: + signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ + Sigs: nil, + }} } return signature } From 855fa190949344955761acdfb9309fd3f3352745 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Mon, 26 Feb 2024 14:45:25 +0100 Subject: [PATCH 04/13] fix: rename capitalized names to sigs --- internal/proto/hotstuffpb/convert.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 87291ebe..965074e5 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -16,25 +16,25 @@ func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { signature := &QuorumSignature{} switch ms := sig.(type) { case crypto.MultiSignature[ecdsa.Signature]: - ECDSASigs := make([]*ECDSASignature, 0, sig.Participants().Len()) + sigs := make([]*ECDSASignature, 0, sig.Participants().Len()) for _, s := range ms { - ECDSASigs = append(ECDSASigs, &ECDSASignature{ + sigs = append(sigs, &ECDSASignature{ Signer: uint32(s.Signer()), R: s.R().Bytes(), S: s.S().Bytes(), }) } signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ - Sigs: ECDSASigs, + Sigs: sigs, }} case crypto.MultiSignature[eddsa.Signature]: - EDDSASigs := make([]*EDDSASignature, 0, sig.Participants().Len()) + sigs := make([]*EDDSASignature, 0, sig.Participants().Len()) for _, s := range ms { - EDDSASigs = append(EDDSASigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) + sigs = append(sigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) } signature.Sig = &QuorumSignature_EDDSASigs{EDDSASigs: &EDDSAMultiSignature{ - Sigs: EDDSASigs, + Sigs: sigs, }} case *bls12.AggregateSignature: From 54270fe07ba477b80490c280cdab82039cf18d31 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Mon, 26 Feb 2024 15:14:10 +0100 Subject: [PATCH 05/13] fix(QuorumSignatureToProto): fixed generic type switch cases --- internal/proto/hotstuffpb/convert.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 965074e5..48c82ae1 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -15,7 +15,7 @@ import ( func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { signature := &QuorumSignature{} switch ms := sig.(type) { - case crypto.MultiSignature[ecdsa.Signature]: + case crypto.MultiSignature[*ecdsa.Signature]: sigs := make([]*ECDSASignature, 0, sig.Participants().Len()) for _, s := range ms { sigs = append(sigs, &ECDSASignature{ @@ -28,7 +28,7 @@ func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { Sigs: sigs, }} - case crypto.MultiSignature[eddsa.Signature]: + case crypto.MultiSignature[*eddsa.Signature]: sigs := make([]*EDDSASignature, 0, sig.Participants().Len()) for _, s := range ms { sigs = append(sigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) @@ -42,11 +42,6 @@ func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { Sig: ms.ToBytes(), Participants: ms.Bitfield().Bytes(), }} - - default: - signature.Sig = &QuorumSignature_ECDSASigs{ECDSASigs: &ECDSAMultiSignature{ - Sigs: nil, - }} } return signature } From d9bd7b6f6aaed2e805a3d0d36c207cdbda1e4374 Mon Sep 17 00:00:00 2001 From: hanish gogada Date: Wed, 6 Mar 2024 23:12:47 +0100 Subject: [PATCH 06/13] fix(eddsa): fixed the multisignature type initialization While converting the quorum signature from proto, initialization of the multi signature is causing type conversion failures in the crypto modules. --- internal/proto/hotstuffpb/convert.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 48c82ae1..6c7275bb 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -49,7 +49,7 @@ func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { // QuorumSignatureFromProto converts a protocol buffers message to a threshold signature. func QuorumSignatureFromProto(sig *QuorumSignature) hotstuff.QuorumSignature { if signature := sig.GetECDSASigs(); signature != nil { - sigs := make([]crypto.Signature, len(signature.GetSigs())) + sigs := make([]*ecdsa.Signature, len(signature.GetSigs())) for i, sig := range signature.GetSigs() { r := new(big.Int) r.SetBytes(sig.GetR()) @@ -60,7 +60,7 @@ func QuorumSignatureFromProto(sig *QuorumSignature) hotstuff.QuorumSignature { return crypto.RestoreMultiSignature(sigs) } if signature := sig.GetEDDSASigs(); signature != nil { - sigs := make([]crypto.Signature, len(signature.GetSigs())) + sigs := make([]*eddsa.Signature, len(signature.GetSigs())) for i, sig := range signature.GetSigs() { sigs[i] = eddsa.RestoreSignature(sig.Sig, hotstuff.ID(sig.GetSigner())) } From a8741374d9f7e499c0b5e52956e1070a85cf6c28 Mon Sep 17 00:00:00 2001 From: hanish gogada Date: Sun, 10 Mar 2024 01:13:17 +0100 Subject: [PATCH 07/13] fix: addressed review comments and added two more test cases Addressed review comments except for the comment in keygen.go file, as it would add a switch case in the orchestration layer. Tried to add more cases, this mock layer is not very flexible to add more negative cases. --- crypto/crypto_test.go | 27 +++++++++++++++ crypto/ecdsa/ecdsa.go | 14 ++++---- crypto/eddsa/eddsa.go | 14 ++++---- crypto/multi_signature.go | 35 ++++++++------------ internal/orchestration/orchestration_test.go | 6 ++-- internal/proto/hotstuffpb/convert.go | 8 ++--- 6 files changed, 61 insertions(+), 43 deletions(-) diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index af216e79..0f12f8b9 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -90,6 +90,33 @@ func TestCreateTimeoutCert(t *testing.T) { runAll(t, run) } +func TestCreateQCWithOneSig(t *testing.T) { + run := func(t *testing.T, setup setupFunc) { + ctrl := gomock.NewController(t) + td := setup(t, ctrl, 4) + pcs := testutil.CreatePCs(t, td.block, td.signers) + _, err := td.signers[0].CreateQuorumCert(td.block, pcs[:1]) + if err == nil { + t.Fatal("Expected error when creating QC with only one signature") + } + } + runAll(t, run) +} + +func TestCreateQCWithOverlappingSigs(t *testing.T) { + run := func(t *testing.T, setup setupFunc) { + ctrl := gomock.NewController(t) + td := setup(t, ctrl, 4) + pcs := testutil.CreatePCs(t, td.block, td.signers) + pcs = append(pcs, pcs[0]) + _, err := td.signers[0].CreateQuorumCert(td.block, pcs) + if err == nil { + t.Fatal("Expected error when creating QC with overlapping signatures") + } + } + runAll(t, run) +} + func TestVerifyGenesisQC(t *testing.T) { run := func(t *testing.T, setup setupFunc) { ctrl := gomock.NewController(t) diff --git a/crypto/ecdsa/ecdsa.go b/crypto/ecdsa/ecdsa.go index f2a60acd..2a2e99f6 100644 --- a/crypto/ecdsa/ecdsa.go +++ b/crypto/ecdsa/ecdsa.go @@ -27,8 +27,8 @@ const ( ) var ( - _ hotstuff.QuorumSignature = (*crypto.MultiSignature[*Signature])(nil) - _ hotstuff.IDSet = (*crypto.MultiSignature[*Signature])(nil) + _ hotstuff.QuorumSignature = (*crypto.Multi[*Signature])(nil) + _ hotstuff.IDSet = (*crypto.Multi[*Signature])(nil) ) // Signature is an ECDSA signature @@ -97,7 +97,7 @@ func (ec *ecdsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, e if err != nil { return nil, fmt.Errorf("ecdsa: sign failed: %w", err) } - return crypto.MultiSignature[*Signature]{ec.opts.ID(): &Signature{ + return crypto.Multi[*Signature]{ec.opts.ID(): &Signature{ r: r, s: s, signer: ec.opts.ID(), @@ -110,10 +110,10 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q return nil, crypto.ErrCombineMultiple } - ts := make(crypto.MultiSignature[*Signature]) + ts := make(crypto.Multi[*Signature]) for _, sig1 := range signatures { - if sig2, ok := sig1.(crypto.MultiSignature[*Signature]); ok { + if sig2, ok := sig1.(crypto.Multi[*Signature]); ok { for id, s := range sig2 { if _, ok := ts[id]; ok { return nil, crypto.ErrCombineOverlap @@ -130,7 +130,7 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q // Verify verifies the given quorum signature against the message. func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { - s, ok := signature.(crypto.MultiSignature[*Signature]) + s, ok := signature.(crypto.Multi[*Signature]) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -161,7 +161,7 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) // BatchVerify verifies the given quorum signature against the batch of messages. func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { - s, ok := signature.(crypto.MultiSignature[*Signature]) + s, ok := signature.(crypto.Multi[*Signature]) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } diff --git a/crypto/eddsa/eddsa.go b/crypto/eddsa/eddsa.go index bd2b4975..297991c0 100644 --- a/crypto/eddsa/eddsa.go +++ b/crypto/eddsa/eddsa.go @@ -24,8 +24,8 @@ const ( ) var ( - _ hotstuff.QuorumSignature = (*crypto.MultiSignature[*Signature])(nil) - _ hotstuff.IDSet = (*crypto.MultiSignature[*Signature])(nil) + _ hotstuff.QuorumSignature = (*crypto.Multi[*Signature])(nil) + _ hotstuff.IDSet = (*crypto.Multi[*Signature])(nil) ) // Signature is an ECDSA signature @@ -79,7 +79,7 @@ func (ed *eddsaBase) privateKey() ed25519.PrivateKey { func (ed *eddsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, err error) { sign := ed25519.Sign(ed.privateKey(), message) eddsaSign := &Signature{signer: ed.opts.ID(), sign: sign} - return crypto.MultiSignature[*Signature]{ed.opts.ID(): eddsaSign}, nil + return crypto.Multi[*Signature]{ed.opts.ID(): eddsaSign}, nil } func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.QuorumSignature, error) { @@ -87,10 +87,10 @@ func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q return nil, crypto.ErrCombineMultiple } - ts := make(crypto.MultiSignature[*Signature]) + ts := make(crypto.Multi[*Signature]) for _, sig1 := range signatures { - if sig2, ok := sig1.(crypto.MultiSignature[*Signature]); ok { + if sig2, ok := sig1.(crypto.Multi[*Signature]); ok { for id, s := range sig2 { if _, ok := ts[id]; ok { return nil, crypto.ErrCombineOverlap @@ -105,7 +105,7 @@ func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q } func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { - s, ok := signature.(crypto.MultiSignature[*Signature]) + s, ok := signature.(crypto.Multi[*Signature]) if !ok { ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } @@ -133,7 +133,7 @@ func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) } func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { - s, ok := signature.(crypto.MultiSignature[*Signature]) + s, ok := signature.(crypto.Multi[*Signature]) if !ok { ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } diff --git a/crypto/multi_signature.go b/crypto/multi_signature.go index 3793a4a9..8b1bbb86 100644 --- a/crypto/multi_signature.go +++ b/crypto/multi_signature.go @@ -1,8 +1,6 @@ package crypto import ( - "reflect" - "github.com/relab/hotstuff" "golang.org/x/exp/slices" ) @@ -13,12 +11,12 @@ type Signature interface { ToBytes() []byte } -// MultiSignature is a set of (partial) signatures. -type MultiSignature[T Signature] map[hotstuff.ID]T +// Multi is a set of (partial) signatures. +type Multi[T Signature] map[hotstuff.ID]T -// RestoreMultiSignature should only be used to restore an existing threshold signature from a set of signatures. -func RestoreMultiSignature[T Signature](signatures []T) MultiSignature[T] { - sig := make(MultiSignature[T], len(signatures)) +// Restore should only be used to restore an existing threshold signature from a set of signatures. +func Restore[T Signature](signatures []T) Multi[T] { + sig := make(Multi[T], len(signatures)) for _, s := range signatures { sig[s.Signer()] = s } @@ -26,7 +24,7 @@ func RestoreMultiSignature[T Signature](signatures []T) MultiSignature[T] { } // ToBytes returns the object as bytes. -func (sig MultiSignature[T]) ToBytes() []byte { +func (sig Multi[T]) ToBytes() []byte { var b []byte // sort by ID to make it deterministic order := make([]hotstuff.ID, 0, len(sig)) @@ -41,30 +39,30 @@ func (sig MultiSignature[T]) ToBytes() []byte { } // Participants returns the IDs of replicas who participated in the threshold signature. -func (sig MultiSignature[T]) Participants() hotstuff.IDSet { +func (sig Multi[T]) Participants() hotstuff.IDSet { return sig } // Add adds an ID to the set. -func (sig MultiSignature[T]) Add(_ hotstuff.ID) { +func (sig Multi[T]) Add(_ hotstuff.ID) { panic("not implemented") } // Contains returns true if the set contains the ID. -func (sig MultiSignature[T]) Contains(id hotstuff.ID) bool { +func (sig Multi[T]) Contains(id hotstuff.ID) bool { _, ok := sig[id] return ok } // ForEach calls f for each ID in the set. -func (sig MultiSignature[T]) ForEach(f func(hotstuff.ID)) { +func (sig Multi[T]) ForEach(f func(hotstuff.ID)) { for id := range sig { f(id) } } // RangeWhile calls f for each ID in the set until f returns false. -func (sig MultiSignature[T]) RangeWhile(f func(hotstuff.ID) bool) { +func (sig Multi[T]) RangeWhile(f func(hotstuff.ID) bool) { for id := range sig { if !f(id) { break @@ -73,17 +71,10 @@ func (sig MultiSignature[T]) RangeWhile(f func(hotstuff.ID) bool) { } // Len returns the number of entries in the set. -func (sig MultiSignature[T]) Len() int { +func (sig Multi[T]) Len() int { return len(sig) } -func (sig MultiSignature[T]) String() string { +func (sig Multi[T]) String() string { return hotstuff.IDSetToString(sig) } - -func (sig MultiSignature[T]) Type() reflect.Type { - for _, s := range sig { - return reflect.TypeOf(s) - } - return nil -} diff --git a/internal/orchestration/orchestration_test.go b/internal/orchestration/orchestration_test.go index 97a1cdc4..a9e8f0cf 100644 --- a/internal/orchestration/orchestration_test.go +++ b/internal/orchestration/orchestration_test.go @@ -74,14 +74,14 @@ func TestOrchestration(t *testing.T) { } t.Run("ChainedHotStuff+ECDSA", func(t *testing.T) { run(t, "chainedhotstuff", "ecdsa", nil, "") }) + t.Run("ChainedHotStuff+EDDSA", func(t *testing.T) { run(t, "chainedhotstuff", "eddsa", nil, "") }) t.Run("ChainedHotStuff+BLS12", func(t *testing.T) { run(t, "chainedhotstuff", "bls12", nil, "") }) t.Run("Fast-HotStuff+ECDSA", func(t *testing.T) { run(t, "fasthotstuff", "ecdsa", nil, "") }) + t.Run("Fast-HotStuff+EDDSA", func(t *testing.T) { run(t, "fasthotstuff", "eddsa", nil, "") }) t.Run("Fast-HotStuff+BLS12", func(t *testing.T) { run(t, "fasthotstuff", "bls12", nil, "") }) t.Run("Simple-HotStuff+ECDSA", func(t *testing.T) { run(t, "simplehotstuff", "ecdsa", nil, "") }) - t.Run("Simple-HotStuff+BLS12", func(t *testing.T) { run(t, "simplehotstuff", "bls12", nil, "") }) - t.Run("ChainedHotStuff+EDDSA", func(t *testing.T) { run(t, "chainedhotstuff", "eddsa", nil, "") }) - t.Run("Fast-HotStuff+EDDSA", func(t *testing.T) { run(t, "fasthotstuff", "eddsa", nil, "") }) t.Run("Simple-HotStuff+EDDSA", func(t *testing.T) { run(t, "simplehotstuff", "eddsa", nil, "") }) + t.Run("Simple-HotStuff+BLS12", func(t *testing.T) { run(t, "simplehotstuff", "bls12", nil, "") }) // handel mods := []string{"handel"} diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 6c7275bb..3c316044 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -15,7 +15,7 @@ import ( func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { signature := &QuorumSignature{} switch ms := sig.(type) { - case crypto.MultiSignature[*ecdsa.Signature]: + case crypto.Multi[*ecdsa.Signature]: sigs := make([]*ECDSASignature, 0, sig.Participants().Len()) for _, s := range ms { sigs = append(sigs, &ECDSASignature{ @@ -28,7 +28,7 @@ func QuorumSignatureToProto(sig hotstuff.QuorumSignature) *QuorumSignature { Sigs: sigs, }} - case crypto.MultiSignature[*eddsa.Signature]: + case crypto.Multi[*eddsa.Signature]: sigs := make([]*EDDSASignature, 0, sig.Participants().Len()) for _, s := range ms { sigs = append(sigs, &EDDSASignature{Signer: uint32(s.Signer()), Sig: s.ToBytes()}) @@ -57,14 +57,14 @@ func QuorumSignatureFromProto(sig *QuorumSignature) hotstuff.QuorumSignature { s.SetBytes(sig.GetS()) sigs[i] = ecdsa.RestoreSignature(r, s, hotstuff.ID(sig.GetSigner())) } - return crypto.RestoreMultiSignature(sigs) + return crypto.Restore(sigs) } if signature := sig.GetEDDSASigs(); signature != nil { sigs := make([]*eddsa.Signature, len(signature.GetSigs())) for i, sig := range signature.GetSigs() { sigs[i] = eddsa.RestoreSignature(sig.Sig, hotstuff.ID(sig.GetSigner())) } - return crypto.RestoreMultiSignature(sigs) + return crypto.Restore(sigs) } if signature := sig.GetBLS12Sig(); signature != nil { aggSig, err := bls12.RestoreAggregateSignature(signature.GetSig(), crypto.BitfieldFromBytes(signature.GetParticipants())) From c6ffc0a8718300deec9aabfe73beda5a6146a0c6 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Sun, 10 Mar 2024 08:49:23 +0100 Subject: [PATCH 08/13] fix: tidy after master merge --- crypto/ecdsa/ecdsa.go | 1 - go.mod | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crypto/ecdsa/ecdsa.go b/crypto/ecdsa/ecdsa.go index dff2b8f0..2a2e99f6 100644 --- a/crypto/ecdsa/ecdsa.go +++ b/crypto/ecdsa/ecdsa.go @@ -7,7 +7,6 @@ import ( "crypto/sha256" "fmt" "math/big" - "slices" "github.com/relab/hotstuff" "github.com/relab/hotstuff/crypto" diff --git a/go.mod b/go.mod index 7168b12a..ff762534 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.22.1 require ( github.com/felixge/fgprof v0.9.4 github.com/golang/mock v1.6.0 + github.com/golang/protobuf v1.5.4 github.com/kilic/bls12-381 v0.1.1-0.20210208205449-6045b0235e36 github.com/mattn/go-isatty v0.0.20 github.com/mitchellh/go-homedir v1.1.0 @@ -44,7 +45,6 @@ require ( github.com/go-pdf/fpdf v0.9.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/gonuts/binary v0.2.0 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect From 6cfadb2d3ac8b075192aa60b983341e3afba8dd7 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Sun, 10 Mar 2024 08:50:44 +0100 Subject: [PATCH 09/13] fix: replace golang.org/x/exp/slices with std lib slices --- crypto/{multi_signature.go => multisignature.go} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename crypto/{multi_signature.go => multisignature.go} (98%) diff --git a/crypto/multi_signature.go b/crypto/multisignature.go similarity index 98% rename from crypto/multi_signature.go rename to crypto/multisignature.go index 8b1bbb86..1ea00e08 100644 --- a/crypto/multi_signature.go +++ b/crypto/multisignature.go @@ -1,8 +1,9 @@ package crypto import ( + "slices" + "github.com/relab/hotstuff" - "golang.org/x/exp/slices" ) // Signature is the individual component in MultiSignature From 870abccf340e8dac8357c958eadd1fd1ffc1cc50 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Sun, 10 Mar 2024 08:59:10 +0100 Subject: [PATCH 10/13] fix: added missing doc comments and minor cleanup --- crypto/ecdsa/ecdsa.go | 37 ++++++++++++++----------------------- crypto/eddsa/eddsa.go | 34 ++++++++++++++++------------------ 2 files changed, 30 insertions(+), 41 deletions(-) diff --git a/crypto/ecdsa/ecdsa.go b/crypto/ecdsa/ecdsa.go index 2a2e99f6..a4333de2 100644 --- a/crypto/ecdsa/ecdsa.go +++ b/crypto/ecdsa/ecdsa.go @@ -1,4 +1,4 @@ -// Package ecdsa supports spec-k256 curve signature +// Package ecdsa implements the spec-k256 curve signature. package ecdsa import ( @@ -21,7 +21,6 @@ func init() { const ( // PrivateKeyFileType is the PEM type for a private key. PrivateKeyFileType = "ECDSA PRIVATE KEY" - // PublicKeyFileType is the PEM type for a public key. PublicKeyFileType = "ECDSA PUBLIC KEY" ) @@ -29,15 +28,17 @@ const ( var ( _ hotstuff.QuorumSignature = (*crypto.Multi[*Signature])(nil) _ hotstuff.IDSet = (*crypto.Multi[*Signature])(nil) + _ crypto.Signature = (*Signature)(nil) ) -// Signature is an ECDSA signature +// Signature is an ECDSA signature. type Signature struct { r, s *big.Int signer hotstuff.ID } -// RestoreSignature restores an existing signature. It should not be used to create new signatures, use Sign instead. +// RestoreSignature restores an existing signature. +// It should not be used to create new signatures, use Sign instead. func RestoreSignature(r, s *big.Int, signer hotstuff.ID) *Signature { return &Signature{r, s, signer} } @@ -47,17 +48,17 @@ func (sig Signature) Signer() hotstuff.ID { return sig.signer } -// R returns the r value of the signature +// R returns the r value of the signature. func (sig Signature) R() *big.Int { return sig.r } -// S returns the s value of the signature +// S returns the s value of the signature. func (sig Signature) S() *big.Int { return sig.s } -// ToBytes returns a raw byte string representation of the signature +// ToBytes returns a raw byte string representation of the signature. func (sig Signature) ToBytes() []byte { var b []byte b = append(b, sig.r.Bytes()...) @@ -76,10 +77,6 @@ func New() modules.CryptoBase { return &ecdsaBase{} } -func (ec *ecdsaBase) getPrivateKey() *ecdsa.PrivateKey { - return ec.opts.PrivateKey().(*ecdsa.PrivateKey) -} - // InitModule gives the module a reference to the Core object. // It also allows the module to set module options using the OptionsBuilder. func (ec *ecdsaBase) InitModule(mods *modules.Core) { @@ -90,10 +87,14 @@ func (ec *ecdsaBase) InitModule(mods *modules.Core) { ) } +func (ec *ecdsaBase) privateKey() *ecdsa.PrivateKey { + return ec.opts.PrivateKey().(*ecdsa.PrivateKey) +} + // Sign creates a cryptographic signature of the given message. func (ec *ecdsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, err error) { hash := sha256.Sum256(message) - r, s, err := ecdsa.Sign(rand.Reader, ec.getPrivateKey(), hash[:]) + r, s, err := ecdsa.Sign(rand.Reader, ec.privateKey(), hash[:]) if err != nil { return nil, fmt.Errorf("ecdsa: sign failed: %w", err) } @@ -111,11 +112,10 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q } ts := make(crypto.Multi[*Signature]) - for _, sig1 := range signatures { if sig2, ok := sig1.(crypto.Multi[*Signature]); ok { for id, s := range sig2 { - if _, ok := ts[id]; ok { + if _, duplicate := ts[id]; duplicate { return nil, crypto.ErrCombineOverlap } ts[id] = s @@ -124,7 +124,6 @@ func (ec *ecdsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q ec.logger.Panicf("cannot combine signature of incompatible type %T (expected %T)", sig1, sig2) } } - return ts, nil } @@ -134,7 +133,6 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } - n := signature.Participants().Len() if n == 0 { return false @@ -142,20 +140,17 @@ func (ec *ecdsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) results := make(chan bool, n) hash := sha256.Sum256(message) - for _, sig := range s { go func(sig *Signature, hash hotstuff.Hash) { results <- ec.verifySingle(sig, hash) }(sig, hash) } - valid := true for range s { if !<-results { valid = false } } - return valid } @@ -165,7 +160,6 @@ func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h if !ok { ec.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } - n := signature.Participants().Len() if n == 0 { return false @@ -184,7 +178,6 @@ func (ec *ecdsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h results <- ec.verifySingle(sig, hash) }(sig, hash) } - valid := true for range s { if !<-results { @@ -205,5 +198,3 @@ func (ec *ecdsaBase) verifySingle(sig *Signature, hash hotstuff.Hash) bool { pk := replica.PublicKey().(*ecdsa.PublicKey) return ecdsa.Verify(pk, hash[:], sig.R(), sig.S()) } - -var _ crypto.Signature = (*Signature)(nil) diff --git a/crypto/eddsa/eddsa.go b/crypto/eddsa/eddsa.go index 297991c0..a71da854 100644 --- a/crypto/eddsa/eddsa.go +++ b/crypto/eddsa/eddsa.go @@ -1,4 +1,4 @@ -// Package eddsa implements 25519 curve signature +// Package eddsa implements the ed25519 curve signature. package eddsa import ( @@ -18,7 +18,6 @@ func init() { const ( // PrivateKeyFileType is the PEM type for a private key. PrivateKeyFileType = "EDDSA PRIVATE KEY" - // PublicKeyFileType is the PEM type for a public key. PublicKeyFileType = "EDDSA PUBLIC KEY" ) @@ -26,15 +25,17 @@ const ( var ( _ hotstuff.QuorumSignature = (*crypto.Multi[*Signature])(nil) _ hotstuff.IDSet = (*crypto.Multi[*Signature])(nil) + _ crypto.Signature = (*Signature)(nil) ) -// Signature is an ECDSA signature +// Signature is an EDDSA signature. type Signature struct { signer hotstuff.ID sign []byte } -// RestoreSignature restores an existing signature. It should not be used to create new signatures, use Sign instead. +// RestoreSignature restores an existing signature. +// It should not be used to create new signatures, use Sign instead. func RestoreSignature(sign []byte, signer hotstuff.ID) *Signature { return &Signature{signer, sign} } @@ -44,7 +45,7 @@ func (sig Signature) Signer() hotstuff.ID { return sig.signer } -// ToBytes returns a raw byte string representation of the signature +// ToBytes returns a raw byte string representation of the signature. func (sig Signature) ToBytes() []byte { var b []byte b = append(b, sig.sign...) @@ -57,7 +58,7 @@ type eddsaBase struct { opts *modules.Options } -// New returns a new instance of the ECDSA CryptoBase implementation. +// New returns a new instance of the EDDSA CryptoBase implementation. func New() modules.CryptoBase { return &eddsaBase{} } @@ -76,23 +77,24 @@ func (ed *eddsaBase) privateKey() ed25519.PrivateKey { return ed.opts.PrivateKey().(ed25519.PrivateKey) } +// Sign creates a cryptographic signature of the given message. func (ed *eddsaBase) Sign(message []byte) (signature hotstuff.QuorumSignature, err error) { sign := ed25519.Sign(ed.privateKey(), message) eddsaSign := &Signature{signer: ed.opts.ID(), sign: sign} return crypto.Multi[*Signature]{ed.opts.ID(): eddsaSign}, nil } +// Combine combines multiple signatures into a single signature. func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.QuorumSignature, error) { if len(signatures) < 2 { return nil, crypto.ErrCombineMultiple } ts := make(crypto.Multi[*Signature]) - for _, sig1 := range signatures { if sig2, ok := sig1.(crypto.Multi[*Signature]); ok { for id, s := range sig2 { - if _, ok := ts[id]; ok { + if _, duplicate := ts[id]; duplicate { return nil, crypto.ErrCombineOverlap } ts[id] = s @@ -104,6 +106,7 @@ func (ed *eddsaBase) Combine(signatures ...hotstuff.QuorumSignature) (hotstuff.Q return ts, nil } +// Verify verifies the given quorum signature against the message. func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) bool { s, ok := signature.(crypto.Multi[*Signature]) if !ok { @@ -115,29 +118,26 @@ func (ed *eddsaBase) Verify(signature hotstuff.QuorumSignature, message []byte) } results := make(chan bool, n) - for _, sig := range s { go func(sig *Signature, msg []byte) { results <- ed.verifySingle(sig, msg) }(sig, message) } - valid := true for range s { if !<-results { valid = false } } - return valid - } + +// BatchVerify verifies the given quorum signature against the batch of messages. func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[hotstuff.ID][]byte) bool { s, ok := signature.(crypto.Multi[*Signature]) if !ok { ed.logger.Panicf("cannot verify signature of incompatible type %T (expected %T)", signature, s) } - n := signature.Participants().Len() if n == 0 { return false @@ -156,7 +156,6 @@ func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h results <- ed.verifySingle(sig, msg) }(sig, message) } - valid := true for range s { if !<-results { @@ -167,18 +166,17 @@ func (ed *eddsaBase) BatchVerify(signature hotstuff.QuorumSignature, batch map[h // valid if all partial signatures are valid and there are no duplicate messages return valid && len(set) == len(batch) } + func (ed *eddsaBase) verifySingle(sig *Signature, message []byte) bool { replica, ok := ed.configuration.Replica(sig.Signer()) if !ok { - ed.logger.Warnf("ecdsaBase: got signature from replica whose ID (%d) was not in the config.", sig.Signer()) + ed.logger.Warnf("eddsaBase: got signature from replica whose ID (%d) was not in the config.", sig.Signer()) return false } pk, ok := replica.PublicKey().([]byte) if !ok { - ed.logger.Infof("ecdsaBase: got public key from replica that was not of type []byte.") + ed.logger.Infof("eddsaBase: got public key from replica that was not of type []byte.") pk = replica.PublicKey().(ed25519.PublicKey) } return ed25519.Verify(pk, message, sig.sign) } - -var _ crypto.Signature = (*Signature)(nil) From a1b98e6a436dee67890047e4c60949d0a950373d Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Sun, 10 Mar 2024 10:13:19 +0100 Subject: [PATCH 11/13] fix: typo --- internal/proto/hotstuffpb/convert.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/proto/hotstuffpb/convert.go b/internal/proto/hotstuffpb/convert.go index 3c316044..71c3292e 100644 --- a/internal/proto/hotstuffpb/convert.go +++ b/internal/proto/hotstuffpb/convert.go @@ -76,7 +76,7 @@ func QuorumSignatureFromProto(sig *QuorumSignature) hotstuff.QuorumSignature { return nil } -// PartialCertToProto converts a consensus.PartialCert to a hotstuffpb.Partialcert. +// PartialCertToProto converts a consensus.PartialCert to a hotstuffpb.PartialCert. func PartialCertToProto(cert hotstuff.PartialCert) *PartialCert { hash := cert.BlockHash() return &PartialCert{ From 5b1fa0b39e1acd17cd8beeecb350776af981c346 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Sun, 10 Mar 2024 10:36:30 +0100 Subject: [PATCH 12/13] fix: type casting to ed25519.PublicKey now works as expected We now use ed25519.PublicKey directly instead of []byte. The ed25519.PublicKey is a type alias for []byte, but it is best to use the correct type. --- crypto/eddsa/eddsa.go | 6 +----- crypto/keygen/keygen.go | 19 +++++++++---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/crypto/eddsa/eddsa.go b/crypto/eddsa/eddsa.go index a71da854..c886731f 100644 --- a/crypto/eddsa/eddsa.go +++ b/crypto/eddsa/eddsa.go @@ -173,10 +173,6 @@ func (ed *eddsaBase) verifySingle(sig *Signature, message []byte) bool { ed.logger.Warnf("eddsaBase: got signature from replica whose ID (%d) was not in the config.", sig.Signer()) return false } - pk, ok := replica.PublicKey().([]byte) - if !ok { - ed.logger.Infof("eddsaBase: got public key from replica that was not of type []byte.") - pk = replica.PublicKey().(ed25519.PublicKey) - } + pk := replica.PublicKey().(ed25519.PublicKey) return ed25519.Verify(pk, message, sig.sign) } diff --git a/crypto/keygen/keygen.go b/crypto/keygen/keygen.go index 0c96b0e6..d0d2f163 100644 --- a/crypto/keygen/keygen.go +++ b/crypto/keygen/keygen.go @@ -31,7 +31,7 @@ func GenerateECDSAPrivateKey() (pk *ecdsa.PrivateKey, err error) { return pk, nil } -// GenerateED25519Key generates 25519 key +// GenerateED25519Key generates ed25519 key. func GenerateED25519Key() (pub ed25519.PublicKey, pk ed25519.PrivateKey, err error) { pub, pk, err = ed25519.GenerateKey(rand.Reader) if err != nil { @@ -129,7 +129,7 @@ func PrivateKeyToPEM(key hotstuff.PrivateKey) ([]byte, error) { // WritePrivateKeyFile writes a private key to the specified file. func WritePrivateKeyFile(key hotstuff.PrivateKey, filePath string) (err error) { - f, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + f, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return } @@ -166,7 +166,7 @@ func PublicKeyToPEM(key hotstuff.PublicKey) ([]byte, error) { marshaled = k.ToBytes() keyType = bls12.PublicKeyFileType case ed25519.PublicKey: - marshaled = make([]byte, ed25519.PublicKeySize) + marshaled = make(ed25519.PublicKey, ed25519.PublicKeySize) copy(marshaled, k) keyType = eddsa.PublicKeyFileType } @@ -181,7 +181,7 @@ func PublicKeyToPEM(key hotstuff.PublicKey) ([]byte, error) { // WritePublicKeyFile writes a public key to the specified file. func WritePublicKeyFile(key hotstuff.PublicKey, filePath string) (err error) { - f, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + f, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return } @@ -203,7 +203,7 @@ func WritePublicKeyFile(key hotstuff.PublicKey, filePath string) (err error) { // WriteCertFile writes an x509 certificate to a file. func WriteCertFile(cert *x509.Certificate, file string) (err error) { - f, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + f, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return } @@ -233,10 +233,9 @@ func ParsePrivateKey(buf []byte) (key hotstuff.PrivateKey, err error) { k.FromBytes(b.Bytes) key = k case eddsa.PrivateKeyFileType: - k := ed25519.NewKeyFromSeed(b.Bytes[:32]) - key = k + key = ed25519.NewKeyFromSeed(b.Bytes[:32]) default: - return nil, fmt.Errorf("file type did not match any known types %v", b.Type) + return nil, fmt.Errorf("private key file type did not match any known types %v", b.Type) } if err != nil { return nil, fmt.Errorf("failed to parse key: %w", err) @@ -270,11 +269,11 @@ func ParsePublicKey(buf []byte) (key hotstuff.PublicKey, err error) { } key = k case eddsa.PublicKeyFileType: - k := make([]byte, ed25519.PublicKeySize) + k := make(ed25519.PublicKey, ed25519.PublicKeySize) copy(k, b.Bytes) key = k default: - return nil, fmt.Errorf("file type did not match any known types %v", b.Type) + return nil, fmt.Errorf("public key file type did not match any known types %v", b.Type) } if err != nil { return nil, fmt.Errorf("failed to parse key: %w", err) From 8928cbcc022d6e4e382a4d3cd000f2e98635cb66 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Sun, 10 Mar 2024 11:23:13 +0100 Subject: [PATCH 13/13] fix: use x509 marshaling and parsing also for ed25519 keys --- crypto/keygen/keygen.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/crypto/keygen/keygen.go b/crypto/keygen/keygen.go index d0d2f163..4ecb455a 100644 --- a/crypto/keygen/keygen.go +++ b/crypto/keygen/keygen.go @@ -112,14 +112,17 @@ func PrivateKeyToPEM(key hotstuff.PrivateKey) ([]byte, error) { return nil, err } keyType = ecdsacrypto.PrivateKeyFileType + case ed25519.PrivateKey: + marshaled, err = x509.MarshalPKCS8PrivateKey(k) + if err != nil { + return nil, err + } + keyType = eddsa.PrivateKeyFileType case *bls12.PrivateKey: marshaled = k.ToBytes() keyType = bls12.PrivateKeyFileType - case ed25519.PrivateKey: - marshaled = make([]byte, ed25519.PrivateKeySize) - copy(marshaled, k) - keyType = eddsa.PrivateKeyFileType } + b := &pem.Block{ Type: keyType, Bytes: marshaled, @@ -162,20 +165,21 @@ func PublicKeyToPEM(key hotstuff.PublicKey) ([]byte, error) { return nil, err } keyType = ecdsacrypto.PublicKeyFileType + case ed25519.PublicKey: + marshaled, err = x509.MarshalPKIXPublicKey(k) + if err != nil { + return nil, err + } + keyType = eddsa.PublicKeyFileType case *bls12.PublicKey: marshaled = k.ToBytes() keyType = bls12.PublicKeyFileType - case ed25519.PublicKey: - marshaled = make(ed25519.PublicKey, ed25519.PublicKeySize) - copy(marshaled, k) - keyType = eddsa.PublicKeyFileType } b := &pem.Block{ Type: keyType, Bytes: marshaled, } - return pem.EncodeToMemory(b), nil } @@ -228,12 +232,12 @@ func ParsePrivateKey(buf []byte) (key hotstuff.PrivateKey, err error) { switch b.Type { case ecdsacrypto.PrivateKeyFileType: key, err = x509.ParseECPrivateKey(b.Bytes) + case eddsa.PrivateKeyFileType: + key = ed25519.NewKeyFromSeed(b.Bytes[:32]) case bls12.PrivateKeyFileType: k := &bls12.PrivateKey{} k.FromBytes(b.Bytes) key = k - case eddsa.PrivateKeyFileType: - key = ed25519.NewKeyFromSeed(b.Bytes[:32]) default: return nil, fmt.Errorf("private key file type did not match any known types %v", b.Type) } @@ -261,6 +265,8 @@ func ParsePublicKey(buf []byte) (key hotstuff.PublicKey, err error) { switch b.Type { case ecdsacrypto.PublicKeyFileType: key, err = x509.ParsePKIXPublicKey(b.Bytes) + case eddsa.PublicKeyFileType: + key, err = x509.ParsePKIXPublicKey(b.Bytes) case bls12.PublicKeyFileType: k := &bls12.PublicKey{} err = k.FromBytes(b.Bytes) @@ -268,10 +274,6 @@ func ParsePublicKey(buf []byte) (key hotstuff.PublicKey, err error) { return nil, err } key = k - case eddsa.PublicKeyFileType: - k := make(ed25519.PublicKey, ed25519.PublicKeySize) - copy(k, b.Bytes) - key = k default: return nil, fmt.Errorf("public key file type did not match any known types %v", b.Type) }