CT: Don't assume size of a serialized pubkey (removes a magic number).

This commit is contained in:
Mark Friedenbach 2017-03-10 04:39:34 -08:00 committed by Gregory Sanders
parent 88a31dff93
commit d2d0fd02fa

View file

@ -217,8 +217,9 @@ int BlindOutputs(std::vector<uint256 >& input_blinding_factors, const std::vecto
CKey ephemeral_key;
ephemeral_key.MakeNewKey(true);
CPubKey ephemeral_pubkey = ephemeral_key.GetPubKey();
out.nNonce.vchCommitment.resize(33);
memcpy(&out.nNonce.vchCommitment[0], &ephemeral_pubkey[0], 33);
assert(ephemeral_pubkey.size() == CConfidentialNonce::nCommittedSize);
out.nNonce.vchCommitment.resize(ephemeral_pubkey.size());
memcpy(&out.nNonce.vchCommitment[0], &ephemeral_pubkey[0], ephemeral_pubkey.size());
// Generate nonce
uint256 nonce = ephemeral_key.ECDH(output_pubkeys[nOut]);
CSHA256().Write(nonce.begin(), 32).Finalize(nonce.begin());