Skip to content

Commit

Permalink
Merge #673: Shrink sidechannel array, use wallet const for size
Browse files Browse the repository at this point in the history
533a890 Shrink sidechannel array, use wallet const for size (Gregory Sanders)

Pull request description:

Tree-SHA512: 9c4328c6c60dcaa6f821cec1e7632829297e275e2067a2e3d30a62e0e27731b43199614fa7df3e7cc32b524eab2c4ef49574cb728515eec9e1e64d78e6f1e77c
  • Loading branch information
stevenroose committed Jul 2, 2019
2 parents 9bc016f + 533a890 commit b9727ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/blind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion src/blind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b9727ae

Please sign in to comment.