mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge pull request #1390 from ElementsProject/simplicity
Update to latest Simplicity
This commit is contained in:
commit
368010a308
40 changed files with 1364 additions and 1238 deletions
|
|
@ -195,7 +195,6 @@ LCOV_FILTER_PATTERN = \
|
|||
-p "src/crypto/ctaes" \
|
||||
-p "src/minisketch" \
|
||||
-p "src/secp256k1" \
|
||||
-p "src/simplicity/secp256k1" \
|
||||
-p "depends"
|
||||
|
||||
DIR_FUZZ_SEED_CORPUS ?= qa-assets/fuzz_seed_corpus
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ include simplicity/elements-sources.mk
|
|||
LIBELEMENTSSIMPLICITY = libelementssimplicity.la
|
||||
noinst_LTLIBRARIES += $(LIBELEMENTSSIMPLICITY)
|
||||
libelementssimplicity_la_SOURCES = $(ELEMENTS_SIMPLICITY_LIB_SOURCES_INT) $(ELEMENTS_SIMPLICITY_DIST_HEADERS_INT) $(ELEMENTS_SIMPLICITY_LIB_HEADERS_INT)
|
||||
libelementssimplicity_la_CPPFLAGS = $(AM_CPPFLAGS) $(SHANI_CXXFLAGS) -I$(srcdir)/$(ELEMENTS_SIMPLICITY_INCLUDE_DIR_INT)
|
||||
libelementssimplicity_la_CPPFLAGS = $(AM_CPPFLAGS) $(SHANI_CXXFLAGS) $(SANITIZER_CXXFLAGS) -I$(srcdir)/$(ELEMENTS_SIMPLICITY_INCLUDE_DIR_INT)
|
||||
|
|
|
|||
|
|
@ -2660,7 +2660,8 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
|
|||
}
|
||||
|
||||
rawTransaction simplicityRawTx;
|
||||
simplicityRawTx.txid = txTo.GetHash().begin();
|
||||
uint256 rawHash = txTo.GetHash();
|
||||
simplicityRawTx.txid = rawHash.begin();
|
||||
simplicityRawTx.input = simplicityRawInput.data();
|
||||
simplicityRawTx.numInputs = simplicityRawInput.size();
|
||||
simplicityRawTx.output = simplicityRawOutput.data();
|
||||
|
|
@ -3123,7 +3124,7 @@ bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& progr
|
|||
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())) {
|
||||
assert(!"simplicity_elements_execSimplicity internal error");
|
||||
}
|
||||
free(simplicityTapEnv);
|
||||
simplicity_elements_freeTapEnv(simplicityTapEnv);
|
||||
switch (error) {
|
||||
case SIMPLICITY_NO_ERROR: return set_success(serror);
|
||||
case SIMPLICITY_ERR_MALLOC:
|
||||
|
|
@ -3133,7 +3134,7 @@ bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& progr
|
|||
case SIMPLICITY_ERR_DATA_OUT_OF_RANGE: return set_error(serror, SCRIPT_ERR_SIMPLICITY_DATA_OUT_OF_RANGE);
|
||||
case SIMPLICITY_ERR_DATA_OUT_OF_ORDER: return set_error(serror, SCRIPT_ERR_SIMPLICITY_DATA_OUT_OF_ORDER);
|
||||
case SIMPLICITY_ERR_FAIL_CODE: return set_error(serror, SCRIPT_ERR_SIMPLICITY_FAIL_CODE);
|
||||
case SIMPLICITY_ERR_STOP_CODE: return set_error(serror, SCRIPT_ERR_SIMPLICITY_STOP_CODE);
|
||||
case SIMPLICITY_ERR_RESERVED_CODE: return set_error(serror, SCRIPT_ERR_SIMPLICITY_RESERVED_CODE);
|
||||
case SIMPLICITY_ERR_HIDDEN: return set_error(serror, SCRIPT_ERR_SIMPLICITY_HIDDEN);
|
||||
case SIMPLICITY_ERR_BITSTREAM_EOF: return set_error(serror, SCRIPT_ERR_SIMPLICITY_BITSTREAM_EOF);
|
||||
case SIMPLICITY_ERR_BITSTREAM_TRAILING_BYTES: return set_error(serror, SCRIPT_ERR_SIMPLICITY_BITSTREAM_TRAILING_BYTES);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ struct PrecomputedTransactionData
|
|||
template <class T>
|
||||
explicit PrecomputedTransactionData(const T& tx);
|
||||
~PrecomputedTransactionData() {
|
||||
free(m_simplicity_tx_data);
|
||||
simplicity_elements_freeTransaction(m_simplicity_tx_data);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ std::string ScriptErrorString(const ScriptError serror)
|
|||
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_DATA_OUT_OF_ORDER);
|
||||
case SCRIPT_ERR_SIMPLICITY_FAIL_CODE:
|
||||
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_FAIL_CODE);
|
||||
case SCRIPT_ERR_SIMPLICITY_STOP_CODE:
|
||||
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_STOP_CODE);
|
||||
case SCRIPT_ERR_SIMPLICITY_RESERVED_CODE:
|
||||
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_RESERVED_CODE);
|
||||
case SCRIPT_ERR_SIMPLICITY_HIDDEN:
|
||||
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_HIDDEN);
|
||||
case SCRIPT_ERR_SIMPLICITY_BITSTREAM_EOF:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ typedef enum ScriptError_t
|
|||
SCRIPT_ERR_SIMPLICITY_DATA_OUT_OF_RANGE,
|
||||
SCRIPT_ERR_SIMPLICITY_DATA_OUT_OF_ORDER,
|
||||
SCRIPT_ERR_SIMPLICITY_FAIL_CODE,
|
||||
SCRIPT_ERR_SIMPLICITY_STOP_CODE,
|
||||
SCRIPT_ERR_SIMPLICITY_RESERVED_CODE,
|
||||
SCRIPT_ERR_SIMPLICITY_HIDDEN,
|
||||
SCRIPT_ERR_SIMPLICITY_BITSTREAM_EOF,
|
||||
SCRIPT_ERR_SIMPLICITY_BITSTREAM_TRAILING_BYTES,
|
||||
|
|
|
|||
|
|
@ -270,8 +270,8 @@ const uint32_t ctx8Pruned_cmr[] = {
|
|||
0x7f11746fu, 0xb68fdaedu, 0x3cadda80u, 0xc7cd0245u, 0xa341b927u, 0xe98e60f8u, 0x745dc441u, 0xe11ce1a3u
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above ctx8Pruned Simplicity expression. */
|
||||
const uint32_t ctx8Pruned_imr[] = {
|
||||
/* The identity hash of the root of the above ctx8Pruned Simplicity expression. */
|
||||
const uint32_t ctx8Pruned_ihr[] = {
|
||||
0x8e8742acu, 0x27f42d29u, 0xd87f5229u, 0x02bc0ae2u, 0xbcfc1298u, 0x1641a2ddu, 0x77091830u, 0xb79bf12du
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ extern const size_t sizeof_ctx8Pruned_witness;
|
|||
/* The commitment Merkle root of the above ctx8Pruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Pruned_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above ctx8Pruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Pruned_imr[];
|
||||
/* The identity hash of the root of the above ctx8Pruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Pruned_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above ctx8Pruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Pruned_amr[];
|
||||
|
|
|
|||
|
|
@ -260,8 +260,8 @@ const uint32_t ctx8Unpruned_cmr[] = {
|
|||
0x7f11746fu, 0xb68fdaedu, 0x3cadda80u, 0xc7cd0245u, 0xa341b927u, 0xe98e60f8u, 0x745dc441u, 0xe11ce1a3u
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above ctx8Unpruned Simplicity expression. */
|
||||
const uint32_t ctx8Unpruned_imr[] = {
|
||||
/* The identity hash of the root of the above ctx8Unpruned Simplicity expression. */
|
||||
const uint32_t ctx8Unpruned_ihr[] = {
|
||||
0x8e8742acu, 0x27f42d29u, 0xd87f5229u, 0x02bc0ae2u, 0xbcfc1298u, 0x1641a2ddu, 0x77091830u, 0xb79bf12du
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ extern const size_t sizeof_ctx8Unpruned_witness;
|
|||
/* The commitment Merkle root of the above ctx8Unpruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Unpruned_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above ctx8Unpruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Unpruned_imr[];
|
||||
/* The identity hash of the root of the above ctx8Unpruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Unpruned_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above ctx8Unpruned Simplicity expression. */
|
||||
extern const uint32_t ctx8Unpruned_amr[];
|
||||
|
|
|
|||
|
|
@ -77,16 +77,16 @@ static sha256_midstate amrIV(tag_t tag) {
|
|||
SIMPLICITY_UNREACHABLE;
|
||||
}
|
||||
|
||||
/* Given the IMR of a jet specification, return the CMR for a jet that implements that specification.
|
||||
/* Given the identity hash of a jet specification, return the CMR for a jet that implements that specification.
|
||||
*
|
||||
* Precondition: uint32_t imr[8]
|
||||
* Precondition: uint32_t ih[8]
|
||||
*/
|
||||
static sha256_midstate mkJetCMR(uint32_t *imr, uint_fast64_t weight) {
|
||||
static sha256_midstate mkJetCMR(uint32_t *ih, uint_fast64_t weight) {
|
||||
sha256_midstate result = jetIV;
|
||||
uint32_t block[16] = {0};
|
||||
block[6] = (uint32_t)(weight >> 32);
|
||||
block[7] = (uint32_t)weight;
|
||||
memcpy(&block[8], imr, sizeof(uint32_t[8]));
|
||||
memcpy(&block[8], ih, sizeof(uint32_t[8]));
|
||||
simplicity_sha256_compression(result.s, block);
|
||||
|
||||
return result;
|
||||
|
|
@ -100,7 +100,7 @@ sha256_midstate simplicity_computeWordCMR(const bitstring* value, size_t n) {
|
|||
/* 'stack' is an array of 30 hashes consisting of 8 'uint32_t's each. */
|
||||
uint32_t stack[8*30] = {0};
|
||||
uint32_t *stack_ptr = stack;
|
||||
sha256_midstate imr = identityIV;
|
||||
sha256_midstate ih = identityIV;
|
||||
simplicity_assert(n < 32);
|
||||
simplicity_assert((size_t)1 << n == value->len);
|
||||
/* Pass 1: Compute the CMR for the expression that writes 'value'.
|
||||
|
|
@ -135,14 +135,14 @@ sha256_midstate simplicity_computeWordCMR(const bitstring* value, size_t n) {
|
|||
/* value->len is a power of 2.*/
|
||||
simplicity_assert(stack_ptr == stack + 8);
|
||||
|
||||
/* Pass 2: Compute the IMR for the expression by adding the type roots of ONE and TWO^(2^n) to the CMR. */
|
||||
simplicity_sha256_compression(imr.s, stack);
|
||||
/* Pass 2: Compute the identity hash for the expression by adding the type roots of ONE and TWO^(2^n) to the CMR. */
|
||||
simplicity_sha256_compression(ih.s, stack);
|
||||
memcpy(&stack[0], word_type_root[0].s, sizeof(uint32_t[8]));
|
||||
memcpy(&stack[8], word_type_root[n+1].s, sizeof(uint32_t[8]));
|
||||
simplicity_sha256_compression(imr.s, stack);
|
||||
simplicity_sha256_compression(ih.s, stack);
|
||||
|
||||
/* Pass 3: Compute the jet's CMR from the specificion's IMR. */
|
||||
return mkJetCMR(imr.s, ((uint_fast64_t)1 << n));
|
||||
/* Pass 3: Compute the jet's CMR from the specificion's identity hash. */
|
||||
return mkJetCMR(ih.s, ((uint_fast64_t)1 << n));
|
||||
}
|
||||
|
||||
/* Given a well-formed dag[i + 1], such that for all 'j', 0 <= 'j' < 'i',
|
||||
|
|
@ -192,21 +192,21 @@ void simplicity_computeCommitmentMerkleRoot(dag_node* dag, const uint_fast32_t i
|
|||
}
|
||||
}
|
||||
|
||||
/* Computes the identity Merkle roots of every subexpression in a well-typed 'dag' with witnesses.
|
||||
* 'imr[i]' is set to the identity Merkle root of the subexpression 'dag[i]'.
|
||||
* When 'HIDDEN == dag[i].tag', then 'imr[i]' is instead set to a hidden root hash for that hidden node.
|
||||
/* Computes the identity hash roots of every subexpression in a well-typed 'dag' with witnesses.
|
||||
* 'ihr[i]' is set to the identity hash of the root of the subexpression 'dag[i]'.
|
||||
* When 'HIDDEN == dag[i].tag', then 'ihr[i]' is instead set to a hidden root hash for that hidden node.
|
||||
*
|
||||
* Precondition: sha256_midstate imr[len];
|
||||
* Precondition: sha256_midstate ihr[len];
|
||||
* dag_node dag[len] and 'dag' is well-typed with 'type_dag' and contains witnesses.
|
||||
*/
|
||||
static void computeIdentityMerkleRoot(sha256_midstate* imr, const dag_node* dag, const type* type_dag, const uint_fast32_t len) {
|
||||
static void computeIdentityHashRoots(sha256_midstate* ihr, const dag_node* dag, const type* type_dag, const uint_fast32_t len) {
|
||||
/* Pass 1 */
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
uint32_t block[16] = {0};
|
||||
size_t j = 8;
|
||||
|
||||
/* For jets, the first pass identity Merkle root is the same as their commitment Merkle root. */
|
||||
imr[i] = HIDDEN == dag[i].tag ? dag[i].cmr
|
||||
ihr[i] = HIDDEN == dag[i].tag ? dag[i].cmr
|
||||
: JET == dag[i].tag ? dag[i].cmr
|
||||
: WORD == dag[i].tag ? dag[i].cmr
|
||||
: imrIV(dag[i].tag);
|
||||
|
|
@ -214,7 +214,7 @@ static void computeIdentityMerkleRoot(sha256_midstate* imr, const dag_node* dag,
|
|||
case WITNESS:
|
||||
simplicity_sha256_bitstring(block, &dag[i].compactValue);
|
||||
memcpy(block + 8, type_dag[WITNESS_B(dag, type_dag, i)].typeMerkleRoot.s, sizeof(uint32_t[8]));
|
||||
simplicity_sha256_compression(imr[i].s, block);
|
||||
simplicity_sha256_compression(ihr[i].s, block);
|
||||
break;
|
||||
case COMP:
|
||||
case ASSERTL:
|
||||
|
|
@ -222,15 +222,15 @@ static void computeIdentityMerkleRoot(sha256_midstate* imr, const dag_node* dag,
|
|||
case CASE:
|
||||
case PAIR:
|
||||
case DISCONNECT:
|
||||
memcpy(block + j, imr[dag[i].child[1]].s, sizeof(uint32_t[8]));
|
||||
memcpy(block + j, ihr[dag[i].child[1]].s, sizeof(uint32_t[8]));
|
||||
j = 0;
|
||||
/*@fallthrough@*/
|
||||
case INJL:
|
||||
case INJR:
|
||||
case TAKE:
|
||||
case DROP:
|
||||
memcpy(block + j, imr[dag[i].child[0]].s, sizeof(uint32_t[8]));
|
||||
simplicity_sha256_compression(imr[i].s, block);
|
||||
memcpy(block + j, ihr[dag[i].child[0]].s, sizeof(uint32_t[8]));
|
||||
simplicity_sha256_compression(ihr[i].s, block);
|
||||
case IDEN:
|
||||
case UNIT:
|
||||
case HIDDEN:
|
||||
|
|
@ -245,16 +245,16 @@ static void computeIdentityMerkleRoot(sha256_midstate* imr, const dag_node* dag,
|
|||
uint32_t block[16] = {0};
|
||||
|
||||
if (HIDDEN == dag[i].tag) {
|
||||
memcpy(block + 8, imr[i].s, sizeof(uint32_t[8]));
|
||||
imr[i] = hiddenIV;
|
||||
simplicity_sha256_compression(imr[i].s, block);
|
||||
memcpy(block + 8, ihr[i].s, sizeof(uint32_t[8]));
|
||||
ihr[i] = hiddenIV;
|
||||
simplicity_sha256_compression(ihr[i].s, block);
|
||||
} else {
|
||||
memcpy(block + 8, imr[i].s, sizeof(uint32_t[8]));
|
||||
imr[i] = identityIV;
|
||||
simplicity_sha256_compression(imr[i].s, block);
|
||||
memcpy(block + 8, ihr[i].s, sizeof(uint32_t[8]));
|
||||
ihr[i] = identityIV;
|
||||
simplicity_sha256_compression(ihr[i].s, block);
|
||||
memcpy(block, type_dag[dag[i].sourceType].typeMerkleRoot.s, sizeof(uint32_t[8]));
|
||||
memcpy(block + 8, type_dag[dag[i].targetType].typeMerkleRoot.s, sizeof(uint32_t[8]));
|
||||
simplicity_sha256_compression(imr[i].s, block);
|
||||
simplicity_sha256_compression(ihr[i].s, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -559,30 +559,30 @@ simplicity_err simplicity_fillWitnessData(dag_node* dag, type* type_dag, const u
|
|||
return SIMPLICITY_NO_ERROR;
|
||||
}
|
||||
|
||||
/* Verifies that identity Merkle roots of every subexpression in a well-typed 'dag' with witnesses are all unique,
|
||||
/* Verifies that identity hash of every subexpression in a well-typed 'dag' with witnesses are all unique,
|
||||
* including that each hidden root hash for every 'HIDDEN' node is unique.
|
||||
*
|
||||
* if 'imr' is not NULL, then '*imr' is set to the identity Merkle root of the 'dag'.
|
||||
* if 'ihr' is not NULL, then '*ihr' is set to the identity hash of the root of the 'dag'.
|
||||
*
|
||||
* If malloc fails, returns 'SIMPLICITY_ERR_MALLOC'.
|
||||
* If all the identity Merkle roots (and hidden roots) are all unique, returns 'SIMPLICITY_NO_ERROR'.
|
||||
* If all the identity hahes (and hidden roots) are all unique, returns 'SIMPLICITY_NO_ERROR'.
|
||||
* Otherwise returns 'SIMPLICITY_ERR_UNSHARED_SUBEXPRESSION'.
|
||||
*
|
||||
* Precondition: dag_node dag[len] and 'dag' is well-typed with 'type_dag' and contains witnesses.
|
||||
*/
|
||||
simplicity_err simplicity_verifyNoDuplicateIdentityRoots(sha256_midstate* imr, const dag_node* dag, const type* type_dag, const uint_fast32_t dag_len) {
|
||||
simplicity_err simplicity_verifyNoDuplicateIdentityHashes(sha256_midstate* ihr, const dag_node* dag, const type* type_dag, const uint_fast32_t dag_len) {
|
||||
simplicity_assert(0 < dag_len);
|
||||
simplicity_assert(dag_len <= DAG_LEN_MAX);
|
||||
sha256_midstate* imr_buf = simplicity_malloc((size_t)dag_len * sizeof(sha256_midstate));
|
||||
if (!imr_buf) return SIMPLICITY_ERR_MALLOC;
|
||||
sha256_midstate* ih_buf = simplicity_malloc((size_t)dag_len * sizeof(sha256_midstate));
|
||||
if (!ih_buf) return SIMPLICITY_ERR_MALLOC;
|
||||
|
||||
computeIdentityMerkleRoot(imr_buf, dag, type_dag, dag_len);
|
||||
computeIdentityHashRoots(ih_buf, dag, type_dag, dag_len);
|
||||
|
||||
if (imr) *imr = imr_buf[dag_len-1];
|
||||
if (ihr) *ihr = ih_buf[dag_len-1];
|
||||
|
||||
int result = simplicity_hasDuplicates(imr_buf, dag_len);
|
||||
int result = simplicity_hasDuplicates(ih_buf, dag_len);
|
||||
|
||||
simplicity_free(imr_buf);
|
||||
simplicity_free(ih_buf);
|
||||
|
||||
switch (result) {
|
||||
case -1: return SIMPLICITY_ERR_MALLOC;
|
||||
|
|
|
|||
|
|
@ -377,17 +377,17 @@ simplicity_err simplicity_verifyCanonicalOrder(dag_node* dag, const uint_fast32_
|
|||
*/
|
||||
simplicity_err simplicity_fillWitnessData(dag_node* dag, type* type_dag, const uint_fast32_t len, bitstream *witness);
|
||||
|
||||
/* Verifies that identity Merkle roots of every subexpression in a well-typed 'dag' with witnesses are all unique,
|
||||
/* Verifies that identity hash of every subexpression in a well-typed 'dag' with witnesses are all unique,
|
||||
* including that each hidden root hash for every 'HIDDEN' node is unique.
|
||||
*
|
||||
* if 'imr' is not NULL, then '*imr' is set to the identity Merkle root of the 'dag'.
|
||||
* if 'ihr' is not NULL, then '*ihr' is set to the identity hash of the root of the 'dag'.
|
||||
*
|
||||
* If malloc fails, returns 'SIMPLICITY_ERR_MALLOC'.
|
||||
* If all the identity Merkle roots (and hidden roots) are all unique, returns 'SIMPLICITY_NO_ERROR'.
|
||||
* If all the identity hahes (and hidden roots) are all unique, returns 'SIMPLICITY_NO_ERROR'.
|
||||
* Otherwise returns 'SIMPLICITY_ERR_UNSHARED_SUBEXPRESSION'.
|
||||
*
|
||||
* Precondition: dag_node dag[len] and 'dag' is well-typed with 'type_dag' and contains witnesses.
|
||||
*/
|
||||
simplicity_err simplicity_verifyNoDuplicateIdentityRoots(sha256_midstate* imr, const dag_node* dag, const type* type_dag, const uint_fast32_t dag_len);
|
||||
simplicity_err simplicity_verifyNoDuplicateIdentityHashes(sha256_midstate* ihr, const dag_node* dag, const type* type_dag, const uint_fast32_t dag_len);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
1037
src/simplicity/decodeCoreJets.inc
Normal file
1037
src/simplicity/decodeCoreJets.inc
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -42,8 +42,8 @@ static simplicity_err getHash(sha256_midstate* result, bitstream* stream) {
|
|||
/* Decode a single node of a Simplicity dag from 'stream' into 'dag'['i'].
|
||||
* Returns 'SIMPLICITY_ERR_FAIL_CODE' if the encoding of a fail expression is encountered
|
||||
* (all fail subexpressions ought to have been pruned prior to serialization).
|
||||
* Returns 'SIMPLICITY_ERR_STOP_CODE' if the encoding of a stop tag is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if the decoded node has illegal HIDDEN children.
|
||||
* Returns 'SIMPLICITY_ERR_RESERVED_CODE' if a reserved codeword is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if the decoded node has a HIDDEN child in a position where it is not allowed.
|
||||
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if the node's child isn't a reference to one of the preceding nodes.
|
||||
* or some encoding for a non-existent jet is encountered
|
||||
* or the size of a WORD encoding is greater than 2^31 bits.
|
||||
|
|
@ -114,7 +114,7 @@ static simplicity_err decodeNode(dag_node* dag, uint_fast32_t i, bitstream* stre
|
|||
case 0: dag[i].tag = IDEN; break;
|
||||
case 1: dag[i].tag = UNIT; break;
|
||||
case 2: return SIMPLICITY_ERR_FAIL_CODE;
|
||||
case 3: return SIMPLICITY_ERR_STOP_CODE;
|
||||
case 3: return SIMPLICITY_ERR_RESERVED_CODE;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
|
@ -143,8 +143,8 @@ static simplicity_err decodeNode(dag_node* dag, uint_fast32_t i, bitstream* stre
|
|||
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if some node's child isn't a reference to one of the preceding nodes.
|
||||
* Returns 'SIMPLICITY_ERR_FAIL_CODE' if the encoding of a fail expression is encountered
|
||||
* (all fail subexpressions ought to have been pruned prior to deserialization).
|
||||
* Returns 'SIMPLICITY_ERR_STOP_CODE' if the encoding of a stop tag is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if there are illegal HIDDEN children in the DAG.
|
||||
* Returns 'SIMPLICITY_ERR_RESERVED_CODE' if a reserved codeword is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if the decoded node has a HIDDEN child in a position where it is not allowed.
|
||||
* Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'.
|
||||
* In the above error cases, 'dag' may be modified.
|
||||
* Returns 'SIMPLICITY_NO_ERROR' if successful.
|
||||
|
|
@ -168,8 +168,8 @@ static simplicity_err decodeDag(dag_node* dag, const uint_fast32_t len, combinat
|
|||
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if some node's child isn't a reference to one of the preceding nodes.
|
||||
* Returns 'SIMPLICITY_ERR_FAIL_CODE' if the encoding of a fail expression is encountered
|
||||
* (all fail subexpressions ought to have been pruned prior to deserialization).
|
||||
* Returns 'SIMPLICITY_ERR_STOP_CODE' if the encoding of a stop tag is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if there are illegal HIDDEN children in the DAG.
|
||||
* Returns 'SIMPLICITY_ERR_RESERVED_CODE' if a reserved codeword is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if the decoded node has a HIDDEN child in a position where it is not allowed.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN_ROOT' if the root of the DAG is a HIDDEN node.
|
||||
* Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'.
|
||||
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if nodes are not serialized in the canonical order.
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if some node's child isn't a reference to one of the preceding nodes.
|
||||
* Returns 'SIMPLICITY_ERR_FAIL_CODE' if the encoding of a fail expression is encountered
|
||||
* (all fail subexpressions ought to have been pruned prior to deserialization).
|
||||
* Returns 'SIMPLICITY_ERR_STOP_CODE' if the encoding of a stop tag is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if there are illegal HIDDEN children in the DAG.
|
||||
* Returns 'SIMPLICITY_ERR_RESERVED_CODE' if a reserved codeword is encountered.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN' if the decoded node has a HIDDEN child in a position where it is not allowed.
|
||||
* Returns 'SIMPLICITY_ERR_HIDDEN_ROOT' if the root of the DAG is a HIDDEN node.
|
||||
* Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'.
|
||||
* Returns 'SIMPLICITY_ERR_MALLOC' if malloc fails.
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/bitstream.h
|
|||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/bitstring.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/bounded.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/dag.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/decodeCoreJets.inc
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/deserialize.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/eval.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/frame.h
|
||||
|
|
@ -88,6 +89,7 @@ ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/secp256k1/secp256k1.h
|
|||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/secp256k1/secp256k1_impl.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/secp256k1/util.h
|
||||
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/decodeElementsJets.inc
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/elementsJets.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/ops.h
|
||||
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitive.h
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ const uint32_t hashBlock_cmr[] = {
|
|||
0xa07dd7d8u, 0x22aed1adu, 0x40576a7au, 0x69fa1082u, 0x52d3dd89u, 0x539b1e4eu, 0x1f567851u, 0x9abf54e5u
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above hashBlock Simplicity expression. */
|
||||
const uint32_t hashBlock_imr[] = {
|
||||
/* The identity hash of the root of the above hashBlock Simplicity expression. */
|
||||
const uint32_t hashBlock_ihr[] = {
|
||||
0x609cc145u, 0x9375db72u, 0x8f2172c9u, 0x62807e31u, 0x61df4cceu, 0xd6592d2cu, 0x4e594a77u, 0x79ab3175u
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ extern const size_t sizeof_hashBlock_witness;
|
|||
/* The commitment Merkle root of the above hashBlock Simplicity expression. */
|
||||
extern const uint32_t hashBlock_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above hashBlock Simplicity expression. */
|
||||
extern const uint32_t hashBlock_imr[];
|
||||
/* The identity hash of the root of the above hashBlock Simplicity expression. */
|
||||
extern const uint32_t hashBlock_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above hashBlock Simplicity expression. */
|
||||
extern const uint32_t hashBlock_amr[];
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ typedef struct rawInput {
|
|||
|
||||
/* A structure representing data for an Elements transaction, including the TXO data of each output being redeemed.
|
||||
*
|
||||
* Invariant: rawInput input[numInputs];
|
||||
* Invariant: unsigned char txid[32];
|
||||
* rawInput input[numInputs];
|
||||
* rawOutput output[numOutputs];
|
||||
*/
|
||||
typedef struct rawTransaction {
|
||||
|
|
@ -86,13 +87,17 @@ typedef struct rawTransaction {
|
|||
/* A forward declaration for the structure containing a copy (and digest) of the rawTransaction data */
|
||||
typedef struct transaction transaction;
|
||||
|
||||
/* Allocate and initialize a 'transaction' from a 'rawOutput', copying or hashing the data as needed.
|
||||
/* Allocate and initialize a 'transaction' from a 'rawTransaction', copying or hashing the data as needed.
|
||||
* Returns NULL if malloc fails (or if malloc cannot be called because we require an allocation larger than SIZE_MAX).
|
||||
*
|
||||
* Precondition: NULL != rawTx
|
||||
*/
|
||||
extern transaction* simplicity_elements_mallocTransaction(const rawTransaction* rawTx);
|
||||
|
||||
/* Free a pointer to 'transaction'.
|
||||
*/
|
||||
extern void simplicity_elements_freeTransaction(transaction* tx);
|
||||
|
||||
/* A structure representing taproot spending data for an Elements transaction.
|
||||
*
|
||||
* Invariant: pathLen <= 128;
|
||||
|
|
@ -114,4 +119,8 @@ typedef struct tapEnv tapEnv;
|
|||
* Precondition: *rawEnv is well-formed (i.e. rawEnv->pathLen <= 128.)
|
||||
*/
|
||||
extern tapEnv* simplicity_elements_mallocTapEnv(const rawTapEnv* rawEnv);
|
||||
|
||||
/* Free a pointer to 'tapEnv'.
|
||||
*/
|
||||
extern void simplicity_elements_freeTapEnv(tapEnv* env);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,19 +19,20 @@
|
|||
*
|
||||
* Otherwise '*error' is set to 'SIMPLICITY_NO_ERROR'.
|
||||
*
|
||||
* If 'imr != NULL' and '*error' is set to 'SIMPLICITY_NO_ERROR', then the identity Merkle root of the decoded expression is written to 'imr'.
|
||||
* Otherwise if 'imr != NULL' and '*error' is not set to 'SIMPLCITY_NO_ERROR', then 'imr' may or may not be written to.
|
||||
* If 'ihr != NULL' and '*error' is set to 'SIMPLICITY_NO_ERROR', then the identity hash of the root of the decoded expression is written to 'ihr'.
|
||||
* Otherwise if 'ihr != NULL' and '*error' is not set to 'SIMPLCITY_NO_ERROR', then 'ihr' may or may not be written to.
|
||||
*
|
||||
* Precondition: NULL != error;
|
||||
* NULL != imr implies unsigned char imr[32]
|
||||
* NULL != ihr implies unsigned char ihr[32]
|
||||
* NULL != tx;
|
||||
* NULL != taproot;
|
||||
* unsigned char genesisBlockHash[32]
|
||||
* 0 <= budget;
|
||||
* NULL != amr implies unsigned char amr[32]
|
||||
* unsigned char program[program_len]
|
||||
* unsigned char witness[witness_len]
|
||||
*/
|
||||
extern bool simplicity_elements_execSimplicity( simplicity_err* error, unsigned char* imr
|
||||
extern bool simplicity_elements_execSimplicity( simplicity_err* error, unsigned char* ihr
|
||||
, const transaction* tx, uint_fast32_t ix, const tapEnv* taproot
|
||||
, const unsigned char* genesisBlockHash
|
||||
, int64_t budget
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ typedef enum {
|
|||
SIMPLICITY_ERR_DATA_OUT_OF_RANGE = -2,
|
||||
SIMPLICITY_ERR_DATA_OUT_OF_ORDER = -4,
|
||||
SIMPLICITY_ERR_FAIL_CODE = -6,
|
||||
SIMPLICITY_ERR_STOP_CODE = -8,
|
||||
SIMPLICITY_ERR_RESERVED_CODE = -8,
|
||||
SIMPLICITY_ERR_HIDDEN = -10,
|
||||
SIMPLICITY_ERR_BITSTREAM_EOF = -12,
|
||||
SIMPLICITY_ERR_BITSTREAM_TRAILING_BYTES = -14,
|
||||
|
|
@ -62,10 +62,10 @@ static inline const char * SIMPLICITY_ERR_MSG(simplicity_err err) {
|
|||
return "Non-canonical order";
|
||||
case SIMPLICITY_ERR_FAIL_CODE:
|
||||
return "Program has FAIL node";
|
||||
case SIMPLICITY_ERR_STOP_CODE:
|
||||
return "Program has STOP node";
|
||||
case SIMPLICITY_ERR_RESERVED_CODE:
|
||||
return "Program has reserved codeword";
|
||||
case SIMPLICITY_ERR_HIDDEN:
|
||||
return "Program has illegal HIDDEN child node";
|
||||
return "Program has node with a HIDDEN child in a position where it is not allowed";
|
||||
case SIMPLICITY_ERR_BITSTREAM_EOF:
|
||||
return "Unexpected end of bitstream";
|
||||
case SIMPLICITY_ERR_BITSTREAM_TRAILING_BYTES:
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ const uint32_t elementsCheckSigHashAllTx1_cmr[] = {
|
|||
0xf3cd4537u, 0xd7ebb201u, 0x73220319u, 0x5b30b549u, 0xb8dc0c2cu, 0x6257b3a0u, 0xd53bedb0u, 0x8ea02874u
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
|
||||
const uint32_t elementsCheckSigHashAllTx1_imr[] = {
|
||||
/* The identity hash of the root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
|
||||
const uint32_t elementsCheckSigHashAllTx1_ihr[] = {
|
||||
0xd3a5130du, 0xf6abce06u, 0x51eb717au, 0x6dd04222u, 0xb7517651u, 0x9117ec5cu, 0x07bb9edbu, 0xac335e1bu
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ extern const size_t sizeof_elementsCheckSigHashAllTx1_witness;
|
|||
/* The commitment Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
|
||||
extern const uint32_t elementsCheckSigHashAllTx1_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
|
||||
extern const uint32_t elementsCheckSigHashAllTx1_imr[];
|
||||
/* The identity hash of the root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
|
||||
extern const uint32_t elementsCheckSigHashAllTx1_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
|
||||
extern const uint32_t elementsCheckSigHashAllTx1_amr[];
|
||||
|
|
|
|||
136
src/simplicity/primitive/elements/decodeElementsJets.inc
Normal file
136
src/simplicity/primitive/elements/decodeElementsJets.inc
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/* This file has been automatically generated. */
|
||||
|
||||
{
|
||||
int32_t code;
|
||||
code = simplicity_decodeUptoMaxInt(stream);
|
||||
if (code < 0) return (simplicity_err)code;
|
||||
switch (code) {
|
||||
case 1:
|
||||
code = simplicity_decodeUptoMaxInt(stream);
|
||||
if (code < 0) return (simplicity_err)code;
|
||||
switch (code) {
|
||||
case 1: *result = SIG_ALL_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 2: *result = TX_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 3: *result = TAP_ENV_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 4: *result = OUTPUTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 5: *result = INPUTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 6: *result = ISSUANCES_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 7: *result = INPUT_UTXOS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 8: *result = OUTPUT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 9: *result = OUTPUT_AMOUNTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 10: *result = OUTPUT_SCRIPTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 11: *result = OUTPUT_NONCES_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 12: *result = OUTPUT_RANGE_PROOFS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 13: *result = OUTPUT_SURJECTION_PROOFS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 14: *result = INPUT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 15: *result = INPUT_OUTPOINTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 16: *result = INPUT_SEQUENCES_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 17: *result = INPUT_ANNEXES_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 18: *result = INPUT_SCRIPT_SIGS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 19: *result = ISSUANCE_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 20: *result = ISSUANCE_ASSET_AMOUNTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 21: *result = ISSUANCE_TOKEN_AMOUNTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 22: *result = ISSUANCE_RANGE_PROOFS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 23: *result = ISSUANCE_BLINDING_ENTROPY_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 24: *result = INPUT_UTXO_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 25: *result = INPUT_AMOUNTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 26: *result = INPUT_SCRIPTS_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 27: *result = TAPLEAF_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 28: *result = TAPPATH_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 29: *result = OUTPOINT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 30: *result = ASSET_AMOUNT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 31: *result = NONCE_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 32: *result = ANNEX_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 33: *result = BUILD_TAPLEAF_SIMPLICITY; return SIMPLICITY_NO_ERROR;
|
||||
case 34: *result = BUILD_TAPBRANCH; return SIMPLICITY_NO_ERROR;
|
||||
case 35: *result = BUILD_TAPTWEAK; return SIMPLICITY_NO_ERROR;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
code = simplicity_decodeUptoMaxInt(stream);
|
||||
if (code < 0) return (simplicity_err)code;
|
||||
switch (code) {
|
||||
case 1: *result = CHECK_LOCK_HEIGHT; return SIMPLICITY_NO_ERROR;
|
||||
case 2: *result = CHECK_LOCK_TIME; return SIMPLICITY_NO_ERROR;
|
||||
case 3: *result = CHECK_LOCK_DISTANCE; return SIMPLICITY_NO_ERROR;
|
||||
case 4: *result = CHECK_LOCK_DURATION; return SIMPLICITY_NO_ERROR;
|
||||
case 5: *result = TX_LOCK_HEIGHT; return SIMPLICITY_NO_ERROR;
|
||||
case 6: *result = TX_LOCK_TIME; return SIMPLICITY_NO_ERROR;
|
||||
case 7: *result = TX_LOCK_DISTANCE; return SIMPLICITY_NO_ERROR;
|
||||
case 8: *result = TX_LOCK_DURATION; return SIMPLICITY_NO_ERROR;
|
||||
case 9: *result = TX_IS_FINAL; return SIMPLICITY_NO_ERROR;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
code = simplicity_decodeUptoMaxInt(stream);
|
||||
if (code < 0) return (simplicity_err)code;
|
||||
switch (code) {
|
||||
case 1: *result = ISSUANCE; return SIMPLICITY_NO_ERROR;
|
||||
case 2: *result = ISSUANCE_ASSET; return SIMPLICITY_NO_ERROR;
|
||||
case 3: *result = ISSUANCE_TOKEN; return SIMPLICITY_NO_ERROR;
|
||||
case 4: *result = ISSUANCE_ENTROPY; return SIMPLICITY_NO_ERROR;
|
||||
case 5: *result = CALCULATE_ISSUANCE_ENTROPY; return SIMPLICITY_NO_ERROR;
|
||||
case 6: *result = CALCULATE_ASSET; return SIMPLICITY_NO_ERROR;
|
||||
case 7: *result = CALCULATE_EXPLICIT_TOKEN; return SIMPLICITY_NO_ERROR;
|
||||
case 8: *result = CALCULATE_CONFIDENTIAL_TOKEN; return SIMPLICITY_NO_ERROR;
|
||||
case 9: *result = LBTC_ASSET; return SIMPLICITY_NO_ERROR;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
code = simplicity_decodeUptoMaxInt(stream);
|
||||
if (code < 0) return (simplicity_err)code;
|
||||
switch (code) {
|
||||
case 1: *result = SCRIPT_CMR; return SIMPLICITY_NO_ERROR;
|
||||
case 2: *result = INTERNAL_KEY; return SIMPLICITY_NO_ERROR;
|
||||
case 3: *result = CURRENT_INDEX; return SIMPLICITY_NO_ERROR;
|
||||
case 4: *result = NUM_INPUTS; return SIMPLICITY_NO_ERROR;
|
||||
case 5: *result = NUM_OUTPUTS; return SIMPLICITY_NO_ERROR;
|
||||
case 6: *result = LOCK_TIME; return SIMPLICITY_NO_ERROR;
|
||||
case 7: *result = OUTPUT_ASSET; return SIMPLICITY_NO_ERROR;
|
||||
case 8: *result = OUTPUT_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 9: *result = OUTPUT_NONCE; return SIMPLICITY_NO_ERROR;
|
||||
case 10: *result = OUTPUT_SCRIPT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 11: *result = OUTPUT_NULL_DATUM; return SIMPLICITY_NO_ERROR;
|
||||
case 12: *result = OUTPUT_IS_FEE; return SIMPLICITY_NO_ERROR;
|
||||
case 13: *result = OUTPUT_SURJECTION_PROOF; return SIMPLICITY_NO_ERROR;
|
||||
case 14: *result = OUTPUT_RANGE_PROOF; return SIMPLICITY_NO_ERROR;
|
||||
case 15: *result = TOTAL_FEE; return SIMPLICITY_NO_ERROR;
|
||||
case 16: *result = CURRENT_PEGIN; return SIMPLICITY_NO_ERROR;
|
||||
case 17: *result = CURRENT_PREV_OUTPOINT; return SIMPLICITY_NO_ERROR;
|
||||
case 18: *result = CURRENT_ASSET; return SIMPLICITY_NO_ERROR;
|
||||
case 19: *result = CURRENT_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 20: *result = CURRENT_SCRIPT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 21: *result = CURRENT_SEQUENCE; return SIMPLICITY_NO_ERROR;
|
||||
case 22: *result = CURRENT_ANNEX_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 23: *result = CURRENT_SCRIPT_SIG_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 24: *result = CURRENT_REISSUANCE_BLINDING; return SIMPLICITY_NO_ERROR;
|
||||
case 25: *result = CURRENT_NEW_ISSUANCE_CONTRACT; return SIMPLICITY_NO_ERROR;
|
||||
case 26: *result = CURRENT_REISSUANCE_ENTROPY; return SIMPLICITY_NO_ERROR;
|
||||
case 27: *result = CURRENT_ISSUANCE_ASSET_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 28: *result = CURRENT_ISSUANCE_TOKEN_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 29: *result = CURRENT_ISSUANCE_ASSET_PROOF; return SIMPLICITY_NO_ERROR;
|
||||
case 30: *result = CURRENT_ISSUANCE_TOKEN_PROOF; return SIMPLICITY_NO_ERROR;
|
||||
case 31: *result = INPUT_PEGIN; return SIMPLICITY_NO_ERROR;
|
||||
case 32: *result = INPUT_PREV_OUTPOINT; return SIMPLICITY_NO_ERROR;
|
||||
case 33: *result = INPUT_ASSET; return SIMPLICITY_NO_ERROR;
|
||||
case 34: *result = INPUT_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 35: *result = INPUT_SCRIPT_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 36: *result = INPUT_SEQUENCE; return SIMPLICITY_NO_ERROR;
|
||||
case 37: *result = INPUT_ANNEX_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 38: *result = INPUT_SCRIPT_SIG_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 39: *result = REISSUANCE_BLINDING; return SIMPLICITY_NO_ERROR;
|
||||
case 40: *result = NEW_ISSUANCE_CONTRACT; return SIMPLICITY_NO_ERROR;
|
||||
case 41: *result = REISSUANCE_ENTROPY; return SIMPLICITY_NO_ERROR;
|
||||
case 42: *result = ISSUANCE_ASSET_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 43: *result = ISSUANCE_TOKEN_AMOUNT; return SIMPLICITY_NO_ERROR;
|
||||
case 44: *result = ISSUANCE_ASSET_PROOF; return SIMPLICITY_NO_ERROR;
|
||||
case 45: *result = ISSUANCE_TOKEN_PROOF; return SIMPLICITY_NO_ERROR;
|
||||
case 46: *result = TAPLEAF_VERSION; return SIMPLICITY_NO_ERROR;
|
||||
case 47: *result = TAPPATH; return SIMPLICITY_NO_ERROR;
|
||||
case 48: *result = VERSION; return SIMPLICITY_NO_ERROR;
|
||||
case 49: *result = GENESIS_BLOCK_HASH; return SIMPLICITY_NO_ERROR;
|
||||
case 50: *result = TRANSACTION_ID; return SIMPLICITY_NO_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -305,7 +305,8 @@ static uint_fast32_t sumFees(sigOutput** feeOutputs, uint_fast32_t numFees) {
|
|||
|
||||
return result + 1;
|
||||
}
|
||||
/* Allocate and initialize a 'transaction' from a 'rawOutput', copying or hashing the data as needed.
|
||||
|
||||
/* Allocate and initialize a 'transaction' from a 'rawTransaction', copying or hashing the data as needed.
|
||||
* Returns NULL if malloc fails (or if malloc cannot be called because we require an allocation larger than SIZE_MAX).
|
||||
*
|
||||
* Precondition: NULL != rawTx
|
||||
|
|
@ -568,6 +569,12 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
|
|||
return tx;
|
||||
}
|
||||
|
||||
/* Free a pointer to 'transaction'.
|
||||
*/
|
||||
extern void simplicity_elements_freeTransaction(transaction* tx) {
|
||||
simplicity_free(tx);
|
||||
}
|
||||
|
||||
/* Allocate and initialize a 'tapEnv' from a 'rawTapEnv', copying or hashing the data as needed.
|
||||
* Returns NULL if malloc fails (or if malloc cannot be called because we require an allocation larger than SIZE_MAX).
|
||||
*
|
||||
|
|
@ -639,6 +646,12 @@ extern tapEnv* simplicity_elements_mallocTapEnv(const rawTapEnv* rawEnv) {
|
|||
return env;
|
||||
}
|
||||
|
||||
/* Free a pointer to 'tapEnv'.
|
||||
*/
|
||||
extern void simplicity_elements_freeTapEnv(tapEnv* env) {
|
||||
simplicity_free(env);
|
||||
}
|
||||
|
||||
/* Contstruct a txEnv structure from its components.
|
||||
* This function will precompute any cached values.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
*
|
||||
* Otherwise '*error' is set to 'SIMPLICITY_NO_ERROR'.
|
||||
*
|
||||
* If 'imr != NULL' and '*error' is set to 'SIMPLICITY_NO_ERROR', then the identity Merkle root of the decoded expression is written to 'imr'.
|
||||
* Otherwise if 'imr != NULL' and '*error' is not set to 'SIMPLCITY_NO_ERROR', then 'imr' may or may not be written to.
|
||||
* If 'ihr != NULL' and '*error' is set to 'SIMPLICITY_NO_ERROR', then the identity hash of the root of the decoded expression is written to 'ihr'.
|
||||
* Otherwise if 'ihr != NULL' and '*error' is not set to 'SIMPLCITY_NO_ERROR', then 'ihr' may or may not be written to.
|
||||
*
|
||||
* Precondition: NULL != error;
|
||||
* NULL != imr implies unsigned char imr[32]
|
||||
* NULL != ihr implies unsigned char ihr[32]
|
||||
* NULL != tx;
|
||||
* NULL != taproot;
|
||||
* unsigned char genesisBlockHash[32]
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
* unsigned char program[program_len]
|
||||
* unsigned char witness[witness_len]
|
||||
*/
|
||||
extern bool simplicity_elements_execSimplicity( simplicity_err* error, unsigned char* imr
|
||||
extern bool simplicity_elements_execSimplicity( simplicity_err* error, unsigned char* ihr
|
||||
, const transaction* tx, uint_fast32_t ix, const tapEnv* taproot
|
||||
, const unsigned char* genesisBlockHash
|
||||
, int64_t budget
|
||||
|
|
@ -96,12 +96,9 @@ extern bool simplicity_elements_execSimplicity( simplicity_err* error, unsigned
|
|||
}
|
||||
}
|
||||
if (IS_OK(*error)) {
|
||||
sha256_midstate imr_buf;
|
||||
static_assert(DAG_LEN_MAX <= SIZE_MAX / sizeof(sha256_midstate), "imr_buf array too large.");
|
||||
static_assert(1 <= DAG_LEN_MAX, "DAG_LEN_MAX is zero.");
|
||||
static_assert(DAG_LEN_MAX - 1 <= UINT32_MAX, "imr_buf array index does nto fit in uint32_t.");
|
||||
*error = simplicity_verifyNoDuplicateIdentityRoots(&imr_buf, dag, type_dag, (uint_fast32_t)dag_len);
|
||||
if (IS_OK(*error) && imr) sha256_fromMidstate(imr, imr_buf.s);
|
||||
sha256_midstate ihr_buf;
|
||||
*error = simplicity_verifyNoDuplicateIdentityHashes(&ihr_buf, dag, type_dag, (uint_fast32_t)dag_len);
|
||||
if (IS_OK(*error) && ihr) sha256_fromMidstate(ihr, ihr_buf.s);
|
||||
}
|
||||
if (IS_OK(*error) && amr) {
|
||||
static_assert(DAG_LEN_MAX <= SIZE_MAX / sizeof(analyses), "analysis array too large.");
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -29,8 +29,8 @@ const uint32_t schnorr0_cmr[] = {
|
|||
0x8a9e9767u, 0x6b24be77u, 0x97d9ee0bu, 0xf32dd76bu, 0xcd78028eu, 0x973025f7u, 0x85eae8dcu, 0x91c8a0dau
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above schnorr0 Simplicity expression. */
|
||||
const uint32_t schnorr0_imr[] = {
|
||||
/* The identity hash of the root of the above schnorr0 Simplicity expression. */
|
||||
const uint32_t schnorr0_ihr[] = {
|
||||
0xad7c38b1u, 0x6b912964u, 0x6dc89b52u, 0xcff144deu, 0x94a80e38u, 0x3c4983b5u, 0x3de65e35u, 0x75abcf38u
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ extern const size_t sizeof_schnorr0_witness;
|
|||
/* The commitment Merkle root of the above schnorr0 Simplicity expression. */
|
||||
extern const uint32_t schnorr0_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above schnorr0 Simplicity expression. */
|
||||
extern const uint32_t schnorr0_imr[];
|
||||
/* The identity hash of the root of the above schnorr0 Simplicity expression. */
|
||||
extern const uint32_t schnorr0_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above schnorr0 Simplicity expression. */
|
||||
extern const uint32_t schnorr0_amr[];
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ const uint32_t schnorr6_cmr[] = {
|
|||
0x83b6b5bcu, 0xc9bdc956u, 0xaf326376u, 0xf201aa7au, 0x2e65bb9eu, 0xedca6a06u, 0x65976452u, 0x5203cf68u
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above schnorr6 Simplicity expression. */
|
||||
const uint32_t schnorr6_imr[] = {
|
||||
/* The identity hash of the root of the above schnorr6 Simplicity expression. */
|
||||
const uint32_t schnorr6_ihr[] = {
|
||||
0x53acece2u, 0xa5e61e36u, 0xd6c57f92u, 0x4cff9c45u, 0x0a283badu, 0x853aab59u, 0xebdf384du, 0x26264fefu
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ extern const size_t sizeof_schnorr6_witness;
|
|||
/* The commitment Merkle root of the above schnorr6 Simplicity expression. */
|
||||
extern const uint32_t schnorr6_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above schnorr6 Simplicity expression. */
|
||||
extern const uint32_t schnorr6_imr[];
|
||||
/* The identity hash of the root of the above schnorr6 Simplicity expression. */
|
||||
extern const uint32_t schnorr6_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above schnorr6 Simplicity expression. */
|
||||
extern const uint32_t schnorr6_amr[];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <stdint.h>
|
||||
#include "util.h"
|
||||
|
||||
typedef struct {
|
||||
typedef struct secp256k1_uint128 {
|
||||
uint64_t lo;
|
||||
uint64_t hi;
|
||||
} secp256k1_uint128;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
/* A signed 62-bit limb representation of integers.
|
||||
*
|
||||
* Its value is sum(v[i] * 2^(62*i), i=0..4). */
|
||||
typedef struct {
|
||||
typedef struct secp256k1_modinv64_signed62 {
|
||||
int64_t v[5];
|
||||
} secp256k1_modinv64_signed62;
|
||||
|
||||
typedef struct {
|
||||
typedef struct secp256k1_modinv64_modinfo {
|
||||
/* The modulus in signed62 notation, must be odd and in [3, 2^256]. */
|
||||
secp256k1_modinv64_signed62 modulus;
|
||||
|
||||
|
|
@ -28,6 +28,18 @@ typedef struct {
|
|||
uint64_t modulus_inv62;
|
||||
} secp256k1_modinv64_modinfo;
|
||||
|
||||
static inline void secp256k1_modinv64_signed62_assign(secp256k1_modinv64_signed62 *dst, const secp256k1_modinv64_signed62 *src) {
|
||||
#ifdef VST
|
||||
dst->v[0] = src->v[0];
|
||||
dst->v[1] = src->v[1];
|
||||
dst->v[2] = src->v[2];
|
||||
dst->v[3] = src->v[3];
|
||||
dst->v[4] = src->v[4];
|
||||
#else
|
||||
*dst = *src;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Replace x with its modular inverse mod modinfo->modulus. x must be in range [0, modulus).
|
||||
* If x is zero, the result will be zero as well. If not, the inverse must exist (i.e., the gcd of
|
||||
* x and modulus must be 1). These rules are automatically satisfied if the modulus is prime.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
* t = [ u v ]
|
||||
* [ q r ]
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct secp256k1_modinv64_trans2x2 {
|
||||
int64_t u, v, q, r;
|
||||
} secp256k1_modinv64_trans2x2;
|
||||
|
||||
|
|
@ -651,8 +651,10 @@ static void secp256k1_modinv64_var(secp256k1_modinv64_signed62 *x, const secp256
|
|||
/* Start with d=0, e=1, f=modulus, g=x, eta=-1. */
|
||||
secp256k1_modinv64_signed62 d = {{0, 0, 0, 0, 0}};
|
||||
secp256k1_modinv64_signed62 e = {{1, 0, 0, 0, 0}};
|
||||
secp256k1_modinv64_signed62 f = modinfo->modulus;
|
||||
secp256k1_modinv64_signed62 g = *x;
|
||||
secp256k1_modinv64_signed62 f, g;
|
||||
secp256k1_modinv64_signed62_assign(&(f), &(modinfo->modulus));
|
||||
secp256k1_modinv64_signed62_assign(&(g), &(*x));
|
||||
|
||||
#ifdef VERIFY
|
||||
int i = 0;
|
||||
#endif
|
||||
|
|
@ -723,7 +725,7 @@ static void secp256k1_modinv64_var(secp256k1_modinv64_signed62 *x, const secp256
|
|||
|
||||
/* Optionally negate d, normalize to [0,modulus), and return it. */
|
||||
secp256k1_modinv64_normalize_62(&d, f.v[len - 1], modinfo);
|
||||
*x = d;
|
||||
secp256k1_modinv64_signed62_assign(&(*x), &(d));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
# error Cannot compile precomputed_ecmult.c in exhaustive test mode
|
||||
#endif /* EXHAUSTIVE_TEST_ORDER */
|
||||
#define WINDOW_G ECMULT_WINDOW_SIZE
|
||||
static const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)] = {
|
||||
static const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)]
|
||||
#ifndef VST
|
||||
= {
|
||||
S(79be667e,f9dcbbac,55a06295,ce870b07,29bfcdb,2dce28d9,59f2815b,16f81798,483ada77,26a3c465,5da4fbfc,e1108a8,fd17b448,a6855419,9c47d08f,fb10d4b8)
|
||||
#if WINDOW_G > 2
|
||||
,S(f9308a01,9258c310,49344f85,f89d5229,b531c845,836f99b0,8601f113,bce036f9,388f7b0f,632de814,fe337e6,2a37f356,6500a999,34c2231b,6cb9fd75,84b8e672)
|
||||
|
|
@ -8237,8 +8239,12 @@ static const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)] =
|
|||
,S(20990660,f1055420,b885fb0a,38824740,3b141c37,5aa20dce,8a29191a,e77bbb16,7d434476,9e302e38,9e14c02e,f5fd8a5c,64cfcf3d,e9813f1c,f53bc6d3,4da93559)
|
||||
,S(1e70619c,381a6adc,e5d925e0,c9c74f97,3c02ff64,ff2662d7,34efc485,d2bce895,c923f771,f543ffed,42935c28,8474aaaf,80a46ad4,3c579ce0,bb5e663d,668b24b3)
|
||||
#endif
|
||||
};
|
||||
static const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)] = {
|
||||
}
|
||||
#endif
|
||||
;
|
||||
static const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)]
|
||||
#ifndef VST
|
||||
= {
|
||||
S(8f68b9d2,f63b5f33,9239c1ad,981f162e,e88c5678,723ea335,1b7b444c,9ec4c0da,662a9f2d,ba063986,de1d90c2,b6be215d,bbea2cfe,95510bfd,f23cbf79,501fff82)
|
||||
#if WINDOW_G > 2
|
||||
,S(38381dbe,2e509f22,8ba93363,f2451f08,fd845cb3,51d954be,18e2b8ed,d23809fa,e4a32d0a,fb917dc,b09405a5,520eb1cc,3681fccb,32d8f24d,bd707518,331fed52)
|
||||
|
|
@ -16457,7 +16463,9 @@ static const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G
|
|||
,S(15a1ae40,b4fc51dc,554b75d4,db0c2bfd,62dfbbfc,dede18e1,4edbb689,91525cff,4f0453b7,e4e0e99d,9663e5c6,bb018007,b52c8e14,d78a28d,c4a888e4,8c4326c2)
|
||||
,S(1b9a142f,fc4d03ea,4b079f2d,b05fad98,8ddb2d32,b359967f,c173801f,63320825,59bda7ed,5b691c20,4fc8f8ac,f53be298,ae628954,a8134d0f,dd097e67,be9ff9b6)
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif
|
||||
;
|
||||
#undef S
|
||||
|
||||
#endif /* SECP256K1_PRECOMPUTED_ECMULT_H */
|
||||
|
|
|
|||
|
|
@ -127,13 +127,13 @@ static void test_hashBlock(void) {
|
|||
}
|
||||
}
|
||||
{
|
||||
sha256_midstate imr;
|
||||
if (IS_OK(simplicity_verifyNoDuplicateIdentityRoots(&imr, dag, type_dag, (uint_fast32_t)len)) &&
|
||||
0 == memcmp(hashBlock_imr, imr.s, sizeof(uint32_t[8]))) {
|
||||
sha256_midstate ihr;
|
||||
if (IS_OK(simplicity_verifyNoDuplicateIdentityHashes(&ihr, dag, type_dag, (uint_fast32_t)len)) &&
|
||||
0 == memcmp(hashBlock_ihr, ihr.s, sizeof(uint32_t[8]))) {
|
||||
successes++;
|
||||
} else {
|
||||
failures++;
|
||||
printf("Unexpected IMR of hashblock\n");
|
||||
printf("Unexpected IHR of hashblock\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ static void test_hashBlock(void) {
|
|||
|
||||
static void test_program(char* name, const unsigned char* program, size_t program_len, const unsigned char* witness, size_t witness_len,
|
||||
simplicity_err expectedResult, const uint32_t* expectedCMR,
|
||||
const uint32_t* expectedIMR, const uint32_t* expectedAMR, const ubounded *expectedCost) {
|
||||
const uint32_t* expectedIHR, const uint32_t* expectedAMR, const ubounded *expectedCost) {
|
||||
printf("Test %s\n", name);
|
||||
dag_node* dag;
|
||||
combinator_counters census;
|
||||
|
|
@ -253,13 +253,13 @@ static void test_program(char* name, const unsigned char* program, size_t progra
|
|||
}
|
||||
}
|
||||
{
|
||||
sha256_midstate imr;
|
||||
if (IS_OK(simplicity_verifyNoDuplicateIdentityRoots(&imr, dag, type_dag, (uint_fast32_t)len)) &&
|
||||
(!expectedIMR || 0 == memcmp(expectedIMR, imr.s, sizeof(uint32_t[8])))) {
|
||||
sha256_midstate ihr;
|
||||
if (IS_OK(simplicity_verifyNoDuplicateIdentityHashes(&ihr, dag, type_dag, (uint_fast32_t)len)) &&
|
||||
(!expectedIHR || 0 == memcmp(expectedIHR, ihr.s, sizeof(uint32_t[8])))) {
|
||||
successes++;
|
||||
} else {
|
||||
failures++;
|
||||
printf("Unexpected IMR.\n");
|
||||
printf("Unexpected IHR.\n");
|
||||
}
|
||||
}
|
||||
if (expectedCost) {
|
||||
|
|
@ -404,15 +404,15 @@ static void test_elements(void) {
|
|||
}
|
||||
}
|
||||
{
|
||||
unsigned char imrResult[32];
|
||||
if (simplicity_elements_execSimplicity(&execResult, imrResult, tx1, 0, taproot, genesisHash, (elementsCheckSigHashAllTx1_cost + 999)/1000, amr, elementsCheckSigHashAllTx1, sizeof_elementsCheckSigHashAllTx1, elementsCheckSigHashAllTx1_witness, sizeof_elementsCheckSigHashAllTx1_witness) && IS_OK(execResult)) {
|
||||
sha256_midstate imr;
|
||||
sha256_toMidstate(imr.s, imrResult);
|
||||
if (0 == memcmp(imr.s, elementsCheckSigHashAllTx1_imr, sizeof(uint32_t[8]))) {
|
||||
unsigned char ihrResult[32];
|
||||
if (simplicity_elements_execSimplicity(&execResult, ihrResult, tx1, 0, taproot, genesisHash, (elementsCheckSigHashAllTx1_cost + 999)/1000, amr, elementsCheckSigHashAllTx1, sizeof_elementsCheckSigHashAllTx1, elementsCheckSigHashAllTx1_witness, sizeof_elementsCheckSigHashAllTx1_witness) && IS_OK(execResult)) {
|
||||
sha256_midstate ihr;
|
||||
sha256_toMidstate(ihr.s, ihrResult);
|
||||
if (0 == memcmp(ihr.s, elementsCheckSigHashAllTx1_ihr, sizeof(uint32_t[8]))) {
|
||||
successes++;
|
||||
} else {
|
||||
failures++;
|
||||
printf("Unexpected IMR of elementsCheckSigHashAllTx1\n");
|
||||
printf("Unexpected IHR of elementsCheckSigHashAllTx1\n");
|
||||
}
|
||||
} else {
|
||||
failures++;
|
||||
|
|
@ -421,7 +421,7 @@ static void test_elements(void) {
|
|||
if (elementsCheckSigHashAllTx1_cost){
|
||||
/* test the same transaction without adequate budget. */
|
||||
simplicity_assert(elementsCheckSigHashAllTx1_cost);
|
||||
if (simplicity_elements_execSimplicity(&execResult, imrResult, tx1, 0, taproot, genesisHash, (elementsCheckSigHashAllTx1_cost - 1)/1000, amr, elementsCheckSigHashAllTx1, sizeof_elementsCheckSigHashAllTx1, elementsCheckSigHashAllTx1_witness, sizeof_elementsCheckSigHashAllTx1_witness) && SIMPLICITY_ERR_EXEC_BUDGET == execResult) {
|
||||
if (simplicity_elements_execSimplicity(&execResult, ihrResult, tx1, 0, taproot, genesisHash, (elementsCheckSigHashAllTx1_cost - 1)/1000, amr, elementsCheckSigHashAllTx1, sizeof_elementsCheckSigHashAllTx1, elementsCheckSigHashAllTx1_witness, sizeof_elementsCheckSigHashAllTx1_witness) && SIMPLICITY_ERR_EXEC_BUDGET == execResult) {
|
||||
successes++;
|
||||
} else {
|
||||
failures++;
|
||||
|
|
@ -445,7 +445,7 @@ static void test_elements(void) {
|
|||
printf("mallocTransaction(&rawTx1) failed\n");
|
||||
failures++;
|
||||
}
|
||||
simplicity_free(tx1);
|
||||
simplicity_elements_freeTransaction(tx1);
|
||||
}
|
||||
/* test a modified transaction with the same signature. */
|
||||
{
|
||||
|
|
@ -494,9 +494,9 @@ static void test_elements(void) {
|
|||
printf("mallocTransaction(&testTx2) failed\n");
|
||||
failures++;
|
||||
}
|
||||
simplicity_free(tx2);
|
||||
simplicity_elements_freeTransaction(tx2);
|
||||
}
|
||||
simplicity_free(taproot);
|
||||
simplicity_elements_freeTapEnv(taproot);
|
||||
}
|
||||
|
||||
static sha256_midstate hashint(uint_fast32_t n) {
|
||||
|
|
@ -664,16 +664,16 @@ int main(int argc, char **argv) {
|
|||
test_hasDuplicates("hasDuplicates one duplicate testcase", 1, rsort_one_duplicate, 10000);
|
||||
test_hasDuplicates("hasDuplicates diagonal testcase", 0, rsort_diagonal, 33);
|
||||
|
||||
test_program("ctx8Pruned", ctx8Pruned, sizeof_ctx8Pruned, ctx8Pruned_witness, sizeof_ctx8Pruned_witness, SIMPLICITY_NO_ERROR, ctx8Pruned_cmr, ctx8Pruned_imr, ctx8Pruned_amr, &ctx8Pruned_cost);
|
||||
test_program("ctx8Unpruned", ctx8Unpruned, sizeof_ctx8Unpruned, ctx8Unpruned_witness, sizeof_ctx8Unpruned_witness, SIMPLICITY_ERR_ANTIDOS, ctx8Unpruned_cmr, ctx8Unpruned_imr, ctx8Unpruned_amr, &ctx8Unpruned_cost);
|
||||
test_program("ctx8Pruned", ctx8Pruned, sizeof_ctx8Pruned, ctx8Pruned_witness, sizeof_ctx8Pruned_witness, SIMPLICITY_NO_ERROR, ctx8Pruned_cmr, ctx8Pruned_ihr, ctx8Pruned_amr, &ctx8Pruned_cost);
|
||||
test_program("ctx8Unpruned", ctx8Unpruned, sizeof_ctx8Unpruned, ctx8Unpruned_witness, sizeof_ctx8Unpruned_witness, SIMPLICITY_ERR_ANTIDOS, ctx8Unpruned_cmr, ctx8Unpruned_ihr, ctx8Unpruned_amr, &ctx8Unpruned_cost);
|
||||
if (0 == memcmp(ctx8Pruned_cmr, ctx8Unpruned_cmr, sizeof(uint32_t[8]))) {
|
||||
successes++;
|
||||
} else {
|
||||
failures++;
|
||||
printf("Pruned and Unpruned CMRs are not the same.\n");
|
||||
}
|
||||
test_program("schnorr0", schnorr0, sizeof_schnorr0, schnorr0_witness, sizeof_schnorr0_witness, SIMPLICITY_NO_ERROR, schnorr0_cmr, schnorr0_imr, schnorr0_amr, &schnorr0_cost);
|
||||
test_program("schnorr6", schnorr6, sizeof_schnorr6, schnorr6_witness, sizeof_schnorr6_witness, SIMPLICITY_ERR_EXEC_JET, schnorr6_cmr, schnorr6_imr, schnorr6_amr, &schnorr0_cost);
|
||||
test_program("schnorr0", schnorr0, sizeof_schnorr0, schnorr0_witness, sizeof_schnorr0_witness, SIMPLICITY_NO_ERROR, schnorr0_cmr, schnorr0_ihr, schnorr0_amr, &schnorr0_cost);
|
||||
test_program("schnorr6", schnorr6, sizeof_schnorr6, schnorr6_witness, sizeof_schnorr6_witness, SIMPLICITY_ERR_EXEC_JET, schnorr6_cmr, schnorr6_ihr, schnorr6_amr, &schnorr0_cost);
|
||||
test_program("typeSkipTest", typeSkipTest, sizeof_typeSkipTest, typeSkipTest_witness, sizeof_typeSkipTest_witness, SIMPLICITY_NO_ERROR, NULL, NULL, NULL, NULL);
|
||||
test_elements();
|
||||
regression_tests();
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ const uint32_t typeSkipTest_cmr[] = {
|
|||
0x2a791cd8u, 0xf1e2beeau, 0x883e53f2u, 0xce36db2bu, 0x246b3156u, 0xcc40f91bu, 0xb2f59059u, 0xb601ac4au
|
||||
};
|
||||
|
||||
/* The identity Merkle root of the above typeSkipTest Simplicity expression. */
|
||||
const uint32_t typeSkipTest_imr[] = {
|
||||
/* The identity hash of the root of the above typeSkipTest Simplicity expression. */
|
||||
const uint32_t typeSkipTest_ihr[] = {
|
||||
0xbadac773u, 0x19e9cabau, 0x7fe49174u, 0x54d0e25eu, 0x7d4c4a7eu, 0x4867c392u, 0x20bf409au, 0xc6e6bf10u
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ extern const size_t sizeof_typeSkipTest_witness;
|
|||
/* The commitment Merkle root of the above typeSkipTest Simplicity expression. */
|
||||
extern const uint32_t typeSkipTest_cmr[];
|
||||
|
||||
/* The identity Merkle root of the above typeSkipTest Simplicity expression. */
|
||||
extern const uint32_t typeSkipTest_imr[];
|
||||
/* The identity hash of the root of the above typeSkipTest Simplicity expression. */
|
||||
extern const uint32_t typeSkipTest_ihr[];
|
||||
|
||||
/* The annotated Merkle root of the above typeSkipTest Simplicity expression. */
|
||||
extern const uint32_t typeSkipTest_amr[];
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ static ScriptErrorDesc script_errors[]={
|
|||
{SCRIPT_ERR_SIMPLICITY_DATA_OUT_OF_RANGE, "SIMPLICITY_DATA_OUT_OF_RANGE"},
|
||||
{SCRIPT_ERR_SIMPLICITY_DATA_OUT_OF_ORDER, "SIMPLICITY_DATA_OUT_OF_ORDER"},
|
||||
{SCRIPT_ERR_SIMPLICITY_FAIL_CODE, "SIMPLICITY_FAIL_CODE"},
|
||||
{SCRIPT_ERR_SIMPLICITY_STOP_CODE, "SIMPLICITY_STOP_CODE"},
|
||||
{SCRIPT_ERR_SIMPLICITY_RESERVED_CODE, "SIMPLICITY_RESERVED_CODE"},
|
||||
{SCRIPT_ERR_SIMPLICITY_HIDDEN, "SIMPLICITY_HIDDEN"},
|
||||
{SCRIPT_ERR_SIMPLICITY_BITSTREAM_EOF, "SIMPLICITY_BITSTREAM_EOF"},
|
||||
{SCRIPT_ERR_SIMPLICITY_BITSTREAM_TRAILING_BYTES, "SIMPLICITY_BITSTREAM_TRAILING_BYTES"},
|
||||
|
|
|
|||
|
|
@ -79,3 +79,5 @@ implicit-integer-sign-change:blech32.cpp
|
|||
implicit-integer-sign-change:primitives/block.h
|
||||
implicit-integer-sign-change:primitives/confidential.cpp
|
||||
implicit-integer-sign-change:primitives/confidential.h
|
||||
shift-base:simplicity/sha256.c
|
||||
unsigned-integer-overflow:simplicity/sha256.c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue