Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions build_msvc/libelementssimplicity/libelementssimplicity.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>
<ItemGroup>
<ClCompile Include="..\..\src\simplicity\bitstream.c" />
<ClCompile Include="..\..\src\simplicity\cmr.c" />
<ClCompile Include="..\..\src\simplicity\dag.c" />
<ClCompile Include="..\..\src\simplicity\deserialize.c" />
<ClCompile Include="..\..\src\simplicity\eval.c" />
Expand All @@ -20,11 +19,13 @@
<ClCompile Include="..\..\src\simplicity\sha256.c" />
<ClCompile Include="..\..\src\simplicity\type.c" />
<ClCompile Include="..\..\src\simplicity\typeInference.c" />
<ClCompile Include="..\..\src\simplicity\primitive\elements\env.c" />
<ClCompile Include="..\..\src\simplicity\primitive\elements\exec.c" />
<ClCompile Include="..\..\src\simplicity\primitive\elements\elementsJets.c" />
<ClCompile Include="..\..\src\simplicity\primitive\elements\ops.c" />
<ClCompile Include="..\..\src\simplicity\primitive\elements\primitive.c" />
<ClCompile Include="..\..\src\simplicity\elements\cmr.c" />
<ClCompile Include="..\..\src\simplicity\elements\env.c" />
<ClCompile Include="..\..\src\simplicity\elements\exec.c" />
<ClCompile Include="..\..\src\simplicity\elements\elementsJets.c" />
<ClCompile Include="..\..\src\simplicity\elements\ops.c" />
<ClCompile Include="..\..\src\simplicity\elements\primitive.c" />
<ClCompile Include="..\..\src\simplicity\elements\txEnv.c" />
</ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
Expand Down
17 changes: 9 additions & 8 deletions src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2601,8 +2601,8 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
m_spent_output_spk_single_hashes = GetSpentScriptPubKeysSHA256(m_spent_outputs);
m_output_spk_single_hashes = GetOutputScriptPubKeysSHA256(txTo);

std::vector<rawBuffer> simplicityRawAnnex(txTo.witness.vtxinwit.size());
std::vector<rawInput> simplicityRawInput(txTo.vin.size());
std::vector<rawElementsBuffer> simplicityRawAnnex(txTo.witness.vtxinwit.size());
std::vector<rawElementsInput> simplicityRawInput(txTo.vin.size());
for (size_t i = 0; i < txTo.vin.size(); ++i) {
simplicityRawInput[i].prevTxid = txTo.vin[i].prevout.hash.begin();
simplicityRawInput[i].prevIx = txTo.vin[i].prevout.n;
Expand Down Expand Up @@ -2639,7 +2639,7 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
}
}

std::vector<rawOutput> simplicityRawOutput(txTo.vout.size());
std::vector<rawElementsOutput> simplicityRawOutput(txTo.vout.size());
for (size_t i = 0; i < txTo.vout.size(); ++i) {
simplicityRawOutput[i].asset = txTo.vout[i].nAsset.vchCommitment.empty() ? NULL : txTo.vout[i].nAsset.vchCommitment.data();
simplicityRawOutput[i].value = txTo.vout[i].nValue.vchCommitment.empty() ? NULL : txTo.vout[i].nValue.vchCommitment.data();
Expand All @@ -2659,7 +2659,7 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
}
}

rawTransaction simplicityRawTx;
rawElementsTransaction simplicityRawTx;
uint256 rawHash = txTo.GetHash();
simplicityRawTx.txid = rawHash.begin();
simplicityRawTx.input = simplicityRawInput.data();
Expand Down Expand Up @@ -3114,14 +3114,14 @@ uint32_t GenericTransactionSignatureChecker<T>::GetnIn() const
}

template <class T>
bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& program, const valtype& witness, const rawTapEnv& simplicityRawTap, int64_t budget, ScriptError* serror) const
bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& program, const valtype& witness, const rawElementsTapEnv& simplicityRawTap, int64_t budget, ScriptError* serror) const
{
simplicity_err error;
tapEnv* simplicityTapEnv = simplicity_elements_mallocTapEnv(&simplicityRawTap);
elementsTapEnv* simplicityTapEnv = simplicity_elements_mallocTapEnv(&simplicityRawTap);

assert(txdata->m_simplicity_tx_data);
assert(simplicityTapEnv);
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())) {
if (!simplicity_elements_execSimplicity(&error, 0, txdata->m_simplicity_tx_data.get(), nIn, simplicityTapEnv, txdata->m_hash_genesis_block.data(), 0, budget, 0, program.data(), program.size(), witness.data(), witness.size())) {
assert(!"simplicity_elements_execSimplicity internal error");
}
simplicity_elements_freeTapEnv(simplicityTapEnv);
Expand Down Expand Up @@ -3154,6 +3154,7 @@ bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& progr
case SIMPLICITY_ERR_ANTIDOS: return set_error(serror, SCRIPT_ERR_SIMPLICITY_ANTIDOS);
case SIMPLICITY_ERR_HIDDEN_ROOT: return set_error(serror, SCRIPT_ERR_SIMPLICITY_HIDDEN_ROOT);
case SIMPLICITY_ERR_AMR: return set_error(serror, SCRIPT_ERR_SIMPLICITY_AMR);
case SIMPLICITY_ERR_OVERWEIGHT: return set_error(serror, SCRIPT_ERR_SIMPLICITY_OVERWEIGHT);
default: return set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR);
}
}
Expand Down Expand Up @@ -3312,7 +3313,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
const valtype& simplicity_program = SpanPopBack(stack);
const valtype& simplicity_witness = SpanPopBack(stack);
const int64_t budget = ::GetSerializeSize(witness.stack, PROTOCOL_VERSION) + VALIDATION_WEIGHT_OFFSET;
rawTapEnv simplicityRawTap;
rawElementsTapEnv simplicityRawTap;
simplicityRawTap.controlBlock = control.data();
simplicityRawTap.pathLen = (control.size() - TAPROOT_CONTROL_BASE_SIZE) / TAPROOT_CONTROL_NODE_SIZE;
simplicityRawTap.scriptCMR = script_bytes.data();
Expand Down
8 changes: 4 additions & 4 deletions src/script/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned i

struct SimplicityTransactionDeleter
{
void operator()(transaction* ptr)
void operator()(elementsTransaction* ptr)
{
simplicity_elements_freeTransaction(ptr);
}
};
using SimplicityTransactionUniquePtr = std::unique_ptr<transaction, SimplicityTransactionDeleter>;
using SimplicityTransactionUniquePtr = std::unique_ptr<elementsTransaction, SimplicityTransactionDeleter>;

struct PrecomputedTransactionData
{
Expand Down Expand Up @@ -345,7 +345,7 @@ class BaseSignatureChecker
return std::numeric_limits<uint32_t>::max();
}

virtual bool CheckSimplicity(const std::vector<unsigned char>& witness, const std::vector<unsigned char>& program, const rawTapEnv& simplicityRawTap, int64_t budget, ScriptError* serror) const
virtual bool CheckSimplicity(const std::vector<unsigned char>& witness, const std::vector<unsigned char>& program, const rawElementsTapEnv& simplicityRawTap, int64_t budget, ScriptError* serror) const
{
return false;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ class GenericTransactionSignatureChecker : public BaseSignatureChecker

const PrecomputedTransactionData* GetPrecomputedTransactionData() const override;
uint32_t GetnIn() const override;
bool CheckSimplicity(const std::vector<unsigned char>& program, const std::vector<unsigned char>& witness, const rawTapEnv& simplicityRawTap, int64_t budget, ScriptError* serror) const override;
bool CheckSimplicity(const std::vector<unsigned char>& program, const std::vector<unsigned char>& witness, const rawElementsTapEnv& simplicityRawTap, int64_t budget, ScriptError* serror) const override;
};

using TransactionSignatureChecker = GenericTransactionSignatureChecker<CTransaction>;
Expand Down
2 changes: 2 additions & 0 deletions src/script/script_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ std::string ScriptErrorString(const ScriptError serror)
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_HIDDEN_ROOT);
case SCRIPT_ERR_SIMPLICITY_AMR:
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_AMR);
case SCRIPT_ERR_SIMPLICITY_OVERWEIGHT:
return SIMPLICITY_ERR_MSG(SIMPLICITY_ERR_OVERWEIGHT);
case SCRIPT_ERR_UNKNOWN_ERROR:
case SCRIPT_ERR_ERROR_COUNT:
default: break;
Expand Down
1 change: 1 addition & 0 deletions src/script/script_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef enum ScriptError_t
SCRIPT_ERR_SIMPLICITY_ANTIDOS,
SCRIPT_ERR_SIMPLICITY_HIDDEN_ROOT,
SCRIPT_ERR_SIMPLICITY_AMR,
SCRIPT_ERR_SIMPLICITY_OVERWEIGHT,

/* Must go last */
SCRIPT_ERR_ERROR_COUNT
Expand Down
6 changes: 3 additions & 3 deletions src/simplicity/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OBJS := bitstream.o cmr.o dag.o deserialize.o eval.o frame.o jets.o jets-secp256k1.o rsort.o sha256.o type.o typeInference.o primitive/elements/env.o primitive/elements/exec.o primitive/elements/ops.o primitive/elements/elementsJets.o primitive/elements/primitive.o
TEST_OBJS := test.o ctx8Pruned.o ctx8Unpruned.o hashBlock.o regression4.o schnorr0.o schnorr6.o typeSkipTest.o primitive/elements/checkSigHashAllTx1.o
OBJS := bitstream.o dag.o deserialize.o eval.o frame.o jets.o jets-secp256k1.o rsort.o sha256.o type.o typeInference.o elements/env.o elements/exec.o elements/ops.o elements/elementsJets.o elements/primitive.o elements/cmr.o elements/txEnv.o
TEST_OBJS := test.o ctx8Pruned.o ctx8Unpruned.o hashBlock.o regression4.o schnorr0.o schnorr6.o typeSkipTest.o elements/checkSigHashAllTx1.o

# From https://fastcompression.blogspot.com/2019/01/compiler-warnings.html
CWARN := -Werror -Wall -Wextra -Wcast-qual -Wcast-align -Wstrict-aliasing -Wpointer-arith -Winit-self -Wshadow -Wswitch-enum -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wfloat-equal -Wundef -Wconversion
Expand All @@ -14,7 +14,7 @@ CFLAGS := $(CFLAGS) -I include
jets-secp256k1.o: jets-secp256k1.c
$(CC) -c $(CFLAGS) $(CWARN) -Wno-conversion $(CPPFLAGS) -o $@ $<

primitive/elements/elementsJets.o: primitive/elements/elementsJets.c
elements/elementsJets.o: elements/elementsJets.c
$(CC) -c $(CFLAGS) $(CWARN) -Wno-switch-enum -Wswitch $(CPPFLAGS) -o $@ $<

sha256.o: sha256.c
Expand Down
13 changes: 6 additions & 7 deletions src/simplicity/deserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <limits.h>
#include "limitations.h"
#include "primitive.h"
#include "simplicity_alloc.h"
#include "simplicity_assert.h"

Expand Down Expand Up @@ -55,15 +54,15 @@ static simplicity_err getHash(sha256_midstate* result, bitstream* stream) {
* i < 2^31 - 1
* NULL != stream
*/
static simplicity_err decodeNode(dag_node* dag, uint_fast32_t i, bitstream* stream) {
static simplicity_err decodeNode(dag_node* dag, simplicity_callback_decodeJet decodeJet, uint_fast32_t i, bitstream* stream) {
int32_t bit = read1Bit(stream);
if (bit < 0) return (simplicity_err)bit;
dag[i] = (dag_node){0};
if (bit) {
bit = read1Bit(stream);
if (bit < 0) return (simplicity_err)bit;
if (bit) {
return simplicity_decodeJet(&dag[i], stream);
return decodeJet(&dag[i], stream);
} else {
/* Decode WORD. */
int32_t depth = simplicity_decodeUptoMaxInt(stream);
Expand Down Expand Up @@ -153,9 +152,9 @@ static simplicity_err decodeNode(dag_node* dag, uint_fast32_t i, bitstream* stre
* len < 2^31
* NULL != stream
*/
static simplicity_err decodeDag(dag_node* dag, const uint_fast32_t len, combinator_counters* census, bitstream* stream) {
static simplicity_err decodeDag(dag_node* dag, simplicity_callback_decodeJet decodeJet, const uint_fast32_t len, combinator_counters* census, bitstream* stream) {
for (uint_fast32_t i = 0; i < len; ++i) {
simplicity_err error = decodeNode(dag, i, stream);
simplicity_err error = decodeNode(dag, decodeJet, i, stream);
if (!IS_OK(error)) return error;

enumerator(census, dag[i].tag);
Expand Down Expand Up @@ -186,7 +185,7 @@ static simplicity_err decodeDag(dag_node* dag, const uint_fast32_t len, combinat
* of the function is positive and when NULL != census;
* NULL == *dag when the return value is negative.
*/
int_fast32_t simplicity_decodeMallocDag(dag_node** dag, combinator_counters* census, bitstream* stream) {
int_fast32_t simplicity_decodeMallocDag(dag_node** dag, simplicity_callback_decodeJet decodeJet, combinator_counters* census, bitstream* stream) {
*dag = NULL;
int32_t dagLen = simplicity_decodeUptoMaxInt(stream);
if (dagLen <= 0) return dagLen;
Expand All @@ -199,7 +198,7 @@ int_fast32_t simplicity_decodeMallocDag(dag_node** dag, combinator_counters* cen
if (!*dag) return SIMPLICITY_ERR_MALLOC;

if (census) *census = (combinator_counters){0};
simplicity_err error = decodeDag(*dag, (uint_fast32_t)dagLen, census, stream);
simplicity_err error = decodeDag(*dag, decodeJet, (uint_fast32_t)dagLen, census, stream);

if (IS_OK(error)) {
error = HIDDEN == (*dag)[dagLen - 1].tag
Expand Down
14 changes: 13 additions & 1 deletion src/simplicity/deserialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
#include "bitstream.h"
#include "dag.h"

/* Decode an application specific jet from 'stream' into 'node'.
* All jets begin with a bit prefix of '1' which needs to have already been consumed from the 'stream'.
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if the stream's prefix doesn't match any valid code for a jet.
* 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.
*
* Precondition: NULL != node
* NULL != stream
*/
typedef simplicity_err (*simplicity_callback_decodeJet)(dag_node* node, bitstream* stream);

/* Decode a length-prefixed Simplicity DAG from 'stream'.
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' the length prefix's value is too large.
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if some node's child isn't a reference to one of the preceding nodes.
Expand All @@ -28,6 +40,6 @@
* of the function is positive and when NULL != census;
* NULL == *dag when the return value is negative.
*/
int_fast32_t simplicity_decodeMallocDag(dag_node** dag, combinator_counters* census, bitstream* stream);
int_fast32_t simplicity_decodeMallocDag(dag_node** dag, simplicity_callback_decodeJet decodeJet, combinator_counters* census, bitstream* stream);

#endif
33 changes: 17 additions & 16 deletions src/simplicity/elements-sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
ELEMENTS_SIMPLICITY_INCLUDE_DIR_INT = %reldir%/include

ELEMENTS_SIMPLICITY_DIST_HEADERS_INT =
ELEMENTS_SIMPLICITY_DIST_HEADERS_INT += %reldir%/include/simplicity/cmr.h
ELEMENTS_SIMPLICITY_DIST_HEADERS_INT += %reldir%/include/simplicity/errorCodes.h
ELEMENTS_SIMPLICITY_DIST_HEADERS_INT += %reldir%/include/simplicity/elements/cmr.h
ELEMENTS_SIMPLICITY_DIST_HEADERS_INT += %reldir%/include/simplicity/elements/env.h
ELEMENTS_SIMPLICITY_DIST_HEADERS_INT += %reldir%/include/simplicity/elements/exec.h

ELEMENTS_SIMPLICITY_LIB_SOURCES_INT =
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/bitstream.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/cmr.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/dag.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/deserialize.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/eval.c
Expand All @@ -24,11 +23,13 @@ ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/sha256.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/type.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/typeInference.c

ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/env.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/exec.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/elementsJets.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/ops.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/primitive.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/cmr.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/env.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/exec.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/elementsJets.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/ops.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/primitive.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/txEnv.c

ELEMENTS_SIMPLICITY_LIB_HEADERS_INT =
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/bitstream.h
Expand All @@ -42,7 +43,6 @@ ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/frame.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/jets.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/limitations.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/precomputed.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/rsort.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/sha256.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/sha256_x86.inc
Expand Down Expand Up @@ -89,11 +89,12 @@ 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
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveEnumJet.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveEnumTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveInitTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveJetNode.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/decodeElementsJets.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/elementsJets.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/ops.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitive.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveEnumJet.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveEnumTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveInitTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveJetNode.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/txEnv.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef SIMPLICITY_PRIMITIVE_ELEMENTS_CHECKSIGHASHALLTX1_H
#define SIMPLICITY_PRIMITIVE_ELEMENTS_CHECKSIGHASHALLTX1_H
#ifndef SIMPLICITY_ELEMENTS_CHECKSIGHASHALLTX1_H
#define SIMPLICITY_ELEMENTS_CHECKSIGHASHALLTX1_H

#include <stddef.h>
#include <stdint.h>
#include "../../bounded.h"
#include "../bounded.h"

/* A length-prefixed encoding of the following Simplicity program:
* Simplicity.Programs.CheckSig.Lib.checkSigVerify' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash
Expand Down
17 changes: 9 additions & 8 deletions src/simplicity/cmr.c → src/simplicity/elements/cmr.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <simplicity/cmr.h>
#include <simplicity/elements/cmr.h>

#include "deserialize.h"
#include "limitations.h"
#include "simplicity_alloc.h"
#include "simplicity_assert.h"
#include "../deserialize.h"
#include "../limitations.h"
#include "../simplicity_alloc.h"
#include "../simplicity_assert.h"
#include "primitive.h"

/* Deserialize a Simplicity 'program' and compute its CMR.
*
Expand All @@ -18,15 +19,15 @@
* unsigned char cmr[32]
* unsigned char program[program_len]
*/
bool simplicity_computeCmr( simplicity_err* error, unsigned char* cmr
, const unsigned char* program, size_t program_len) {
bool simplicity_elements_computeCmr( simplicity_err* error, unsigned char* cmr
, const unsigned char* program, size_t program_len) {
simplicity_assert(NULL != error);
simplicity_assert(NULL != cmr);
simplicity_assert(NULL != program || 0 == program_len);

bitstream stream = initializeBitstream(program, program_len);
dag_node* dag = NULL;
int_fast32_t dag_len = simplicity_decodeMallocDag(&dag, NULL, &stream);
int_fast32_t dag_len = simplicity_decodeMallocDag(&dag, simplicity_elements_decodeJet, NULL, &stream);
if (dag_len <= 0) {
simplicity_assert(dag_len < 0);
*error = (simplicity_err)dag_len;
Expand Down
Loading