mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
commit
5c0fb8fc2b
27 changed files with 115 additions and 88 deletions
|
|
@ -57,9 +57,9 @@
|
|||
<Target Name="AfterBuild">
|
||||
<Copy SourceFiles="$(ConfigIniIn)" DestinationFiles="$(ConfigIniOut)" ></Copy>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
Replace="@PACKAGE_NAME@" By="Bitcoin Core"></ReplaceInFile>
|
||||
Replace="@PACKAGE_NAME@" By="Elements Core"></ReplaceInFile>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
Replace="@PACKAGE_BUGREPORT@" By="https://github.com/bitcoin/bitcoin/issues"></ReplaceInFile>
|
||||
Replace="@PACKAGE_BUGREPORT@" By="https://github.com/ElementsProject/elements/issues"></ReplaceInFile>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
Replace="@abs_top_srcdir@" By="..\.." ToFullPath="true"></ReplaceInFile>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ AC_PREREQ([2.69])
|
|||
define(_CLIENT_VERSION_MAJOR, 23)
|
||||
define(_CLIENT_VERSION_MINOR, 3)
|
||||
define(_CLIENT_VERSION_BUILD, 0)
|
||||
define(_CLIENT_VERSION_RC, 4)
|
||||
define(_CLIENT_VERSION_RC, 5)
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2024)
|
||||
define(_COPYRIGHT_HOLDERS,[The %s developers])
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_bloc
|
|||
| SCRIPT_VERIFY_SIGPUSHONLY // Witness is push-only
|
||||
| SCRIPT_VERIFY_LOW_S // Stop easiest signature fiddling
|
||||
| SCRIPT_VERIFY_WITNESS // Witness and to enforce cleanstack
|
||||
| (is_dyna ? 0 : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
|
||||
| (is_dyna ? SCRIPT_VERIFY_NONE : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
|
||||
return GenericVerifyScript(scriptSig, witness, challenge, proof_flags, block);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2131,29 +2131,30 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
|
|||
// If we are already too far ahead of where we want to be on headers, discard
|
||||
// the received headers. We can still get ahead by up to a single maximum-sized
|
||||
// headers message here, but never further, so that's fine.
|
||||
if (pindexBestHeader) {
|
||||
int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight();
|
||||
bool too_far_ahead = node::fTrimHeaders && (headers_ahead >= node::nHeaderDownloadBuffer);
|
||||
if (too_far_ahead) {
|
||||
LOCK(cs_main);
|
||||
CNodeState *nodestate = State(pfrom.GetId());
|
||||
if ((nodestate->pindexBestKnownBlock == nullptr) ||
|
||||
if (node::fTrimHeaders) {
|
||||
LOCK(cs_main);
|
||||
if (pindexBestHeader) {
|
||||
int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight();
|
||||
if (headers_ahead >= node::nHeaderDownloadBuffer) {
|
||||
CNodeState *nodestate = State(pfrom.GetId());
|
||||
if ((nodestate->pindexBestKnownBlock == nullptr) ||
|
||||
(nodestate->pindexBestKnownBlock->nHeight < m_chainman.ActiveHeight())) {
|
||||
// Our notion of what blocks a peer has available is based on its pindexBestKnownBlock,
|
||||
// which is based on headers received from it. If we don't have one, or it's too old,
|
||||
// then we can never get blocks from this peer until we accept headers from it first.
|
||||
LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
if (nodestate->fSyncStarted) {
|
||||
// Cancel sync from this node, so we don't penalize it later.
|
||||
// This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later,
|
||||
// if we still need to sync headers.
|
||||
nSyncStarted--;
|
||||
nodestate->fSyncStarted = false;
|
||||
nodestate->m_headers_sync_timeout = 0us;
|
||||
// Our notion of what blocks a peer has available is based on its pindexBestKnownBlock,
|
||||
// which is based on headers received from it. If we don't have one, or it's too old,
|
||||
// then we can never get blocks from this peer until we accept headers from it first.
|
||||
LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
if (nodestate->fSyncStarted) {
|
||||
// Cancel sync from this node, so we don't penalize it later.
|
||||
// This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later,
|
||||
// if we still need to sync headers.
|
||||
nSyncStarted--;
|
||||
nodestate->fSyncStarted = false;
|
||||
nodestate->m_headers_sync_timeout = 0us;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public:
|
|||
return -1;
|
||||
}
|
||||
|
||||
assert(IsExplicit());;
|
||||
assert(IsExplicit());
|
||||
return ReadBE64(&vchCommitment[1]);
|
||||
}
|
||||
void SetToAmount(CAmount nAmount);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,10 @@ static fs::path GetMainchainAuthCookieFile()
|
|||
if (gArgs.GetChainName() == "liquidv1") {
|
||||
cookie_file = ".cookie";
|
||||
}
|
||||
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file)));
|
||||
fs::path cookie_path = fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file));
|
||||
if (cookie_path.is_absolute())
|
||||
return cookie_path;
|
||||
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), cookie_path);
|
||||
}
|
||||
|
||||
bool GetMainchainAuthCookie(std::string *cookie_out)
|
||||
|
|
@ -148,7 +151,7 @@ bool GetMainchainAuthCookie(std::string *cookie_out)
|
|||
std::string cookie;
|
||||
|
||||
std::filesystem::path filepath = GetMainchainAuthCookieFile();
|
||||
file.open(filepath.string().c_str());
|
||||
file.open(filepath);
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
std::getline(file, cookie);
|
||||
|
|
|
|||
|
|
@ -2669,7 +2669,7 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
|
|||
simplicityRawTx.version = txTo.nVersion;
|
||||
simplicityRawTx.lockTime = txTo.nLockTime;
|
||||
|
||||
m_simplicity_tx_data = simplicity_elements_mallocTransaction(&simplicityRawTx);
|
||||
m_simplicity_tx_data = SimplicityTransactionUniquePtr(simplicity_elements_mallocTransaction(&simplicityRawTx));
|
||||
|
||||
m_bip341_taproot_ready = true;
|
||||
}
|
||||
|
|
@ -3121,7 +3121,7 @@ bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& progr
|
|||
|
||||
assert(txdata->m_simplicity_tx_data);
|
||||
assert(simplicityTapEnv);
|
||||
if (!simplicity_elements_execSimplicity(&error, 0, txdata->m_simplicity_tx_data, nIn, simplicityTapEnv, txdata->m_hash_genesis_block.data(), budget, 0, program.data(), program.size(), witness.data(), witness.size())) {
|
||||
if (!simplicity_elements_execSimplicity(&error, 0, txdata->m_simplicity_tx_data.get(), nIn, simplicityTapEnv, txdata->m_hash_genesis_block.data(), budget, 0, program.data(), program.size(), witness.data(), witness.size())) {
|
||||
assert(!"simplicity_elements_execSimplicity internal error");
|
||||
}
|
||||
simplicity_elements_freeTapEnv(simplicityTapEnv);
|
||||
|
|
|
|||
|
|
@ -169,9 +169,18 @@ enum : uint32_t {
|
|||
|
||||
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
|
||||
|
||||
struct SimplicityTransactionDeleter
|
||||
{
|
||||
void operator()(transaction* ptr)
|
||||
{
|
||||
simplicity_elements_freeTransaction(ptr);
|
||||
}
|
||||
};
|
||||
using SimplicityTransactionUniquePtr = std::unique_ptr<transaction, SimplicityTransactionDeleter>;
|
||||
|
||||
struct PrecomputedTransactionData
|
||||
{
|
||||
transaction* m_simplicity_tx_data = nullptr;
|
||||
SimplicityTransactionUniquePtr m_simplicity_tx_data;
|
||||
// BIP341 precomputed data.
|
||||
// These are single-SHA256, see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-15.
|
||||
uint256 m_prevouts_single_hash;
|
||||
|
|
@ -221,9 +230,6 @@ struct PrecomputedTransactionData
|
|||
|
||||
template <class T>
|
||||
explicit PrecomputedTransactionData(const T& tx);
|
||||
~PrecomputedTransactionData() {
|
||||
simplicity_elements_freeTransaction(m_simplicity_tx_data);
|
||||
}
|
||||
};
|
||||
|
||||
enum class SigVersion
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ void simplicity_computeAnnotatedMerkleRoot(analyses* analysis, const dag_node* d
|
|||
}
|
||||
|
||||
/* Verifies that the 'dag' is in canonical order, meaning that nodes under the left branches have lower indices than nodes under
|
||||
* right branches, with the exception that nodes under right braches may (cross-)reference identical nodes that already occur under
|
||||
* right branches, with the exception that nodes under right branches may (cross-)reference identical nodes that already occur under
|
||||
* left branches.
|
||||
*
|
||||
* Returns 'SIMPLICITY_NO_ERROR' if the 'dag' is in canonical order, and returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if it is not.
|
||||
|
|
@ -389,7 +389,7 @@ simplicity_err simplicity_verifyCanonicalOrder(dag_node* dag, const uint_fast32_
|
|||
/* We use dag[i].aux as a "stack" to manage the traversal of the DAG. */
|
||||
dag[top].aux = len; /* We will set top to 'len' to indicate we are finished. */
|
||||
|
||||
/* Each time any particular 'top' value is revisted in this loop, bottom has increased to be strictly larger than the last 'child'
|
||||
/* Each time any particular 'top' value is revisited in this loop, bottom has increased to be strictly larger than the last 'child'
|
||||
value examined. Therefore we will make further progress in the loop the next time around.
|
||||
By this reasoning any given 'top' value will be visited no more than numChildren(dag[top].tag) + 1 <= 3 times.
|
||||
Thus this loop iterates at most O('len') times.
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ void simplicity_computeCommitmentMerkleRoot(dag_node* dag, uint_fast32_t i);
|
|||
void simplicity_computeAnnotatedMerkleRoot(analyses* analysis, const dag_node* dag, const type* type_dag, uint_fast32_t len);
|
||||
|
||||
/* Verifies that the 'dag' is in canonical order, meaning that nodes under the left branches have lower indices than nodes under
|
||||
* right branches, with the exception that nodes under right braches may (cross-)reference identical nodes that already occur under
|
||||
* right branches, with the exception that nodes under right branches may (cross-)reference identical nodes that already occur under
|
||||
* left branches.
|
||||
*
|
||||
* Returns 'SIMPLICITY_NO_ERROR' if the 'dag' is in canonical order, and returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if it is not.
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ bool simplicity_hash_to_curve(frameItem* dst, frameItem src, const txEnv* env) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* THIS IS NOT A JET. It doesn't have the type signatue of a jet
|
||||
/* THIS IS NOT A JET. It doesn't have the type signature of a jet
|
||||
* This is a generic taptweak jet implementation parameterized by the tag used in the hash.
|
||||
* It is designed to be specialized to implement slightly different taptweak operations for Bitcoin and Elements.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -591,7 +591,7 @@ RIGHT_EXTEND_(32,64)
|
|||
|
||||
#define LEFT_SHIFT_(log, bits) \
|
||||
static inline void left_shift_helper_##bits(bool with, frameItem* dst, frameItem *src) { \
|
||||
static_assert(log <= 8, "Only log parameter upto 8 is supported."); \
|
||||
static_assert(log <= 8, "Only log parameter up to 8 is supported."); \
|
||||
uint_fast8_t amt = simplicity_read##log(src); \
|
||||
uint_fast##bits##_t output = simplicity_read##bits(src); \
|
||||
if (with) output = UINT##bits##_MAX ^ output; \
|
||||
|
|
@ -625,7 +625,7 @@ LEFT_SHIFT_(8,64)
|
|||
|
||||
#define RIGHT_SHIFT_(log, bits) \
|
||||
static inline void right_shift_helper_##bits(bool with, frameItem* dst, frameItem *src) { \
|
||||
static_assert(log <= 8, "Only log parameter upto 8 is supported."); \
|
||||
static_assert(log <= 8, "Only log parameter up to 8 is supported."); \
|
||||
uint_fast8_t amt = simplicity_read##log(src); \
|
||||
uint_fast##bits##_t output = simplicity_read##bits(src); \
|
||||
if (with) output = UINT##bits##_MAX ^ output; \
|
||||
|
|
@ -1046,7 +1046,7 @@ DIVIDES_(64)
|
|||
/* Implements the 3n/2n division algorithm for n=32 bits.
|
||||
* For more details see "Fast Recursive Division" by Christoph Burnikel and Joachim Ziegler, MPI-I-98-1-022, Oct. 1998.
|
||||
*
|
||||
* Given a 96 bit (unsigned) value A and a 64 bit value B, set *q and *r to the quotent and remainder of A divided by B.
|
||||
* Given a 96 bit (unsigned) value A and a 64 bit value B, set *q and *r to the quotient and remainder of A divided by B.
|
||||
*
|
||||
* ah is passed the high 64 bits of A, and al is passed the low 32 bits of A.
|
||||
* We say that A = [ah;al] where [ah;al] denotes ah * 2^32 + al.
|
||||
|
|
@ -1067,7 +1067,7 @@ DIVIDES_(64)
|
|||
*
|
||||
* Preconditon 2 ensures that this estimate is close to the true value of Q. In fact Q <= estQ <= Q + 2 (see proof below)
|
||||
*
|
||||
* There is a corresponding estR value satifying the equation estR = A - estQ * B.
|
||||
* There is a corresponding estR value satisfying the equation estR = A - estQ * B.
|
||||
* This estR is one of {R, R - B, R - 2B}.
|
||||
* Therefore if estR is non-negative, then estR is equal to the true R value, and hence estQ is equal to the true Q value.
|
||||
*
|
||||
|
|
@ -1085,7 +1085,7 @@ DIVIDES_(64)
|
|||
*
|
||||
* Lemma 2: estQ < [1;2] (== 2^32 + 2).
|
||||
* First note that ah - [bh;0] < [1;0] because
|
||||
* ah < B (by precondtion 1)
|
||||
* ah < B (by precondition 1)
|
||||
* < [bh+1;0]
|
||||
* == [bh;0] + [1;0]
|
||||
*
|
||||
|
|
@ -1116,7 +1116,7 @@ static void div_mod_96_64(uint_fast32_t *q, uint_fast64_t *r,
|
|||
/* B == b == [bh;bl] */
|
||||
uint_fast64_t estQ = ah / bh;
|
||||
|
||||
/* Precondition 1 guarentees Q is 32-bits, if estQ is greater than UINT32_MAX, then reduce our initial estimated quotient to UINT32_MAX. */
|
||||
/* Precondition 1 guarantees Q is 32-bits, if estQ is greater than UINT32_MAX, then reduce our initial estimated quotient to UINT32_MAX. */
|
||||
*q = estQ <= UINT32_MAX ? (uint_fast32_t)estQ : UINT32_MAX;
|
||||
|
||||
/* *q * bh <= estQ * bh <= ah */
|
||||
|
|
@ -1131,7 +1131,7 @@ static void div_mod_96_64(uint_fast32_t *q, uint_fast64_t *r,
|
|||
* This value is negative when [rh;al] < d.
|
||||
* Note that d is 64 bit and thus if rh is greater than UINT32_MAX, then this value cannot be negative.
|
||||
*/
|
||||
/* This loop is exectued at most twice. */
|
||||
/* This loop is executed at most twice. */
|
||||
while (rh <= UINT32_MAX && 0x100000000u*rh + al < d) {
|
||||
/* Our estimated remainder, A - *q * B is negative. */
|
||||
/* 0 < d == *q * bl and hence 0 < *q, so this decrement does not underflow. */
|
||||
|
|
@ -1173,7 +1173,7 @@ bool simplicity_div_mod_128_64(frameItem* dst, frameItem src, const txEnv* env)
|
|||
* RR
|
||||
*
|
||||
* First divide the high 3 "digit"s (96-bits) of A by the two "digit"s (64-bits) of B,
|
||||
* returning the first "digit" (high 32-bits) of the quotient, and an intermediate remainer consisiting of 2 "digit"s (64-bits).
|
||||
* returning the first "digit" (high 32-bits) of the quotient, and an intermediate remainder consisiting of 2 "digit"s (64-bits).
|
||||
*/
|
||||
div_mod_96_64(&qh, &r, ah, am, b);
|
||||
simplicity_debug_assert(r < b);
|
||||
|
|
@ -1187,8 +1187,8 @@ bool simplicity_div_mod_128_64(frameItem* dst, frameItem src, const txEnv* env)
|
|||
* ---
|
||||
* RR
|
||||
*
|
||||
* Then append the last "digit" of A to the intermidiate remainder and divide that value (96_bits) by the two "digit"s (64-bits) of B,
|
||||
* returning the second "digit" (low 32-bits) of the quotient, and the final remainer consisiting of 2 "digit"s (64-bits).
|
||||
* Then append the last "digit" of A to the intermediate remainder and divide that value (96_bits) by the two "digit"s (64-bits) of B,
|
||||
* returning the second "digit" (low 32-bits) of the quotient, and the final remainder consisiting of 2 "digit"s (64-bits).
|
||||
*/
|
||||
div_mod_96_64(&ql, &r, r, al, b);
|
||||
simplicity_write32(dst, qh);
|
||||
|
|
|
|||
|
|
@ -260,11 +260,11 @@ static void copyOutput(sigOutput* result, opcode** allocation, size_t* allocatio
|
|||
|
||||
/* Tally a sorted list of feeOutputs
|
||||
*
|
||||
* Given a sorted array of feeOutput pointers, tally all the (explict) amounts of the entries with the same asset id,
|
||||
* Given a sorted array of feeOutput pointers, tally all the (explicit) amounts of the entries with the same asset id,
|
||||
* which are all necessarily next to each other, into the assetFee field of the first entry of the bunch.
|
||||
*
|
||||
* Discard all entries other than the first one of each bunch.
|
||||
* Return 'ret_value', the number of remaning entries in the array after these discards.
|
||||
* Return 'ret_value', the number of remaining entries in the array after these discards.
|
||||
*
|
||||
* Note: the array is not re-allocated, so there will be "junk" values in the array past the end of 'ret_value'.
|
||||
*
|
||||
|
|
@ -497,7 +497,7 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
|
|||
uint_fast32_t ix_fee = 0;
|
||||
|
||||
/* perm is a temporary array the same length (numFees) and size as feeOutputs.
|
||||
* perm is used to initalize feeOutputs and is not used afterward.
|
||||
* perm is used to initialize feeOutputs and is not used afterward.
|
||||
* This makes it safe for perm to use the same memory allocation as feeOutputs.
|
||||
*/
|
||||
static_assert(sizeof(const sha256_midstate*) == sizeof(sigOutput*), "Pointers (to structures) ought to have the same size.");
|
||||
|
|
@ -528,8 +528,8 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
|
|||
/* Initialize the feeOutputs array from the perm array.
|
||||
* Because the perm array entries are the same size as the feeOutputs array entries, it is safe to initialize one by one.
|
||||
*
|
||||
* In practical C implementations, the feeOutputs array entires are initalized to the same value as the perm array entries.
|
||||
* In practical C implementations, this is a no-op, and generally compiliers are able to see this fact and eliminate this loop.
|
||||
* In practical C implementations, the feeOutputs array entries are initialized to the same value as the perm array entries.
|
||||
* In practical C implementations, this is a no-op, and generally compilers are able to see this fact and eliminate this loop.
|
||||
*
|
||||
* We keep the loop in the code just to be pedantic.
|
||||
*/
|
||||
|
|
@ -652,7 +652,7 @@ extern void simplicity_elements_freeTapEnv(tapEnv* env) {
|
|||
simplicity_free(env);
|
||||
}
|
||||
|
||||
/* Contstruct a txEnv structure from its components.
|
||||
/* Construct a txEnv structure from its components.
|
||||
* This function will precompute any cached values.
|
||||
*
|
||||
* Precondition: NULL != tx
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ typedef struct tapEnv {
|
|||
unsigned char leafVersion;
|
||||
} tapEnv;
|
||||
|
||||
/* The 'txEnv' structure used by the Elements application of Simplcity.
|
||||
/* The 'txEnv' structure used by the Elements application of Simplicity.
|
||||
*
|
||||
* It includes
|
||||
* + the transaction data, which may be shared when Simplicity expressions are used for multiple inputs in the same transaction),
|
||||
|
|
@ -263,7 +263,7 @@ typedef struct txEnv {
|
|||
uint_fast32_t ix;
|
||||
} txEnv;
|
||||
|
||||
/* Contstruct a txEnv structure from its components.
|
||||
/* Construct a txEnv structure from its components.
|
||||
* This function will precompute any cached values.
|
||||
*
|
||||
* Precondition: NULL != tx
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ static_assert(UCHAR_MAX < SIZE_MAX, "UCHAR_MAX >= SIZE_MAX");
|
|||
/* Return the 'i'th char of the object representation of the midstate pointed to by a.
|
||||
*
|
||||
* In C, values are represented as 'unsigned char [sizeof(v)]' array. However the exact
|
||||
* specification of how this represenation works is implementation defined.
|
||||
* specification of how this representation works is implementation defined.
|
||||
*
|
||||
* For the 'uint32_t' values of 'sha256_midstate', the object representation of these values will differ
|
||||
* between big endian and little endian archtectures.
|
||||
* between big endian and little endian architectures.
|
||||
*
|
||||
* Precondition: NULL != a
|
||||
* i < sizeof(a->s);
|
||||
|
|
@ -138,7 +138,7 @@ static void rsort_ex(const sha256_midstate** a, uint_fast32_t len, const sha256_
|
|||
We will decrease len as we go as we find out that items at the end of the array are in their proper, sorted position.
|
||||
|
||||
The 'i'th bucket is the subarray a[stack[i]:stack[i+1]),
|
||||
excecpt for the last bucket which is the subarray a[stack[totalBucketCount-1]:len).
|
||||
except for the last bucket which is the subarray a[stack[totalBucketCount-1]:len).
|
||||
|
||||
The depth to which various buckets are sorted increases the further down the stack you go.
|
||||
The 'bucketCount' stores how many buckets are sorted to various depths.
|
||||
|
|
@ -169,7 +169,7 @@ static void rsort_ex(const sha256_midstate** a, uint_fast32_t len, const sha256_
|
|||
Note: there is an added optimization where by if there is only one non-empty bucket found when attempting to sort,
|
||||
i.e. it happens that every bucket item already has identical 'depth' characters,
|
||||
we skip the subdivision and move onto the next depth immediately.
|
||||
(This is equivalent to pushing the one non-empty bucket onto the stack and immediately poping it back off.)
|
||||
(This is equivalent to pushing the one non-empty bucket onto the stack and immediately popping it back off.)
|
||||
|
||||
If the last bucket is of size 0 or 1, it must be already be sorted.
|
||||
Since this bucket is at the end of the array we decrease 'len'.
|
||||
|
|
|
|||
|
|
@ -49,4 +49,4 @@ Lastly, all active uses of normalize are replaced with the variable-time impleme
|
|||
|
||||
[^1]: More specifically, the when a point has a very low and odd order, the `ai` values in the `secp256k1_ecmult_odd_multiples_table` can reach infinity, violating libsecp256k1's assumption that `secp256k1_gej_add_ge_var`'s `a` parameter is never infinity.
|
||||
The value we set to the `rzr` in this case does not matter since it ends up only being multiplied with zero in `secp256k1_ge_table_set_globalz`.
|
||||
It just needs to be set to some value to avoid reading uninitalized memory.
|
||||
It just needs to be set to some value to avoid reading uninitialized memory.
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ static void secp256k1_scalar_split_lambda_verify(const secp256k1_scalar *r1, con
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Both lambda and beta are primitive cube roots of unity. That is lamba^3 == 1 mod n and
|
||||
* Both lambda and beta are primitive cube roots of unity. That is lambda^3 == 1 mod n and
|
||||
* beta^3 == 1 mod p, where n is the curve order and p is the field order.
|
||||
*
|
||||
* Furthermore, because (X^3 - 1) = (X - 1)(X^2 + X + 1), the primitive cube roots of unity are
|
||||
* roots of X^2 + X + 1. Therefore lambda^2 + lamba == -1 mod n and beta^2 + beta == -1 mod p.
|
||||
* roots of X^2 + X + 1. Therefore lambda^2 + lambda == -1 mod n and beta^2 + beta == -1 mod p.
|
||||
* (The other primitive cube roots of unity are lambda^2 and beta^2 respectively.)
|
||||
*
|
||||
* Let l = -1/2 + i*sqrt(3)/2, the complex root of X^2 + X + 1. We can define a ring
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2,
|
|||
# define SECP256K1_INT128_NATIVE 1
|
||||
#elif defined(USE_FORCE_WIDEMUL_INT64)
|
||||
/* If USE_FORCE_WIDEMUL_INT64 is set, use int64. */
|
||||
# error WIDEMUL_INT64 not suported in Simplicity.
|
||||
# error WIDEMUL_INT64 not supported in Simplicity.
|
||||
#elif defined(UINT128_MAX) || defined(__SIZEOF_INT128__)
|
||||
/* If a native 128-bit integer type exists, use int128. */
|
||||
# define SECP256K1_WIDEMUL_INT128 1
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ static void sha256_compression_portable(uint32_t* s, const uint32_t* chunk) {
|
|||
void (*simplicity_sha256_compression)(uint32_t* midstate, const uint32_t* block) = sha256_compression_portable;
|
||||
|
||||
/* For information purposes only.
|
||||
* Returns true if the sha256_compression implemenation has been optimized for the CPU.
|
||||
* Returns true if the sha256_compression implementation has been optimized for the CPU.
|
||||
* Otherwise returns false.
|
||||
*/
|
||||
bool simplicity_sha256_compression_is_optimized(void) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ static inline void WriteLE32(unsigned char* ptr, uint_fast32_t x) {
|
|||
ptr[0] = 0xff & x;
|
||||
}
|
||||
|
||||
/* Coverts a given 'midstate' value to a 'hash' value as 32 bytes stored in an unsigned char array.
|
||||
/* Converts a given 'midstate' value to a 'hash' value as 32 bytes stored in an unsigned char array.
|
||||
*
|
||||
* Precondition: unsigned char hash[32];
|
||||
* uint32_t midstate[8]
|
||||
|
|
@ -91,7 +91,7 @@ static inline void sha256_fromMidstate(unsigned char* hash, const uint32_t* mids
|
|||
WriteBE32(hash + 7*4, midstate[7]);
|
||||
}
|
||||
|
||||
/* Coverts a given 'hash' value as 32 bytes stored in an unsigned char array to a 'midstate' value.
|
||||
/* Converts a given 'hash' value as 32 bytes stored in an unsigned char array to a 'midstate' value.
|
||||
*
|
||||
* Precondition: uint32_t midstate[8];
|
||||
* unsigned char hash[32]
|
||||
|
|
@ -130,7 +130,7 @@ static inline void sha256_iv(uint32_t* iv) {
|
|||
extern void (*simplicity_sha256_compression)(uint32_t* midstate, const uint32_t* block);
|
||||
|
||||
/* For information purposes only.
|
||||
* Returns true if the sha256_compression implemenation has been optimized for the CPU.
|
||||
* Returns true if the sha256_compression implementation has been optimized for the CPU.
|
||||
* Otherwise returns false.
|
||||
*/
|
||||
bool simplicity_sha256_compression_is_optimized(void);
|
||||
|
|
@ -188,7 +188,7 @@ typedef struct sha256_context {
|
|||
|
||||
/* SHA-256 is limited to strictly less than 2^64 bits or 2^56 bytes of data.
|
||||
* This limit cannot be reached in practice under proper use of the SHA-256 interface.
|
||||
* However some jets in simplicity load and store this context and it is easy to syntesize contexts with absurdly large counter values.
|
||||
* However some jets in simplicity load and store this context and it is easy to synthesize contexts with absurdly large counter values.
|
||||
*/
|
||||
static const uint_fast64_t sha256_max_counter = 0x2000000000000000;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,12 +85,12 @@ static inline size_t typeSkip(size_t i, const type* type_dag) {
|
|||
}
|
||||
|
||||
/* Precondition: type type_dag[i] and 'type_dag' is well-formed.
|
||||
* if type_dag[i] is a non-trival 'PRODUCT', then both of its two type arguements are non-trival.
|
||||
* if type_dag[i] is a non-trival 'PRODUCT', then both of its two type arguments are non-trival.
|
||||
* Postconditon: value == type_dag[i]
|
||||
*/
|
||||
static inline void setTypeBack(size_t i, type* type_dag, size_t value) {
|
||||
/* .back cannot be used if .skip is in use.
|
||||
Specifically it cannot be a non-trivial 'PRODUCT' type where one of its two type arguements is a trivial type.
|
||||
Specifically it cannot be a non-trivial 'PRODUCT' type where one of its two type arguments is a trivial type.
|
||||
*/
|
||||
simplicity_assert((PRODUCT != type_dag[i].kind ||
|
||||
0 == type_dag[i].bitSize ||
|
||||
|
|
|
|||
|
|
@ -204,13 +204,13 @@ FUZZ_TARGET_INIT(simplicity, initialize_simplicity)
|
|||
PrecomputedTransactionData txdata{GENESIS_HASH};
|
||||
std::vector<CTxOut> spent_outs_copy{spent_outs};
|
||||
txdata.Init(mtx, std::move(spent_outs_copy));
|
||||
assert(txdata.m_simplicity_tx_data != NULL);
|
||||
assert(txdata.m_simplicity_tx_data);
|
||||
|
||||
// 4. Main test
|
||||
unsigned char imr_out[32];
|
||||
unsigned char *imr = mtx.vin[0].prevout.hash.data()[2] & 2 ? imr_out : NULL;
|
||||
|
||||
const transaction* tx = txdata.m_simplicity_tx_data;
|
||||
const transaction* tx = txdata.m_simplicity_tx_data.get();
|
||||
tapEnv* taproot = simplicity_elements_mallocTapEnv(&simplicityRawTap);
|
||||
simplicity_elements_execSimplicity(&error, imr, tx, nIn, taproot, GENESIS_HASH.data(), budget, amr, prog_bytes.data(), prog_bytes.size(), wit_bytes.data(), wit_bytes.size());
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ FUZZ_TARGET_INIT(simplicity_tx, initialize_simplicity_tx)
|
|||
// that we will allocate Simplicity data. The check for whether to do this is very
|
||||
// lax: is this a 34-byte scriptPubKey that starts with OP_1 and does it have a
|
||||
// nonempty witness.
|
||||
assert(txdata.m_simplicity_tx_data != NULL);
|
||||
assert(txdata.m_simplicity_tx_data);
|
||||
}
|
||||
|
||||
const CTransaction tx{mtx};
|
||||
|
|
|
|||
|
|
@ -1446,6 +1446,8 @@ static bool CreateTransactionInternal(
|
|||
return false;
|
||||
}
|
||||
txNew = tx_blinded; // sigh, `fillBlindDetails` may have modified txNew
|
||||
// Update the change position to the new tx
|
||||
change_position = txNew.vout.begin() + nChangePosInOut;
|
||||
|
||||
int ret = BlindTransaction(blind_details->i_amount_blinds, blind_details->i_asset_blinds, blind_details->i_assets, blind_details->i_amounts, blind_details->o_amount_blinds, blind_details->o_asset_blinds, blind_details->o_pubkeys, issuance_asset_keys, issuance_token_keys, tx_blinded);
|
||||
assert(ret != -1);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ from test_framework.util import (
|
|||
)
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
from test_framework.liquid_addr import (
|
||||
encode,
|
||||
|
|
@ -51,7 +52,7 @@ class CTTest (BitcoinTestFramework):
|
|||
self.skip_if_no_wallet()
|
||||
|
||||
def test_wallet_recovery(self):
|
||||
file_path = "/tmp/blind_details"
|
||||
file_path = os.path.join(tempfile.gettempdir(), "blind_details")
|
||||
try:
|
||||
os.remove(file_path)
|
||||
except OSError:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_approx,
|
||||
assert_equal,
|
||||
)
|
||||
|
||||
|
|
@ -80,10 +81,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326'))
|
||||
assert_equal(decoded['vsize'], 326)
|
||||
assert_equal(decoded['weight'], 1302)
|
||||
# tx weight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['weight'], 1301.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326)
|
||||
|
||||
self.log.info("Send confidential tx to node 0")
|
||||
|
|
@ -98,10 +101,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326) # node1 has discountvsize
|
||||
|
||||
self.log.info("Send explicit tx to node 1")
|
||||
|
|
@ -116,10 +121,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326'))
|
||||
assert_equal(decoded['vsize'], 326)
|
||||
assert_equal(decoded['weight'], 1302)
|
||||
# tx weight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['weight'], 1301.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx weight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326)
|
||||
|
||||
self.log.info("Send confidential (undiscounted) tx to node 1")
|
||||
|
|
@ -134,10 +141,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326) # node1 has discountvsize
|
||||
|
||||
self.log.info("Send confidential (discounted) tx to node 1")
|
||||
|
|
@ -161,8 +170,10 @@ class CTTest(BitcoinTestFramework):
|
|||
else:
|
||||
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000326'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
assert_equal(decoded['discountweight'], 1302)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(decoded['discountvsize'], 326)
|
||||
|
||||
# node0 only has vsize
|
||||
|
|
@ -191,8 +202,10 @@ class CTTest(BitcoinTestFramework):
|
|||
else:
|
||||
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000033'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
assert_equal(decoded['discountweight'], 1302)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(decoded['discountvsize'], 326)
|
||||
# node0 only has vsize
|
||||
tx = node0.getrawtransaction(txid, True)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
import os
|
||||
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
|
@ -152,7 +153,7 @@ class FedPegTest(BitcoinTestFramework):
|
|||
else:
|
||||
# Need to specify where to find parent cookie file
|
||||
datadir = get_datadir_path(self.options.tmpdir, n)
|
||||
extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie")
|
||||
extra_args.append('-mainchainrpccookiefile='+os.path.join(datadir, parent_chain, ".cookie"))
|
||||
|
||||
self.add_nodes(1, [extra_args], chain=["elementsregtest"])
|
||||
self.start_node(2+n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue