Merge #673: Shrink sidechannel array, use wallet const for size

533a89097 Shrink sidechannel array, use wallet const for size (Gregory Sanders)

Pull request description:

Tree-SHA512: 9c4328c6c60dcaa6f821cec1e7632829297e275e2067a2e3d30a62e0e27731b43199614fa7df3e7cc32b524eab2c4ef49574cb728515eec9e1e64d78e6f1e77c
This commit is contained in:
Steven Roose 2019-07-02 19:02:22 +01:00
commit b9727ae60c
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87
2 changed files with 8 additions and 7 deletions

View file

@ -59,10 +59,8 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
nonce = uint256(std::vector<unsigned char>(blinding_key.begin(), blinding_key.end()));
}
// API-prescribed sidechannel maximum size, though we only use 64 bytes
unsigned char msg[4096] = {0};
// 32 bytes of asset type, 32 bytes of asset blinding factor in sidechannel
size_t msg_size = 64;
unsigned char msg[SIDECHANNEL_MSG_SIZE] = {0};
size_t msg_size = SIDECHANNEL_MSG_SIZE;
// If value is unblinded, we don't support unblinding just the asset
if (!conf_value.IsCommitment()) {
@ -102,7 +100,7 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
// Asset sidechannel of asset type + asset blinder
secp256k1_generator recalculated_gen;
if (msg_size != 64 || secp256k1_generator_generate_blinded(secp256k1_blind_context, &recalculated_gen, asset_type, asset_blinder) != 1) {
if (msg_size != SIDECHANNEL_MSG_SIZE || secp256k1_generator_generate_blinded(secp256k1_blind_context, &recalculated_gen, asset_type, asset_blinder) != 1) {
return false;
}
@ -175,7 +173,7 @@ bool GenerateRangeproof(std::vector<unsigned char>& rangeproof, const std::vecto
rangeproof.resize(nRangeProofLen);
// Compose sidechannel message to convey asset info (ID and asset blinds)
unsigned char asset_message[64];
unsigned char asset_message[SIDECHANNEL_MSG_SIZE];
memcpy(asset_message, asset.begin(), 32);
memcpy(asset_message+32, asset_blindptrs[asset_blindptrs.size()-1], 32);

View file

@ -14,8 +14,11 @@
#include <secp256k1_rangeproof.h>
#include <secp256k1_surjectionproof.h>
//! ELEMENTS: 36-bit rangeproof size
//! ELEMENTS:
// 36-bit rangeproof size
static const size_t DEFAULT_RANGEPROOF_SIZE = 2893;
// 32 bytes of asset type, 32 bytes of asset blinding factor in sidechannel
static const size_t SIDECHANNEL_MSG_SIZE = 64;
/*
* Unblind a pair of confidential asset and value.