Shrink sidechannel array, use wallet const for size

This commit is contained in:
Gregory Sanders 2019-07-01 10:06:46 -04:00
parent c977f2b99d
commit 533a890972
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.