@@ -198,28 +198,31 @@ public void key_test1()
198198 }
199199 // compact signatures (with key recovery)
200200
201- byte [ ] csign1 = null , csign2 = null , csign1C = null , csign2C = null ;
202-
203- csign1 = key1 . SignCompact ( hashMsg ) ;
204- csign2 = key2 . SignCompact ( hashMsg ) ;
205- csign1C = key1C . SignCompact ( hashMsg ) ;
206- csign2C = key2C . SignCompact ( hashMsg ) ;
207-
208- PubKey rkey1 = null , rkey2 = null , rkey1C = null , rkey2C = null ;
209- rkey1 = PubKey . RecoverCompact ( hashMsg , csign1 ) ;
210- rkey2 = PubKey . RecoverCompact ( hashMsg , csign2 ) ;
211- rkey1C = PubKey . RecoverCompact ( hashMsg , csign1C ) ;
212- rkey2C = PubKey . RecoverCompact ( hashMsg , csign2C ) ;
213-
214- Assert . True ( rkey1 . ToHex ( ) == pubkey1 . ToHex ( ) ) ;
215- Assert . True ( rkey2 . ToHex ( ) == pubkey2 . ToHex ( ) ) ;
216- Assert . True ( rkey1C . ToHex ( ) == pubkey1C . ToHex ( ) ) ;
217- Assert . True ( rkey2C . ToHex ( ) == pubkey2C . ToHex ( ) ) ;
218-
219- Assert . True ( sign1 . IsLowR && sign1 . ToDER ( ) . Length <= 70 ) ;
220- Assert . True ( sign2 . IsLowR && sign2 . ToDER ( ) . Length <= 70 ) ;
221- Assert . True ( sign1C . IsLowR && sign1C . ToDER ( ) . Length <= 70 ) ;
222- Assert . True ( sign2C . IsLowR && sign2C . ToDER ( ) . Length <= 70 ) ;
201+ CompactSignature csign1 = null , csign2 = null , csign1C = null , csign2C = null ;
202+
203+ if ( key1 . IsCompressed )
204+ {
205+ csign1 = key1 . SignCompact ( hashMsg ) ;
206+ csign2 = key2 . SignCompact ( hashMsg ) ;
207+ csign1C = key1C . SignCompact ( hashMsg ) ;
208+ csign2C = key2C . SignCompact ( hashMsg ) ;
209+
210+ PubKey rkey1 = null , rkey2 = null , rkey1C = null , rkey2C = null ;
211+ rkey1 = PubKey . RecoverCompact ( hashMsg , csign1 ) ;
212+ rkey2 = PubKey . RecoverCompact ( hashMsg , csign2 ) ;
213+ rkey1C = PubKey . RecoverCompact ( hashMsg , csign1C ) ;
214+ rkey2C = PubKey . RecoverCompact ( hashMsg , csign2C ) ;
215+
216+ Assert . True ( rkey1 . ToHex ( ) == pubkey1 . ToHex ( ) ) ;
217+ Assert . True ( rkey2 . ToHex ( ) == pubkey2 . ToHex ( ) ) ;
218+ Assert . True ( rkey1C . ToHex ( ) == pubkey1C . ToHex ( ) ) ;
219+ Assert . True ( rkey2C . ToHex ( ) == pubkey2C . ToHex ( ) ) ;
220+
221+ Assert . True ( sign1 . IsLowR && sign1 . ToDER ( ) . Length <= 70 ) ;
222+ Assert . True ( sign2 . IsLowR && sign2 . ToDER ( ) . Length <= 70 ) ;
223+ Assert . True ( sign1C . IsLowR && sign1C . ToDER ( ) . Length <= 70 ) ;
224+ Assert . True ( sign2C . IsLowR && sign2C . ToDER ( ) . Length <= 70 ) ;
225+ }
223226 }
224227 }
225228
0 commit comments