@@ -11,6 +11,7 @@ import (
11
11
"github.com/pkg/errors"
12
12
"github.com/rs/zerolog/log"
13
13
14
+ "github.com/shutter-network/shutter/shlib/puredkg"
14
15
"github.com/shutter-network/shutter/shlib/shcrypto"
15
16
16
17
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/database"
@@ -74,7 +75,13 @@ func (handler *DecryptionKeyHandler) ValidateMessage(ctx context.Context, msg p2
74
75
if len (key .Keys ) > int (handler .config .GetMaxNumKeysPerMessage ()) {
75
76
return pubsub .ValidationReject , errors .Errorf ("too many keys in message (%d > %d)" , len (key .Keys ), handler .config .GetMaxNumKeysPerMessage ())
76
77
}
77
- for i , k := range key .Keys {
78
+
79
+ validationResult , err := checkKeysErrors (key .Keys , pureDKGResult )
80
+ return validationResult , err
81
+ }
82
+
83
+ func checkKeysErrors (keys []* p2pmsg.Key , pureDKGResult * puredkg.Result ) (pubsub.ValidationResult , error ) {
84
+ for i , k := range keys {
78
85
epochSecretKey , err := k .GetEpochSecretKey ()
79
86
if err != nil {
80
87
return pubsub .ValidationReject , err
@@ -87,7 +94,7 @@ func (handler *DecryptionKeyHandler) ValidateMessage(ctx context.Context, msg p2
87
94
return pubsub .ValidationReject , errors .Errorf ("epoch secret key for identity %x is not valid" , k .Identity )
88
95
}
89
96
90
- if i > 0 && bytes .Compare (k .Identity , key . Keys [i - 1 ].Identity ) < 0 {
97
+ if i > 0 && bytes .Compare (k .Identity , keys [i - 1 ].Identity ) < 0 {
91
98
return pubsub .ValidationReject , errors .Errorf ("keys not ordered" )
92
99
}
93
100
}
0 commit comments