@@ -164,44 +164,21 @@ func (sc *SyncCommittee) VerifySignature(signingRoot common.Hash, signature *Syn
164
164
return bls .FastAggregateVerify (keys , signingRoot [:], & sig )
165
165
}
166
166
167
+ //go:generate go run github.com/fjl/gencodec -type SyncAggregate -field-override syncAggregateMarshaling -out gen_syncaggregate_json.go
168
+
167
169
// SyncAggregate represents an aggregated BLS signature with Signers referring
168
170
// to a subset of the corresponding sync committee.
169
171
//
170
172
// See data structure definition here:
171
173
// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#syncaggregate
172
174
type SyncAggregate struct {
173
- Signers [params .SyncCommitteeBitmaskSize ]byte
174
- Signature [params .BLSSignatureSize ]byte
175
- }
176
-
177
- type jsonSyncAggregate struct {
178
- Signers hexutil.Bytes `json:"sync_committee_bits"`
179
- Signature hexutil.Bytes `json:"sync_committee_signature"`
175
+ Signers [params .SyncCommitteeBitmaskSize ]byte `gencodec:"required" json:"sync_committee_bits"`
176
+ Signature [params .BLSSignatureSize ]byte `gencodec:"required" json:"sync_committee_signature"`
180
177
}
181
178
182
- // MarshalJSON implements json.Marshaler.
183
- func (s * SyncAggregate ) MarshalJSON () ([]byte , error ) {
184
- return json .Marshal (& jsonSyncAggregate {
185
- Signers : s .Signers [:],
186
- Signature : s .Signature [:],
187
- })
188
- }
189
-
190
- // UnmarshalJSON implements json.Marshaler.
191
- func (s * SyncAggregate ) UnmarshalJSON (input []byte ) error {
192
- var sc jsonSyncAggregate
193
- if err := json .Unmarshal (input , & sc ); err != nil {
194
- return err
195
- }
196
- if len (sc .Signers ) != params .SyncCommitteeBitmaskSize {
197
- return fmt .Errorf ("invalid signature bitmask size %d" , len (sc .Signers ))
198
- }
199
- if len (sc .Signature ) != params .BLSSignatureSize {
200
- return fmt .Errorf ("invalid signature size %d" , len (sc .Signature ))
201
- }
202
- copy (s .Signers [:], sc .Signers )
203
- copy (s .Signature [:], sc .Signature )
204
- return nil
179
+ type syncAggregateMarshaling struct {
180
+ Signers hexutil.Bytes
181
+ Signature hexutil.Bytes
205
182
}
206
183
207
184
// SignerCount returns the number of signers in the aggregate signature.
0 commit comments