@@ -171,6 +171,7 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchS
171171 return false ;
172172 secp256k1_pubkey pubkey;
173173 secp256k1_ecdsa_signature sig;
174+ assert (secp256k1_context_verify && " secp256k1_context_verify must be initialized to use CPubKey." );
174175 if (!secp256k1_ec_pubkey_parse (secp256k1_context_verify, &pubkey, vch, size ())) {
175176 return false ;
176177 }
@@ -190,6 +191,7 @@ bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned cha
190191 bool fComp = ((vchSig[0 ] - 27 ) & 4 ) != 0 ;
191192 secp256k1_pubkey pubkey;
192193 secp256k1_ecdsa_recoverable_signature sig;
194+ assert (secp256k1_context_verify && " secp256k1_context_verify must be initialized to use CPubKey." );
193195 if (!secp256k1_ecdsa_recoverable_signature_parse_compact (secp256k1_context_verify, &sig, &vchSig[1 ], recid)) {
194196 return false ;
195197 }
@@ -207,13 +209,15 @@ bool CPubKey::IsFullyValid() const {
207209 if (!IsValid ())
208210 return false ;
209211 secp256k1_pubkey pubkey;
212+ assert (secp256k1_context_verify && " secp256k1_context_verify must be initialized to use CPubKey." );
210213 return secp256k1_ec_pubkey_parse (secp256k1_context_verify, &pubkey, vch, size ());
211214}
212215
213216bool CPubKey::Decompress () {
214217 if (!IsValid ())
215218 return false ;
216219 secp256k1_pubkey pubkey;
220+ assert (secp256k1_context_verify && " secp256k1_context_verify must be initialized to use CPubKey." );
217221 if (!secp256k1_ec_pubkey_parse (secp256k1_context_verify, &pubkey, vch, size ())) {
218222 return false ;
219223 }
@@ -232,6 +236,7 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi
232236 BIP32Hash (cc, nChild, *begin (), begin ()+1 , out);
233237 memcpy (ccChild.begin (), out+32 , 32 );
234238 secp256k1_pubkey pubkey;
239+ assert (secp256k1_context_verify && " secp256k1_context_verify must be initialized to use CPubKey." );
235240 if (!secp256k1_ec_pubkey_parse (secp256k1_context_verify, &pubkey, vch, size ())) {
236241 return false ;
237242 }
@@ -273,6 +278,7 @@ bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
273278
274279/* static */ bool CPubKey::CheckLowS (const std::vector<unsigned char >& vchSig) {
275280 secp256k1_ecdsa_signature sig;
281+ assert (secp256k1_context_verify && " secp256k1_context_verify must be initialized to use CPubKey." );
276282 if (!ecdsa_signature_parse_der_lax (secp256k1_context_verify, &sig, vchSig.data (), vchSig.size ())) {
277283 return false ;
278284 }
0 commit comments