21
21
import org .bitcoinj .crypto .BLSLazyPublicKey ;
22
22
import org .bitcoinj .crypto .BLSLazySignature ;
23
23
import org .bitcoinj .crypto .BLSPublicKey ;
24
- import org .bitcoinj .crypto .BLSScheme ;
25
24
import org .bitcoinj .crypto .BLSSignature ;
26
25
import org .bitcoinj .evolution .Masternode ;
27
26
import org .bitcoinj .evolution .SpecialTxPayload ;
@@ -56,11 +55,11 @@ public class FinalCommitment extends SpecialTxPayload {
56
55
ArrayList <Boolean > signers ;
57
56
ArrayList <Boolean > validMembers ;
58
57
59
- BLSPublicKey quorumPublicKey ;
58
+ BLSLazyPublicKey quorumPublicKey ;
60
59
Sha256Hash quorumVvecHash ;
61
60
62
- BLSSignature quorumSignature ;
63
- BLSSignature membersSignature ;
61
+ BLSLazySignature quorumSignature ;
62
+ BLSLazySignature membersSignature ;
64
63
private boolean verified = false ;
65
64
66
65
public FinalCommitment (NetworkParameters params , byte [] payload , int offset ) {
@@ -90,10 +89,10 @@ public FinalCommitment(NetworkParameters params, int version,
90
89
int quorumSize = LLMQParameters .fromType (LLMQParameters .LLMQType .fromValue (llmqType )).size ;
91
90
this .signers = Utils .booleanArrayList (quorumSize , signers );
92
91
this .validMembers = Utils .booleanArrayList (quorumSize , validMembers );
93
- this .quorumPublicKey = new BLSPublicKey (params , quorumPublicKey , 0 , isLegacy ());
92
+ this .quorumPublicKey = new BLSLazyPublicKey (params , quorumPublicKey , 0 , isLegacy ());
94
93
this .quorumVvecHash = quorumVvecHash ;
95
- this .quorumSignature = signature . getSignature ( );
96
- this .membersSignature = membersSignature . getSignature ( );
94
+ this .quorumSignature = new BLSLazySignature ( signature );
95
+ this .membersSignature = new BLSLazySignature ( membersSignature );
97
96
length = 1 + 32 +
98
97
(isIndexed () ? 2 : 0 ) +
99
98
VarInt .sizeOf (quorumSize ) * 2 +
@@ -115,15 +114,15 @@ protected void parse() throws ProtocolException {
115
114
signers = readBooleanArrayList ();
116
115
validMembers = readBooleanArrayList ();
117
116
118
- quorumPublicKey = new BLSPublicKey (params , payload , cursor , isLegacy ());
117
+ quorumPublicKey = new BLSLazyPublicKey (params , payload , cursor , isLegacy ());
119
118
cursor += quorumPublicKey .getMessageSize ();
120
119
121
120
quorumVvecHash = readHash ();
122
121
123
- quorumSignature = new BLSSignature (params , payload , cursor , isLegacy ());
122
+ quorumSignature = new BLSLazySignature (params , payload , cursor , isLegacy ());
124
123
cursor += quorumSignature .getMessageSize ();
125
124
126
- membersSignature = new BLSSignature (params , payload , cursor , isLegacy ());
125
+ membersSignature = new BLSLazySignature (params , payload , cursor , isLegacy ());
127
126
cursor += membersSignature .getMessageSize ();
128
127
129
128
length = cursor - offset ;
@@ -293,7 +292,7 @@ public boolean verify(StoredBlock block, ArrayList<Masternode> members, boolean
293
292
294
293
// sigs are only checked when the block is processed
295
294
if (checkSigs ) {
296
- Sha256Hash commitmentHash = LLMQUtils .buildCommitmentHash (llmqParameters .type , quorumHash , validMembers , quorumPublicKey , quorumVvecHash );
295
+ Sha256Hash commitmentHash = LLMQUtils .buildCommitmentHash (llmqParameters .type , quorumHash , validMembers , quorumPublicKey . getPublicKey () , quorumVvecHash );
297
296
298
297
ArrayList <BLSPublicKey > memberPubKeys = Lists .newArrayList ();
299
298
for (int i = 0 ; i < members .size (); i ++) {
@@ -303,15 +302,15 @@ public boolean verify(StoredBlock block, ArrayList<Masternode> members, boolean
303
302
memberPubKeys .add (members .get (i ).getPubKeyOperator ());
304
303
}
305
304
306
- if (!membersSignature .verifySecureAggregated (memberPubKeys , commitmentHash , isLegacy ())) {
305
+ if (!membersSignature .getSignature (). verifySecureAggregated (memberPubKeys , commitmentHash , isLegacy ())) {
307
306
log .error ("invalid aggregated members signature" );
308
307
return false ;
309
308
}
310
309
311
- Context .get ().signingManager .logSignature ("QUORUM" , quorumPublicKey , commitmentHash , quorumSignature );
310
+ Context .get ().signingManager .logSignature ("QUORUM" , quorumPublicKey . getPublicKey () , commitmentHash , quorumSignature . getSignature () );
312
311
313
312
if (Context .get ().masternodeSync .hasVerifyFlag (MasternodeSync .VERIFY_FLAGS .BLS_SIGNATURES )) {
314
- if (!quorumSignature .verifyInsecure (quorumPublicKey , commitmentHash , isLegacy ())) {
313
+ if (!quorumSignature .getSignature (). verifyInsecure (quorumPublicKey . getPublicKey () , commitmentHash , isLegacy ())) {
315
314
log .error ("invalid quorum signature" );
316
315
return false ;
317
316
}
@@ -393,19 +392,19 @@ public LLMQParameters.LLMQType getLlmqType() {
393
392
}
394
393
395
394
public BLSPublicKey getQuorumPublicKey () {
396
- return quorumPublicKey ;
395
+ return quorumPublicKey . getPublicKey () ;
397
396
}
398
397
399
398
public Sha256Hash getQuorumVvecHash () {
400
399
return quorumVvecHash ;
401
400
}
402
401
403
402
public BLSSignature getMembersSignature () {
404
- return membersSignature ;
403
+ return membersSignature . getSignature () ;
405
404
}
406
405
407
406
public BLSSignature getQuorumSignature () {
408
- return quorumSignature ;
407
+ return quorumSignature . getSignature () ;
409
408
}
410
409
411
410
public ArrayList <Boolean > getSigners () {
0 commit comments