@@ -122,15 +122,13 @@ func (scheme *Scheme) Verify(x kyber.Point, msg, sig []byte) error {
122
122
123
123
// AggregateSignatures aggregates the signatures using a coefficient for each
124
124
// one of them where c = H(pk) and H: keyGroup -> R with R = {1, ..., 2^128}
125
- func (scheme * Scheme ) AggregateSignatures (sigs [][]byte , mask * sign.Mask ) (kyber.Point , error ) {
126
- publics := mask .Publics ()
127
- coefs , err := hashPointToR (publics )
125
+ func (scheme * Scheme ) AggregateSignatures (sigs [][]byte , mask Mask ) (kyber.Point , error ) {
126
+ bdnMask , err := newCachedMask (mask , false )
128
127
if err != nil {
129
128
return nil , err
130
129
}
131
-
132
130
agg := scheme .sigGroup .Point ()
133
- for i := range publics {
131
+ for i := range bdnMask . publics {
134
132
if enabled , err := mask .GetBit (i ); err != nil {
135
133
// this should never happen because of the loop boundary
136
134
// an error here is probably a bug in the mask implementation
@@ -152,7 +150,7 @@ func (scheme *Scheme) AggregateSignatures(sigs [][]byte, mask *sign.Mask) (kyber
152
150
return nil , err
153
151
}
154
152
155
- sigC := sig .Clone ().Mul (coefs [i ], sig )
153
+ sigC := sig .Clone ().Mul (bdnMask . coefs [i ], sig )
156
154
// c+1 because R is in the range [1, 2^128] and not [0, 2^128-1]
157
155
sigC = sigC .Add (sigC , sig )
158
156
agg = agg .Add (agg , sigC )
@@ -164,15 +162,14 @@ func (scheme *Scheme) AggregateSignatures(sigs [][]byte, mask *sign.Mask) (kyber
164
162
// AggregatePublicKeys aggregates a set of public keys (similarly to
165
163
// AggregateSignatures for signatures) using the hash function
166
164
// H: keyGroup -> R with R = {1, ..., 2^128}.
167
- func (scheme * Scheme ) AggregatePublicKeys (mask * sign.Mask ) (kyber.Point , error ) {
168
- publics := mask .Publics ()
169
- coefs , err := hashPointToR (publics )
165
+ func (scheme * Scheme ) AggregatePublicKeys (mask Mask ) (kyber.Point , error ) {
166
+ bdnMask , err := newCachedMask (mask , false )
170
167
if err != nil {
171
168
return nil , err
172
169
}
173
170
174
171
agg := scheme .keyGroup .Point ()
175
- for i , pub := range publics {
172
+ for i := range bdnMask . publics {
176
173
if enabled , err := mask .GetBit (i ); err != nil {
177
174
// this should never happen because of the loop boundary
178
175
// an error here is probably a bug in the mask implementation
@@ -181,9 +178,7 @@ func (scheme *Scheme) AggregatePublicKeys(mask *sign.Mask) (kyber.Point, error)
181
178
continue
182
179
}
183
180
184
- pubC := pub .Clone ().Mul (coefs [i ], pub )
185
- pubC = pubC .Add (pubC , pub )
186
- agg = agg .Add (agg , pubC )
181
+ agg = agg .Add (agg , bdnMask .getOrComputePubC (i ))
187
182
}
188
183
189
184
return agg , nil
@@ -217,14 +212,14 @@ func Verify(suite pairing.Suite, x kyber.Point, msg, sig []byte) error {
217
212
// AggregateSignatures aggregates the signatures using a coefficient for each
218
213
// one of them where c = H(pk) and H: G2 -> R with R = {1, ..., 2^128}
219
214
// Deprecated: use the new scheme methods instead.
220
- func AggregateSignatures (suite pairing.Suite , sigs [][]byte , mask * sign. Mask ) (kyber.Point , error ) {
215
+ func AggregateSignatures (suite pairing.Suite , sigs [][]byte , mask Mask ) (kyber.Point , error ) {
221
216
return NewSchemeOnG1 (suite ).AggregateSignatures (sigs , mask )
222
217
}
223
218
224
219
// AggregatePublicKeys aggregates a set of public keys (similarly to
225
220
// AggregateSignatures for signatures) using the hash function
226
221
// H: G2 -> R with R = {1, ..., 2^128}.
227
222
// Deprecated: use the new scheme methods instead.
228
- func AggregatePublicKeys (suite pairing.Suite , mask * sign. Mask ) (kyber.Point , error ) {
223
+ func AggregatePublicKeys (suite pairing.Suite , mask Mask ) (kyber.Point , error ) {
229
224
return NewSchemeOnG1 (suite ).AggregatePublicKeys (mask )
230
225
}
0 commit comments