mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
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:
commit
b9727ae60c
2 changed files with 8 additions and 7 deletions
|
|
@ -59,10 +59,8 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
|
||||||
nonce = uint256(std::vector<unsigned char>(blinding_key.begin(), blinding_key.end()));
|
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[SIDECHANNEL_MSG_SIZE] = {0};
|
||||||
unsigned char msg[4096] = {0};
|
size_t msg_size = SIDECHANNEL_MSG_SIZE;
|
||||||
// 32 bytes of asset type, 32 bytes of asset blinding factor in sidechannel
|
|
||||||
size_t msg_size = 64;
|
|
||||||
|
|
||||||
// If value is unblinded, we don't support unblinding just the asset
|
// If value is unblinded, we don't support unblinding just the asset
|
||||||
if (!conf_value.IsCommitment()) {
|
if (!conf_value.IsCommitment()) {
|
||||||
|
|
@ -102,7 +100,7 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
|
||||||
|
|
||||||
// Asset sidechannel of asset type + asset blinder
|
// Asset sidechannel of asset type + asset blinder
|
||||||
secp256k1_generator recalculated_gen;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +173,7 @@ bool GenerateRangeproof(std::vector<unsigned char>& rangeproof, const std::vecto
|
||||||
rangeproof.resize(nRangeProofLen);
|
rangeproof.resize(nRangeProofLen);
|
||||||
|
|
||||||
// Compose sidechannel message to convey asset info (ID and asset blinds)
|
// 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, asset.begin(), 32);
|
||||||
memcpy(asset_message+32, asset_blindptrs[asset_blindptrs.size()-1], 32);
|
memcpy(asset_message+32, asset_blindptrs[asset_blindptrs.size()-1], 32);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,11 @@
|
||||||
#include <secp256k1_rangeproof.h>
|
#include <secp256k1_rangeproof.h>
|
||||||
#include <secp256k1_surjectionproof.h>
|
#include <secp256k1_surjectionproof.h>
|
||||||
|
|
||||||
//! ELEMENTS: 36-bit rangeproof size
|
//! ELEMENTS:
|
||||||
|
// 36-bit rangeproof size
|
||||||
static const size_t DEFAULT_RANGEPROOF_SIZE = 2893;
|
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.
|
* Unblind a pair of confidential asset and value.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue