diff --git a/.cirrus.yml b/.cirrus.yml
index e1102be4467..4a4aa87ac81 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -194,10 +194,10 @@ task:
FILE_ENV: "./ci/test/00_setup_env_win64.sh"
task:
- name: '32-bit + dash [gui] [CentOS 8]'
+ name: '32-bit + dash [gui] [Rocky 8]'
<< : *GLOBAL_TASK_TEMPLATE
container:
- image: quay.io/centos/centos:stream8
+ image: quay.io/rockylinux/rockylinux:8
env:
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
PACKAGE_MANAGER_INSTALL: "yum install -y"
@@ -214,10 +214,10 @@ task:
FILE_ENV: "./ci/test/00_setup_env_native_qt5.sh"
task:
- name: '[TSan, depends, gui] [jammy]'
+ name: '[TSan, depends, gui] [2404]'
<< : *GLOBAL_TASK_TEMPLATE
container:
- image: ubuntu:jammy
+ image: ubuntu:24.04
cpu: 6 # Increase CPU and Memory to avoid timeout
memory: 24G
env:
diff --git a/Makefile.am b/Makefile.am
index c76e7dd55e3..59fb949699e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in b/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in
index 39bb696c787..14614ebdfac 100644
--- a/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in
+++ b/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in
@@ -9,22 +9,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -36,6 +54,12 @@
{bb493552-3b8c-4a8c-bf69-a6e7a51d2ea6}
+
+ {18430fef-6b61-4c53-b396-718e02850f1b}
+
+
+ {abae25f0-d700-46e1-9ef6-5d6ddfcf8b26}
+
diff --git a/build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj b/build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj
index 47ba9a75c1e..943934ac402 100644
--- a/build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj
+++ b/build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj
@@ -34,6 +34,11 @@
+
+
+ {abae25f0-d700-46e1-9ef6-5d6ddfcf8b26}
+
+
diff --git a/build_msvc/test_bitcoin/test_bitcoin.vcxproj b/build_msvc/test_bitcoin/test_bitcoin.vcxproj
index 3fa2e16bf1c..e53e057e284 100644
--- a/build_msvc/test_bitcoin/test_bitcoin.vcxproj
+++ b/build_msvc/test_bitcoin/test_bitcoin.vcxproj
@@ -15,7 +15,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ci/test/00_setup_env_i686_centos.sh b/ci/test/00_setup_env_i686_centos.sh
index 8f1cc8af29e..28583c6e63b 100755
--- a/ci/test/00_setup_env_i686_centos.sh
+++ b/ci/test/00_setup_env_i686_centos.sh
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_centos
-export DOCKER_NAME_TAG=quay.io/centos/centos:stream8
+export DOCKER_NAME_TAG=quay.io/rockylinux/rockylinux:8
export DOCKER_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache libtool make git python3 python3-zmq which patch lbzip2 xz procps-ng dash rsync coreutils bison"
export GOAL="install"
export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports"
diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh
index ae942d892b3..0b3505cb0b6 100755
--- a/ci/test/00_setup_env_native_tsan.sh
+++ b/ci/test/00_setup_env_native_tsan.sh
@@ -7,8 +7,8 @@
export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_native_tsan
-export DOCKER_NAME_TAG=ubuntu:22.04
-export PACKAGES="clang-13 llvm-13 libc++abi-13-dev libc++-13-dev python3-zmq"
-export DEP_OPTS="CC=clang-13 CXX='clang++-13 -stdlib=libc++'"
+export DOCKER_NAME_TAG="docker.io/ubuntu:24.04"
+export PACKAGES="clang-18 llvm-18 libclang-rt-18-dev libc++abi-18-dev libc++-18-dev python3-zmq"
+export DEP_OPTS="CC=clang-18 CXX='clang++-18 -stdlib=libc++'"
export GOAL="install"
-export BITCOIN_CONFIG="--enable-zmq CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' CXXFLAGS='-g' --with-sanitizers=thread CC=clang-13 CXX='clang++-13 -stdlib=libc++'"
+export BITCOIN_CONFIG="--enable-zmq CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' CXXFLAGS='-g' --with-sanitizers=thread"
diff --git a/ci/test/04_install.sh b/ci/test/04_install.sh
index eaeecec60ad..1e8ec188408 100755
--- a/ci/test/04_install.sh
+++ b/ci/test/04_install.sh
@@ -64,7 +64,7 @@ if [ -n "$DPKG_ADD_ARCH" ]; then
CI_EXEC dpkg --add-architecture "$DPKG_ADD_ARCH"
fi
-if [[ $DOCKER_NAME_TAG == *centos* ]]; then
+if [[ $DOCKER_NAME_TAG == *centos* ]] || [[ $DOCKER_NAME_TAG == *rocky* ]]; then
${CI_RETRY_EXE} CI_EXEC dnf -y install epel-release
${CI_RETRY_EXE} CI_EXEC dnf -y --allowerasing install "$DOCKER_PACKAGES" "$PACKAGES"
elif [ "$CI_USE_APT_INSTALL" != "no" ]; then
diff --git a/ci/test/05_before_script.sh b/ci/test/05_before_script.sh
index 8f75fbd1faf..b1cb1e300f3 100755
--- a/ci/test/05_before_script.sh
+++ b/ci/test/05_before_script.sh
@@ -44,7 +44,7 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
fi
if [ -z "$NO_DEPENDS" ]; then
- if [[ $DOCKER_NAME_TAG == *centos* ]]; then
+ if [[ $DOCKER_NAME_TAG == *centos* ]] || [[ $DOCKER_NAME_TAG == *rocky* ]]; then
# CentOS has problems building the depends if the config shell is not explicitly set
# (i.e. for libevent a Makefile with an empty SHELL variable is generated, leading to
# an error as the first command is executed)
diff --git a/configure.ac b/configure.ac
index 55e57c58473..7fcc48ddc11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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, 2)
+define(_CLIENT_VERSION_RC, 3)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2024)
define(_COPYRIGHT_HOLDERS,[The %s developers])
diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk
index 563848c3988..938e9971ba8 100644
--- a/depends/packages/boost.mk
+++ b/depends/packages/boost.mk
@@ -1,8 +1,8 @@
package=boost
-$(package)_version=1.77.0
-$(package)_download_path=https://boostorg.jfrog.io/artifactory/main/release/$($(package)_version)/source/
-$(package)_file_name=boost_$(subst .,_,$($(package)_version)).tar.bz2
-$(package)_sha256_hash=fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854
+$(package)_version=1.81.0
+$(package)_download_path=https://archives.boost.io/release/$($(package)_version)/source/
+$(package)_file_name=boost_$(subst .,_,$($(package)_version)).tar.gz
+$(package)_sha256_hash=205666dea9f6a7cfed87c7a6dfbeb52a2c1b9de55712c9c1a87735d7181452b6
define $(package)_stage_cmds
mkdir -p $($(package)_staging_prefix_dir)/include && \
diff --git a/depends/packages/xcb_proto.mk b/depends/packages/xcb_proto.mk
index 9be822506db..6e1c5a10a87 100644
--- a/depends/packages/xcb_proto.mk
+++ b/depends/packages/xcb_proto.mk
@@ -1,8 +1,8 @@
package=xcb_proto
-$(package)_version=1.14.1
+$(package)_version=1.15.2
$(package)_download_path=https://xorg.freedesktop.org/archive/individual/proto
$(package)_file_name=xcb-proto-$($(package)_version).tar.xz
-$(package)_sha256_hash=f04add9a972ac334ea11d9d7eb4fc7f8883835da3e4859c9afa971efdf57fcc3
+$(package)_sha256_hash=7072beb1f680a2fe3f9e535b797c146d22528990c72f63ddb49d2f350a3653ed
define $(package)_config_cmds
$($(package)_autoconf)
diff --git a/doc/man/elements-cli.1 b/doc/man/elements-cli.1
index c2b9dcb9a55..cf491caf5eb 100644
--- a/doc/man/elements-cli.1
+++ b/doc/man/elements-cli.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
-.TH ELEMENTS-CLI "1" "November 2024" "elements-cli v23.3.0" "User Commands"
+.TH ELEMENTS-CLI "1" "February 2025" "elements-cli v23.3.0" "User Commands"
.SH NAME
elements-cli \- manual page for elements-cli v23.3.0
.SH SYNOPSIS
diff --git a/doc/man/elements-qt.1 b/doc/man/elements-qt.1
index e600a8a02e1..3c82275a009 100644
--- a/doc/man/elements-qt.1
+++ b/doc/man/elements-qt.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
-.TH ELEMENTS-QT "1" "November 2024" "elements-qt v23.3.0" "User Commands"
+.TH ELEMENTS-QT "1" "February 2025" "elements-qt v23.3.0" "User Commands"
.SH NAME
elements-qt \- manual page for elements-qt v23.3.0
.SH SYNOPSIS
@@ -637,7 +637,8 @@ Chain selection options:
.HP
\fB\-acceptdiscountct\fR
.IP
-Accept discounted fees for Confidential Transactions (default: false)
+Accept discounted fees for Confidential Transactions (default: true in
+liquidtestnet and liquidv1, false otherwise)
.HP
\fB\-bech32_hrp\fR
.IP
diff --git a/doc/man/elements-tx.1 b/doc/man/elements-tx.1
index 798bf385ef3..344c25200c6 100644
--- a/doc/man/elements-tx.1
+++ b/doc/man/elements-tx.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
-.TH ELEMENTS-TX "1" "November 2024" "elements-tx v23.3.0" "User Commands"
+.TH ELEMENTS-TX "1" "February 2025" "elements-tx v23.3.0" "User Commands"
.SH NAME
elements-tx \- manual page for elements-tx v23.3.0
.SH SYNOPSIS
diff --git a/doc/man/elements-util.1 b/doc/man/elements-util.1
index 54e8ab0ff38..593b63d5b08 100644
--- a/doc/man/elements-util.1
+++ b/doc/man/elements-util.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
-.TH ELEMENTS-UTIL "1" "November 2024" "elements-util v23.3.0" "User Commands"
+.TH ELEMENTS-UTIL "1" "February 2025" "elements-util v23.3.0" "User Commands"
.SH NAME
elements-util \- manual page for elements-util v23.3.0
.SH SYNOPSIS
diff --git a/doc/man/elements-wallet.1 b/doc/man/elements-wallet.1
index aa41b2af59b..c585bc4c777 100644
--- a/doc/man/elements-wallet.1
+++ b/doc/man/elements-wallet.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
-.TH ELEMENTS-WALLET "1" "November 2024" "elements-wallet v23.3.0" "User Commands"
+.TH ELEMENTS-WALLET "1" "February 2025" "elements-wallet v23.3.0" "User Commands"
.SH NAME
elements-wallet \- manual page for elements-wallet v23.3.0
.SH DESCRIPTION
diff --git a/doc/man/elementsd.1 b/doc/man/elementsd.1
index 0fec023408b..9513bc4a2b4 100644
--- a/doc/man/elementsd.1
+++ b/doc/man/elementsd.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
-.TH ELEMENTSD "1" "November 2024" "elementsd v23.3.0" "User Commands"
+.TH ELEMENTSD "1" "February 2025" "elementsd v23.3.0" "User Commands"
.SH NAME
elementsd \- manual page for elementsd v23.3.0
.SH SYNOPSIS
@@ -637,7 +637,8 @@ Chain selection options:
.HP
\fB\-acceptdiscountct\fR
.IP
-Accept discounted fees for Confidential Transactions (default: false)
+Accept discounted fees for Confidential Transactions (default: true in
+liquidtestnet and liquidv1, false otherwise)
.HP
\fB\-bech32_hrp\fR
.IP
diff --git a/src/Makefile.elementssimplicity.include b/src/Makefile.elementssimplicity.include
index 2a6c06fc49f..f1e54219576 100644
--- a/src/Makefile.elementssimplicity.include
+++ b/src/Makefile.elementssimplicity.include
@@ -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)
diff --git a/src/mapport.cpp b/src/mapport.cpp
index 42ca3660893..af983a2c5b8 100644
--- a/src/mapport.cpp
+++ b/src/mapport.cpp
@@ -168,8 +168,11 @@ static bool ProcessUpnp()
struct UPNPUrls urls;
struct IGDdatas data;
int r;
-
+#if MINIUPNPC_API_VERSION <= 17
r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
+#else
+ r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), nullptr, 0);
+#endif
if (r == 1)
{
if (fDiscover) {
diff --git a/src/primitives/confidential.h b/src/primitives/confidential.h
index a85703cca04..12d72f52c77 100644
--- a/src/primitives/confidential.h
+++ b/src/primitives/confidential.h
@@ -135,6 +135,11 @@ class CConfidentialValue : public CConfidentialCommitment<9, 8, 9>
CConfidentialValue() { SetNull(); }
CConfidentialValue(CAmount nAmount) { SetToAmount(nAmount); }
+ template
+ inline void Unserialize(Stream& s) {
+ CConfidentialCommitment::Unserialize(s);
+ }
+
/* An explicit value is called an amount. The first byte indicates it is
* an explicit value, and the remaining 8 bytes is the value serialized as
* a 64-bit big-endian integer. */
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h
index 6b7ecaf69ff..00f509454bb 100644
--- a/src/primitives/transaction.h
+++ b/src/primitives/transaction.h
@@ -295,6 +295,9 @@ class CTxOut
s >> nAsset;
s >> nValue;
s >> nNonce;
+ if (nAsset.IsNull() || nValue.IsNull()) {
+ throw std::ios_base::failure("Confidential values may not be null");
+ }
} else {
CAmount value;
s >> value;
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 5945356439b..de5a3c499a2 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -2660,7 +2660,8 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector&& 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::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::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);
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 4881b74651b..e317a3aad52 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -222,7 +222,7 @@ struct PrecomputedTransactionData
template
explicit PrecomputedTransactionData(const T& tx);
~PrecomputedTransactionData() {
- free(m_simplicity_tx_data);
+ simplicity_elements_freeTransaction(m_simplicity_tx_data);
}
};
diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp
index b7be7b2139c..a50888dd8f9 100644
--- a/src/script/script_error.cpp
+++ b/src/script/script_error.cpp
@@ -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:
diff --git a/src/script/script_error.h b/src/script/script_error.h
index db137937f21..8fac6496d08 100644
--- a/src/script/script_error.h
+++ b/src/script/script_error.h
@@ -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,
diff --git a/src/simplicity/ctx8Pruned.c b/src/simplicity/ctx8Pruned.c
index cc8488ec128..c3963816719 100644
--- a/src/simplicity/ctx8Pruned.c
+++ b/src/simplicity/ctx8Pruned.c
@@ -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
};
diff --git a/src/simplicity/ctx8Pruned.h b/src/simplicity/ctx8Pruned.h
index 7b66bdbecab..26d107b28da 100644
--- a/src/simplicity/ctx8Pruned.h
+++ b/src/simplicity/ctx8Pruned.h
@@ -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[];
diff --git a/src/simplicity/ctx8Unpruned.c b/src/simplicity/ctx8Unpruned.c
index b92bc2e4d7c..e9c4a9bb89d 100644
--- a/src/simplicity/ctx8Unpruned.c
+++ b/src/simplicity/ctx8Unpruned.c
@@ -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
};
diff --git a/src/simplicity/ctx8Unpruned.h b/src/simplicity/ctx8Unpruned.h
index 8024e33c2bd..5af8deab762 100644
--- a/src/simplicity/ctx8Unpruned.h
+++ b/src/simplicity/ctx8Unpruned.h
@@ -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[];
diff --git a/src/simplicity/dag.c b/src/simplicity/dag.c
index 0b604a2a370..bfcf561b024 100644
--- a/src/simplicity/dag.c
+++ b/src/simplicity/dag.c
@@ -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;
diff --git a/src/simplicity/dag.h b/src/simplicity/dag.h
index f2f9cd27017..afe0d44eb74 100644
--- a/src/simplicity/dag.h
+++ b/src/simplicity/dag.h
@@ -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
diff --git a/src/simplicity/decodeCoreJets.inc b/src/simplicity/decodeCoreJets.inc
new file mode 100644
index 00000000000..a38932e81b1
--- /dev/null
+++ b/src/simplicity/decodeCoreJets.inc
@@ -0,0 +1,1037 @@
+/* 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 = VERIFY; return SIMPLICITY_NO_ERROR;
+ case 2:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LOW_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LOW_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LOW_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LOW_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LOW_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = HIGH_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = HIGH_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = HIGH_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = HIGH_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = HIGH_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = COMPLEMENT_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = COMPLEMENT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = COMPLEMENT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = COMPLEMENT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = COMPLEMENT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = AND_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = AND_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = AND_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = AND_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = AND_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = OR_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = OR_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = OR_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = OR_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = OR_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 7:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = XOR_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = XOR_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = XOR_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = XOR_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = XOR_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 8:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = MAJ_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = MAJ_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = MAJ_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = MAJ_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = MAJ_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 9:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = XOR_XOR_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = XOR_XOR_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = XOR_XOR_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = XOR_XOR_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = XOR_XOR_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 10:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = CH_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = CH_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = CH_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = CH_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = CH_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 11:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = SOME_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = SOME_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = SOME_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = SOME_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = SOME_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 12:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = ALL_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = ALL_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = ALL_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = ALL_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 13:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = EQ_1; return SIMPLICITY_NO_ERROR;
+ case 3: *result = EQ_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = EQ_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = EQ_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = EQ_64; return SIMPLICITY_NO_ERROR;
+ case 8: *result = EQ_256; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 14:
+ 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 3: *result = FULL_LEFT_SHIFT_8_1; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_LEFT_SHIFT_16_1; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_LEFT_SHIFT_32_1; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_LEFT_SHIFT_64_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 2:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 2: *result = FULL_LEFT_SHIFT_8_2; return SIMPLICITY_NO_ERROR;
+ case 3: *result = FULL_LEFT_SHIFT_16_2; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_LEFT_SHIFT_32_2; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_LEFT_SHIFT_64_2; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_LEFT_SHIFT_8_4; return SIMPLICITY_NO_ERROR;
+ case 2: *result = FULL_LEFT_SHIFT_16_4; return SIMPLICITY_NO_ERROR;
+ case 3: *result = FULL_LEFT_SHIFT_32_4; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_LEFT_SHIFT_64_4; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_LEFT_SHIFT_16_8; return SIMPLICITY_NO_ERROR;
+ case 2: *result = FULL_LEFT_SHIFT_32_8; return SIMPLICITY_NO_ERROR;
+ case 3: *result = FULL_LEFT_SHIFT_64_8; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_LEFT_SHIFT_32_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = FULL_LEFT_SHIFT_64_16; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_LEFT_SHIFT_64_32; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 15:
+ 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 3: *result = FULL_RIGHT_SHIFT_8_1; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_RIGHT_SHIFT_16_1; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_RIGHT_SHIFT_32_1; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_RIGHT_SHIFT_64_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 2:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 2: *result = FULL_RIGHT_SHIFT_8_2; return SIMPLICITY_NO_ERROR;
+ case 3: *result = FULL_RIGHT_SHIFT_16_2; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_RIGHT_SHIFT_32_2; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_RIGHT_SHIFT_64_2; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_RIGHT_SHIFT_8_4; return SIMPLICITY_NO_ERROR;
+ case 2: *result = FULL_RIGHT_SHIFT_16_4; return SIMPLICITY_NO_ERROR;
+ case 3: *result = FULL_RIGHT_SHIFT_32_4; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_RIGHT_SHIFT_64_4; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_RIGHT_SHIFT_16_8; return SIMPLICITY_NO_ERROR;
+ case 2: *result = FULL_RIGHT_SHIFT_32_8; return SIMPLICITY_NO_ERROR;
+ case 3: *result = FULL_RIGHT_SHIFT_64_8; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_RIGHT_SHIFT_32_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = FULL_RIGHT_SHIFT_64_16; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = FULL_RIGHT_SHIFT_64_32; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 16:
+ 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 3: *result = LEFTMOST_8_1; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFTMOST_16_1; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFTMOST_32_1; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFTMOST_64_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 2:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 2: *result = LEFTMOST_8_2; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LEFTMOST_16_2; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFTMOST_32_2; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFTMOST_64_2; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFTMOST_8_4; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFTMOST_16_4; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LEFTMOST_32_4; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFTMOST_64_4; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFTMOST_16_8; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFTMOST_32_8; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LEFTMOST_64_8; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFTMOST_32_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFTMOST_64_16; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFTMOST_64_32; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 17:
+ 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 3: *result = RIGHTMOST_8_1; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHTMOST_16_1; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHTMOST_32_1; return SIMPLICITY_NO_ERROR;
+ case 6: *result = RIGHTMOST_64_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 2:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 2: *result = RIGHTMOST_8_2; return SIMPLICITY_NO_ERROR;
+ case 3: *result = RIGHTMOST_16_2; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHTMOST_32_2; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHTMOST_64_2; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHTMOST_8_4; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHTMOST_16_4; return SIMPLICITY_NO_ERROR;
+ case 3: *result = RIGHTMOST_32_4; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHTMOST_64_4; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHTMOST_16_8; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHTMOST_32_8; return SIMPLICITY_NO_ERROR;
+ case 3: *result = RIGHTMOST_64_8; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHTMOST_32_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHTMOST_64_16; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHTMOST_64_32; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 18:
+ 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 3: *result = LEFT_PAD_LOW_1_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFT_PAD_LOW_1_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFT_PAD_LOW_1_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFT_PAD_LOW_1_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_PAD_LOW_8_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFT_PAD_LOW_8_32; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LEFT_PAD_LOW_8_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_PAD_LOW_16_32; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFT_PAD_LOW_16_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_PAD_LOW_32_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 19:
+ 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 3: *result = LEFT_PAD_HIGH_1_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFT_PAD_HIGH_1_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFT_PAD_HIGH_1_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFT_PAD_HIGH_1_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_PAD_HIGH_8_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFT_PAD_HIGH_8_32; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LEFT_PAD_HIGH_8_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_PAD_HIGH_16_32; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFT_PAD_HIGH_16_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_PAD_HIGH_32_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 20:
+ 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 3: *result = LEFT_EXTEND_1_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFT_EXTEND_1_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFT_EXTEND_1_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFT_EXTEND_1_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_EXTEND_8_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFT_EXTEND_8_32; return SIMPLICITY_NO_ERROR;
+ case 3: *result = LEFT_EXTEND_8_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_EXTEND_16_32; return SIMPLICITY_NO_ERROR;
+ case 2: *result = LEFT_EXTEND_16_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LEFT_EXTEND_32_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 21:
+ 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 3: *result = RIGHT_PAD_LOW_1_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHT_PAD_LOW_1_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHT_PAD_LOW_1_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = RIGHT_PAD_LOW_1_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_PAD_LOW_8_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHT_PAD_LOW_8_32; return SIMPLICITY_NO_ERROR;
+ case 3: *result = RIGHT_PAD_LOW_8_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_PAD_LOW_16_32; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHT_PAD_LOW_16_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_PAD_LOW_32_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 22:
+ 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 3: *result = RIGHT_PAD_HIGH_1_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHT_PAD_HIGH_1_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHT_PAD_HIGH_1_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = RIGHT_PAD_HIGH_1_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_PAD_HIGH_8_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHT_PAD_HIGH_8_32; return SIMPLICITY_NO_ERROR;
+ case 3: *result = RIGHT_PAD_HIGH_8_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_PAD_HIGH_16_32; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHT_PAD_HIGH_16_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_PAD_HIGH_32_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 23:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_EXTEND_8_16; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHT_EXTEND_8_32; return SIMPLICITY_NO_ERROR;
+ case 3: *result = RIGHT_EXTEND_8_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_EXTEND_16_32; return SIMPLICITY_NO_ERROR;
+ case 2: *result = RIGHT_EXTEND_16_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 6:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = RIGHT_EXTEND_32_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 24:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = LEFT_SHIFT_WITH_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFT_SHIFT_WITH_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFT_SHIFT_WITH_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFT_SHIFT_WITH_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 25:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = RIGHT_SHIFT_WITH_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHT_SHIFT_WITH_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHT_SHIFT_WITH_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = RIGHT_SHIFT_WITH_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 26:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = LEFT_SHIFT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFT_SHIFT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFT_SHIFT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFT_SHIFT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 27:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = RIGHT_SHIFT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHT_SHIFT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHT_SHIFT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = RIGHT_SHIFT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 28:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = LEFT_ROTATE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LEFT_ROTATE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LEFT_ROTATE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LEFT_ROTATE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 29:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = RIGHT_ROTATE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = RIGHT_ROTATE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = RIGHT_ROTATE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = RIGHT_ROTATE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 2:
+ 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 3: *result = ONE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = ONE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = ONE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = ONE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 2:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = FULL_ADD_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_ADD_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_ADD_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_ADD_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = ADD_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = ADD_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = ADD_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = ADD_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = FULL_INCREMENT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_INCREMENT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_INCREMENT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_INCREMENT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = INCREMENT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = INCREMENT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = INCREMENT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = INCREMENT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 7:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = FULL_SUBTRACT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_SUBTRACT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_SUBTRACT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_SUBTRACT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 8:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = SUBTRACT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = SUBTRACT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = SUBTRACT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = SUBTRACT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 9:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = NEGATE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = NEGATE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = NEGATE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = NEGATE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 10:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = FULL_DECREMENT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_DECREMENT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_DECREMENT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_DECREMENT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 11:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = DECREMENT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = DECREMENT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = DECREMENT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = DECREMENT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 12:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = FULL_MULTIPLY_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = FULL_MULTIPLY_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = FULL_MULTIPLY_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = FULL_MULTIPLY_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 13:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = MULTIPLY_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = MULTIPLY_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = MULTIPLY_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = MULTIPLY_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 14:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = IS_ZERO_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = IS_ZERO_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = IS_ZERO_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = IS_ZERO_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 15:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = IS_ONE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = IS_ONE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = IS_ONE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = IS_ONE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 16:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = LE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 17:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = LT_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = LT_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = LT_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = LT_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 18:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = MIN_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = MIN_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = MIN_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = MIN_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 19:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = MAX_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = MAX_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = MAX_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = MAX_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 20:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = MEDIAN_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = MEDIAN_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = MEDIAN_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = MEDIAN_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 21:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 6: *result = DIV_MOD_128_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 22:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = DIV_MOD_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = DIV_MOD_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = DIV_MOD_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = DIV_MOD_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 23:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = DIVIDE_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = DIVIDE_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = DIVIDE_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = DIVIDE_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 24:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = MODULO_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = MODULO_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = MODULO_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = MODULO_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 25:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 3: *result = DIVIDES_8; return SIMPLICITY_NO_ERROR;
+ case 4: *result = DIVIDES_16; return SIMPLICITY_NO_ERROR;
+ case 5: *result = DIVIDES_32; return SIMPLICITY_NO_ERROR;
+ case 6: *result = DIVIDES_64; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 3:
+ 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 = SHA_256_BLOCK; return SIMPLICITY_NO_ERROR;
+ case 2: *result = SHA_256_IV; return SIMPLICITY_NO_ERROR;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = SHA_256_CTX_8_ADD_1; return SIMPLICITY_NO_ERROR;
+ case 2: *result = SHA_256_CTX_8_ADD_2; return SIMPLICITY_NO_ERROR;
+ case 3: *result = SHA_256_CTX_8_ADD_4; return SIMPLICITY_NO_ERROR;
+ case 4: *result = SHA_256_CTX_8_ADD_8; return SIMPLICITY_NO_ERROR;
+ case 5: *result = SHA_256_CTX_8_ADD_16; return SIMPLICITY_NO_ERROR;
+ case 6: *result = SHA_256_CTX_8_ADD_32; return SIMPLICITY_NO_ERROR;
+ case 7: *result = SHA_256_CTX_8_ADD_64; return SIMPLICITY_NO_ERROR;
+ case 8: *result = SHA_256_CTX_8_ADD_128; return SIMPLICITY_NO_ERROR;
+ case 9: *result = SHA_256_CTX_8_ADD_256; return SIMPLICITY_NO_ERROR;
+ case 10: *result = SHA_256_CTX_8_ADD_512; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4: *result = SHA_256_CTX_8_ADD_BUFFER_511; return SIMPLICITY_NO_ERROR;
+ case 5: *result = SHA_256_CTX_8_FINALIZE; return SIMPLICITY_NO_ERROR;
+ case 6: *result = SHA_256_CTX_8_INIT; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+ break;
+ case 4:
+ 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 = POINT_VERIFY_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 2: *result = DECOMPRESS; return SIMPLICITY_NO_ERROR;
+ case 3:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LINEAR_VERIFY_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 4:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = LINEAR_COMBINATION_1; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5: *result = SCALE; return SIMPLICITY_NO_ERROR;
+ case 6: *result = GENERATE; return SIMPLICITY_NO_ERROR;
+ case 7: *result = GEJ_INFINITY; return SIMPLICITY_NO_ERROR;
+ case 8: *result = GEJ_NORMALIZE; return SIMPLICITY_NO_ERROR;
+ case 9: *result = GEJ_NEGATE; return SIMPLICITY_NO_ERROR;
+ case 10: *result = GE_NEGATE; return SIMPLICITY_NO_ERROR;
+ case 11: *result = GEJ_DOUBLE; return SIMPLICITY_NO_ERROR;
+ case 12: *result = GEJ_ADD; return SIMPLICITY_NO_ERROR;
+ case 13: *result = GEJ_GE_ADD_EX; return SIMPLICITY_NO_ERROR;
+ case 14: *result = GEJ_GE_ADD; return SIMPLICITY_NO_ERROR;
+ case 15: *result = GEJ_RESCALE; return SIMPLICITY_NO_ERROR;
+ case 16: *result = GEJ_IS_INFINITY; return SIMPLICITY_NO_ERROR;
+ case 17: *result = GEJ_EQUIV; return SIMPLICITY_NO_ERROR;
+ case 18: *result = GEJ_GE_EQUIV; return SIMPLICITY_NO_ERROR;
+ case 19: *result = GEJ_X_EQUIV; return SIMPLICITY_NO_ERROR;
+ case 20: *result = GEJ_Y_IS_ODD; return SIMPLICITY_NO_ERROR;
+ case 21: *result = GEJ_IS_ON_CURVE; return SIMPLICITY_NO_ERROR;
+ case 22: *result = GE_IS_ON_CURVE; return SIMPLICITY_NO_ERROR;
+ case 23: *result = SCALAR_NORMALIZE; return SIMPLICITY_NO_ERROR;
+ case 24: *result = SCALAR_NEGATE; return SIMPLICITY_NO_ERROR;
+ case 25: *result = SCALAR_ADD; return SIMPLICITY_NO_ERROR;
+ case 26: *result = SCALAR_SQUARE; return SIMPLICITY_NO_ERROR;
+ case 27: *result = SCALAR_MULTIPLY; return SIMPLICITY_NO_ERROR;
+ case 28: *result = SCALAR_MULTIPLY_LAMBDA; return SIMPLICITY_NO_ERROR;
+ case 29: *result = SCALAR_INVERT; return SIMPLICITY_NO_ERROR;
+ case 30: *result = SCALAR_IS_ZERO; return SIMPLICITY_NO_ERROR;
+ case 35: *result = FE_NORMALIZE; return SIMPLICITY_NO_ERROR;
+ case 36: *result = FE_NEGATE; return SIMPLICITY_NO_ERROR;
+ case 37: *result = FE_ADD; return SIMPLICITY_NO_ERROR;
+ case 38: *result = FE_SQUARE; return SIMPLICITY_NO_ERROR;
+ case 39: *result = FE_MULTIPLY; return SIMPLICITY_NO_ERROR;
+ case 40: *result = FE_MULTIPLY_BETA; return SIMPLICITY_NO_ERROR;
+ case 41: *result = FE_INVERT; return SIMPLICITY_NO_ERROR;
+ case 42: *result = FE_SQUARE_ROOT; return SIMPLICITY_NO_ERROR;
+ case 43: *result = FE_IS_ZERO; return SIMPLICITY_NO_ERROR;
+ case 44: *result = FE_IS_ODD; return SIMPLICITY_NO_ERROR;
+ case 46: *result = HASH_TO_CURVE; return SIMPLICITY_NO_ERROR;
+ case 47: *result = SWU; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 5:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = CHECK_SIG_VERIFY; return SIMPLICITY_NO_ERROR;
+ case 2: *result = BIP_0340_VERIFY; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ case 7:
+ code = simplicity_decodeUptoMaxInt(stream);
+ if (code < 0) return (simplicity_err)code;
+ switch (code) {
+ case 1: *result = PARSE_LOCK; return SIMPLICITY_NO_ERROR;
+ case 2: *result = PARSE_SEQUENCE; return SIMPLICITY_NO_ERROR;
+ case 3: *result = TAPDATA_INIT; return SIMPLICITY_NO_ERROR;
+ }
+ break;
+ }
+}
\ No newline at end of file
diff --git a/src/simplicity/deserialize.c b/src/simplicity/deserialize.c
index 699fc4a2330..d65c0d5c5cf 100644
--- a/src/simplicity/deserialize.c
+++ b/src/simplicity/deserialize.c
@@ -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.
diff --git a/src/simplicity/deserialize.h b/src/simplicity/deserialize.h
index d0ebfb543ed..d20561b011c 100644
--- a/src/simplicity/deserialize.h
+++ b/src/simplicity/deserialize.h
@@ -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.
diff --git a/src/simplicity/elements-sources.mk b/src/simplicity/elements-sources.mk
index 9c06c87a794..189a04983af 100644
--- a/src/simplicity/elements-sources.mk
+++ b/src/simplicity/elements-sources.mk
@@ -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
diff --git a/src/simplicity/hashBlock.c b/src/simplicity/hashBlock.c
index aea64c51b0c..0839a5d1098 100644
--- a/src/simplicity/hashBlock.c
+++ b/src/simplicity/hashBlock.c
@@ -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
};
diff --git a/src/simplicity/hashBlock.h b/src/simplicity/hashBlock.h
index c2f7ec62fe9..e4f7d57961d 100644
--- a/src/simplicity/hashBlock.h
+++ b/src/simplicity/hashBlock.h
@@ -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[];
diff --git a/src/simplicity/include/simplicity/elements/env.h b/src/simplicity/include/simplicity/elements/env.h
index 9d070c2310a..e5c683f9f2c 100644
--- a/src/simplicity/include/simplicity/elements/env.h
+++ b/src/simplicity/include/simplicity/elements/env.h
@@ -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
diff --git a/src/simplicity/include/simplicity/elements/exec.h b/src/simplicity/include/simplicity/elements/exec.h
index f083642f76e..758df913a16 100644
--- a/src/simplicity/include/simplicity/elements/exec.h
+++ b/src/simplicity/include/simplicity/elements/exec.h
@@ -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
diff --git a/src/simplicity/include/simplicity/errorCodes.h b/src/simplicity/include/simplicity/errorCodes.h
index 8c1548e0e48..00ffee51c07 100644
--- a/src/simplicity/include/simplicity/errorCodes.h
+++ b/src/simplicity/include/simplicity/errorCodes.h
@@ -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:
diff --git a/src/simplicity/primitive/elements/checkSigHashAllTx1.c b/src/simplicity/primitive/elements/checkSigHashAllTx1.c
index b32ef07b304..c22d6c861c2 100644
--- a/src/simplicity/primitive/elements/checkSigHashAllTx1.c
+++ b/src/simplicity/primitive/elements/checkSigHashAllTx1.c
@@ -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
};
diff --git a/src/simplicity/primitive/elements/checkSigHashAllTx1.h b/src/simplicity/primitive/elements/checkSigHashAllTx1.h
index 75dd1eaa5c8..b2bb7c5d9d0 100644
--- a/src/simplicity/primitive/elements/checkSigHashAllTx1.h
+++ b/src/simplicity/primitive/elements/checkSigHashAllTx1.h
@@ -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[];
diff --git a/src/simplicity/primitive/elements/decodeElementsJets.inc b/src/simplicity/primitive/elements/decodeElementsJets.inc
new file mode 100644
index 00000000000..b2478e45aef
--- /dev/null
+++ b/src/simplicity/primitive/elements/decodeElementsJets.inc
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/simplicity/primitive/elements/env.c b/src/simplicity/primitive/elements/env.c
index 3c7adee2543..e9f03ac6fd1 100644
--- a/src/simplicity/primitive/elements/env.c
+++ b/src/simplicity/primitive/elements/env.c
@@ -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.
*
diff --git a/src/simplicity/primitive/elements/exec.c b/src/simplicity/primitive/elements/exec.c
index aaffd505656..e38c9ca41a5 100644
--- a/src/simplicity/primitive/elements/exec.c
+++ b/src/simplicity/primitive/elements/exec.c
@@ -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.");
diff --git a/src/simplicity/primitive/elements/primitive.c b/src/simplicity/primitive/elements/primitive.c
index f14c2319676..da08b920940 100644
--- a/src/simplicity/primitive/elements/primitive.c
+++ b/src/simplicity/primitive/elements/primitive.c
@@ -71,1104 +71,11 @@ static simplicity_err decodePrimitive(jetName* result, bitstream* stream) {
if (bit < 0) return (simplicity_err)bit;
if (!bit) {
/* Core jets */
- int32_t code = simplicity_decodeUptoMaxInt(stream);
- int32_t code2;
- if (code < 0) return (simplicity_err)code;
-
- switch (code) {
- case 1: /* Word jets chapter */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: /* Verify */
- *result = VERIFY; return SIMPLICITY_NO_ERROR;
- case 2: /* Low */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = LOW_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = LOW_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LOW_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LOW_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LOW_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 3: /* High */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = HIGH_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = HIGH_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = HIGH_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = HIGH_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = HIGH_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4: /* Complement */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = COMPLEMENT_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = COMPLEMENT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = COMPLEMENT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = COMPLEMENT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = COMPLEMENT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5: /* And */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = AND_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = AND_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = AND_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = AND_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = AND_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6: /* Or */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = OR_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = OR_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = OR_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = OR_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = OR_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 7: /* Xor */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = XOR_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = XOR_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = XOR_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = XOR_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = XOR_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 8: /* Maj */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = MAJ_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = MAJ_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = MAJ_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = MAJ_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = MAJ_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 9: /* Xor_Xor */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = XOR_XOR_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = XOR_XOR_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = XOR_XOR_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = XOR_XOR_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = XOR_XOR_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 10: /* Ch */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = CH_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = CH_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = CH_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = CH_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = CH_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 11: /* Some */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = SOME_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = SOME_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = SOME_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = SOME_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = SOME_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 12: /* All */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = ALL_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = ALL_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = ALL_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = ALL_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 13: /* Eq */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = EQ_1; return SIMPLICITY_NO_ERROR;
- case 3: *result = EQ_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = EQ_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = EQ_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = EQ_64; return SIMPLICITY_NO_ERROR;
- case 8: *result = EQ_256; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 14: /* FullLeftShift */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = FULL_LEFT_SHIFT_8_1; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_LEFT_SHIFT_16_1; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_LEFT_SHIFT_32_1; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_LEFT_SHIFT_64_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 2:
- switch (code2) {
- case 2: *result = FULL_LEFT_SHIFT_8_2; return SIMPLICITY_NO_ERROR;
- case 3: *result = FULL_LEFT_SHIFT_16_2; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_LEFT_SHIFT_32_2; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_LEFT_SHIFT_64_2; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 3:
- switch (code2) {
- case 1: *result = FULL_LEFT_SHIFT_8_4; return SIMPLICITY_NO_ERROR;
- case 2: *result = FULL_LEFT_SHIFT_16_4; return SIMPLICITY_NO_ERROR;
- case 3: *result = FULL_LEFT_SHIFT_32_4; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_LEFT_SHIFT_64_4; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = FULL_LEFT_SHIFT_16_8; return SIMPLICITY_NO_ERROR;
- case 2: *result = FULL_LEFT_SHIFT_32_8; return SIMPLICITY_NO_ERROR;
- case 3: *result = FULL_LEFT_SHIFT_64_8; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = FULL_LEFT_SHIFT_32_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = FULL_LEFT_SHIFT_64_16; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = FULL_LEFT_SHIFT_64_32; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 15: /* FullRightShift */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = FULL_RIGHT_SHIFT_8_1; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_RIGHT_SHIFT_16_1; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_RIGHT_SHIFT_32_1; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_RIGHT_SHIFT_64_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 2:
- switch (code2) {
- case 2: *result = FULL_RIGHT_SHIFT_8_2; return SIMPLICITY_NO_ERROR;
- case 3: *result = FULL_RIGHT_SHIFT_16_2; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_RIGHT_SHIFT_32_2; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_RIGHT_SHIFT_64_2; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 3:
- switch (code2) {
- case 1: *result = FULL_RIGHT_SHIFT_8_4; return SIMPLICITY_NO_ERROR;
- case 2: *result = FULL_RIGHT_SHIFT_16_4; return SIMPLICITY_NO_ERROR;
- case 3: *result = FULL_RIGHT_SHIFT_32_4; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_RIGHT_SHIFT_64_4; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = FULL_RIGHT_SHIFT_16_8; return SIMPLICITY_NO_ERROR;
- case 2: *result = FULL_RIGHT_SHIFT_32_8; return SIMPLICITY_NO_ERROR;
- case 3: *result = FULL_RIGHT_SHIFT_64_8; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = FULL_RIGHT_SHIFT_32_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = FULL_RIGHT_SHIFT_64_16; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = FULL_RIGHT_SHIFT_64_32; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 16: /* Leftmost */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = LEFTMOST_8_1; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFTMOST_16_1; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFTMOST_32_1; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFTMOST_64_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 2:
- switch (code2) {
- case 2: *result = LEFTMOST_8_2; return SIMPLICITY_NO_ERROR;
- case 3: *result = LEFTMOST_16_2; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFTMOST_32_2; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFTMOST_64_2; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 3:
- switch (code2) {
- case 1: *result = LEFTMOST_8_4; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFTMOST_16_4; return SIMPLICITY_NO_ERROR;
- case 3: *result = LEFTMOST_32_4; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFTMOST_64_4; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = LEFTMOST_16_8; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFTMOST_32_8; return SIMPLICITY_NO_ERROR;
- case 3: *result = LEFTMOST_64_8; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = LEFTMOST_32_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFTMOST_64_16; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = LEFTMOST_64_32; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 17: /* Rightmost */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = RIGHTMOST_8_1; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHTMOST_16_1; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHTMOST_32_1; return SIMPLICITY_NO_ERROR;
- case 6: *result = RIGHTMOST_64_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 2:
- switch (code2) {
- case 2: *result = RIGHTMOST_8_2; return SIMPLICITY_NO_ERROR;
- case 3: *result = RIGHTMOST_16_2; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHTMOST_32_2; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHTMOST_64_2; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 3:
- switch (code2) {
- case 1: *result = RIGHTMOST_8_4; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHTMOST_16_4; return SIMPLICITY_NO_ERROR;
- case 3: *result = RIGHTMOST_32_4; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHTMOST_64_4; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = RIGHTMOST_16_8; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHTMOST_32_8; return SIMPLICITY_NO_ERROR;
- case 3: *result = RIGHTMOST_64_8; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = RIGHTMOST_32_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHTMOST_64_16; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = RIGHTMOST_64_32; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 18: /* LeftPadLow */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = LEFT_PAD_LOW_1_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFT_PAD_LOW_1_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFT_PAD_LOW_1_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFT_PAD_LOW_1_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = LEFT_PAD_LOW_8_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFT_PAD_LOW_8_32; return SIMPLICITY_NO_ERROR;
- case 3: *result = LEFT_PAD_LOW_8_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = LEFT_PAD_LOW_16_32; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFT_PAD_LOW_16_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = LEFT_PAD_LOW_32_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 19: /* LeftPadHigh */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = LEFT_PAD_HIGH_1_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFT_PAD_HIGH_1_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFT_PAD_HIGH_1_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFT_PAD_HIGH_1_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = LEFT_PAD_HIGH_8_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFT_PAD_HIGH_8_32; return SIMPLICITY_NO_ERROR;
- case 3: *result = LEFT_PAD_HIGH_8_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = LEFT_PAD_HIGH_16_32; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFT_PAD_HIGH_16_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = LEFT_PAD_HIGH_32_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 20: /* LeftExtend */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = LEFT_EXTEND_1_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFT_EXTEND_1_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFT_EXTEND_1_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFT_EXTEND_1_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = LEFT_EXTEND_8_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFT_EXTEND_8_32; return SIMPLICITY_NO_ERROR;
- case 3: *result = LEFT_EXTEND_8_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = LEFT_EXTEND_16_32; return SIMPLICITY_NO_ERROR;
- case 2: *result = LEFT_EXTEND_16_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = LEFT_EXTEND_32_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 21: /* RightPadLow */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = RIGHT_PAD_LOW_1_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHT_PAD_LOW_1_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHT_PAD_LOW_1_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = RIGHT_PAD_LOW_1_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = RIGHT_PAD_LOW_8_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHT_PAD_LOW_8_32; return SIMPLICITY_NO_ERROR;
- case 3: *result = RIGHT_PAD_LOW_8_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = RIGHT_PAD_LOW_16_32; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHT_PAD_LOW_16_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = RIGHT_PAD_LOW_32_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 22: /* RightPadHigh */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 1:
- switch (code2) {
- case 3: *result = RIGHT_PAD_HIGH_1_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHT_PAD_HIGH_1_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHT_PAD_HIGH_1_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = RIGHT_PAD_HIGH_1_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4:
- switch (code2) {
- case 1: *result = RIGHT_PAD_HIGH_8_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHT_PAD_HIGH_8_32; return SIMPLICITY_NO_ERROR;
- case 3: *result = RIGHT_PAD_HIGH_8_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = RIGHT_PAD_HIGH_16_32; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHT_PAD_HIGH_16_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = RIGHT_PAD_HIGH_32_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 23: /* RightExtend */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- code2 = simplicity_decodeUptoMaxInt(stream);
- if (code2 < 0) return (simplicity_err)code2;
- switch (code) {
- case 4:
- switch (code2) {
- case 1: *result = RIGHT_EXTEND_8_16; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHT_EXTEND_8_32; return SIMPLICITY_NO_ERROR;
- case 3: *result = RIGHT_EXTEND_8_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5:
- switch (code2) {
- case 1: *result = RIGHT_EXTEND_16_32; return SIMPLICITY_NO_ERROR;
- case 2: *result = RIGHT_EXTEND_16_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 6:
- switch (code2) {
- case 1: *result = RIGHT_EXTEND_32_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 24: /* LeftShiftWith */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = LEFT_SHIFT_WITH_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFT_SHIFT_WITH_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFT_SHIFT_WITH_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFT_SHIFT_WITH_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 25: /* RightShiftWith */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = RIGHT_SHIFT_WITH_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHT_SHIFT_WITH_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHT_SHIFT_WITH_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = RIGHT_SHIFT_WITH_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 26: /* LeftShift */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = LEFT_SHIFT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFT_SHIFT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFT_SHIFT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFT_SHIFT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 27: /* RightShift */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = RIGHT_SHIFT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHT_SHIFT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHT_SHIFT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = RIGHT_SHIFT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 28: /* LeftRotate */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = LEFT_ROTATE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LEFT_ROTATE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LEFT_ROTATE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LEFT_ROTATE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 29: /* RightRotate */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = RIGHT_ROTATE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = RIGHT_ROTATE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = RIGHT_ROTATE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = RIGHT_ROTATE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 2: /* Arith jets chapter */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
-
- switch (code) {
- case 1: /* One */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = ONE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = ONE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = ONE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = ONE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 2: /* FullAdd */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = FULL_ADD_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_ADD_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_ADD_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_ADD_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 3: /* Add */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = ADD_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = ADD_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = ADD_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = ADD_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4: /* FullIncrement */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = FULL_INCREMENT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_INCREMENT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_INCREMENT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_INCREMENT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5: /* Increment */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = INCREMENT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = INCREMENT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = INCREMENT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = INCREMENT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 7: /* FullSubtract */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = FULL_SUBTRACT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_SUBTRACT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_SUBTRACT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_SUBTRACT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 8: /* Subtract */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = SUBTRACT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = SUBTRACT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = SUBTRACT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = SUBTRACT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 9: /* Negate */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = NEGATE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = NEGATE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = NEGATE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = NEGATE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 10: /* FullDecrement */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = FULL_DECREMENT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_DECREMENT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_DECREMENT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_DECREMENT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 11: /* Decrement */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = DECREMENT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = DECREMENT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = DECREMENT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = DECREMENT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 12: /* FullMultiply */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = FULL_MULTIPLY_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = FULL_MULTIPLY_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = FULL_MULTIPLY_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = FULL_MULTIPLY_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 13: /* Multiply */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = MULTIPLY_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = MULTIPLY_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = MULTIPLY_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = MULTIPLY_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 14: /* IsZero */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = IS_ZERO_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = IS_ZERO_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = IS_ZERO_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = IS_ZERO_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 15: /* IsOne */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = IS_ONE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = IS_ONE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = IS_ONE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = IS_ONE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 16: /* Le */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = LE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 17: /* Lt */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = LT_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = LT_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = LT_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = LT_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 18: /* Min */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = MIN_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = MIN_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = MIN_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = MIN_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 19: /* Max */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = MAX_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = MAX_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = MAX_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = MAX_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 20: /* Median */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = MEDIAN_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = MEDIAN_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = MEDIAN_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = MEDIAN_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 21: /* Div2n1n */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 6: *result = DIV_MOD_128_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 22: /* DivMod */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = DIV_MOD_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = DIV_MOD_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = DIV_MOD_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = DIV_MOD_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 23: /* Divide */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = DIVIDE_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = DIVIDE_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = DIVIDE_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = DIVIDE_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 24: /* Modulo */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = MODULO_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = MODULO_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = MODULO_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = MODULO_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 25: /* Divides */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 3: *result = DIVIDES_8; return SIMPLICITY_NO_ERROR;
- case 4: *result = DIVIDES_16; return SIMPLICITY_NO_ERROR;
- case 5: *result = DIVIDES_32; return SIMPLICITY_NO_ERROR;
- case 6: *result = DIVIDES_64; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 3: /* Hash jets chapter */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: /* SHA-256 section */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = SHA_256_BLOCK; return SIMPLICITY_NO_ERROR;
- case 2: *result = SHA_256_IV; return SIMPLICITY_NO_ERROR;
- case 3: /* SHA-256-CTX-8-ADD-n subsection */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = SHA_256_CTX_8_ADD_1; return SIMPLICITY_NO_ERROR;
- case 2: *result = SHA_256_CTX_8_ADD_2; return SIMPLICITY_NO_ERROR;
- case 3: *result = SHA_256_CTX_8_ADD_4; return SIMPLICITY_NO_ERROR;
- case 4: *result = SHA_256_CTX_8_ADD_8; return SIMPLICITY_NO_ERROR;
- case 5: *result = SHA_256_CTX_8_ADD_16; return SIMPLICITY_NO_ERROR;
- case 6: *result = SHA_256_CTX_8_ADD_32; return SIMPLICITY_NO_ERROR;
- case 7: *result = SHA_256_CTX_8_ADD_64; return SIMPLICITY_NO_ERROR;
- case 8: *result = SHA_256_CTX_8_ADD_128; return SIMPLICITY_NO_ERROR;
- case 9: *result = SHA_256_CTX_8_ADD_256; return SIMPLICITY_NO_ERROR;
- case 10: *result = SHA_256_CTX_8_ADD_512; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4: *result = SHA_256_CTX_8_ADD_BUFFER_511; return SIMPLICITY_NO_ERROR;
- case 5: *result = SHA_256_CTX_8_FINALIZE; return SIMPLICITY_NO_ERROR;
- case 6: *result = SHA_256_CTX_8_INIT; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
- break;
- case 4: /* Secp256k1 jets chapter */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: /* point-verify */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = POINT_VERIFY_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 2: *result = DECOMPRESS; return SIMPLICITY_NO_ERROR;
- case 3: /* linear-verify */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = LINEAR_VERIFY_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 4: /* linear-combination */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = LINEAR_COMBINATION_1; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5: *result = SCALE; return SIMPLICITY_NO_ERROR;
- case 6: *result = GENERATE; return SIMPLICITY_NO_ERROR;
- case 7: *result = GEJ_INFINITY; return SIMPLICITY_NO_ERROR;
- case 8: *result = GEJ_NORMALIZE; return SIMPLICITY_NO_ERROR;
- case 9: *result = GEJ_NEGATE; return SIMPLICITY_NO_ERROR;
- case 10: *result = GE_NEGATE; return SIMPLICITY_NO_ERROR;
- case 11: *result = GEJ_DOUBLE; return SIMPLICITY_NO_ERROR;
- case 12: *result = GEJ_ADD; return SIMPLICITY_NO_ERROR;
- case 13: *result = GEJ_GE_ADD_EX; return SIMPLICITY_NO_ERROR;
- case 14: *result = GEJ_GE_ADD; return SIMPLICITY_NO_ERROR;
- case 15: *result = GEJ_RESCALE; return SIMPLICITY_NO_ERROR;
- case 16: *result = GEJ_IS_INFINITY; return SIMPLICITY_NO_ERROR;
- case 17: *result = GEJ_EQUIV; return SIMPLICITY_NO_ERROR;
- case 18: *result = GEJ_GE_EQUIV; return SIMPLICITY_NO_ERROR;
- case 19: *result = GEJ_X_EQUIV; return SIMPLICITY_NO_ERROR;
- case 20: *result = GEJ_Y_IS_ODD; return SIMPLICITY_NO_ERROR;
- case 21: *result = GEJ_IS_ON_CURVE; return SIMPLICITY_NO_ERROR;
- case 22: *result = GE_IS_ON_CURVE; return SIMPLICITY_NO_ERROR;
- case 23: *result = SCALAR_NORMALIZE; return SIMPLICITY_NO_ERROR;
- case 24: *result = SCALAR_NEGATE; return SIMPLICITY_NO_ERROR;
- case 25: *result = SCALAR_ADD; return SIMPLICITY_NO_ERROR;
- case 26: *result = SCALAR_SQUARE; return SIMPLICITY_NO_ERROR;
- case 27: *result = SCALAR_MULTIPLY; return SIMPLICITY_NO_ERROR;
- case 28: *result = SCALAR_MULTIPLY_LAMBDA; return SIMPLICITY_NO_ERROR;
- case 29: *result = SCALAR_INVERT; return SIMPLICITY_NO_ERROR;
- case 30: *result = SCALAR_IS_ZERO; return SIMPLICITY_NO_ERROR;
-
- case 35: *result = FE_NORMALIZE; return SIMPLICITY_NO_ERROR;
- case 36: *result = FE_NEGATE; return SIMPLICITY_NO_ERROR;
- case 37: *result = FE_ADD; return SIMPLICITY_NO_ERROR;
- case 38: *result = FE_SQUARE; return SIMPLICITY_NO_ERROR;
- case 39: *result = FE_MULTIPLY; return SIMPLICITY_NO_ERROR;
- case 40: *result = FE_MULTIPLY_BETA; return SIMPLICITY_NO_ERROR;
- case 41: *result = FE_INVERT; return SIMPLICITY_NO_ERROR;
- case 42: *result = FE_SQUARE_ROOT; return SIMPLICITY_NO_ERROR;
- case 43: *result = FE_IS_ZERO; return SIMPLICITY_NO_ERROR;
- case 44: *result = FE_IS_ODD; return SIMPLICITY_NO_ERROR;
-
- case 46: *result = HASH_TO_CURVE; return SIMPLICITY_NO_ERROR;
- case 47: *result = SWU; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 5: /* Signature jets chapter */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = CHECK_SIG_VERIFY; return SIMPLICITY_NO_ERROR;
- case 2: *result = BIP_0340_VERIFY; return SIMPLICITY_NO_ERROR;
- }
- break;
- case 7: /* Bitcoin jets chapter */
- code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: *result = PARSE_LOCK; return SIMPLICITY_NO_ERROR;
- case 2: *result = PARSE_SEQUENCE; return SIMPLICITY_NO_ERROR;
- case 3: *result = TAPDATA_INIT; return SIMPLICITY_NO_ERROR;
- }
- break;
- }
+#include "../../decodeCoreJets.inc"
return SIMPLICITY_ERR_DATA_OUT_OF_RANGE;
} else {
/* Elements jets */
- int32_t code = simplicity_decodeUptoMaxInt(stream);
- if (code < 0) return (simplicity_err)code;
- switch (code) {
- case 1: /* SigHash jets chapter */
- 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: /* Timelock jets chapter */
- 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: /* Issuance jets chapter */
- 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: /* Transaction jets chapter */
- 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;
- }
+#include "decodeElementsJets.inc"
return SIMPLICITY_ERR_DATA_OUT_OF_RANGE;
}
}
diff --git a/src/simplicity/schnorr0.c b/src/simplicity/schnorr0.c
index 9064f313300..bf0a475342c 100644
--- a/src/simplicity/schnorr0.c
+++ b/src/simplicity/schnorr0.c
@@ -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
};
diff --git a/src/simplicity/schnorr0.h b/src/simplicity/schnorr0.h
index 6ead60e5088..1513d31dd91 100644
--- a/src/simplicity/schnorr0.h
+++ b/src/simplicity/schnorr0.h
@@ -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[];
diff --git a/src/simplicity/schnorr6.c b/src/simplicity/schnorr6.c
index d02059d2af3..9b6a11d3390 100644
--- a/src/simplicity/schnorr6.c
+++ b/src/simplicity/schnorr6.c
@@ -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
};
diff --git a/src/simplicity/schnorr6.h b/src/simplicity/schnorr6.h
index a90bbd690e4..8ad66a7bdb0 100644
--- a/src/simplicity/schnorr6.h
+++ b/src/simplicity/schnorr6.h
@@ -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[];
diff --git a/src/simplicity/secp256k1/int128_struct.h b/src/simplicity/secp256k1/int128_struct.h
index 6156f82cc2d..e835062a958 100644
--- a/src/simplicity/secp256k1/int128_struct.h
+++ b/src/simplicity/secp256k1/int128_struct.h
@@ -4,7 +4,7 @@
#include
#include "util.h"
-typedef struct {
+typedef struct secp256k1_uint128 {
uint64_t lo;
uint64_t hi;
} secp256k1_uint128;
diff --git a/src/simplicity/secp256k1/modinv64.h b/src/simplicity/secp256k1/modinv64.h
index dda494f0bde..fc263edf4c7 100644
--- a/src/simplicity/secp256k1/modinv64.h
+++ b/src/simplicity/secp256k1/modinv64.h
@@ -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.
diff --git a/src/simplicity/secp256k1/modinv64_impl.h b/src/simplicity/secp256k1/modinv64_impl.h
index 13e2c693e53..191de31f179 100644
--- a/src/simplicity/secp256k1/modinv64_impl.h
+++ b/src/simplicity/secp256k1/modinv64_impl.h
@@ -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
diff --git a/src/simplicity/secp256k1/precomputed_ecmult.h b/src/simplicity/secp256k1/precomputed_ecmult.h
index d04a45c3d02..a80bc49827e 100644
--- a/src/simplicity/secp256k1/precomputed_ecmult.h
+++ b/src/simplicity/secp256k1/precomputed_ecmult.h
@@ -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 */
diff --git a/src/simplicity/test.c b/src/simplicity/test.c
index b5033bd5e7e..445b5726786 100644
--- a/src/simplicity/test.c
+++ b/src/simplicity/test.c
@@ -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();
diff --git a/src/simplicity/typeSkipTest.c b/src/simplicity/typeSkipTest.c
index 1a8ac83a634..0629f1645a1 100644
--- a/src/simplicity/typeSkipTest.c
+++ b/src/simplicity/typeSkipTest.c
@@ -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
};
diff --git a/src/simplicity/typeSkipTest.h b/src/simplicity/typeSkipTest.h
index 73b308b59a8..61230c10609 100644
--- a/src/simplicity/typeSkipTest.h
+++ b/src/simplicity/typeSkipTest.h
@@ -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[];
diff --git a/src/test/fuzz/rbf.cpp b/src/test/fuzz/rbf.cpp
index 8dcaa609b54..a3828b51f80 100644
--- a/src/test/fuzz/rbf.cpp
+++ b/src/test/fuzz/rbf.cpp
@@ -15,7 +15,13 @@
#include
#include
-FUZZ_TARGET(rbf)
+void initialize_rbf(void) {
+ // ELEMENTS: our mempool needs Params() to be set for multiple reasons -- to check
+ // the discount CT rate, to figure out pegin policy, etc
+ SelectParams(CBaseChainParams::LIQUID1);
+}
+
+FUZZ_TARGET_INIT(rbf, initialize_rbf)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
SetMockTime(ConsumeTime(fuzzed_data_provider));
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 3ddf915f3a8..37e6f77c369 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -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"},
diff --git a/test/functional/example_elements_code_tutorial.py b/test/functional/example_elements_code_tutorial.py
index feb645f1f10..138750ec538 100755
--- a/test/functional/example_elements_code_tutorial.py
+++ b/test/functional/example_elements_code_tutorial.py
@@ -25,6 +25,7 @@ def set_test_params(self):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
def run_test(self):
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
diff --git a/test/functional/feature_discount_ct.py b/test/functional/feature_discount_ct.py
index 84e2c096b19..0c949ba27e5 100755
--- a/test/functional/feature_discount_ct.py
+++ b/test/functional/feature_discount_ct.py
@@ -36,6 +36,7 @@ def set_test_params(self):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
def run_test(self):
feerate = 1.0
diff --git a/test/functional/feature_discount_ct_ordering.py b/test/functional/feature_discount_ct_ordering.py
index aed8a1f0db7..2b9e1554e2a 100755
--- a/test/functional/feature_discount_ct_ordering.py
+++ b/test/functional/feature_discount_ct_ordering.py
@@ -33,6 +33,7 @@ def set_test_params(self):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
def run_test(self):
diff --git a/test/functional/feature_taphash_pegins_issuances.py b/test/functional/feature_taphash_pegins_issuances.py
index e4716e8ebc0..21ad0049481 100755
--- a/test/functional/feature_taphash_pegins_issuances.py
+++ b/test/functional/feature_taphash_pegins_issuances.py
@@ -41,6 +41,7 @@ def set_test_params(self):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
def setup_network(self, split=False):
self.setup_nodes()
diff --git a/test/functional/feature_tapscript_opcodes.py b/test/functional/feature_tapscript_opcodes.py
index 8772a08d72b..5dbb62bc692 100755
--- a/test/functional/feature_tapscript_opcodes.py
+++ b/test/functional/feature_tapscript_opcodes.py
@@ -45,6 +45,7 @@ def set_test_params(self):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
def setup_network(self, split=False):
self.setup_nodes()
diff --git a/test/functional/feature_trim_headers.py b/test/functional/feature_trim_headers.py
index 8d44ee92a95..93926c752f0 100755
--- a/test/functional/feature_trim_headers.py
+++ b/test/functional/feature_trim_headers.py
@@ -39,6 +39,7 @@ def make_signblockscript(num_nodes, required_signers, keys):
class TrimHeadersTest(BitcoinTestFramework):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
# Dynamically generate N keys to be used for block signing.
def init_keys(self, num_keys):
diff --git a/test/functional/wallet_elements_21million.py b/test/functional/wallet_elements_21million.py
index f9faafdbeab..ea6b34dd6f0 100755
--- a/test/functional/wallet_elements_21million.py
+++ b/test/functional/wallet_elements_21million.py
@@ -50,8 +50,8 @@ def run_test(self):
assert_equal(self.nodes[1].getbalance()[asset], 22_000_000)
# unload/load wallet
- self.nodes[1].unloadwallet("")
- self.nodes[1].loadwallet("")
+ self.nodes[1].unloadwallet(self.default_wallet_name)
+ self.nodes[1].loadwallet(self.default_wallet_name)
assert_equal(self.nodes[1].getbalance()[asset], 22_000_000)
# send more than 45 million of that asset
@@ -62,8 +62,8 @@ def run_test(self):
assert_equal(self.nodes[2].getbalance()[asset], 46_000_000)
# unload/load wallet
- self.nodes[2].unloadwallet("")
- self.nodes[2].loadwallet("")
+ self.nodes[2].unloadwallet(self.default_wallet_name)
+ self.nodes[2].loadwallet(self.default_wallet_name)
assert_equal(self.nodes[2].getbalance()[asset], 46_000_000)
# send some policy asset to node 1 for fees
@@ -86,8 +86,8 @@ def run_test(self):
assert_equal(self.nodes[2].getbalance()[asset], 200_000_000)
# unload/load wallet
- self.nodes[2].unloadwallet("")
- self.nodes[2].loadwallet("")
+ self.nodes[2].unloadwallet(self.default_wallet_name)
+ self.nodes[2].loadwallet(self.default_wallet_name)
assert_equal(self.nodes[2].getbalance()[asset], 200_000_000)
if __name__ == '__main__':
diff --git a/test/functional/wallet_elements_regression_1263.py b/test/functional/wallet_elements_regression_1263.py
index c4f713c8e36..2f5ce36ebed 100755
--- a/test/functional/wallet_elements_regression_1263.py
+++ b/test/functional/wallet_elements_regression_1263.py
@@ -19,6 +19,7 @@ def set_test_params(self):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ self.skip_if_no_bdb()
def run_test(self):
self.log.info("Start in Bitcoin regtest mode")
diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan
index 2d5df53f759..682ec7f60bc 100644
--- a/test/sanitizer_suppressions/ubsan
+++ b/test/sanitizer_suppressions/ubsan
@@ -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