diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f2ebba9..9a8c8a1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -27,7 +27,7 @@ assignees: "" - **OS**: - **Rust version**: - **Commit / tag**: -- **Affected crate(s)**: +- **Affected crate(s)**: ## Logs diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 987dd29..5ab9599 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -16,7 +16,7 @@ assignees: "" ## Affected crate(s) - + ## Alternatives considered diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index cdd3453..761b07f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,10 +14,8 @@ ## Affected crates - [ ] `core` -- [ ] `jet_plugins` - [ ] `service` - [ ] `cli` -- [ ] `plugin_tests` - [ ] CI / tooling ## Checklist diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 391dafe..9bebccd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,11 +6,9 @@ Contributions of all kinds are welcome — bug reports, documentation improvemen The workspace is organised into focused crates. Keep changes scoped to the appropriate crate and discuss cross-crate changes in an issue first. -- [`core`](core/README.md): Simplicity execution engine, Bitcoin/Elements environments, and the dynamic jet loading API. -- [`jet_plugins`](jet_plugins/README.md): Procedural macro that derives the `Jet` trait and C FFI for custom jet plugins. +- [`core`](core/README.md): Simplicity execution engine and Bitcoin/Elements environments. - [`service`](service/README.md): Axum HTTP service exposing the sign/PSBT, sign/PSET, and key-tweak endpoints. - [`cli`](cli/README.md): `clap`-based CLI for interacting with the service and accessing ecosystem utilities. -- `plugin_tests/`: Example and integration-test jet plugins for Bitcoin, Elements, and opcode pubkey variants. ## Issues @@ -33,43 +31,6 @@ If this is just a bug report or a feature request, please open an issue first so - Adding a new dependency requires justification. Prefer `[workspace.dependencies]` entries and avoid floating version requirements. - Add unit tests under a `#[cfg(test)]` module in the same file. -## Adding Custom Jets - -Custom jets are the primary extension point. To add a new jet plugin: - -1. Create a new crate that depends on `jet_plugins` and `simplicity_unchained_core`, declare it as a `cdylib`: - - ```toml - # Cargo.toml - [lib] - crate-type = ["cdylib"] - ``` - -2. Define your jet functions matching the expected signature: - - ```rust - fn my_jet(_dst: &mut CFrameItem, _src: CFrameItem, _env: &BitcoinUnchainedEnv) -> bool { - // return true on success - todo!() - } - ``` - -3. Register them with the `register_jets!` macro: - - ```rust - use jet_plugins::register_jets; - use simplicity_unchained_core::jets::environments::BitcoinUnchainedEnv; - use hal_simplicity::simplicity::ffi::CFrameItem; - - register_jets!( - hal_simplicity::simplicity::jet::Core, // base jet set - BitcoinUnchainedEnv, // environment type - "my_jet_name" => my_jet, b"h", b"h", // (name, fn, source_type, target_type) - ); - ``` - -4. Pass the compiled `.so`/`.dylib` path to the core runner via the dynamic loading API. See `core/src/jets/jet_dyn.rs` and `cli/assets/custom_jet_dlls/` for reference. - ## Running the Service Locally ```bash diff --git a/Cargo.lock b/Cargo.lock index da27fee..6db90da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,15 +214,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "bitcoin" -version = "0.1.0" -dependencies = [ - "core", - "hal-simplicity", - "jet_plugins", -] - [[package]] name = "bitcoin" version = "0.32.8" @@ -423,7 +414,6 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" name = "core" version = "0.1.0" dependencies = [ - "dlopen2", "hal-simplicity", "hex 0.4.3", "hex-literal", @@ -492,38 +482,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dlopen2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2c5bd4158e66d1e215c49b837e11d62f3267b30c92f1d171c4d3105e3dc4d4" -dependencies = [ - "dlopen2_derive", - "libc", - "once_cell", - "winapi", -] - -[[package]] -name = "dlopen2_derive" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbbb781877580993a8707ec48672673ec7b81eeba04cfd2310bd28c08e47c8f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "elements" -version = "0.1.0" -dependencies = [ - "core", - "hal-simplicity", - "jet_plugins", -] - [[package]] name = "elements" version = "0.25.2" @@ -531,7 +489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81b2569d3495bfdfce36c504fd4d78752ff4a7699f8a33e6f3ee523bddf9f6ad" dependencies = [ "bech32", - "bitcoin 0.32.8", + "bitcoin", "secp256k1-zkp", "serde", "serde_json", @@ -720,7 +678,7 @@ checksum = "f57a34f3cc18f2967a98c61abea03b1b9521075e880b18f45b63561a88c3c174" dependencies = [ "base64-compat", "bip39", - "bitcoin 0.32.8", + "bitcoin", "byteorder", "chrono", "clap 2.33.3", @@ -745,7 +703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52a540615bef9124e283bbd087e007af922c9f6cfac210412bda4d1c34b2a74d" dependencies = [ "clap 2.33.3", - "elements 0.25.2", + "elements", "fern", "hal", "hex 0.3.2", @@ -1128,17 +1086,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee5b5339afb4c41626dde77b7a611bd4f2c202b897852b4bcf5d03eddc61010" -[[package]] -name = "jet_plugins" -version = "0.1.0" -dependencies = [ - "bitcoin_hashes", - "core", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "jobserver" version = "0.1.34" @@ -1178,7 +1125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11209f386879b97198b2bfc9e9c1e5d42870825c6bd4376f17f95357244d6600" dependencies = [ "bech32", - "bitcoin 0.32.8", + "bitcoin", "lightning-types", ] @@ -1188,7 +1135,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2cd84d4e71472035903e43caded8ecc123066ce466329ccd5ae537a8d5488c7" dependencies = [ - "bitcoin 0.32.8", + "bitcoin", ] [[package]] @@ -1240,7 +1187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "487906208f38448e186e3deb02f2b8ef046a9078b0de00bdb28bf4fb9b76951c" dependencies = [ "bech32", - "bitcoin 0.32.8", + "bitcoin", ] [[package]] @@ -1301,24 +1248,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" -[[package]] -name = "opcode_pubkey_bitcoin" -version = "0.1.0" -dependencies = [ - "core", - "hal-simplicity", - "jet_plugins", -] - -[[package]] -name = "opcode_pubkey_elements" -version = "0.1.0" -dependencies = [ - "core", - "hal-simplicity", - "jet_plugins", -] - [[package]] name = "openssl" version = "0.10.75" @@ -1764,7 +1693,6 @@ dependencies = [ "base64 0.22.1", "clap 4.5.53", "core", - "dlopen2", "hal-simplicity", "hex 0.4.3", "log", @@ -1805,10 +1733,10 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70e57bd4d84853974a212eab24ed89da54f49fbccf5e33e93bcd29f0a6591cd5" dependencies = [ - "bitcoin 0.32.8", + "bitcoin", "bitcoin_hashes", "byteorder", - "elements 0.25.2", + "elements", "getrandom 0.2.16", "ghost-cell", "hex-conservative", diff --git a/Cargo.toml b/Cargo.toml index a5d5e6d..013125e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,6 @@ resolver = "2" members = [ "cli", "core", - "jet_plugins", - "plugin_tests/bitcoin", - "plugin_tests/opcode_pubkey_elements", - "plugin_tests/opcode_pubkey_bitcoin", - "plugin_tests/elements", "service", ] diff --git a/README.md b/README.md index de27077..a3b0750 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,7 @@ See [core/README.md](core/README.md) for a detailed explanation of the unchained ## Project Structure -- [`core`](core/README.md): Contains the fundamental logic for executing Simplicity programs, interacting with Bitcoin and Elements environments and interface for loading custom jet implementations from dynamic libraries. (Note: In the future, parts of this logic may be migrated to [hal-simplicity](https://github.com/BlockstreamResearch/hal-simplicity)) - -- [`jet_plugins`](jet_plugins/README.md): Procedural macro for deriving Jet trait for given custom jets alongside with it's C FFI. Currently supports extending Bitcoin and Elements jets. +- [`core`](core/README.md): Contains the fundamental logic for executing Simplicity programs and interacting with Bitcoin and Elements environments. (Note: In the future, parts of this logic may be migrated to [hal-simplicity](https://github.com/BlockstreamResearch/hal-simplicity)) - [`service`](service/README.md): Implements a web service providing endpoints to interact with Simplicity Unchained. Currently, it supports a 2-of-2 multisig co-signing flow on Bitcoin and Elements, triggered by the successful execution of a Simplicity program. diff --git a/cli/assets/custom_jet_dlls/libbitcoin.so b/cli/assets/custom_jet_dlls/libbitcoin.so deleted file mode 100755 index dfd68a5..0000000 Binary files a/cli/assets/custom_jet_dlls/libbitcoin.so and /dev/null differ diff --git a/cli/assets/custom_jet_dlls/libelements.so b/cli/assets/custom_jet_dlls/libelements.so deleted file mode 100755 index 93210dc..0000000 Binary files a/cli/assets/custom_jet_dlls/libelements.so and /dev/null differ diff --git a/cli/assets/custom_jet_dlls/libopcode_pubkey_bitcoin.so b/cli/assets/custom_jet_dlls/libopcode_pubkey_bitcoin.so deleted file mode 100755 index 649c8c6..0000000 Binary files a/cli/assets/custom_jet_dlls/libopcode_pubkey_bitcoin.so and /dev/null differ diff --git a/cli/assets/custom_jet_dlls/libopcode_pubkey_elements.so b/cli/assets/custom_jet_dlls/libopcode_pubkey_elements.so deleted file mode 100755 index 13bb11c..0000000 Binary files a/cli/assets/custom_jet_dlls/libopcode_pubkey_elements.so and /dev/null differ diff --git a/core/Cargo.toml b/core/Cargo.toml index 4651449..6b7a6bc 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -13,4 +13,3 @@ hex-literal = "1.1.0" hal-simplicity = { workspace = true } thiserror = { workspace = true } hex = { workspace = true } -dlopen2 = "0.8.2" diff --git a/core/README.md b/core/README.md index e89206c..fd72ea3 100644 --- a/core/README.md +++ b/core/README.md @@ -6,8 +6,7 @@ Contains the fundamental logic for executing Simplicity programs and interacting - Execute Simplicity programs with provided data and environment. - Utilities for interacting with Elements and Simplicity environments. -- Custom execution environment supporting the injection of custom jets. -- Provides API for loading custom Jet trait implementation derived via jet_plugins crate via dynamic library. +- Custom execution environment extending the Bitcoin and Elements jet sets with additional jets. ## How It Works diff --git a/core/src/jets/custom_jet.rs b/core/src/jets/custom_jet.rs deleted file mode 100644 index 3af69a3..0000000 --- a/core/src/jets/custom_jet.rs +++ /dev/null @@ -1,445 +0,0 @@ -//! High level wrapper for loading custom jets from DLL. -use crate::jets::{ - environments::UnchainedEnv, - jet_dyn::{CCustomJet, CustomJetApi}, -}; -use dlopen2::wrapper::Container; -use hal_simplicity::simplicity::jet::Jet; -use std::{marker::PhantomData, sync::LazyLock}; - -pub(crate) static JET_DLL: LazyLock>> = LazyLock::new(|| { - std::env::var("JET_DLL_PATH") - .ok() - .and_then(|path| unsafe { Container::::load(&path) }.ok()) -}); - -/// `simplicity_unchained_core::jets::jet_dyn::decode` copies input bits into a separate buffer to transfer them via FFI. -/// This constant controls how many bits will be read. -/// Not used right now because decode trees are hardcoded due to lack of BitIter rewind. -const MAX_JET_BIT_LEN: u32 = 30; - -#[repr(transparent)] -/// Wrapper for interacting with Jet defined inside DLL. -/// Unless `Api` generic defined manually, loads DLL from path given by `std::env::var` -pub struct CustomJet { - inner: CCustomJet, - _env: PhantomData E>, - _dll: PhantomData Api>, -} - -pub trait JetApiProvider { - fn get() -> &'static Option>; -} - -// Loads DLL from `std::env::var` by `JET_DLL_PATH` name -pub struct DefaultApi; - -impl JetApiProvider for DefaultApi { - fn get() -> &'static Option> { - &JET_DLL - } -} - -impl From for CustomJet -where - Api: JetApiProvider, -{ - fn from(value: CCustomJet) -> Self { - Self { - inner: value, - _env: PhantomData, - _dll: PhantomData, - } - } -} - -impl CustomJet -where - Api: JetApiProvider, -{ - pub fn all() -> &'static [Self] { - unsafe { std::mem::transmute(Api::get().as_ref().expect("DLL is not loaded").all_jets()) } - } - - /// Tries to convert dynamic jet representation to instance of base type jet. - /// Returns Some if given jet is from base jet set, None if custom. - /// # Safety - /// It's caller responsibility to guarantee that base type inside DLL is same - /// as type provided as generic to this function. - pub unsafe fn to_base_jet(&self) -> Option { - unsafe { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .to_base_jet(self.inner) - } - } - - /// Converts base type jet representation to instance of dynamic jet. - /// # Safety - /// It's caller responsibility to guarantee that base type inside DLL is same - /// as type provided as generic to this function. - pub unsafe fn from_base_jet(jet: &T) -> Self { - unsafe { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .from_base_jet(jet) - .into() - } - } -} - -impl std::str::FromStr for CustomJet -where - Api: JetApiProvider, -{ - type Err = hal_simplicity::simplicity::Error; - - fn from_str(s: &str) -> Result { - match Api::get().as_ref().expect("DLL is not loaded").from_str(s) { - Ok(_jet) => Ok(_jet.into()), - Err(err) => Err(err), - } - } -} -impl Copy for CustomJet where Api: JetApiProvider {} - -impl Clone for CustomJet -where - Api: JetApiProvider, -{ - fn clone(&self) -> Self { - *self - } -} - -impl PartialEq for CustomJet -where - Api: JetApiProvider, -{ - fn eq(&self, other: &Self) -> bool { - self.inner == other.inner - } -} - -impl Eq for CustomJet where Api: JetApiProvider {} - -#[allow(clippy::non_canonical_partial_ord_impl)] -impl PartialOrd for CustomJet -where - Api: JetApiProvider, -{ - fn partial_cmp(&self, other: &Self) -> Option { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .partial_cmp(self.inner, other.inner) - } -} - -impl Ord for CustomJet -where - Api: JetApiProvider, -{ - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .cmp(self.inner, other.inner) - } -} - -impl core::hash::Hash for CustomJet -where - Api: JetApiProvider, -{ - fn hash(&self, state: &mut H) { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .hash(self.inner, state); - } -} - -impl std::fmt::Debug for CustomJet -where - Api: JetApiProvider, -{ - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .debug_fmt(self.inner, f) - } -} - -impl std::fmt::Display for CustomJet -where - Api: JetApiProvider, -{ - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .display_fmt(self.inner, f) - } -} - -impl Jet for CustomJet -where - Api: JetApiProvider, -{ - type Environment = UnchainedEnv; - type CJetEnvironment = UnchainedEnv; - - fn c_jet_env(env: &Self::Environment) -> &Self::CJetEnvironment { - env - } - - fn cmr(&self) -> hal_simplicity::simplicity::Cmr { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .cmr(self.inner) - } - - fn source_ty(&self) -> hal_simplicity::simplicity::jet::type_name::TypeName { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .source_ty(self.inner) - } - - fn target_ty(&self) -> hal_simplicity::simplicity::jet::type_name::TypeName { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .target_ty(self.inner) - } - - fn encode( - &self, - w: &mut hal_simplicity::simplicity::BitWriter, - ) -> std::io::Result { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .encode(self.inner, w) - } - - fn decode>( - bits: &mut hal_simplicity::simplicity::BitIter, - ) -> Result { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .decode(bits, MAX_JET_BIT_LEN) - .map(|jet| jet.into()) - } - - fn c_jet_ptr( - &self, - ) -> &dyn Fn( - &mut hal_simplicity::simplicity::ffi::CFrameItem, - hal_simplicity::simplicity::ffi::CFrameItem, - &Self::CJetEnvironment, - ) -> bool { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .c_jet_ptr(self.inner) - } - - fn cost(&self) -> hal_simplicity::simplicity::Cost { - Api::get() - .as_ref() - .expect("DLL is not loaded") - .cost(self.inner) - } -} - -#[cfg(test)] -mod test { - use std::{ - hash::{Hash, Hasher}, - str::FromStr, - }; - - use hal_simplicity::simplicity::{BitIter, BitWriter}; - - use crate::jets::environments::{BitcoinUnchainedEnv, ElementsUnchainedEnv}; - - use super::*; - - // --- DLLs for tests --- - // Use the cargo-built output from target/debug/ with the platform-appropriate extension - // (dylib on macOS, so on Linux) instead of pre-built platform-specific binaries. - static ELEMENTS_TEST_DLL: LazyLock>> = - LazyLock::new(|| unsafe { - let path = format!( - "{}/../target/debug/libelements.{}", - env!("CARGO_MANIFEST_DIR"), - std::env::consts::DLL_EXTENSION - ); - Container::::load(&path).ok() - }); - - static CORE_TEST_DLL: LazyLock>> = LazyLock::new(|| unsafe { - let path = format!( - "{}/../target/debug/libbitcoin.{}", - env!("CARGO_MANIFEST_DIR"), - std::env::consts::DLL_EXTENSION - ); - Container::::load(&path).ok() - }); - - struct ElementsTestApi; - impl JetApiProvider for ElementsTestApi { - fn get() -> &'static Option> { - &ELEMENTS_TEST_DLL - } - } - - struct CoreTestApi; - impl JetApiProvider for CoreTestApi { - fn get() -> &'static Option> { - &CORE_TEST_DLL - } - } - - type CustomJetElements = CustomJet; - type CustomJetBitcoin = CustomJet; - - // --------------------- - #[test] - fn test_dll_from_str_elements() { - let jet = CustomJetElements::from_str("custom_jet_1"); - - assert!(jet.is_ok()); - assert_eq!(jet.unwrap().to_string(), "custom_jet_1") - } - - #[test] - fn test_dll_hash_elements() { - let jet = CustomJetElements::from_str("custom_jet_1").expect("Failed to load jet"); - - let mut hasher = std::collections::hash_map::DefaultHasher::new(); - jet.hash(&mut hasher); - - let _ = hasher.finish(); - } - - #[test] - fn test_dll_encode_elements() { - let custom_jet = CustomJetElements::from_str("custom_jet_1").expect("Failed to load jet"); - let elements_jet = CustomJetElements::from_str("input_asset").expect("Failed to load jet"); - - let mut buffer = Vec::new(); - let mut w = BitWriter::new(&mut buffer); - - let res1 = custom_jet.encode(&mut w); - let res2 = elements_jet.encode(&mut w); - - assert!(res1.is_ok()); - assert!(res2.is_ok()); - - assert_eq!(res1.unwrap(), 20); - assert_eq!(res2.unwrap(), 19); - - w.flush_all().unwrap(); - - let mut bit_iter = BitIter::from(buffer); - - let mut read_code = |read_bits: u8| -> Option { - let mut res = 0; - let mut cursor = 1 << (read_bits - 1); - - for _ in 0..read_bits { - match bit_iter.next() { - None => return None, - Some(true) => res |= cursor, - Some(false) => {} - } - cursor >>= 1; - } - Some(res) - }; - - let custom_jet_code = read_code(20); - let elements_jet_code = read_code(19); - - assert!(custom_jet_code.is_some()); - assert!(elements_jet_code.is_some()); - - assert_eq!(custom_jet_code.unwrap(), 1047454); - assert_eq!(elements_jet_code.unwrap(), 462369); - } - - #[test] - fn test_dll_decode_elements() { - let custom_jet = CustomJetElements::from_str("custom_jet_1").expect("Failed to load jet"); - let elements_jet = CustomJetElements::from_str("input_asset").expect("Failed to load jet"); - - let mut buffer = Vec::new(); - let mut w = BitWriter::new(&mut buffer); - - let res1 = custom_jet.encode(&mut w); - let res2 = elements_jet.encode(&mut w); - - assert!(res1.is_ok()); - assert!(res2.is_ok()); - - w.flush_all().unwrap(); - - let mut bit_iter = BitIter::from(buffer.as_ref()); - - let custom_decoded = CustomJetElements::decode(&mut bit_iter); - assert!(custom_decoded.is_ok()); - - assert_eq!(custom_decoded.unwrap().to_string(), "custom_jet_1"); - - let elements_decoded = CustomJetElements::decode(&mut bit_iter); - assert!(elements_decoded.is_ok()); - - assert_eq!(elements_decoded.unwrap().to_string(), "input_asset"); - } - - #[test] - fn test_dll_decode_bitcoin() { - let custom_jet = CustomJetBitcoin::from_str("custom_jet_1").expect("Failed to load jet"); - let elements_jet = CustomJetBitcoin::from_str("leftmost_16_8").expect("Failed to load jet"); - - let mut buffer = Vec::new(); - let mut w = BitWriter::new(&mut buffer); - - let res1 = custom_jet.encode(&mut w); - let res2 = elements_jet.encode(&mut w); - - assert!(res1.is_ok()); - assert!(res2.is_ok()); - - w.flush_all().unwrap(); - - let mut bit_iter = BitIter::from(buffer.as_ref()); - - let custom_decoded = CustomJetBitcoin::decode(&mut bit_iter); - assert!(custom_decoded.is_ok()); - - assert_eq!(custom_decoded.unwrap().to_string(), "custom_jet_1"); - - let elements_decoded = CustomJetBitcoin::decode(&mut bit_iter); - assert!(elements_decoded.is_ok()); - - assert_eq!(elements_decoded.unwrap().to_string(), "leftmost_16_8"); - } - - #[test] - fn test_dll_c_jet_ptr_elements() { - let custom_jet = CustomJetElements::from_str("custom_jet_1").expect("Failed to load jet"); - let elements_jet = CustomJetElements::from_str("input_asset").expect("Failed to load jet"); - - let _ = custom_jet.c_jet_ptr(); - let _ = elements_jet.c_jet_ptr(); - } -} diff --git a/core/src/jets/jet_dyn.rs b/core/src/jets/jet_dyn.rs deleted file mode 100644 index 135c286..0000000 --- a/core/src/jets/jet_dyn.rs +++ /dev/null @@ -1,330 +0,0 @@ -//! FFI layer for loading Jet trait from DLL using dlopen2. -//! See jet_plugins::c_wrappers for interface on other side. -#![allow(clippy::duplicate_underscore_argument)] // originates from `WrapperApi` macro -use dlopen2::wrapper::WrapperApi; -use hal_simplicity::simplicity::{ - BitIter, BitWriter, Cmr, Cost, ffi::CFrameItem, jet::type_name::TypeName, -}; -use std::{fmt::Formatter, hash::Hasher, io::Write}; - -#[repr(C)] -#[derive(Clone, Copy, PartialEq, Eq)] -pub struct CCustomJet { - // index of jet inside `ALL` constant - pub index: usize, -} - -#[repr(C)] -pub struct JetSelfHandle(()); - -#[repr(C)] -pub struct CmrHandle(()); - -#[repr(C)] -pub struct TypeNameHandle(()); - -#[repr(C)] -pub struct CostHandle(()); - -#[repr(C)] -pub struct HasherHandle<'a> { - pub _hasher: &'a mut dyn Hasher, -} - -#[repr(C)] -pub struct FmtHandle<'a, 'b> { - pub _formatter: &'a mut core::fmt::Formatter<'b>, -} - -#[repr(C)] -pub struct StrHandle<'a> { - pub _str: &'a dyn AsRef, -} - -#[repr(i8)] -pub enum COrdering { - Less = -1, - Equal = 0, - Greater = 1, -} - -impl From for COrdering { - fn from(o: std::cmp::Ordering) -> Self { - match o { - std::cmp::Ordering::Less => COrdering::Less, - std::cmp::Ordering::Equal => COrdering::Equal, - std::cmp::Ordering::Greater => COrdering::Greater, - } - } -} - -impl From for std::cmp::Ordering { - fn from(o: COrdering) -> Self { - match o { - COrdering::Less => std::cmp::Ordering::Less, - COrdering::Equal => std::cmp::Ordering::Equal, - COrdering::Greater => std::cmp::Ordering::Greater, - } - } -} - -#[repr(i8)] -pub enum COptionOrdering { - None = i8::MIN, - Less = -1, - Equal = 0, - Greater = 1, -} - -impl From> for COptionOrdering { - fn from(o: Option) -> Self { - match o { - None => COptionOrdering::None, - Some(std::cmp::Ordering::Less) => COptionOrdering::Less, - Some(std::cmp::Ordering::Equal) => COptionOrdering::Equal, - Some(std::cmp::Ordering::Greater) => COptionOrdering::Greater, - } - } -} - -impl From for Option { - fn from(o: COptionOrdering) -> Self { - match o { - COptionOrdering::None => None, - COptionOrdering::Less => Some(std::cmp::Ordering::Less), - COptionOrdering::Equal => Some(std::cmp::Ordering::Equal), - COptionOrdering::Greater => Some(std::cmp::Ordering::Greater), - } - } -} - -#[repr(C)] -pub struct BitIterHandle<'a> { - pub data: &'a mut dyn Iterator, -} - -#[allow(unused)] -#[repr(C)] -/// Deprecated while issue with iterator rewind is not resolved -pub struct BitIterHandleDeprecated<'a> { - pub data: &'a [u8], -} -#[repr(C)] -pub struct DecodeResHandle { - pub jet: *const (), // *const Result - pub bits_read: usize, -} - -#[repr(C)] -pub struct BitWriterHandle<'a> { - pub _writer: BitWriter<&'a mut Vec>, -} - -#[repr(C)] -pub struct AllJetsHandle { - pub jets: *const CCustomJet, - pub len: usize, -} - -#[derive(WrapperApi)] -pub struct CustomJetApi { - _cmp: extern "C" fn(_self: CCustomJet, other: CCustomJet) -> COrdering, - _partial_cmp: extern "C" fn(_self: CCustomJet, other: CCustomJet) -> COptionOrdering, - _hash: extern "C" fn(_self: CCustomJet, hasher_handle: *mut HasherHandle), - _debug_fmt: extern "C" fn(_self: CCustomJet, fmt_handle: *mut FmtHandle) -> *const (), // *const std::fmt::Result - _display_fmt: extern "C" fn(_self: CCustomJet, fmt_handle: *mut FmtHandle) -> *const (), // *const std::fmt::Result - _from_str: extern "C" fn(name: *const StrHandle) -> *const (), // *const Result - _all_jets: extern "C" fn() -> AllJetsHandle, - _cmr: extern "C" fn(_self: CCustomJet) -> *const CmrHandle, - _source_ty: extern "C" fn(_self: CCustomJet) -> *const TypeNameHandle, - _target_ty: extern "C" fn(_self: CCustomJet) -> *const TypeNameHandle, - _encode: extern "C" fn(_self: CCustomJet, w: *mut BitWriterHandle) -> *const (), // *std::io::Result - _decode: extern "C" fn(w: *mut BitIterHandle) -> DecodeResHandle, - _c_jet_ptr: extern "C" fn(_self: CCustomJet) -> *const (), // * &'static dyn Fn(&mut CFrameItem, CFrameItem, &T) -> bool - _cost: extern "C" fn(_self: CCustomJet) -> *const CostHandle, - _to_base_jet: extern "C" fn(_self: CCustomJet) -> *const (), // * Option - _from_base_jet: extern "C" fn(jet: *const ()) -> CCustomJet, // * BaseJetType -} - -impl CustomJetApi { - pub fn from_str(&self, name: &str) -> Result { - let str_handle = StrHandle { _str: &name }; - unsafe { - *Box::from_raw((self._from_str)(&str_handle) - as *mut Result) - } - } - - pub fn all_jets(&self) -> &'static [CCustomJet] { - unsafe { - let AllJetsHandle { jets, len } = (self._all_jets)(); - std::slice::from_raw_parts(jets, len) - } - } - - pub fn cmp(&self, lhs: CCustomJet, rhs: CCustomJet) -> std::cmp::Ordering { - (self._cmp)(lhs, rhs).into() - } - - pub fn partial_cmp(&self, lhs: CCustomJet, rhs: CCustomJet) -> Option { - (self._partial_cmp)(lhs, rhs).into() - } - - pub fn hash(&self, jet: CCustomJet, hasher: &mut H) { - let mut hasher_handle = HasherHandle { _hasher: hasher }; - (self._hash)(jet, &mut hasher_handle) - } - - pub fn debug_fmt(&self, jet: CCustomJet, formatter: &mut Formatter) -> std::fmt::Result { - let mut fmt_handle = FmtHandle { - _formatter: formatter, - }; - unsafe { *Box::from_raw((self._debug_fmt(jet, &mut fmt_handle)) as *mut std::fmt::Result) } - } - - pub fn display_fmt(&self, jet: CCustomJet, formatter: &mut Formatter) -> std::fmt::Result { - let mut fmt_handle = FmtHandle { - _formatter: formatter, - }; - unsafe { - *Box::from_raw((self._display_fmt(jet, &mut fmt_handle)) as *mut std::fmt::Result) - } - } - - pub fn cmr(&self, jet: CCustomJet) -> Cmr { - *unsafe { Box::from_raw((self._cmr)(jet) as *mut Cmr) } - } - - pub fn source_ty(&self, jet: CCustomJet) -> TypeName { - *unsafe { Box::from_raw((self._source_ty)(jet) as *mut TypeName) } - } - - pub fn target_ty(&self, jet: CCustomJet) -> TypeName { - *unsafe { Box::from_raw((self._target_ty)(jet) as *mut TypeName) } - } - - pub fn encode( - &self, - jet: CCustomJet, - w: &mut BitWriter, - ) -> std::io::Result { - let mut buffer = Vec::new(); - let mut _writer = BitWriter::new(&mut buffer); - - let mut handle = BitWriterHandle { _writer }; - - let res = unsafe { - *Box::from_raw((self._encode)(jet, &mut handle) as *mut std::io::Result) - }; - - match res { - Ok(bits_written) => { - handle._writer.flush_all()?; - - let mut bit_iter = BitIter::from(buffer); - for _ in 0..bits_written { - if let Some(bit) = bit_iter.next() { - w.write_bit(bit)?; - } - } - Ok(bits_written) - } - Err(err) => Err(err), - } - } - - pub fn decode>( - &self, - bits: &mut BitIter, - _: u32, - ) -> Result { - let mut bit_iter_handle = BitIterHandle { - data: bits as &mut dyn Iterator, - }; - - let DecodeResHandle { jet, bits_read: _ } = (self._decode)(&mut bit_iter_handle); - - unsafe { - *Box::from_raw( - jet as *mut Result, - ) - } - } - - /// Deprecated while issue with iterator rewind is not resolved - #[allow(dead_code)] - fn decode_deprecated>( - &self, - bits: &mut BitIter, - max_jet_len: u32, - ) -> Result { - let mut bits_copy = unsafe { std::ptr::read(bits) }; - let mut buffer = Vec::with_capacity(max_jet_len.div_ceil(8) as usize); - let mut writer = BitWriter::from(&mut buffer); - - let mut i = 0; - while let Some(bit) = bits_copy.next() - && i < max_jet_len - { - writer - .write_bit(bit) - .expect("Writing to vec should not fail"); - i += 1; - } - println!(); - writer.flush_all().expect("Writing to vec should not fail"); - - let _handle = BitIterHandleDeprecated { data: &buffer }; - - //let DecodeResHandle { jet, bits_read } = (self._decode)(&mut handle); - let (jet, bits_read) = (std::ptr::null::<()>(), 0); - - let decoded = unsafe { - *Box::from_raw( - jet as *mut Result, - ) - }; - - if decoded.is_ok() { - for _ in 0..bits_read { - bits.next(); - } - } - - decoded - } - - #[allow(clippy::type_complexity)] - pub fn c_jet_ptr( - &self, - jet: CCustomJet, - ) -> &'static (dyn Fn(&mut CFrameItem, CFrameItem, &T) -> bool + Send + Sync) { - unsafe { - *Box::from_raw((self._c_jet_ptr)(jet) - as *mut &'static ( - dyn Fn(&mut CFrameItem, CFrameItem, &T) -> bool + Send + Sync - )) - } - } - - pub fn cost(&self, jet: CCustomJet) -> Cost { - unsafe { *Box::from_raw(self._cost(jet) as *mut Cost) } - } - - /// Tries to convert dynamic jet representation to instance of base type jet. - /// Returns Some if given jet is from base jet set, None if custom. - /// # Safety - /// It's caller responsibility to guarantee that base type inside DLL is same - /// as type provided as generic to this function. - pub unsafe fn to_base_jet(&self, jet: CCustomJet) -> Option { - *unsafe { Box::from_raw(self._to_base_jet(jet) as *mut Option) } - } - - /// Converts base type jet representation to instance of dynamic jet. - /// # Safety - /// It's caller responsibility to guarantee that base type inside DLL is same - /// as type provided as generic to this function. - pub unsafe fn from_base_jet(&self, jet: *const T) -> CCustomJet { - self._from_base_jet(jet as *const ()) - } -} diff --git a/core/src/jets/mod.rs b/core/src/jets/mod.rs index 12a8fde..a66019c 100644 --- a/core/src/jets/mod.rs +++ b/core/src/jets/mod.rs @@ -1,9 +1,7 @@ pub mod bitcoin; -pub mod custom_jet; pub mod elements; pub mod environments; pub mod exec; -pub mod jet_dyn; #[cfg(test)] mod tests { diff --git a/core/src/lib.rs b/core/src/lib.rs index 4ad22e7..e76d265 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -71,8 +71,3 @@ impl From for NetworkKind { } } } - -#[doc(hidden)] -pub mod __simplicity { - pub use hal_simplicity::simplicity; -} diff --git a/core/src/runner.rs b/core/src/runner.rs index 2ef4390..d82546b 100644 --- a/core/src/runner.rs +++ b/core/src/runner.rs @@ -16,7 +16,6 @@ use hal_simplicity::simplicity::{ use hex_literal::hex; use crate::jets::bitcoin::CoreExtension; -use crate::jets::custom_jet::{CustomJet, JetApiProvider}; use crate::jets::elements::ElementsExtension; use crate::jets::environments::UnchainedEnv; use crate::{BitcoinNetwork, ElementsNetwork}; @@ -105,28 +104,6 @@ impl SimplicityRunner { Ok(program.commit_prog().cmr()) } - - // NOTE: We will need unused parameters later when we will add more jets. - pub fn execute_custom( - program: Program>, - _input_idx: usize, - _pst: &P, - redeem_script: Script, - env: Env, - _network: Network, - ) -> Result { - let unchained_env = UnchainedEnv::::new(redeem_script, env); - - let redeem_node = program.redeem_node().ok_or(RunnerError::NoRedeemNode)?; - - let mut mac = - BitMachine::for_program(redeem_node).map_err(RunnerError::BitMachineConstruction)?; - - mac.exec(redeem_node, &unchained_env) - .map_err(RunnerError::ExecutionError)?; - - Ok(program.commit_prog().cmr()) - } } pub fn elements_execution_environment( @@ -181,80 +158,3 @@ fn dummy_control_block() -> ControlBlock { merkle_branch: TaprootMerkleBranch::default(), } } - -#[cfg(test)] -mod tests { - use std::sync::{Arc, LazyLock}; - - use crate::jets::custom_jet::{CustomJet, JetApiProvider}; - use crate::jets::jet_dyn::CustomJetApi; - use crate::runner::{SimplicityRunner, elements_execution_environment}; - - use dlopen2::wrapper::Container; - use hal_simplicity::hal_simplicity::Program; - use hal_simplicity::simplicity::elements::hex::FromHex; - use hal_simplicity::simplicity::elements::{Script, Transaction}; - use hal_simplicity::simplicity::jet::elements::ElementsEnv; - use hex_literal::hex; - - use hal_simplicity::simplicity::elements::encode::deserialize; - use hal_simplicity::simplicity::elements::pset::PartiallySignedTransaction; - - static TEST_DLL: LazyLock>> = LazyLock::new(|| unsafe { - let path = format!( - "{}/../target/debug/libopcode_pubkey_elements.{}", - env!("CARGO_MANIFEST_DIR"), - std::env::consts::DLL_EXTENSION - ); - Container::::load(&path).ok() - }); - - struct TestApi; - impl JetApiProvider for TestApi { - fn get() -> &'static Option> { - &TEST_DLL - } - } - - #[test] - fn it_works() { - let script = Script::from_hex( - "5221033523982d58e94be3b735731593f8225043880d53727235b566c515d24a0f7baf21025eb4655feae15a304653e27441ca8e8ced2bef89c22ab6b20424b4c07b3d14cc52ae" - ).unwrap(); - - // cli/assets/check_opcode.simf - let program_str = "4AmwAAR/oHAIsFIGQVZtoIwCBNiDgUA="; - - let pset_bytes = hex!( - "70736574ff0102040200000001030400000000010401010105010201fb04020000000001014e01499a818545f6bae39fc03b637f2a4e1e64e590cac1bc3a6f6d71aa4443654c140100000000000186a000220020649be4e4f326f85b2187adb0698d9cab59c4b1c747cc6d884211e90e60484cf001070001080100010e201b42ba45a12d33a9efd32b738e603f5c606dcd59353fc5826f7486d4d5459858010f0400000000011004ffffffff00010308b88201000000000007fc04707365740220499a818545f6bae39fc03b637f2a4e1e64e590cac1bc3a6f6d71aa4443654c140104220020649be4e4f326f85b2187adb0698d9cab59c4b1c747cc6d884211e90e60484cf000010308e80300000000000007fc04707365740220499a818545f6bae39fc03b637f2a4e1e64e590cac1bc3a6f6d71aa4443654c1401040000" - ); - - let input_index = 0; - - let pset: PartiallySignedTransaction = deserialize(&pset_bytes).expect("valid PSET"); - - let program = Program::>, TestApi>>::from_str( - program_str, - Some(""), - ) - .expect("Simplicity execution failed"); - - let elements_env = elements_execution_environment( - &pset, - input_index, - program.cmr(), - crate::ElementsNetwork::LiquidTestnet.genesis_hash(), - ) - .expect("Failed to initialize env"); - - _ = SimplicityRunner::execute_custom( - program, - input_index, - &pset, - script, - elements_env, - crate::ElementsNetwork::LiquidTestnet, - ) - .expect("should run"); - } -} diff --git a/jet_plugins/Cargo.toml b/jet_plugins/Cargo.toml deleted file mode 100644 index 154ad3b..0000000 --- a/jet_plugins/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "jet_plugins" -version = "0.1.0" -edition = "2024" - -[lib] -proc-macro = true - -[dependencies] -syn = { version = "2.0", features = ["full"] } -quote = "1.0" -proc-macro2 = "1.0" -bitcoin_hashes = "0.14.1" -core = { path = "../core" } diff --git a/jet_plugins/README.md b/jet_plugins/README.md deleted file mode 100644 index aebd959..0000000 --- a/jet_plugins/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Jet Plugins - -Procedural macros for deriving the `Jet` trait for custom jets. - -## Capabilities - -Given a set of base jets and custom jets, this crate derives the `Jet` trait alongside a C FFI for dynamic jet loading. - -Current Limitations: - -- Does not support deriving traits based solely on custom functions. - -- Does not support deriving traits over arbitrary jet sets (other than Bitcoin and Elements). This is due to API limitations within certain internal components of rust-simplicity. - -## Usage example - -```rust -use jet_plugins::register_jets; -use simplicity_unchained_core::jets::environments::ElementsUnchainedEnv; -use simplicity_unchained_core::__simplicity::simplicity::ffi::CFrameItem; - -fn custom_jet1(_dst: &mut CFrameItem, src: CFrameItem, env: &ElementsUnchainedEnv) -> bool { - false -} -fn custom_jet2(_dst: &mut CFrameItem, src: CFrameItem, env: &ElementsUnchainedEnv) -> bool { - false -} - -register_jets!( - simplicity_unchained_core::__simplicity::simplicity::jet::Elements, - simplicity_unchained_core::jets::environments::ElementsUnchainedEnv, - "custom_jet1" => custom_jet1, b"h", b"h", // source/target type - "custom_jet2" => custom_jet2, b"h", b"h", // source/target type -); -``` diff --git a/jet_plugins/src/c_wrappers.rs b/jet_plugins/src/c_wrappers.rs deleted file mode 100644 index 9dcff4a..0000000 --- a/jet_plugins/src/c_wrappers.rs +++ /dev/null @@ -1,392 +0,0 @@ -//! C FFI for Jet trait. -//! See core::jet_dyn for interface on caller's side. -use crate::static_tokens::StaticTokenInfo; -use quote::quote; - -pub(crate) fn impl_c_ffi( - base_type: &syn::Path, - unchained_env: &syn::Path, -) -> proc_macro2::TokenStream { - let cmp = cmp_c_wrapper(); - let partial_cmp = partial_cmp_c_wrapper(); - let hash = hash_c_wrapper(); - let debug_fmt = debug_fmt_c_wrapper(); - let display_fmt = display_fmt_c_wrapper(); - let all_jets = all_jets(); - - let cmr_c_wrapper = cmr_c_wrapper(); - let src_ty_c_wrapper = src_trg_ty_c_wrapper("source"); - let trg_ty_c_wrapper = src_trg_ty_c_wrapper("target"); - let encode_c_wrapper = encode_c_wrapper(); - let decode_c_wrapper = decode_c_wrapper(); - let cost_c_wrapper = cost_c_wrapper(); - let c_jet_ptr_wrapper = c_jet_ptr_wrapper(unchained_env); - let from_str = from_str_c_wrapper(); - let to_base_jet = to_base_jet(); - let from_base_jet = from_base_jet(base_type); - - quote! { - #cmp - #partial_cmp - #hash - #debug_fmt - #display_fmt - #all_jets - #cmr_c_wrapper - #src_ty_c_wrapper - #trg_ty_c_wrapper - #encode_c_wrapper - #decode_c_wrapper - #cost_c_wrapper - #c_jet_ptr_wrapper - #from_str - #to_base_jet - #from_base_jet - } -} - -fn cost_c_wrapper() -> proc_macro2::TokenStream { - let jet_self = StaticTokenInfo::jet_self_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - let cost_handle = StaticTokenInfo::cost_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _cost(_self: #jet_self) -> *const #cost_handle { - let jet = #enum_ident::variant_from_index(_self.index); - let boxed = Box::new( - <#enum_ident as #jet_trait>::cost(&jet) - ); - Box::into_raw(boxed) as *const #cost_handle - } - } -} - -fn c_jet_ptr_wrapper(unchained_env: &syn::Path) -> proc_macro2::TokenStream { - let jet_self = StaticTokenInfo::jet_self_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let c_frame_item = StaticTokenInfo::cframe_item_path(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _c_jet_ptr(_self: #jet_self) -> *const () { - let jet = #enum_ident::variant_from_index(_self.index); - let boxed: Box< - &'static ( - dyn Fn( - &mut #c_frame_item, - #c_frame_item, - &#unchained_env, - ) -> bool - + Send - + Sync - )> - = Box::new(*C_JET_PTRS - .get(&jet) - .expect("All enum's variants should be initialized") - ); - // * &'static dyn Fn(&mut CFrameItem, CFrameItem, &Self::CJetEnvironment) -> bool - Box::into_raw(boxed) as *const () - } - } -} - -fn decode_c_wrapper() -> proc_macro2::TokenStream { - let bititer_handle = StaticTokenInfo::bititer_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let decode_res_handle = StaticTokenInfo::decode_res_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _decode(bits: *mut #bititer_handle) -> #decode_res_handle { - let bits: &mut dyn Iterator = unsafe { (*bits).data }; - let decode_res = #enum_ident::decode_hardcoded(bits); - - let res = Box::new(match decode_res { - Ok(jet) => { - let index = #enum_ident::variant_to_index(&jet); - Ok(#jet_self { - index - }) - } - Err(err) => Err(err) - }); - - // Mocked to 0 to not bother with restructuring output again. - // Original iterator is already shifted correctly by `decode()` action - //let bits_read = bit_iter.n_total_read(); - let bits_read = 0; - - #decode_res_handle { - // *Result - jet: Box::into_raw(res) as *const (), - bits_read - } - } - } -} - -/// Deprecated while issue with iterator rewind is not resolved -#[allow(dead_code)] -fn decode_c_wrapper_deprecated() -> proc_macro2::TokenStream { - let bititer_handle = StaticTokenInfo::bititer_handle(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - let bit_iter = StaticTokenInfo::bit_iter_path(); - let decode_res_handle = StaticTokenInfo::decode_res_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _decode(w: *mut #bititer_handle) -> #decode_res_handle - { - - let data: &[u8] = unsafe { (*w).data }; - let mut bit_iter = #bit_iter::from(data); - - let decode_res = <#enum_ident as #jet_trait>::decode(&mut bit_iter); - - let res = Box::new(match decode_res { - Ok(jet) => { - let index = #enum_ident::variant_to_index(&jet); - Ok(#jet_self { - index - }) - } - Err(err) => Err(err) - }); - let bits_read = bit_iter.n_total_read(); - - #decode_res_handle { - // *Result - jet: Box::into_raw(res) as *const (), - bits_read - } - - } - } -} - -fn encode_c_wrapper() -> proc_macro2::TokenStream { - let bitwriter_handle = StaticTokenInfo::bitwriter_handle(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _encode(_self: #jet_self, w: *mut #bitwriter_handle) -> *const () { - let jet = #enum_ident::variant_from_index(_self.index); - let bit_writer = unsafe { - &mut (*w)._writer - }; - let boxed = Box::new(<#enum_ident as #jet_trait>::encode(&jet, bit_writer)); - // *std::io::Result - Box::into_raw(boxed) as *const () - } - } -} - -fn src_trg_ty_c_wrapper(mode: &str) -> proc_macro2::TokenStream { - let src_trg_ty = quote::format_ident!("{}", { - match mode { - "source" | "target" => format!("{}_ty", mode), - _ => unreachable!(), - } - }); - - let fn_name = quote::format_ident!("{}", { - match mode { - "source" | "target" => format!("_{}_ty", mode), - _ => unreachable!(), - } - }); - - let typename_handle = StaticTokenInfo::typename_handle(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn #fn_name(_self: #jet_self) -> *const #typename_handle { - let jet = #enum_ident::variant_from_index(_self.index); - let boxed = Box::new(<#enum_ident as #jet_trait>::#src_trg_ty(&jet)); - Box::into_raw(boxed) as *const #typename_handle - } - } -} - -fn cmr_c_wrapper() -> proc_macro2::TokenStream { - let cmr_handle = StaticTokenInfo::cmr_handle(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _cmr(_self: #jet_self) -> *const #cmr_handle { - let jet = #enum_ident::variant_from_index(_self.index); - let boxed = Box::new(<#enum_ident as #jet_trait>::cmr(&jet)); - Box::into_raw(boxed) as *const #cmr_handle - } - } -} - -fn all_jets() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let all_jets_handle = StaticTokenInfo::all_jets_handle(); - let jet_self_handle = StaticTokenInfo::jet_self_handle(); - - quote! { - - static ALL_JETS_HANDLE: std::sync::LazyLock> = std::sync::LazyLock::new(|| { - #enum_ident::ALL.iter().map(|jet| jet.into()).collect::>().into_boxed_slice() - }); - - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _all_jets() -> #all_jets_handle { - #all_jets_handle { - jets: ALL_JETS_HANDLE.as_ptr(), - len: ALL_JETS_HANDLE.len() - } - } - } -} - -fn from_base_jet(base_type: &syn::Path) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self_handle = StaticTokenInfo::jet_self_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _from_base_jet(jet_ptr: *const ()) -> #jet_self_handle { - let jet = unsafe { &*(jet_ptr as *const #base_type) }; - (&#enum_ident::from_base_jet(*jet)).into() - } - } -} - -fn to_base_jet() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self_handle = StaticTokenInfo::jet_self_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _to_base_jet(_self: #jet_self_handle) -> *const () { - let inner_jet = #enum_ident::variant_from_index(_self.index); - let try_to_base = Box::new(inner_jet.to_base_jet()); - - // * Option - Box::into_raw(try_to_base) as *const () - } - } -} - -fn from_str_c_wrapper() -> proc_macro2::TokenStream { - let str_handle = StaticTokenInfo::str_handle(); - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _from_str(name: *const #str_handle) -> *const () { - if name.is_null() { - panic!("null ptr at name"); - } - let _str = unsafe { (*name)._str }; - let parsing_res = <#enum_ident as std::str::FromStr>::from_str(_str.as_ref()); - let boxed = Box::new( - match parsing_res { - Ok(jet) => { - let index = #enum_ident::variant_to_index(&jet); - Ok(#jet_self { - index - }) - }, - Err(err) => Err(err) - } - ); - Box::into_raw(boxed) as *const () - } - } -} - -fn display_fmt_c_wrapper() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let fmt_handle = StaticTokenInfo::fmt_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _display_fmt(_self: #jet_self, fmt_handle: *mut #fmt_handle) -> *const () { - let jet = #enum_ident::variant_from_index(_self.index); - let formatter = unsafe { &mut (*fmt_handle)._formatter }; - let boxed = Box::new(<#enum_ident as std::fmt::Display>::fmt(&jet, formatter)); - Box::into_raw(boxed) as *const () - } - } -} - -fn debug_fmt_c_wrapper() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let fmt_handle = StaticTokenInfo::fmt_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _debug_fmt(_self: #jet_self, fmt_handle: *mut #fmt_handle) -> *const () { - let jet = #enum_ident::variant_from_index(_self.index); - let formatter = unsafe { &mut (*fmt_handle)._formatter }; - let boxed = Box::new(<#enum_ident as core::fmt::Debug>::fmt(&jet, formatter)); - Box::into_raw(boxed) as *const () - } - } -} - -fn hash_c_wrapper() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let hasher_handle = StaticTokenInfo::hasher_handle(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _hash(_self: #jet_self, hasher_handle: *mut #hasher_handle) { - let jet = #enum_ident::variant_from_index(_self.index); - let hasher = unsafe { &mut (*hasher_handle)._hasher }; - <#enum_ident as std::hash::Hash>::hash(&jet, hasher) - } - } -} - -fn partial_cmp_c_wrapper() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let c_option_ordering = StaticTokenInfo::c_option_ordering(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _partial_cmp(_self: #jet_self, other: #jet_self) -> #c_option_ordering { - let lhs = #enum_ident::variant_from_index(_self.index); - let rhs = #enum_ident::variant_from_index(other.index); - #c_option_ordering::from(lhs.partial_cmp(&rhs)) - } - } -} - -fn cmp_c_wrapper() -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let jet_self = StaticTokenInfo::jet_self_handle(); - let c_ordering = StaticTokenInfo::c_ordering(); - - quote! { - #[unsafe(no_mangle)] - pub unsafe extern "C" fn _cmp(_self: #jet_self, other: #jet_self) -> #c_ordering { - let lhs = #enum_ident::variant_from_index(_self.index); - let rhs = #enum_ident::variant_from_index(other.index); - #c_ordering::from(lhs.cmp(&rhs)) - } - } -} diff --git a/jet_plugins/src/decode_trees.rs b/jet_plugins/src/decode_trees.rs deleted file mode 100644 index 3f0f6ed..0000000 --- a/jet_plugins/src/decode_trees.rs +++ /dev/null @@ -1,4963 +0,0 @@ -//! Decoding trees for Bitcoin and Elements. -//! Should be replaced with generic flow when issue with BitIter rewind would be resolved. -use quote::quote; - -use crate::StaticTokenInfo; - -pub(crate) fn bitcoin_decode_tree( - custom_tree: proc_macro2::TokenStream, - base_type: &syn::Path, -) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - - quote! { - decode_bits!(bits, { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Verify)}, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Low1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Low8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Low16)}, - 1 => {#enum_ident::BaseJets(#base_type::Low32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Low64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::High1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::High8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::High16)}, - 1 => {#enum_ident::BaseJets(#base_type::High32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::High64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Complement1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Complement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Complement16)}, - 1 => {#enum_ident::BaseJets(#base_type::Complement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Complement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::And1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::And8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::And16)}, - 1 => {#enum_ident::BaseJets(#base_type::And32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::And64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Or1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Or8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Or16)}, - 1 => {#enum_ident::BaseJets(#base_type::Or32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Or64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Xor1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Xor8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Xor16)}, - 1 => {#enum_ident::BaseJets(#base_type::Xor32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Xor64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Maj1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Maj8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Maj16)}, - 1 => {#enum_ident::BaseJets(#base_type::Maj32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Maj64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::XorXor1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::XorXor8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::XorXor16)}, - 1 => {#enum_ident::BaseJets(#base_type::XorXor32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::XorXor64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Ch1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Ch8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Ch16)}, - 1 => {#enum_ident::BaseJets(#base_type::Ch32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Ch64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Some1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Some8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Some16)}, - 1 => {#enum_ident::BaseJets(#base_type::Some32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Some64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::All8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::All16)}, - 1 => {#enum_ident::BaseJets(#base_type::All32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::All64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Eq8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq16)}, - 1 => {#enum_ident::BaseJets(#base_type::Eq32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq64)}, - 1 => {} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq256)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadLow8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadHigh8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftExtend1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftExtend1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftExtend8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadLow1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadLow1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadLow8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadHigh8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::RightExtend8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShiftWith8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShiftWith16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShiftWith32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShiftWith64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightShiftWith8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShiftWith16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightShiftWith32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShiftWith64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShift8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShift16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShift32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShift64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightShift8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShift16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightShift32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShift64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftRotate8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftRotate16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftRotate32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftRotate64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightRotate8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightRotate16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightRotate32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightRotate64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => {} - } - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::One8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::One16)}, - 1 => {#enum_ident::BaseJets(#base_type::One32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::One64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullAdd8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullAdd16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullAdd32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullAdd64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Add8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Add16)}, - 1 => {#enum_ident::BaseJets(#base_type::Add32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Add64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullIncrement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullIncrement16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullIncrement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullIncrement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Increment8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Increment16)}, - 1 => {#enum_ident::BaseJets(#base_type::Increment32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Increment64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullSubtract8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullSubtract16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullSubtract32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullSubtract64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Subtract8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Subtract16)}, - 1 => {#enum_ident::BaseJets(#base_type::Subtract32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Subtract64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Negate8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Negate16)}, - 1 => {#enum_ident::BaseJets(#base_type::Negate32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Negate64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullDecrement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullDecrement16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullDecrement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullDecrement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Decrement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Decrement16)}, - 1 => {#enum_ident::BaseJets(#base_type::Decrement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Decrement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullMultiply8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullMultiply16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullMultiply32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullMultiply64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Multiply8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Multiply16)}, - 1 => {#enum_ident::BaseJets(#base_type::Multiply32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Multiply64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::IsZero8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IsZero16)}, - 1 => {#enum_ident::BaseJets(#base_type::IsZero32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IsZero64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::IsOne8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IsOne16)}, - 1 => {#enum_ident::BaseJets(#base_type::IsOne32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IsOne64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Le8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Le16)}, - 1 => {#enum_ident::BaseJets(#base_type::Le32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Le64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Lt8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Lt16)}, - 1 => {#enum_ident::BaseJets(#base_type::Lt32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Lt64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Min8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Min16)}, - 1 => {#enum_ident::BaseJets(#base_type::Min32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Min64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Max8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Max16)}, - 1 => {#enum_ident::BaseJets(#base_type::Max32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Max64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Median8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Median16)}, - 1 => {#enum_ident::BaseJets(#base_type::Median32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Median64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::DivMod128_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::DivMod8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::DivMod16)}, - 1 => {#enum_ident::BaseJets(#base_type::DivMod32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::DivMod64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Divide8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Divide16)}, - 1 => {#enum_ident::BaseJets(#base_type::Divide32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Divide64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Modulo8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Modulo16)}, - 1 => {#enum_ident::BaseJets(#base_type::Modulo32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Modulo64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Divides8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Divides16)}, - 1 => {#enum_ident::BaseJets(#base_type::Divides32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Divides64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Block)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Iv)}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add1)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add2)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add8)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add16)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add32)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add64)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add128)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add256)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add512)}, - 1 => {} - } - }, - 1 => {} - } - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8AddBuffer511)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Finalize)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Init)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => {} - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::PointVerify1)}, - 1 => {} - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Decompress)}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LinearVerify1)}, - 1 => {} - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LinearCombination1)}, - 1 => {} - }, - 1 => {#enum_ident::BaseJets(#base_type::Scale)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Generate)}, - 1 => {#enum_ident::BaseJets(#base_type::GejInfinity)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejNormalize)}, - 1 => {#enum_ident::BaseJets(#base_type::GejNegate)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GeNegate)}, - 1 => {#enum_ident::BaseJets(#base_type::GejDouble)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejAdd)}, - 1 => {#enum_ident::BaseJets(#base_type::GejGeAddEx)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GejGeAdd)}, - 1 => {#enum_ident::BaseJets(#base_type::GejRescale)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejIsInfinity)}, - 1 => {#enum_ident::BaseJets(#base_type::GejEquiv)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GejGeEquiv)}, - 1 => {#enum_ident::BaseJets(#base_type::GejXEquiv)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejYIsOdd)}, - 1 => {#enum_ident::BaseJets(#base_type::GejIsOnCurve)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GeIsOnCurve)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarNormalize)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarNegate)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarAdd)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarSquare)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarMultiply)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarMultiplyLambda)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarInvert)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarIsZero)}, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FeNormalize)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FeNegate)}, - 1 => {#enum_ident::BaseJets(#base_type::FeAdd)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FeSquare)}, - 1 => {#enum_ident::BaseJets(#base_type::FeMultiply)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FeMultiplyBeta)}, - 1 => {#enum_ident::BaseJets(#base_type::FeInvert)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FeSquareRoot)}, - 1 => {#enum_ident::BaseJets(#base_type::FeIsZero)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FeIsOdd)}, - 1 => {} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::HashToCurve)}, - 1 => {#enum_ident::BaseJets(#base_type::Swu)} - } - } - } - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CheckSigVerify)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Bip0340Verify)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::ParseLock)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ParseSequence)}, - 1 => {#enum_ident::BaseJets(#base_type::TapdataInit)} - }, - 1 => {} - } - } - } - }, - 1 => {} - }, - 1 => { - 0 => {}, - 1 => { - #custom_tree - } - } - } - } - }) - } -} - -pub(crate) fn elements_decode_tree( - custom_tree: proc_macro2::TokenStream, - base_type: &syn::Path, -) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - - quote! { - decode_bits!(bits, { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Verify)}, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Low1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Low8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Low16)}, - 1 => {#enum_ident::BaseJets(#base_type::Low32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Low64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::High1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::High8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::High16)}, - 1 => {#enum_ident::BaseJets(#base_type::High32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::High64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Complement1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Complement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Complement16)}, - 1 => {#enum_ident::BaseJets(#base_type::Complement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Complement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::And1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::And8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::And16)}, - 1 => {#enum_ident::BaseJets(#base_type::And32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::And64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Or1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Or8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Or16)}, - 1 => {#enum_ident::BaseJets(#base_type::Or32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Or64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Xor1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Xor8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Xor16)}, - 1 => {#enum_ident::BaseJets(#base_type::Xor32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Xor64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Maj1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Maj8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Maj16)}, - 1 => {#enum_ident::BaseJets(#base_type::Maj32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Maj64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::XorXor1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::XorXor8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::XorXor16)}, - 1 => {#enum_ident::BaseJets(#base_type::XorXor32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::XorXor64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Ch1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Ch8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Ch16)}, - 1 => {#enum_ident::BaseJets(#base_type::Ch32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Ch64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Some1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Some8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Some16)}, - 1 => {#enum_ident::BaseJets(#base_type::Some32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Some64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::All8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::All16)}, - 1 => {#enum_ident::BaseJets(#base_type::All32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::All64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq1)}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Eq8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq16)}, - 1 => {#enum_ident::BaseJets(#base_type::Eq32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq64)}, - 1 => {} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Eq256)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullLeftShift64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::FullRightShift64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullRightShift64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::Leftmost64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Leftmost64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost8_1)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost16_1)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost32_1)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_1)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost8_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost16_2)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost32_2)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost64_2)} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost8_4)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost16_4)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost32_4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_4)}, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost16_8)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost32_8)}, - 1 => {#enum_ident::BaseJets(#base_type::Rightmost64_8)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost32_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_16)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Rightmost64_32)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadLow8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadLow32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftPadHigh8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftPadHigh32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftExtend1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftExtend1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftExtend8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftExtend32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadLow1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadLow1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadLow8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadLow32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh1_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::RightPadHigh8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightPadHigh32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend8_16)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend8_32)}, - 1 => {#enum_ident::BaseJets(#base_type::RightExtend8_64)} - }, - 1 => {} - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend16_32)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend16_64)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightExtend32_64)}, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShiftWith8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShiftWith16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShiftWith32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShiftWith64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightShiftWith8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShiftWith16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightShiftWith32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShiftWith64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShift8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShift16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftShift32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftShift64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightShift8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShift16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightShift32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightShift64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::LeftRotate8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftRotate16)}, - 1 => {#enum_ident::BaseJets(#base_type::LeftRotate32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LeftRotate64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::RightRotate8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::RightRotate16)}, - 1 => {#enum_ident::BaseJets(#base_type::RightRotate32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::RightRotate64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => {} - } - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::One8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::One16)}, - 1 => {#enum_ident::BaseJets(#base_type::One32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::One64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullAdd8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullAdd16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullAdd32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullAdd64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Add8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Add16)}, - 1 => {#enum_ident::BaseJets(#base_type::Add32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Add64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullIncrement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullIncrement16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullIncrement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullIncrement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Increment8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Increment16)}, - 1 => {#enum_ident::BaseJets(#base_type::Increment32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Increment64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullSubtract8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullSubtract16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullSubtract32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullSubtract64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Subtract8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Subtract16)}, - 1 => {#enum_ident::BaseJets(#base_type::Subtract32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Subtract64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Negate8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Negate16)}, - 1 => {#enum_ident::BaseJets(#base_type::Negate32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Negate64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullDecrement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullDecrement16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullDecrement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullDecrement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Decrement8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Decrement16)}, - 1 => {#enum_ident::BaseJets(#base_type::Decrement32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Decrement64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FullMultiply8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FullMultiply16)}, - 1 => {#enum_ident::BaseJets(#base_type::FullMultiply32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FullMultiply64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Multiply8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Multiply16)}, - 1 => {#enum_ident::BaseJets(#base_type::Multiply32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Multiply64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::IsZero8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IsZero16)}, - 1 => {#enum_ident::BaseJets(#base_type::IsZero32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IsZero64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::IsOne8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IsOne16)}, - 1 => {#enum_ident::BaseJets(#base_type::IsOne32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IsOne64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Le8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Le16)}, - 1 => {#enum_ident::BaseJets(#base_type::Le32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Le64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Lt8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Lt16)}, - 1 => {#enum_ident::BaseJets(#base_type::Lt32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Lt64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Min8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Min16)}, - 1 => {#enum_ident::BaseJets(#base_type::Min32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Min64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Max8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Max16)}, - 1 => {#enum_ident::BaseJets(#base_type::Max32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Max64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Median8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Median16)}, - 1 => {#enum_ident::BaseJets(#base_type::Median32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Median64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::DivMod128_64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::DivMod8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::DivMod16)}, - 1 => {#enum_ident::BaseJets(#base_type::DivMod32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::DivMod64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Divide8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Divide16)}, - 1 => {#enum_ident::BaseJets(#base_type::Divide32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Divide64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Modulo8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Modulo16)}, - 1 => {#enum_ident::BaseJets(#base_type::Modulo32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Modulo64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::Divides8)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Divides16)}, - 1 => {#enum_ident::BaseJets(#base_type::Divides32)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Divides64)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Block)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Iv)}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add1)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add2)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add4)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add8)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add16)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add32)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add64)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add128)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add256)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Add512)}, - 1 => {} - } - }, - 1 => {} - } - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8AddBuffer511)}, - 1 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Finalize)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Sha256Ctx8Init)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => {} - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::PointVerify1)}, - 1 => {} - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Decompress)}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LinearVerify1)}, - 1 => {} - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::LinearCombination1)}, - 1 => {} - }, - 1 => {#enum_ident::BaseJets(#base_type::Scale)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Generate)}, - 1 => {#enum_ident::BaseJets(#base_type::GejInfinity)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejNormalize)}, - 1 => {#enum_ident::BaseJets(#base_type::GejNegate)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GeNegate)}, - 1 => {#enum_ident::BaseJets(#base_type::GejDouble)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejAdd)}, - 1 => {#enum_ident::BaseJets(#base_type::GejGeAddEx)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GejGeAdd)}, - 1 => {#enum_ident::BaseJets(#base_type::GejRescale)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejIsInfinity)}, - 1 => {#enum_ident::BaseJets(#base_type::GejEquiv)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GejGeEquiv)}, - 1 => {#enum_ident::BaseJets(#base_type::GejXEquiv)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::GejYIsOdd)}, - 1 => {#enum_ident::BaseJets(#base_type::GejIsOnCurve)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::GeIsOnCurve)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarNormalize)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarNegate)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarAdd)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarSquare)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarMultiply)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarMultiplyLambda)}, - 1 => {#enum_ident::BaseJets(#base_type::ScalarInvert)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::ScalarIsZero)}, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {}, - 1 => { - 0 => {}, - 1 => {#enum_ident::BaseJets(#base_type::FeNormalize)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FeNegate)}, - 1 => {#enum_ident::BaseJets(#base_type::FeAdd)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FeSquare)}, - 1 => {#enum_ident::BaseJets(#base_type::FeMultiply)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FeMultiplyBeta)}, - 1 => {#enum_ident::BaseJets(#base_type::FeInvert)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::FeSquareRoot)}, - 1 => {#enum_ident::BaseJets(#base_type::FeIsZero)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::FeIsOdd)}, - 1 => {} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::HashToCurve)}, - 1 => {#enum_ident::BaseJets(#base_type::Swu)} - } - } - } - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CheckSigVerify)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Bip0340Verify)}, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => {}, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::ParseLock)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ParseSequence)}, - 1 => {#enum_ident::BaseJets(#base_type::TapdataInit)} - }, - 1 => {} - } - } - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::SigAllHash)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::TxHash)}, - 1 => {#enum_ident::BaseJets(#base_type::TapEnvHash)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::InputsHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuancesHash)}, - 1 => {#enum_ident::BaseJets(#base_type::InputUtxosHash)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputHash)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputAmountsHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputScriptsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputNoncesHash)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputRangeProofsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputSurjectionProofsHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::InputHash)}, - 1 => {#enum_ident::BaseJets(#base_type::InputOutpointsHash)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::InputSequencesHash)}, - 1 => {#enum_ident::BaseJets(#base_type::InputAnnexesHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::InputScriptSigsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::IssuanceHash)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuanceAssetAmountsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::IssuanceTokenAmountsHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuanceRangeProofsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::IssuanceBlindingEntropyHash)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::InputUtxoHash)}, - 1 => {#enum_ident::BaseJets(#base_type::InputAmountsHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::InputScriptsHash)}, - 1 => {#enum_ident::BaseJets(#base_type::TapleafHash)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::TappathHash)}, - 1 => {#enum_ident::BaseJets(#base_type::OutpointHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::AssetAmountHash)}, - 1 => {#enum_ident::BaseJets(#base_type::NonceHash)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::AnnexHash)}, - 1 => {#enum_ident::BaseJets(#base_type::BuildTapleafSimplicity)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::BuildTapbranch)}, - 1 => {#enum_ident::BaseJets(#base_type::BuildTaptweak)} - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CheckLockHeight)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CheckLockTime)}, - 1 => {#enum_ident::BaseJets(#base_type::CheckLockDistance)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CheckLockDuration)}, - 1 => {#enum_ident::BaseJets(#base_type::TxLockHeight)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::TxLockTime)}, - 1 => {#enum_ident::BaseJets(#base_type::TxLockDistance)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::TxLockDuration)}, - 1 => {#enum_ident::BaseJets(#base_type::TxIsFinal)} - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - } - } - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::Issuance)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuanceAsset)}, - 1 => {#enum_ident::BaseJets(#base_type::IssuanceToken)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuanceEntropy)}, - 1 => {#enum_ident::BaseJets(#base_type::CalculateIssuanceEntropy)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CalculateAsset)}, - 1 => {#enum_ident::BaseJets(#base_type::CalculateExplicitToken)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CalculateConfidentialToken)}, - 1 => {#enum_ident::BaseJets(#base_type::LbtcAsset)} - }, - 1 => {} - }, - 1 => {} - } - }, - 1 => {} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::ScriptCMR)}, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::InternalKey)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentIndex)} - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::NumInputs)}, - 1 => {#enum_ident::BaseJets(#base_type::NumOutputs)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::LockTime)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputAsset)} - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputAmount)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputNonce)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputScriptHash)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputNullDatum)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputIsFee)}, - 1 => {#enum_ident::BaseJets(#base_type::OutputSurjectionProof)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::OutputRangeProof)}, - 1 => {#enum_ident::BaseJets(#base_type::TotalFee)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentPegin)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentPrevOutpoint)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentAsset)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentAmount)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentScriptHash)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentSequence)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentAnnexHash)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentScriptSigHash)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentReissuanceBlinding)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentNewIssuanceContract)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentReissuanceEntropy)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentIssuanceAssetAmount)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentIssuanceTokenAmount)}, - 1 => {#enum_ident::BaseJets(#base_type::CurrentIssuanceAssetProof)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::CurrentIssuanceTokenProof)}, - 1 => {#enum_ident::BaseJets(#base_type::InputPegin)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::InputPrevOutpoint)}, - 1 => {#enum_ident::BaseJets(#base_type::InputAsset)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::InputAmount)}, - 1 => {#enum_ident::BaseJets(#base_type::InputScriptHash)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::InputSequence)}, - 1 => {#enum_ident::BaseJets(#base_type::InputAnnexHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::InputScriptSigHash)}, - 1 => {#enum_ident::BaseJets(#base_type::ReissuanceBlinding)} - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::NewIssuanceContract)}, - 1 => {#enum_ident::BaseJets(#base_type::ReissuanceEntropy)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuanceAssetAmount)}, - 1 => {#enum_ident::BaseJets(#base_type::IssuanceTokenAmount)} - } - }, - 1 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::IssuanceAssetProof)}, - 1 => {#enum_ident::BaseJets(#base_type::IssuanceTokenProof)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::TapleafVersion)}, - 1 => {#enum_ident::BaseJets(#base_type::Tappath)} - } - } - } - }, - 1 => { - 0 => { - 0 => { - 0 => { - 0 => {#enum_ident::BaseJets(#base_type::Version)}, - 1 => {#enum_ident::BaseJets(#base_type::GenesisBlockHash)} - }, - 1 => { - 0 => {#enum_ident::BaseJets(#base_type::TransactionId)}, - 1 => {} - } - }, - 1 => {} - }, - 1 => {} - } - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - } - } - } - }, - 1 => {} - }, - 1 => {} - }, - 1 => {} - }, - 1 => { - #custom_tree - } - } - } - } - }) - } -} diff --git a/jet_plugins/src/helpers.rs b/jet_plugins/src/helpers.rs deleted file mode 100644 index 3620e55..0000000 --- a/jet_plugins/src/helpers.rs +++ /dev/null @@ -1,313 +0,0 @@ -//! Helper functions for implementing CMR and `decode_bits!` macro tree. -use bitcoin_hashes::{Hash, HashEngine, sha256}; -use quote::quote; - -const SIMPLICITY_TAG_PREFIX: &[u8] = b"Simplicity\x1fCommitment\x1f"; -const JETIV: sha256::Midstate = sha256::Midstate([ - 0x95, 0x32, 0xee, 0x28, 0xcd, 0xca, 0x69, 0xde, 0xc8, 0xa0, 0xa2, 0x18, 0xb7, 0x9b, 0xe3, 0x62, - 0xf7, 0x40, 0xce, 0xaf, 0x64, 0x7f, 0x15, 0xb3, 0x8a, 0xed, 0x91, 0x68, 0x16, 0x3f, 0x92, 0x1b, -]); -/// Empty while issue with iterator inside decode is not resolved. -/// Prefix is hardcoded by tree -pub const ENCODE_PREFIX: &[u8] = &[]; -pub type JetCodeBits = u32; -pub const JET_ENC_BITLEN: usize = 16 + 4; // + ENCODE_PREFIX.len(); -// `Jet::encode` uses `write_bits_be` which is bounded to u64 -const _: () = { - let _ = 0 as JetCodeBits; - if std::mem::size_of::() > std::mem::size_of::() { - panic!("JetCodeBits type should not exceed u64") - } -}; - -// Warning: The CMRs generated here does not follow the proper Simplicity specification. -// -// TODO(ivanlele): Build valid Simplicity in Haskell from which we can extract the true CMRs. -// Taken from core::utils -#[allow(unused)] -pub fn cmr(name: &str) -> [u8; 32] { - let name = SIMPLICITY_TAG_PREFIX - .iter() - .chain(name.as_bytes().iter()) - .copied() - .collect::>(); - - let right_state = sha256::Hash::hash(&name).as_byte_array().to_owned(); - - let mut engine = sha256::HashEngine::from_midstate(JETIV, 0); - engine.input(&right_state); - - right_state -} - -/// Helper structure for converting jet bit encoding to `decode_bits!` macro input format -/// By construction ensures that token and left/right can not be Some() simultaneously -pub struct JetDecodeTree { - left: Option>, - right: Option>, - token: Option, -} - -// Stores bit pattern starting from most significant bit to be able to input patterns in BE order i.e. -// 0b111 -> -// 0 => {} -// 1 => { -// 0 => {} -// 1 => { -// 0 => {} -// 1 => { -// Ident -// } -// } -// } -#[derive(Clone)] -pub struct JetBranchCode { - pub bits: JetCodeBits, - pub len: usize, - pub token: proc_macro2::Ident, -} - -impl JetBranchCode { - /// Hashes identifier string and takes `JET_ENC_BITLEN - ENCODE_PREFIX.len()` bits of that hash - /// as jet's encoding alongside with `ENCODE_PREFIX` - pub fn from_ident_fixed(token: proc_macro2::Ident) -> Self { - let mut bits = 0 as JetCodeBits; - let mut cursor = 1 << (JET_ENC_BITLEN - 1 - 4); - - for &bit in ENCODE_PREFIX { - if bit == 1 { - bits |= cursor; - } - cursor >>= 1; - } - - let mut token_branch = [0; std::mem::size_of::()]; - token_branch.copy_from_slice( - &sha256::Hash::hash(token.to_string().as_bytes()).to_byte_array() - [0..std::mem::size_of::()], - ); - let mut token_bits = JetCodeBits::from_le_bytes(token_branch); - - // -4 because prefix is empty. remove when issue resolved - for _ in 0..(JET_ENC_BITLEN - ENCODE_PREFIX.len() - 4) { - if token_bits & 1 == 1 { - bits |= cursor; - } - cursor >>= 1; - token_bits >>= 1; - } - - Self { - bits, - len: JET_ENC_BITLEN - 4, // -4 because prefix is empty. remove when issue resolved - token, - } - } -} - -impl JetDecodeTree { - fn new() -> Self { - Self { - left: None, - right: None, - token: None, - } - } - /// Constructs `JetDecodeTree` from branches. - /// ## Panics - /// Panics if some branches bit patterns collide or some bit pattern is prefix of another - pub fn from_branches(branches: Vec) -> Self { - // check for pattern collision - for i in 0..branches.len() { - for j in (i + 1)..branches.len() { - assert!( - branches[i].bits != branches[j].bits, - "Idents {}, {} collide", - branches[i].token, - branches[j].token - ) - } - } - - let mut res = Self::new(); - - for JetBranchCode { bits, len, token } in branches { - let mut curr = &mut res; - let mut cursor = 1 << (len - 1); - - for _ in 0..len { - if curr.token.is_some() { - panic!( - "Existing branch is a prefix of the new branch {:b} being added", - bits - ); - } - let bit = (bits & cursor) != 0; - - match bit { - false => { - if curr.left.is_none() { - curr.left = Some(Box::new(JetDecodeTree::new())); - } - curr = curr.left.as_mut().expect("Visited branch cannot be empty"); - } - true => { - if curr.right.is_none() { - curr.right = Some(Box::new(JetDecodeTree::new())); - } - curr = curr.right.as_mut().expect("Visited branch cannot be empty"); - } - } - cursor >>= 1; - } - - if curr.left.is_some() || curr.right.is_some() { - panic!("{:b} branch is prefix of some other branch", bits); - } - curr.token = Some(token) - } - - res - } -} - -impl From for proc_macro2::TokenStream { - fn from(value: JetDecodeTree) -> Self { - let (left_branch, right_branch, token) = (value.left, value.right, value.token); - - let (left, right, val) = match (left_branch, right_branch, token) { - (Some(left_branch), Some(right_branch), _) => { - (Self::from(*left_branch), Self::from(*right_branch), None) - } - (Some(left_branch), None, _) => (Self::from(*left_branch), quote! {}, None), - (None, Some(right_branch), _) => (quote! {}, Self::from(*right_branch), None), - (None, None, Some(ident)) => (quote! {}, quote! {}, Some(ident)), - _ => unreachable!("Non null ident implifies null left/right branches by construction"), - }; - - if let Some(ident) = val { - return quote! {Self::#ident}; - } - quote! { - 0 => { - #left - }, - 1 => { - #right - } - } - } -} - -pub fn snake_to_pascal_case(s: &str) -> String { - s.split('_') - .map(|word| { - let mut chars = word.chars(); - match chars.next() { - None => String::new(), - Some(f) => f.to_uppercase().collect::() + chars.as_str(), - } - }) - .collect() -} -pub fn pascal_to_snake_case(s: &str) -> String { - let mut snake = String::new(); - let chars = s.chars().collect::>(); - - chars.windows(2).for_each(|pair| { - if let [curr, next] = pair { - snake.extend(pair[0].to_lowercase()); - if curr.is_lowercase() && !next.is_lowercase() { - snake.push('_'); - } - } - }); - - if let Some(c) = chars.last() { - snake.extend(c.to_lowercase()); - } - - snake -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_to_pascal_case() { - let snake = "valid_str"; - let single = "single"; - let empty = ""; - - assert_eq!(snake_to_pascal_case(snake), "ValidStr"); - assert_eq!(snake_to_pascal_case(single), "Single"); - assert_eq!(snake_to_pascal_case(empty), ""); - } - - #[test] - fn test_to_snake_case() { - let pascal = "PascalCase"; - let single = "Single"; - let acronym = "PAScalCase"; - let empty = ""; - - assert_eq!(pascal_to_snake_case(pascal), "pascal_case"); - assert_eq!(pascal_to_snake_case(single), "single"); - assert_eq!(pascal_to_snake_case(acronym), "pascal_case"); - assert_eq!(pascal_to_snake_case(empty), ""); - } - - fn format_arms(ts: proc_macro2::TokenStream) -> String { - let mut lines: Vec = Vec::new(); - let mut indent = 0usize; - let mut line: Vec<&str> = Vec::new(); - - let s = ts.to_string(); - - let flush = |line: &mut Vec<&str>, indent: usize, lines: &mut Vec| { - if !line.is_empty() { - lines.push(format!("{}{}", " ".repeat(indent), line.join(" "))); - line.clear(); - } - }; - - for token in s.split_whitespace() { - match token { - "{" => { - line.push("{"); - flush(&mut line, indent, &mut lines); - indent += 1; - } - "}" => { - flush(&mut line, indent, &mut lines); - indent = indent.saturating_sub(1); - lines.push(format!("{}}}", " ".repeat(indent))); - } - "," => { - flush(&mut line, indent, &mut lines); - } - t => line.push(t), - } - } - - flush(&mut line, indent, &mut lines); - lines.join("\n") - } - - #[test] - fn test_decode_tree() { - let branches = vec![ - JetBranchCode::from_ident_fixed(quote::format_ident!("CustomJet1")), - JetBranchCode::from_ident_fixed(quote::format_ident!("CustomJet2")), - ]; - println!("jet1 bits {:b} {}", branches[0].bits, branches[0].bits); - - let tree = JetDecodeTree::from_branches(branches); - let tree_tokens: proc_macro2::TokenStream = tree.into(); - - let formatted = format_arms(tree_tokens); - - println!("{}", formatted); - } -} diff --git a/jet_plugins/src/jet_trait.rs b/jet_plugins/src/jet_trait.rs deleted file mode 100644 index 1c6344a..0000000 --- a/jet_plugins/src/jet_trait.rs +++ /dev/null @@ -1,421 +0,0 @@ -use crate::{ - CUSTOM_JET_COST, JetsInput, StaticTokenInfo, - decode_trees::{bitcoin_decode_tree, elements_decode_tree}, - helpers::{JET_ENC_BITLEN, JetBranchCode, JetDecodeTree, cmr}, - pascal_to_snake_case, -}; -use quote::quote; - -pub(crate) fn jet_trait_full( - base_type: &syn::Path, - unchained_env: &syn::Path, - names: &[proc_macro2::Ident], - jets: &JetsInput, - base_type_str: &str, // remove this when issue with decode resolved. it dispatches hardcoded tree inside decode -) -> proc_macro2::TokenStream { - let associated_types = associated_types_impl(unchained_env); - let c_jet_env = c_jet_env_impl(); - let cmr = cmr_impl(names); - - let src_ty = src_trg_ty_impl(names, &build_source_tys(jets), "source"); - let trgt_ty = src_trg_ty_impl(names, &build_target_tys(jets), "target"); - - let jet_codes = build_jet_codes(names); - - let jet_encode = encode_impl(names, &jet_codes); - //let jet_decode_unsafe = decode_unsafe_impl(base_type, jet_codes); - let jet_decode = decode_impl(); - let jet_decode_hardcoded = decode_hardcoded_impl(base_type, base_type_str, jet_codes); - - let c_jet_ptr = c_jet_ptr_impl(); - let c_jet_ptr_builder = c_jet_ptr_table_impl(base_type, unchained_env, names, jets); - let cost = cost_impl(); - - let jet_trait_path = StaticTokenInfo::jet_trait_path(); - let enum_ident = StaticTokenInfo::enum_ident(); - - let invalid_jet_err = StaticTokenInfo::invalid_jet_err(); - let end_of_stream_err = StaticTokenInfo::end_of_stream_err(); - - let fmt_impl = fmt_trait_full(names); - let from_str_impl = from_str_trait_full(base_type, names); - - quote! { - // maybe consider moving it somewhere - macro_rules! decode_bits { - ($bits:ident, {}) => { - Err(#invalid_jet_err.into()) - }; - ($bits:ident, {$jet:expr}) => { - Ok($jet) - }; - ($bits:ident, { 0 => $false_branch:tt, 1 => $true_branch:tt }) => { - match $bits.next() { - None => Err(#end_of_stream_err.into()), - Some(false) => decode_bits!($bits, $false_branch), - Some(true) => decode_bits!($bits, $true_branch), - } - }; - } - #c_jet_ptr_builder - impl #enum_ident { - //#jet_decode_unsafe - #jet_decode_hardcoded - } - impl #jet_trait_path for #enum_ident { - #associated_types - #c_jet_env - #cmr - #src_ty - #trgt_ty - #jet_encode - #jet_decode - #c_jet_ptr - #cost - } - - #fmt_impl - #from_str_impl - } -} - -// TODO: settle on namings -fn from_str_trait_full( - base_type: &syn::Path, - names: &[proc_macro2::Ident], -) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let snake_case_names = names - .iter() - .map(|name| pascal_to_snake_case(&name.to_string())); - let simpl_err_ty = StaticTokenInfo::simplicity_error_ty(); - quote! { - impl std::str::FromStr for #enum_ident { - type Err = #simpl_err_ty; - - fn from_str(s: &str) -> Result { - match s { - #(#snake_case_names => Ok(Self::#names), )* - _ => { - let inner_jet = s.parse::<#base_type>()?; - Ok(Self::BaseJets(inner_jet)) - } - } - } - } - } -} - -// TODO: settle on namings -fn fmt_trait_full(names: &[proc_macro2::Ident]) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let snake_case_names = names - .iter() - .map(|name| pascal_to_snake_case(&name.to_string())); - quote! { - impl std::fmt::Display for #enum_ident { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::BaseJets(inner_jet) => f.write_str(&inner_jet.to_string()), - #(Self::#names => f.write_str(#snake_case_names), )* - } - } - } - } -} - -fn cost_impl() -> proc_macro2::TokenStream { - let cost_path = StaticTokenInfo::cost_path(); - quote! { - fn cost(&self) -> #cost_path { - match self { - Self::BaseJets(inner_jet) => inner_jet.cost(), - _ => #cost_path::from_milliweight(#CUSTOM_JET_COST) - } - } - } -} - -fn c_jet_ptr_impl() -> proc_macro2::TokenStream { - let c_frame_path = StaticTokenInfo::cframe_item_path(); - - quote! { - fn c_jet_ptr(&self) -> &dyn Fn(&mut #c_frame_path, #c_frame_path, &Self::CJetEnvironment) -> bool { - C_JET_PTRS.get(self).expect("All enum variants should be initialized") - } - } -} - -/// May have issues with env casting -fn c_jet_ptr_table_impl( - base_type: &syn::Path, - unchained_env: &syn::Path, - names: &[proc_macro2::Ident], - inputs: &JetsInput, -) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let c_frame_item = StaticTokenInfo::cframe_item_path(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - let funcs = inputs.jets.iter().map(|jet| jet.func.clone()); - - quote! { - static C_JET_PTRS: std::sync::LazyLock< - std::collections::HashMap< - #enum_ident, - &'static ( - dyn Fn( - &mut #c_frame_item, - #c_frame_item, - &#unchained_env, - ) -> bool - + Send - + Sync - ), - >, - > = std::sync::LazyLock::new(|| build_c_jet_ptrs()); - - fn build_c_jet_ptrs() - -> std::collections::HashMap< - #enum_ident, - &'static ( - dyn Fn( - &mut #c_frame_item, - #c_frame_item, - &#unchained_env, - ) -> bool - + Send - + Sync - ), - > { - #enum_ident::ALL - .iter() - .map(|jet| { - let boxed: Box< - dyn Fn(&mut #c_frame_item, #c_frame_item, &#unchained_env) -> bool + Send + Sync, - > = match jet { - #enum_ident::BaseJets(inner_jet) => Box::new( - move |dst: &mut #c_frame_item, src: #c_frame_item, env: &#unchained_env| -> bool { - <#base_type as #jet_trait>::c_jet_ptr(inner_jet)(dst, src, env.into()) - }, - ), - // custom jets - #(#enum_ident::#names => Box::new( - move |dst: &mut #c_frame_item, src: #c_frame_item, env: &#unchained_env| -> bool { - #funcs(dst, src, env) - }, - ), )* - }; - let leaked: &'static ( - dyn Fn(&mut #c_frame_item, #c_frame_item, &#unchained_env) -> bool - + Send - + Sync - ) = Box::leak(boxed); - (*jet, leaked) - }) - .collect() - } - } -} - -fn decode_impl() -> proc_macro2::TokenStream { - let bit_iter = StaticTokenInfo::bit_iter_path(); - let decode_err = StaticTokenInfo::decode_err(); - let _enum_ident = StaticTokenInfo::enum_ident(); - - quote! { - fn decode>(bits: &mut #bit_iter) -> Result { - - // Uncomment when issue with iter rewinding will be resolved - //#enum_ident::decode_unsafe(bits) - todo!("Trait impl is empty while issue with iterator rewind not resolved. Use FFI version instead") - } - } -} - -fn decode_hardcoded_impl( - base_type: &syn::Path, - base_type_str: &str, - codes: Vec, -) -> proc_macro2::TokenStream { - let custom_tree: proc_macro2::TokenStream = JetDecodeTree::from_branches(codes).into(); - let decode_err = StaticTokenInfo::decode_err(); - - let decode_tree = match base_type_str { - "Core" => bitcoin_decode_tree(custom_tree, base_type), - "Elements" => elements_decode_tree(custom_tree, base_type), - _ => unreachable!("decode: unkown tree dispatcher"), - }; - - quote! { - fn decode_hardcoded(bits: &mut dyn Iterator) -> Result { - #decode_tree - } - } -} - -/// Deprecated while issue with iterator rewind not resolved. -#[allow(dead_code)] -fn decode_unsafe_impl( - base_type: &syn::Path, - codes: Vec, -) -> proc_macro2::TokenStream { - let custom_decode_tree: proc_macro2::TokenStream = JetDecodeTree::from_branches(codes).into(); - let decode_err = StaticTokenInfo::decode_err(); - let bit_iter = StaticTokenInfo::bit_iter_path(); - let jet_trait = StaticTokenInfo::jet_trait_path(); - - quote! { - pub fn decode_unsafe>(bits: &mut #bit_iter) -> Result { - let (mut elements_iter, mut custom_iter) = - unsafe { (std::ptr::read(bits), std::ptr::read(bits)) }; - - let bits_read = bits.n_total_read(); - - let try_elements = <#base_type as #jet_trait>::decode(&mut elements_iter); - - if let Ok(jet) = try_elements { - for _ in 0..(elements_iter.n_total_read() - bits_read) { - bits.next(); - } - - std::mem::forget(elements_iter); - std::mem::forget(custom_iter); - - return Ok(Self::BaseJets(jet)); - } - - let custom_iter_ref = &mut custom_iter; - let try_custom = decode_bits!(custom_iter_ref, { - #custom_decode_tree - }); - - if try_custom.is_ok() { - for _ in 0..(custom_iter.n_total_read() - bits_read) { - bits.next(); - } - } - - std::mem::forget(elements_iter); - std::mem::forget(custom_iter); - - try_custom - } - } -} - -fn encode_impl( - variants: &[proc_macro2::Ident], - codes: &[JetBranchCode], -) -> proc_macro2::TokenStream { - let code_len = JET_ENC_BITLEN; - let codes_bits = codes - .iter() - .map(|code| code.bits | (15 << (JET_ENC_BITLEN - 4))); // remove when hardcoded decode trees resolved - let bit_writer = StaticTokenInfo::bit_writer_path(); - - quote! { - fn encode(&self, w: &mut #bit_writer) -> std::io::Result { - if let Self::BaseJets(inner_jet) = self { - return inner_jet.encode(w); - } - - let (n, len) = match self { - #(Self::#variants => (#codes_bits, #code_len), )* - _ => unreachable!("encode: all custom variants should be listed"), - }; - - w.write_bits_be(n as u64, len) - } - } -} - -fn src_trg_ty_impl( - variants: &[proc_macro2::Ident], - types: &[Vec], - mode: &str, -) -> proc_macro2::TokenStream { - let type_name_path = StaticTokenInfo::type_name_path(); - let source_or_target_ty = match mode { - "source" => quote::format_ident!("source_ty"), - "target" => quote::format_ident!("target_ty"), - _ => unreachable!("src/trg_ty: unknown dispatcher"), - }; - quote! { - fn #source_or_target_ty(&self) -> #type_name_path { - if let Self::BaseJets(inner_jet) = self { - return inner_jet.#source_or_target_ty(); - } - - let name = match self { - #(Self::#variants => &[#(#types,)*],)* - _ => unreachable!("src/trg_ty: all custom variants should be listed"), - }; - - #type_name_path(name) - } - } -} - -fn cmr_impl(variants: &[proc_macro2::Ident]) -> proc_macro2::TokenStream { - let cmr_by_path = StaticTokenInfo::cmr_path(); - let cmrs = variants - .iter() - .map(|ident| { - let ident_str = ident.to_string(); - cmr(&pascal_to_snake_case(&ident_str)) - }) - .collect::>(); - - quote! { - fn cmr(&self) -> #cmr_by_path { - if let Self::BaseJets(inner_jet) = self { - return inner_jet.cmr(); - } - - let bytes = match self { - #(Self::#variants => [#(#cmrs,)*],)* - _ => unreachable!("cmr: all custom variants should be listed"), - }; - - #cmr_by_path::from_byte_array(bytes) - } - } -} - -fn c_jet_env_impl() -> proc_macro2::TokenStream { - quote! { - fn c_jet_env(env: &Self::Environment) -> &Self::CJetEnvironment { - // For the time being, we are goint to use the initial environment for unchained jets, - // as we are going to implement them in rust. - env - } - } -} - -fn associated_types_impl(unchained_env: &syn::Path) -> proc_macro2::TokenStream { - quote! { - type Environment = #unchained_env; - type CJetEnvironment = #unchained_env; - } -} - -fn build_jet_codes(variants: &[proc_macro2::Ident]) -> Vec { - variants - .iter() - .map(|ident| JetBranchCode::from_ident_fixed(ident.clone())) - .collect() -} - -fn build_target_tys(jets: &JetsInput) -> Vec> { - jets.jets - .iter() - .map(|jet| jet.target_type.value()) - .collect() -} - -fn build_source_tys(jets: &JetsInput) -> Vec> { - jets.jets - .iter() - .map(|jet| jet.source_type.value()) - .collect() -} diff --git a/jet_plugins/src/lib.rs b/jet_plugins/src/lib.rs deleted file mode 100644 index f0d0a07..0000000 --- a/jet_plugins/src/lib.rs +++ /dev/null @@ -1,259 +0,0 @@ -#![recursion_limit = "256"] -use quote::quote; -use syn::{ - Ident, LitByteStr, LitStr, Token, - parse::{Parse, ParseStream}, - parse2, - punctuated::Punctuated, -}; - -mod c_wrappers; -mod decode_trees; -mod helpers; -mod jet_trait; -mod static_tokens; -use helpers::snake_to_pascal_case; - -use crate::{ - c_wrappers::impl_c_ffi, helpers::pascal_to_snake_case, jet_trait::jet_trait_full, - static_tokens::StaticTokenInfo, -}; - -const CUSTOM_JET_COST: u32 = 1000; - -/// Implements `Jet` trait and C FFI compatible with `simplicity_unchained_core::jets::jet_dyn` interface. -/// -/// ## Arguments -/// - `base_type` - a collection of jets the extension will be built on; -/// - `env` - environment type; -/// - `name: literal` - name of jet in snake case; -/// - `function: Fn(CFrameItem, CFrameItem, &ElementsUnchainedEnv)`; -/// -/// see `simplicity::jet::type_name` -/// -/// - `source_type: &[u8]` -/// - `target_type: &[u8]` -/// -/// # Note -/// Right now macro will **panic** if `base_type` other than `Bitcoin` or `Elements` provided due to issue -/// with `decode()` implementation. -/// -/// ## Prerequisites -/// Make sure that input env type implements `Into`, where T is type, which base jets use as env for `c_jet_ptr()`. -/// -/// ## Usage -/// ```rust -/// use jet_plugins::register_jets; -/// use simplicity_unchained_core::jets::environments::ElementsUnchainedEnv; -/// use simplicity_unchained_core::__simplicity::simplicity::ffi::CFrameItem; -/// -/// fn custom_jet1(_dst: &mut CFrameItem, src: CFrameItem, env: &ElementsUnchainedEnv) -> bool { -/// false -/// } -/// -/// fn custom_jet2(_dst: &mut CFrameItem, src: CFrameItem, env: &ElementsUnchainedEnv) -> bool { -/// false -/// } -/// register_jets!( -/// simplicity_unchained_core::__simplicity::simplicity::jet::Elements, -/// simplicity_unchained_core::jets::environments::ElementsUnchainedEnv, -/// "custom_jet1" => custom_jet1, b"h", b"h", // source/target type -/// "custom_jet2" => custom_jet2, b"h", b"h", // source/target type -/// ); -/// ``` -#[proc_macro] -pub fn register_jets(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - let input: JetsInput = parse2(input.into()).expect("Failed to parse JetsInput"); - - let base_type = &input.base_type; - let unchained_env = &input.env_type; - let names = build_custom_fields(&input); - - let base_type_str = base_type - .segments - .last() - .expect("Path should contain last Ident") - .ident - .to_string(); - - let self_impl = self_impl_full(base_type, &names); - let jet_trait_impl = jet_trait_full(base_type, unchained_env, &names, &input, &base_type_str); - let c_ffi = impl_c_ffi(base_type, unchained_env); - - quote! { - #self_impl - #jet_trait_impl - #c_ffi - } - .into() -} - -pub(crate) struct JetsInput { - base_type: syn::Path, - _comma1: Token![,], - env_type: syn::Path, - _comma2: Token![,], - jets: Punctuated, -} - -impl Parse for JetsInput { - fn parse(input: ParseStream) -> syn::Result { - Ok(JetsInput { - base_type: input.parse()?, - _comma1: input.parse()?, - env_type: input.parse()?, - _comma2: input.parse()?, - jets: input.parse_terminated(JetDef::parse, Token![,])?, - }) - } -} - -struct JetDef { - name: LitStr, - _arrow: Token![=>], - pub func: Ident, - _comma1: Token![,], - source_type: LitByteStr, - _comma2: Token![,], - target_type: LitByteStr, -} - -impl Parse for JetDef { - fn parse(input: ParseStream) -> syn::Result { - Ok(JetDef { - // TODO: guarantee that its non-empty and starts from letter - name: input.parse()?, - _arrow: input.parse()?, - func: input.parse()?, - _comma1: input.parse()?, - source_type: input.parse()?, - _comma2: input.parse()?, - target_type: input.parse()?, - }) - } -} - -fn self_impl_full(base_type: &syn::Path, names: &[proc_macro2::Ident]) -> proc_macro2::TokenStream { - let definition = enum_definition_impl(base_type, names); - let all_impl = all_constant_impl(base_type, names); - - quote! { - #definition - #all_impl - } -} - -fn enum_definition_impl( - base_type: &syn::Path, - variants: &[proc_macro2::Ident], -) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - quote! { - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] - pub enum #enum_ident { - BaseJets(#base_type), - #( #variants, )* - } - } -} - -fn build_custom_fields(jets: &JetsInput) -> Vec { - jets.jets - .iter() - .map(|jet| quote::format_ident!("{}", snake_to_pascal_case(&jet.name.value()))) - .collect::>() -} - -fn all_constant_impl( - base_type: &syn::Path, - variants: &[proc_macro2::Ident], -) -> proc_macro2::TokenStream { - let enum_ident = StaticTokenInfo::enum_ident(); - let custom_jets_num = variants.len(); - let jet_self_handle = StaticTokenInfo::jet_self_handle(); - - quote! { - impl #enum_ident { - - // TODO: BaseJets local elements instead of dep - pub const ALL_JETS_NUM: usize = #base_type::ALL.len() + #custom_jets_num; - pub const ALL: [Self; Self::ALL_JETS_NUM] = Self::build_all_variants(); - - const fn build_all_variants() -> [Self; Self::ALL_JETS_NUM] { - - // consider moving it outside of macro - struct AllVariantsBuilder { - data: [std::mem::MaybeUninit; LEN], - len: usize, - } - - impl AllVariantsBuilder { - const fn new() -> Self { - Self { - data: [std::mem::MaybeUninit::uninit(); LEN], - len: 0, - } - } - - const fn push(&mut self, item: Enum) { - assert!(self.len < self.data.len()); - - self.data[self.len].write(item); - self.len += 1; - } - - const fn finalize(self) -> [Enum; LEN] { - assert!(self.len == LEN); - - let ptr = &self.data as *const [std::mem::MaybeUninit; LEN] as *const [Enum; LEN]; - let res = unsafe { std::ptr::read(ptr) }; - - std::mem::forget(self.data); - - res - } - } - - let mut builder = AllVariantsBuilder::new(); - - let mut i = 0; - - while i < #base_type::ALL.len() { - builder.push(#enum_ident::BaseJets(#base_type::ALL[i])); - i += 1; - } - - #(builder.push(#enum_ident::#variants);)* - builder.finalize() - } - - /// Returns index of `self` inside `Self::ALL` array - pub fn variant_to_index(&self) -> usize { - Self::ALL.iter().position(|x| x == self).expect("ALL must contain all enum's variants") - } - - pub fn variant_from_index(idx: usize) -> Self { - Self::ALL[idx] - } - - pub fn to_base_jet(&self) -> Option<#base_type> { - match self { - Self::BaseJets(jet) => Some(*jet), - _ => None - } - } - - pub fn from_base_jet(jet: #base_type) -> Self { - Self::BaseJets(jet) - } - } - - impl Into<#jet_self_handle> for &#enum_ident { - fn into(self) -> #jet_self_handle { - #jet_self_handle { - index: self.variant_to_index() - } - } - } - } -} diff --git a/jet_plugins/src/static_tokens.rs b/jet_plugins/src/static_tokens.rs deleted file mode 100644 index 24164d2..0000000 --- a/jet_plugins/src/static_tokens.rs +++ /dev/null @@ -1,139 +0,0 @@ -const STRUCT_EXTENSION_NAME: &str = "JetExtension"; - -const JET_TRAIT_PATH: &str = "simplicity_unchained_core::__simplicity::simplicity::jet::Jet"; -const BIT_WRITER_PATH: &str = "simplicity_unchained_core::__simplicity::simplicity::BitWriter"; -const BIT_ITER_PATH: &str = "simplicity_unchained_core::__simplicity::simplicity::BitIter"; -const CMR_PATH: &str = "simplicity_unchained_core::__simplicity::simplicity::Cmr"; -const COST_PATH: &str = "simplicity_unchained_core::__simplicity::simplicity::Cost"; -const INVALID_JET_ERR: &str = - "simplicity_unchained_core::__simplicity::simplicity::decode::Error::InvalidJet"; -const END_OF_STREAM_ERR: &str = - "simplicity_unchained_core::__simplicity::simplicity::decode::Error::EndOfStream"; -const DECODE_ERR_TY: &str = "simplicity_unchained_core::__simplicity::simplicity::decode::Error"; -const TYPE_NAME_PATH: &str = - "simplicity_unchained_core::__simplicity::simplicity::jet::type_name::TypeName"; -const CFRAME_ITEM_PATH: &str = - "simplicity_unchained_core::__simplicity::simplicity::ffi::CFrameItem"; -const SIMPLICITY_ERROR_TY: &str = "simplicity_unchained_core::__simplicity::simplicity::Error"; - -// C FFI stuff -const JET_SELF_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::CCustomJet"; -const CMR_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::CmrHandle"; -const TYPENAME_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::TypeNameHandle"; -const BIT_WRITER_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::BitWriterHandle"; -const BIT_ITER_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::BitIterHandle"; -const C_ORDERING: &str = "simplicity_unchained_core::jets::jet_dyn::COrdering"; -const C_OPTION_ORDERING: &str = "simplicity_unchained_core::jets::jet_dyn::COptionOrdering"; -const HASHER_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::HasherHandle"; -const FMT_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::FmtHandle"; -const STR_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::StrHandle"; -const COST_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::CostHandle"; -const ALL_JETS_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::AllJetsHandle"; -const DECODE_RES_HANDLE: &str = "simplicity_unchained_core::jets::jet_dyn::DecodeResHandle"; - -pub(crate) struct StaticTokenInfo {} - -impl StaticTokenInfo { - pub fn enum_ident() -> proc_macro2::Ident { - quote::format_ident!("{}", STRUCT_EXTENSION_NAME) - } - - pub fn jet_trait_path() -> syn::Path { - syn::parse_str(JET_TRAIT_PATH).expect("Failed to find Jet trait by given path") - } - - pub fn bit_iter_path() -> syn::Path { - syn::parse_str(BIT_ITER_PATH).expect("Failed to find BitIter by given path") - } - - pub fn bit_writer_path() -> syn::Path { - syn::parse_str(BIT_WRITER_PATH).expect("Failed to find BitWriter by given path") - } - - pub fn invalid_jet_err() -> syn::Path { - syn::parse_str(INVALID_JET_ERR) - .expect("Failed to find simplicity::decode::Error::InvalidJet by given path") - } - - pub fn end_of_stream_err() -> syn::Path { - syn::parse_str(END_OF_STREAM_ERR) - .expect("Failed to find simplicity::decode::Error::EndOfStream by given path") - } - - pub fn decode_err() -> syn::Path { - syn::parse_str(DECODE_ERR_TY) - .expect("Failed to find simplicity::decode::Error by given path") - } - - pub fn cmr_path() -> syn::Path { - syn::parse_str(CMR_PATH).expect("Failed to find Cmr by given path") - } - - pub fn cost_path() -> syn::Path { - syn::parse_str(COST_PATH).expect("Failed to find Cost by given path") - } - - pub fn type_name_path() -> syn::Path { - syn::parse_str(TYPE_NAME_PATH).expect("Failed to find TypeName by given path") - } - - pub fn cframe_item_path() -> syn::Path { - syn::parse_str(CFRAME_ITEM_PATH).expect("Failed to find CFrame by given path") - } - - pub fn simplicity_error_ty() -> syn::Path { - syn::parse_str(SIMPLICITY_ERROR_TY).expect("Failed to find simplicity::Error by given path") - } - - pub fn jet_self_handle() -> syn::Path { - syn::parse_str(JET_SELF_HANDLE).expect("Failed to find JetSelfHandle by given path") - } - - pub fn cmr_handle() -> syn::Path { - syn::parse_str(CMR_HANDLE).expect("Failed to find CmrHandle by given path") - } - - pub fn typename_handle() -> syn::Path { - syn::parse_str(TYPENAME_HANDLE).expect("Failed to find TypeNameHandle by given path") - } - - pub fn bitwriter_handle() -> syn::Path { - syn::parse_str(BIT_WRITER_HANDLE).expect("Failed to find BitWriterHandle by given path") - } - - pub fn bititer_handle() -> syn::Path { - syn::parse_str(BIT_ITER_HANDLE).expect("Failed to find BitIterHandle by given path") - } - - pub fn c_ordering() -> syn::Path { - syn::parse_str(C_ORDERING).expect("Failed to find COrdering by given path") - } - - pub fn c_option_ordering() -> syn::Path { - syn::parse_str(C_OPTION_ORDERING).expect("Failed to find COptionOrdering by given path") - } - - pub fn hasher_handle() -> syn::Path { - syn::parse_str(HASHER_HANDLE).expect("Failed to find HasherHandle by given path") - } - - pub fn fmt_handle() -> syn::Path { - syn::parse_str(FMT_HANDLE).expect("Failed to find FmtHandle by given path") - } - - pub fn str_handle() -> syn::Path { - syn::parse_str(STR_HANDLE).expect("Failed to find StrHandle by given path") - } - - pub fn cost_handle() -> syn::Path { - syn::parse_str(COST_HANDLE).expect("Failed to find CostHandle by given path") - } - - pub fn all_jets_handle() -> syn::Path { - syn::parse_str(ALL_JETS_HANDLE).expect("Failed to find AllJetsHandle by given path") - } - - pub fn decode_res_handle() -> syn::Path { - syn::parse_str(DECODE_RES_HANDLE).expect("Failed to find DecodeResHandle by given path") - } -} diff --git a/plugin_tests/bitcoin/Cargo.toml b/plugin_tests/bitcoin/Cargo.toml deleted file mode 100644 index 90c7e6f..0000000 --- a/plugin_tests/bitcoin/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "bitcoin" -version = "0.1.0" -edition = "2024" - -[dependencies] -hal-simplicity = { workspace = true } -core = { path = "../../core" } -jet_plugins = { path = "../../jet_plugins" } - -[lib] -crate-type = ["cdylib"] diff --git a/plugin_tests/bitcoin/src/lib.rs b/plugin_tests/bitcoin/src/lib.rs deleted file mode 100644 index aef807e..0000000 --- a/plugin_tests/bitcoin/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -use hal_simplicity::simplicity::ffi::CFrameItem; -use jet_plugins::register_jets; - -use simplicity_unchained_core::jets::environments::BitcoinUnchainedEnv; - -pub fn custom_jet1_bitcoin(_dst: &mut CFrameItem, _: CFrameItem, _: &BitcoinUnchainedEnv) -> bool { - false -} - -pub fn custom_jet2_bitcoin(_dst: &mut CFrameItem, _: CFrameItem, _: &BitcoinUnchainedEnv) -> bool { - false -} - -register_jets!( - hal_simplicity::simplicity::jet::Core, - simplicity_unchained_core::jets::environments::BitcoinUnchainedEnv, - "custom_jet_1" => custom_jet1_bitcoin, b"h", b"h", - "custom_jet_2" => custom_jet2_bitcoin, b"h", b"h", -); diff --git a/plugin_tests/elements/Cargo.toml b/plugin_tests/elements/Cargo.toml deleted file mode 100644 index 49b2991..0000000 --- a/plugin_tests/elements/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "elements" -version = "0.1.0" -edition = "2024" - -[dependencies] -hal-simplicity = { workspace = true } -core = { path = "../../core" } -jet_plugins = { path = "../../jet_plugins" } - -[lib] -crate-type = ["cdylib"] diff --git a/plugin_tests/elements/src/lib.rs b/plugin_tests/elements/src/lib.rs deleted file mode 100644 index f9ab2f3..0000000 --- a/plugin_tests/elements/src/lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -use hal_simplicity::simplicity::ffi::CFrameItem; -use jet_plugins::register_jets; - -use simplicity_unchained_core::jets::environments::ElementsUnchainedEnv; - -pub fn custom_jet1_elements( - _dst: &mut CFrameItem, - _: CFrameItem, - _: &ElementsUnchainedEnv, -) -> bool { - false -} - -pub fn custom_jet2_elements( - _dst: &mut CFrameItem, - _: CFrameItem, - _: &ElementsUnchainedEnv, -) -> bool { - false -} - -register_jets!( - hal_simplicity::simplicity::jet::Elements, - simplicity_unchained_core::jets::environments::ElementsUnchainedEnv, - "custom_jet_1" => custom_jet1_elements, b"h", b"h", - "custom_jet_2" => custom_jet2_elements, b"h", b"h", -); diff --git a/plugin_tests/opcode_pubkey_bitcoin/Cargo.toml b/plugin_tests/opcode_pubkey_bitcoin/Cargo.toml deleted file mode 100644 index 584b3e8..0000000 --- a/plugin_tests/opcode_pubkey_bitcoin/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "opcode_pubkey_bitcoin" -version = "0.1.0" -edition = "2024" - -[dependencies] -hal-simplicity = { workspace = true } -core = { path = "../../core" } -jet_plugins = { path = "../../jet_plugins" } - -[lib] -crate-type = ["cdylib"] diff --git a/plugin_tests/opcode_pubkey_bitcoin/src/lib.rs b/plugin_tests/opcode_pubkey_bitcoin/src/lib.rs deleted file mode 100644 index f45d2e4..0000000 --- a/plugin_tests/opcode_pubkey_bitcoin/src/lib.rs +++ /dev/null @@ -1,86 +0,0 @@ -//! For testing interaction with SimplicityHL -use hal_simplicity::simplicity::{elements::opcodes::all::OP_PUSHBYTES_33, ffi::CFrameItem}; -use jet_plugins::register_jets; -use simplicity_unchained_core::jets::environments::BitcoinUnchainedEnv; - -#[allow(unused)] -unsafe extern "C" { - fn rustsimplicity_0_6_write8(dst: *mut CFrameItem, n: u64); - fn rustsimplicity_0_6_write16(dst: *mut CFrameItem, n: u16); - fn rustsimplicity_0_6_write32(dst: *mut CFrameItem, n: u32); - fn rustsimplicity_0_6_write64(dst: *mut CFrameItem, n: u64); - - fn rustsimplicity_0_6_read8(src: *const CFrameItem) -> u64; - fn rustsimplicity_0_6_read16(src: *const CFrameItem) -> u16; - fn rustsimplicity_0_6_read32(src: *const CFrameItem) -> u32; - fn rustsimplicity_0_6_read64(src: *const CFrameItem) -> u64; -} - -/// 2^8 |- 2^8 -/// -/// Returns the opcode at the given index in the redeem script, each opcode is one byte. -pub fn get_opcode_from_script( - dst: &mut CFrameItem, - src: CFrameItem, - env: &BitcoinUnchainedEnv, -) -> bool { - let index = unsafe { rustsimplicity_0_6_read8(&src as *const CFrameItem) } as usize; - if index >= env.redeem_script.len() { - return false; - } - - let opcode = env.redeem_script.as_bytes()[index]; - - unsafe { - rustsimplicity_0_6_write8(dst as *mut CFrameItem, opcode as u64); - } - - true -} -/// 2^8 |- 2^256 -/// -/// Each pubkey is encoded as: [OP_PUSHBYTES_33][0x02 or 0x03][32 bytes X coordinate] -pub fn get_pubkey_from_script( - dst: &mut CFrameItem, - src: CFrameItem, - env: &BitcoinUnchainedEnv, -) -> bool { - let start_index = unsafe { rustsimplicity_0_6_read8(&src as *const CFrameItem) } as usize; - if start_index + 34 > env.redeem_script.len() { - return false; - } - - let push_bytes_opcode = env.redeem_script.as_bytes()[start_index]; - if push_bytes_opcode != OP_PUSHBYTES_33.into_u8() { - return false; - } - - let prefix = env.redeem_script.as_bytes()[start_index + 1]; - if prefix != 0x02 && prefix != 0x03 { - return false; - } - - let x_only_pubkey_start = start_index + 2; - - let pubkey_bytes = &env.redeem_script.as_bytes()[x_only_pubkey_start..x_only_pubkey_start + 32]; - - let words: Vec = pubkey_bytes - .chunks(4) - .map(|chunk| u32::from_be_bytes(chunk.try_into().expect("Chunk with incorrect length"))) - .collect::>(); - - for word in words.iter() { - unsafe { - rustsimplicity_0_6_write32(dst as *mut CFrameItem, *word); - } - } - - true -} - -register_jets!( - hal_simplicity::simplicity::jet::Core, - simplicity_unchained_core::jets::environments::BitcoinUnchainedEnv, - "get_opcode_from_script" => get_opcode_from_script, b"c", b"c", - "get_pubkey_from_script" => get_pubkey_from_script, b"c", b"h", -); diff --git a/plugin_tests/opcode_pubkey_elements/Cargo.toml b/plugin_tests/opcode_pubkey_elements/Cargo.toml deleted file mode 100644 index 7ae3647..0000000 --- a/plugin_tests/opcode_pubkey_elements/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "opcode_pubkey_elements" -version = "0.1.0" -edition = "2024" - -[dependencies] -hal-simplicity = { workspace = true } -core = { path = "../../core" } -jet_plugins = { path = "../../jet_plugins" } - -[lib] -crate-type = ["cdylib"] diff --git a/plugin_tests/opcode_pubkey_elements/src/lib.rs b/plugin_tests/opcode_pubkey_elements/src/lib.rs deleted file mode 100644 index a8c9578..0000000 --- a/plugin_tests/opcode_pubkey_elements/src/lib.rs +++ /dev/null @@ -1,86 +0,0 @@ -//! For testing interaction with SimplicityHL -use hal_simplicity::simplicity::{elements::opcodes::all::OP_PUSHBYTES_33, ffi::CFrameItem}; -use jet_plugins::register_jets; -use simplicity_unchained_core::jets::environments::ElementsUnchainedEnv; - -#[allow(unused)] -unsafe extern "C" { - fn rustsimplicity_0_6_write8(dst: *mut CFrameItem, n: u64); - fn rustsimplicity_0_6_write16(dst: *mut CFrameItem, n: u16); - fn rustsimplicity_0_6_write32(dst: *mut CFrameItem, n: u32); - fn rustsimplicity_0_6_write64(dst: *mut CFrameItem, n: u64); - - fn rustsimplicity_0_6_read8(src: *const CFrameItem) -> u64; - fn rustsimplicity_0_6_read16(src: *const CFrameItem) -> u16; - fn rustsimplicity_0_6_read32(src: *const CFrameItem) -> u32; - fn rustsimplicity_0_6_read64(src: *const CFrameItem) -> u64; -} - -/// 2^8 |- 2^8 -/// -/// Returns the opcode at the given index in the redeem script, each opcode is one byte. -pub fn get_opcode_from_script( - dst: &mut CFrameItem, - src: CFrameItem, - env: &ElementsUnchainedEnv, -) -> bool { - let index = unsafe { rustsimplicity_0_6_read8(&src as *const CFrameItem) } as usize; - if index >= env.redeem_script.len() { - return false; - } - - let opcode = env.redeem_script.as_bytes()[index]; - - unsafe { - rustsimplicity_0_6_write8(dst as *mut CFrameItem, opcode as u64); - } - - true -} -/// 2^8 |- 2^256 -/// -/// Each pubkey is encoded as: [OP_PUSHBYTES_33][0x02 or 0x03][32 bytes X coordinate] -pub fn get_pubkey_from_script( - dst: &mut CFrameItem, - src: CFrameItem, - env: &ElementsUnchainedEnv, -) -> bool { - let start_index = unsafe { rustsimplicity_0_6_read8(&src as *const CFrameItem) } as usize; - if start_index + 34 > env.redeem_script.len() { - return false; - } - - let push_bytes_opcode = env.redeem_script.as_bytes()[start_index]; - if push_bytes_opcode != OP_PUSHBYTES_33.into_u8() { - return false; - } - - let prefix = env.redeem_script.as_bytes()[start_index + 1]; - if prefix != 0x02 && prefix != 0x03 { - return false; - } - - let x_only_pubkey_start = start_index + 2; - - let pubkey_bytes = &env.redeem_script.as_bytes()[x_only_pubkey_start..x_only_pubkey_start + 32]; - - let words: Vec = pubkey_bytes - .chunks(4) - .map(|chunk| u32::from_be_bytes(chunk.try_into().expect("Chunk with incorrect length"))) - .collect::>(); - - for word in words.iter() { - unsafe { - rustsimplicity_0_6_write32(dst as *mut CFrameItem, *word); - } - } - - true -} - -register_jets!( - hal_simplicity::simplicity::jet::Elements, - simplicity_unchained_core::jets::environments::ElementsUnchainedEnv, - "get_opcode_from_script" => get_opcode_from_script, b"c", b"c", - "get_pubkey_from_script" => get_pubkey_from_script, b"c", b"h", -); diff --git a/service/Cargo.toml b/service/Cargo.toml index 145bbed..1cc1f0f 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -20,4 +20,3 @@ validator = { version = "0.20.0", features = ["derive"] } hal-simplicity = { workspace = true } core = { path = "../core" } -dlopen2 = "0.8.2" diff --git a/service/src/handlers/mod.rs b/service/src/handlers/mod.rs index 91ac4bc..4e78817 100644 --- a/service/src/handlers/mod.rs +++ b/service/src/handlers/mod.rs @@ -45,7 +45,6 @@ pub struct SignerState { pub secp: Arc>, pub elements_network: ElementsNetwork, pub bitcoin_network: BitcoinNetwork, - pub has_custom_jets: bool, } impl SignerState { @@ -60,14 +59,11 @@ impl SignerState { let secret_key = SecretKey::from_slice(&secret_key_bytes) .map_err(|e| format!("Invalid private key: {}", e))?; - let has_custom_jets = std::env::var("JET_DLL_PATH").is_ok(); - Ok(Self { secret_key, secp: Arc::new(Secp256k1::new()), elements_network, bitcoin_network, - has_custom_jets, }) } } diff --git a/service/src/handlers/sign_psbt.rs b/service/src/handlers/sign_psbt.rs index 5efb821..d983b33 100644 --- a/service/src/handlers/sign_psbt.rs +++ b/service/src/handlers/sign_psbt.rs @@ -77,9 +77,8 @@ pub async fn sign_psbt( match sign_psbt_internal(&state, request) { Ok(response) => { log::info!( - "[200] Sign PSBT successful: Tweaked Public Key {}, custom jets used: {}", - response.public_key_hex, - state.has_custom_jets + "[200] Sign PSBT successful: Tweaked Public Key {}", + response.public_key_hex ); (StatusCode::OK, Json(response)).into_response() @@ -277,7 +276,6 @@ mod tests { secp: Arc::new(Secp256k1::new()), elements_network: ElementsNetwork::LiquidTestnet, bitcoin_network: BitcoinNetwork::Testnet, - has_custom_jets: false, } } diff --git a/service/src/handlers/sign_pset.rs b/service/src/handlers/sign_pset.rs index f312145..9538b40 100644 --- a/service/src/handlers/sign_pset.rs +++ b/service/src/handlers/sign_pset.rs @@ -84,9 +84,8 @@ pub async fn sign_pset( match sign_pset_internal(&state, request) { Ok(response) => { log::info!( - "[200] Sign PSET successful: Tweaked Public Key {}, custom jets used: {}", - response.public_key_hex, - state.has_custom_jets + "[200] Sign PSET successful: Tweaked Public Key {}", + response.public_key_hex ); (StatusCode::OK, Json(response)).into_response() @@ -283,7 +282,6 @@ mod tests { secp: Arc::new(Secp256k1::new()), elements_network: ElementsNetwork::LiquidTestnet, bitcoin_network: BitcoinNetwork::Testnet, - has_custom_jets: false, } } diff --git a/service/src/handlers/tweak.rs b/service/src/handlers/tweak.rs index 15ec33e..459db51 100644 --- a/service/src/handlers/tweak.rs +++ b/service/src/handlers/tweak.rs @@ -164,7 +164,6 @@ mod tests { secp: Arc::new(Secp256k1::new()), elements_network: ElementsNetwork::LiquidTestnet, bitcoin_network: BitcoinNetwork::Testnet, - has_custom_jets: false, } }