diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 93f9822..6697034 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,16 +13,6 @@ jobs: run: git submodule update --init - name: Build contract run: make all-via-docker - - name: Build test extensions - run: make -f tests/xudt_rce/extension_scripts.Makefile all-via-docker - - name: Run simulator tests - run: bash tests/validate_signature_rsa/run.sh - - name: Run tests - run: cargo test - - name: Run xudt tests - run: cd tests/xudt_rce_rust && cargo test - - name: Run xudt simulator tests - run: cd tests/xudt_rce && bash run.sh - name: Run omni_lock tests run: cd tests/omni_lock_rust && cargo test - name: Run omni_lock simulator tests diff --git a/.gitmodules b/.gitmodules index dd22239..b0c8ac4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,27 +1,11 @@ -[submodule "deps/secp256k1"] - path = deps/secp256k1 - url = https://github.com/nervosnetwork/secp256k1 -[submodule "deps/ckb-c-std-lib"] - path = deps/ckb-c-std-lib - url = https://github.com/nervosnetwork/ckb-c-stdlib.git [submodule "deps/ckb-c-stdlib-20210801"] path = deps/ckb-c-stdlib-20210801 url = https://github.com/nervosnetwork/ckb-c-stdlib.git branch = master -[submodule "deps/ckb-c-stdlib-20210713"] - path = deps/ckb-c-stdlib-20210713 - url = https://github.com/nervosnetwork/ckb-c-stdlib.git - branch = master [submodule "deps/sparse-merkle-tree"] path = deps/sparse-merkle-tree url = https://github.com/nervosnetwork/sparse-merkle-tree.git branch = master -[submodule "deps/mbedtls"] - path = deps/mbedtls - url = https://github.com/nervosnetwork/mbedtls.git -[submodule "deps/ckb-c-stdlib-20210413"] - path = deps/ckb-c-stdlib-20210413 - url = https://github.com/nervosnetwork/ckb-c-stdlib.git [submodule "deps/secp256k1-20210801"] path = deps/secp256k1-20210801 url = https://github.com/nervosnetwork/secp256k1.git diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 34399e7..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,105 +0,0 @@ -cmake_minimum_required(VERSION 3.12) -project(ckb_production_scripts_simulator C) - -set(CMAKE_C_STANDARD 11) -# uncomment it for sanitize -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined") - -# uncomment it for coverage test -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") -#add_definitions(-DCKB_COVERAGE) -add_definitions(-DCKB_SIMULATOR) -add_definitions(-D__SHARED_LIBRARY__) -add_definitions(-DCKB_DECLARATION_ONLY) -add_definitions(-DCKB_USE_SIM) - -include_directories(tests/validate_signature_rsa) -include_directories(deps/ckb-c-stdlib-20210413/simulator) -include_directories(deps/ckb-c-stdlib-20210413) -# include_directories(deps/ckb-c-stdlib/libc) -# on simulator, we don't use own "libc" -include_directories(deps) -include_directories(deps/ckb-c-stdlib-20210413/molecule) -include_directories(c) -include_directories(build) -include_directories(deps/secp256k1/src) -include_directories(deps/secp256k1) -include_directories(deps/mbedtls) -include_directories(deps/mbedtls/include) - -add_library(mbedtls - deps/mbedtls/library/aes.c - deps/mbedtls/library/aesni.c - deps/mbedtls/library/arc4.c - deps/mbedtls/library/aria.c - deps/mbedtls/library/asn1parse.c - deps/mbedtls/library/asn1write.c - deps/mbedtls/library/base64.c - deps/mbedtls/library/bignum.c - deps/mbedtls/library/blowfish.c - deps/mbedtls/library/camellia.c - deps/mbedtls/library/ccm.c - deps/mbedtls/library/chacha20.c - deps/mbedtls/library/chachapoly.c - deps/mbedtls/library/cipher.c - deps/mbedtls/library/cipher_wrap.c - deps/mbedtls/library/cmac.c - deps/mbedtls/library/ctr_drbg.c - deps/mbedtls/library/des.c - deps/mbedtls/library/dhm.c - deps/mbedtls/library/ecdh.c - deps/mbedtls/library/ecdsa.c - deps/mbedtls/library/ecjpake.c - deps/mbedtls/library/ecp.c - deps/mbedtls/library/ecp_curves.c - deps/mbedtls/library/entropy.c - deps/mbedtls/library/entropy_poll.c - deps/mbedtls/library/error.c - deps/mbedtls/library/gcm.c - deps/mbedtls/library/havege.c - deps/mbedtls/library/hkdf.c - deps/mbedtls/library/hmac_drbg.c - deps/mbedtls/library/md.c - deps/mbedtls/library/md2.c - deps/mbedtls/library/md4.c - deps/mbedtls/library/md5.c - deps/mbedtls/library/memory_buffer_alloc.c - deps/mbedtls/library/nist_kw.c - deps/mbedtls/library/oid.c - deps/mbedtls/library/padlock.c - deps/mbedtls/library/pem.c - deps/mbedtls/library/pk.c - deps/mbedtls/library/pk_wrap.c - deps/mbedtls/library/pkcs12.c - deps/mbedtls/library/pkcs5.c - deps/mbedtls/library/pkparse.c - deps/mbedtls/library/pkwrite.c - deps/mbedtls/library/platform.c - deps/mbedtls/library/platform_util.c - deps/mbedtls/library/poly1305.c - deps/mbedtls/library/psa_crypto.c - deps/mbedtls/library/psa_crypto_se.c - deps/mbedtls/library/psa_crypto_slot_management.c - deps/mbedtls/library/psa_crypto_storage.c - deps/mbedtls/library/psa_its_file.c - deps/mbedtls/library/ripemd160.c - deps/mbedtls/library/rsa.c - deps/mbedtls/library/rsa_internal.c - deps/mbedtls/library/sha1.c - deps/mbedtls/library/sha256.c - deps/mbedtls/library/sha512.c - deps/mbedtls/library/threading.c - deps/mbedtls/library/timing.c - deps/mbedtls/library/version.c - deps/mbedtls/library/version_features.c - deps/mbedtls/library/xtea.c) - -add_executable(validate_signature_rsa tests/validate_signature_rsa/validate_signature_rsa_sim.c c/validate_signature_rsa.h) -target_compile_definitions(validate_signature_rsa PUBLIC -D_FILE_OFFSET_BITS=64 -DCKB_DECLARATION_ONLY) -target_include_directories(validate_signature_rsa PUBLIC deps/ckb-c-stdlib-20210413/libc) -target_link_libraries(validate_signature_rsa mbedtls) - - -add_executable(dlopen_sim tests/validate_signature_rsa/dlopen_sim.c) -target_compile_definitions(dlopen_sim PUBLIC -D_FILE_OFFSET_BITS=64 -DCKB_DECLARATION_ONLY) -#target_include_directories(dlopen_sim PUBLIC deps/ckb-c-stdlib-20210413/libc) diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index e7c8b4d..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,2778 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ed203b9ba68b242c62b3fb7480f589dd49829be1edb3fe8fc8b4ffda2dcb8d" -dependencies = [ - "addr2line", - "cfg-if 1.0.0", - "libc", - "miniz_oxide 0.4.4", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "bit-vec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "blake2b-rs" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e35e362830ef90ecea16f09b21b75d22d33a8562a679c74ab4f4fa49b4fcb87" -dependencies = [ - "cc", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bumpalo" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "either", - "iovec", - "serde", -] - -[[package]] -name = "cc" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "serde", - "time", - "wasm-bindgen", - "winapi 0.3.9", -] - -[[package]] -name = "ckb-chain-spec" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-crypto", - "ckb-dao-utils", - "ckb-error", - "ckb-hash", - "ckb-jsonrpc-types", - "ckb-pow", - "ckb-rational", - "ckb-resource", - "ckb-types", - "failure", - "serde", - "serde_derive", - "toml", -] - -[[package]] -name = "ckb-crypto" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-fixed-hash", - "failure", - "faster-hex 0.4.1", - "lazy_static", - "rand 0.6.5", - "secp256k1", -] - -[[package]] -name = "ckb-dao-utils" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "byteorder", - "ckb-error", - "ckb-types", - "enum-display-derive", - "failure", -] - -[[package]] -name = "ckb-error" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-occupied-capacity", - "enum-display-derive", - "failure", -] - -[[package]] -name = "ckb-fixed-hash" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-fixed-hash-core", - "ckb-fixed-hash-hack", - "proc-macro-hack", -] - -[[package]] -name = "ckb-fixed-hash-core" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "failure", - "faster-hex 0.4.1", - "serde", -] - -[[package]] -name = "ckb-fixed-hash-hack" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-fixed-hash-core", - "proc-macro-hack", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "ckb-hash" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "blake2b-rs", -] - -[[package]] -name = "ckb-jsonrpc-types" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-types", - "faster-hex 0.4.1", - "jsonrpc-core", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "ckb-logger" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ansi_term", - "backtrace", - "chrono", - "crossbeam-channel", - "env_logger", - "lazy_static", - "log", - "parking_lot 0.7.1", - "regex", - "sentry", - "serde", - "serde_derive", -] - -[[package]] -name = "ckb-occupied-capacity" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-occupied-capacity-core", - "ckb-occupied-capacity-macros", - "proc-macro-hack", -] - -[[package]] -name = "ckb-occupied-capacity-core" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "serde", - "serde_derive", -] - -[[package]] -name = "ckb-occupied-capacity-macros" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-occupied-capacity-core", - "proc-macro-hack", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "ckb-pow" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "byteorder", - "ckb-types", - "eaglesong", - "serde", - "serde_derive", -] - -[[package]] -name = "ckb-production-scripts" -version = "0.5.1" -dependencies = [ - "blake2b-rs", - "byteorder", - "ckb-crypto", - "ckb-dao-utils", - "ckb-error", - "ckb-hash", - "ckb-script", - "ckb-types", - "faster-hex 0.3.1", - "includedir", - "includedir_codegen", - "lazy_static", - "phf", - "rand 0.6.5", - "ripemd160", - "secp256k1", - "sha2", -] - -[[package]] -name = "ckb-rational" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "numext-fixed-uint", -] - -[[package]] -name = "ckb-resource" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-system-scripts", - "ckb-types", - "includedir", - "includedir_codegen", - "phf", - "serde", - "serde_derive", - "tempfile", - "walkdir", -] - -[[package]] -name = "ckb-script" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "byteorder", - "ckb-chain-spec", - "ckb-error", - "ckb-hash", - "ckb-logger", - "ckb-script-data-loader", - "ckb-types", - "ckb-vm", - "failure", - "faster-hex 0.4.1", - "serde", - "serde_derive", -] - -[[package]] -name = "ckb-script-data-loader" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "ckb-types", -] - -[[package]] -name = "ckb-system-scripts" -version = "0.4.0-alpha.10+witness-args" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387db7de0020cbc3c20801cdba8ed1ae19acc9fd89ffb0b02c34862c71cda2db" -dependencies = [ - "blake2b-rs", - "faster-hex 0.3.1", - "includedir", - "includedir_codegen", - "phf", -] - -[[package]] -name = "ckb-types" -version = "0.24.0-pre" -source = "git+https://github.com/nervosnetwork/ckb.git?rev=d75e4c5#d75e4c56ffa40e17fd2fe477da3f98c5578edcd1" -dependencies = [ - "bit-vec", - "bytes", - "ckb-error", - "ckb-fixed-hash", - "ckb-hash", - "ckb-occupied-capacity", - "ckb-rational", - "crossbeam-channel", - "failure", - "merkle-cbt", - "molecule", - "numext-fixed-uint", -] - -[[package]] -name = "ckb-vm" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684aca846d958bc5c2196b10839b69ec573cc693b14dc701986adda123ffbef0" -dependencies = [ - "byteorder", - "bytes", - "cc", - "ckb-vm-definitions", - "derive_more", - "goblin", - "libc", - "memmap", -] - -[[package]] -name = "ckb-vm-definitions" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4a65696efd8974a3c785619f2bfc4c40f2cf318ac184c30aa72d0f539a4a4f" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cookie" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" -dependencies = [ - "time", - "url 1.7.2", -] - -[[package]] -name = "cookie_store" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" -dependencies = [ - "cookie", - "failure", - "idna 0.1.5", - "log", - "publicsuffix", - "serde", - "serde_json", - "time", - "try_from", - "url 1.7.2", -] - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" -dependencies = [ - "crossbeam-utils 0.6.6", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard 1.1.0", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -dependencies = [ - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "debugid" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088c9627adec1e494ff9dea77377f1e69893023d631254a0ec68b16ee20be3e9" -dependencies = [ - "lazy_static", - "regex", - "serde", - "uuid", -] - -[[package]] -name = "derive_more" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" -dependencies = [ - "lazy_static", - "proc-macro2 0.4.30", - "quote 0.6.13", - "regex", - "rustc_version", - "syn 0.15.44", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "dtoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" - -[[package]] -name = "eaglesong" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d978bd5d343e8ab9b5c0fc8d93ff9c602fdc96616ffff9c05ac7a155419b824" - -[[package]] -name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "encoding_rs" -version = "0.8.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "enum-display-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ef37b2a9b242295d61a154ee91ae884afff6b8b933b486b12481cc58310ca" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", -] - -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "faster-hex" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b8cccaafb5aae8c282692e5590f341925edea6c696e8715ff0d973320b2646" - -[[package]] -name = "faster-hex" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348138dd23e03bb0018caef99647fb1a5befec5ff4b501991de88f09854d4c28" - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "flate2" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" -dependencies = [ - "crc32fast", - "miniz_oxide 0.6.2", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding 2.2.0", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures", - "num_cpus", -] - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" - -[[package]] -name = "goblin" -version = "0.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" -dependencies = [ - "log", - "plain", - "scroll", -] - -[[package]] -name = "h2" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" -dependencies = [ - "byteorder", - "bytes", - "fnv", - "futures", - "http", - "indexmap", - "log", - "slab", - "string", - "tokio-io", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hostname" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" -dependencies = [ - "libc", - "winutil", -] - -[[package]] -name = "http" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" -dependencies = [ - "bytes", - "fnv", - "itoa 0.4.8", -] - -[[package]] -name = "http-body" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -dependencies = [ - "bytes", - "futures", - "http", - "tokio-buf", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "hyper" -version = "0.12.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c843caf6296fc1f93444735205af9ed4e109a539005abb2564ae1d6fad34c52" -dependencies = [ - "bytes", - "futures", - "futures-cpupool", - "h2", - "http", - "http-body", - "httparse", - "iovec", - "itoa 0.4.8", - "log", - "net2", - "rustc_version", - "time", - "tokio", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" -dependencies = [ - "bytes", - "futures", - "hyper", - "native-tls", - "tokio-io", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "js-sys", - "wasm-bindgen", - "winapi 0.3.9", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "im" -version = "12.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de38d1511a0ce7677538acb1e31b5df605147c458e061b2cdb89858afb1cd182" -dependencies = [ - "rustc_version", - "sized-chunks", - "typenum", -] - -[[package]] -name = "includedir" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97402f770a519ebea51b27131c3b6558cfd2375aff21294bad806bad91bf0b6" -dependencies = [ - "flate2", - "phf", -] - -[[package]] -name = "includedir_codegen" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7d542be113fd84855692fb536c16cc4c09527724d1dca8953047d71cccadef" -dependencies = [ - "flate2", - "phf_codegen", - "walkdir", -] - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg 1.1.0", - "hashbrown", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" - -[[package]] -name = "js-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpc-core" -version = "10.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc15eef5f8b6bef5ac5f7440a957ff95d036e2f98706947741bfc93d1976db4c" -dependencies = [ - "futures", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "owning_ref", - "scopeguard 0.3.3", -] - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard 1.1.0", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "merkle-cbt" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c95c71a8dc57c7ad9b7623cf05711bb4e3daef44f1931c91e7d49c60de693ca" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg 1.1.0", -] - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "molecule" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba0619bb93e13e12d7e04ab7a1e57f2331f37fa7412f64cf8ef49d1603e0a82a" -dependencies = [ - "bytes", - "faster-hex 0.4.1", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d0df99cfcd2530b2e694f6e17e7f37b8e26bb23983ac530c0c97408837c631" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg 1.1.0", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - -[[package]] -name = "numext-constructor" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "621fe0f044729f810c6815cdd77e8f5e0cd803ce4f6a38380ebfc1322af98661" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", -] - -[[package]] -name = "numext-fixed-uint" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c68c76f96d589d1009a666c5072f37f3114d682696505f2cf445f27766c7d70" -dependencies = [ - "numext-fixed-uint-core", - "numext-fixed-uint-hack", -] - -[[package]] -name = "numext-fixed-uint-core" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aab1d6457b97b49482f22a92f0f58a2f39bdd7f3b2f977eae67e8bc206aa980" -dependencies = [ - "heapsize", - "numext-constructor", - "rand 0.7.3", - "serde", - "thiserror", -] - -[[package]] -name = "numext-fixed-uint-hack" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200f8d55c36ec1b6a8cf810115be85d4814f045e0097dfd50033ba25adb4c9e" -dependencies = [ - "numext-fixed-uint-core", - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", -] - -[[package]] -name = "object" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "openssl" -version = "0.10.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" -dependencies = [ - "autocfg 1.1.0", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.3", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66b810a62be75176a80873726630147a5ca780cd33921e0b5709033e66b0a" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "rustc_version", - "smallvec", - "winapi 0.3.9", -] - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -dependencies = [ - "phf_shared", - "rand 0.6.5", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "publicsuffix" -version = "1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b4ce31ff0a27d93c8de1849cf58162283752f065a90d508f1105fa6c9a213f" -dependencies = [ - "idna 0.2.3", - "url 2.3.1", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2 1.0.51", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "reqwest" -version = "0.9.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" -dependencies = [ - "base64", - "bytes", - "cookie", - "cookie_store", - "encoding_rs", - "flate2", - "futures", - "http", - "hyper", - "hyper-tls", - "log", - "mime", - "mime_guess", - "native-tls", - "serde", - "serde_json", - "serde_urlencoded", - "time", - "tokio", - "tokio-executor", - "tokio-io", - "tokio-threadpool", - "tokio-timer", - "url 1.7.2", - "uuid", - "winreg", -] - -[[package]] -name = "ripemd160" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" -dependencies = [ - "block-buffer", - "digest", - "opaque-debug", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "scroll" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" -dependencies = [ - "rustc_version", - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "secp256k1" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d311229f403d64002e9eed9964dfa5a0a0c1ac443344f7546bf48e916c6053a" -dependencies = [ - "cc", - "rand 0.6.5", -] - -[[package]] -name = "security-framework" -version = "2.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "sentry" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509c5fbb9e875fafcd9c4612c0e49d476083b848bf87380cfe1126ebc745c140" -dependencies = [ - "backtrace", - "env_logger", - "failure", - "hostname", - "httpdate", - "im", - "lazy_static", - "libc", - "log", - "rand 0.6.5", - "regex", - "reqwest", - "rustc_version", - "sentry-types", - "uname", - "url 1.7.2", -] - -[[package]] -name = "sentry-types" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b23e3d9c8c6e4a1523f24df6753c4088bfe16c44a73c8881c1d23c70f28ae280" -dependencies = [ - "chrono", - "debugid", - "failure", - "serde", - "serde_json", - "url 1.7.2", - "url_serde", - "uuid", -] - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", -] - -[[package]] -name = "serde_json" -version = "1.0.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" -dependencies = [ - "itoa 1.0.5", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -dependencies = [ - "dtoa", - "itoa 0.4.8", - "serde", - "url 1.7.2", -] - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" - -[[package]] -name = "sized-chunks" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d3e7f23bad2d6694e0f46f5e470ec27eb07b8f3e8b309a4b0dc17501928b9f2" -dependencies = [ - "typenum", -] - -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -dependencies = [ - "bytes", -] - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56e159d99e6c2b93995d171050271edb50ecc5288fbc7cc17de8fdce4e58c14" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", - "unicode-xid 0.2.4", -] - -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if 1.0.0", - "fastrand", - "libc", - "redox_syscall 0.2.16", - "remove_dir_all", - "winapi 0.3.9", -] - -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes", - "futures", - "mio", - "num_cpus", - "tokio-current-thread", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", -] - -[[package]] -name = "tokio-buf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" -dependencies = [ - "bytes", - "either", - "futures", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes", - "futures", - "log", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes", - "futures", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils 0.7.2", - "futures", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures", - "slab", - "tokio-executor", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "try_from" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uname" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" -dependencies = [ - "libc", -] - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna 0.3.0", - "percent-encoding 2.2.0", -] - -[[package]] -name = "url_serde" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea" -dependencies = [ - "serde", - "url 1.7.2", -] - -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", - "serde", -] - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi 0.3.9", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" -dependencies = [ - "futures", - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasm-bindgen" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote 1.0.23", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" -dependencies = [ - "proc-macro2 1.0.51", - "quote 1.0.23", - "syn 1.0.108", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "winreg" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winutil" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 68e52cd..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "ckb-production-scripts" -version = "0.5.1" -authors = ["Nervos Core Dev "] -edition = "2018" -build = "build.rs" -license = "MIT" -description = "CKB Production Scripts" -repository = "https://github.com/nervosnetwork/ckb-production-scripts" -include = ["src/**/*", "Cargo.toml", "build.rs", "specs/cells/*"] - -[dependencies] -includedir = "0.5.0" -phf = "0.7.21" - -[build-dependencies] -includedir_codegen = "0.5.0" -blake2b-rs = "0.1.5" -faster-hex = "0.3" - -[dev-dependencies] -byteorder = "1.3.1" -ckb-types = { git = "https://github.com/nervosnetwork/ckb.git", rev = "d75e4c5" } -ckb-script = { git = "https://github.com/nervosnetwork/ckb.git", rev = "d75e4c5" } -ckb-crypto = { git = "https://github.com/nervosnetwork/ckb.git", rev = "d75e4c5" } -ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb.git", rev = "d75e4c5" } -ckb-hash = { git = "https://github.com/nervosnetwork/ckb.git", rev = "d75e4c5" } -ckb-error = { git = "https://github.com/nervosnetwork/ckb.git", rev = "d75e4c5" } -rand = "0.6.5" -lazy_static = "1.3.0" -ripemd160 = "0.8.0" -sha2 = "0.8.0" -secp256k1 = { version = "0.15.1" } -faster-hex = "0.3" diff --git a/Makefile b/Makefile index b25b3f7..1c46576 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,8 @@ LD := $(TARGET)-gcc OBJCOPY := $(TARGET)-objcopy CFLAGS := -fPIC -O3 -fno-builtin-printf -fno-builtin-memcmp -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I deps/secp256k1/src -I deps/secp256k1 -I deps/ckb-c-std-lib -I deps/ckb-c-std-lib/libc -I deps/ckb-c-std-lib/molecule -I c -I build -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -g LDFLAGS := -Wl,-static -fdata-sections -ffunction-sections -Wl,--gc-sections -SECP256K1_SRC := deps/secp256k1/src/ecmult_static_pre_context.h SECP256K1_SRC_20210801 := deps/secp256k1-20210801/src/ecmult_static_pre_context.h -XUDT_RCE_CFLAGS=$(subst ckb-c-std-lib,ckb-c-stdlib-20210713,$(CFLAGS)) -I deps/sparse-merkle-tree/c OMNI_LOCK_CFLAGS :=$(subst ckb-c-std-lib,ckb-c-stdlib-20210801,$(CFLAGS)) -I deps/sparse-merkle-tree/c OMNI_LOCK_CFLAGS := $(subst secp256k1,secp256k1-20210801,$(OMNI_LOCK_CFLAGS)) @@ -19,56 +17,29 @@ PROTOCOL_URL := https://raw.githubusercontent.com/nervosnetwork/ckb/${PROTOCOL_V MOLC := moleculec MOLC_VERSION := 0.7.0 -# RSA/mbedtls -CFLAGS_MBEDTLS := $(subst ckb-c-std-lib,ckb-c-stdlib-20210413,$(CFLAGS)) -I deps/mbedtls/include -LDFLAGS_MBEDTLS := $(LDFLAGS) -PASSED_MBEDTLS_CFLAGS := -O3 -fPIC -nostdinc -nostdlib -DCKB_DECLARATION_ONLY -I ../../ckb-c-stdlib-20210413/libc -fdata-sections -ffunction-sections - # docker pull nervos/ckb-riscv-gnu-toolchain:gnu-bionic-20191012 BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:aae8a3f79705f67d505d1f1d5ddc694a4fd537ed1c7e9622420a470d59ba2ec3 CLANG_FORMAT_DOCKER := kason223/clang-format@sha256:3cce35b0400a7d420ec8504558a02bdfc12fd2d10e40206f140c4545059cd95d -all: build/simple_udt build/anyone_can_pay build/always_success build/validate_signature_rsa build/xudt_rce build/rce_validator build/omni_lock +all: build/omni_lock build/always_success all-via-docker: ${PROTOCOL_HEADER} docker run --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make" -build/simple_udt: c/simple_udt.c - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< - $(OBJCOPY) --only-keep-debug $@ $@.debug - $(OBJCOPY) --strip-debug --strip-all $@ - -build/anyone_can_pay: c/anyone_can_pay.c ${PROTOCOL_HEADER} c/secp256k1_lock.h build/secp256k1_data_info.h $(SECP256K1_SRC) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< - $(OBJCOPY) --only-keep-debug $@ $@.debug - $(OBJCOPY) --strip-debug --strip-all $@ build/always_success: c/always_success.c - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + $(CC) $(OMNI_LOCK_CFLAGS) $(LDFLAGS) -o $@ $< $(OBJCOPY) --only-keep-debug $@ $@.debug $(OBJCOPY) --strip-debug --strip-all $@ -build/secp256k1_data_info.h: build/dump_secp256k1_data - $< - build/secp256k1_data_info_20210801.h: build/dump_secp256k1_data_20210801 $< -build/dump_secp256k1_data: c/dump_secp256k1_data.c $(SECP256K1_SRC) - mkdir -p build - gcc -I deps/secp256k1/src -I deps/secp256k1 -o $@ $< - build/dump_secp256k1_data_20210801: c/dump_secp256k1_data_20210801.c $(SECP256K1_SRC_20210801) mkdir -p build gcc -I deps/secp256k1-20210801/src -I deps/secp256k1-20210801 -o $@ $< -$(SECP256K1_SRC): - cd deps/secp256k1 && \ - ./autogen.sh && \ - CC=$(CC) LD=$(LD) ./configure --with-bignum=no --enable-ecmult-static-precomputation --enable-endomorphism --enable-module-recovery --host=$(TARGET) && \ - make src/ecmult_static_pre_context.h src/ecmult_static_context.h - $(SECP256K1_SRC_20210801): cd deps/secp256k1-20210801 && \ ./autogen.sh && \ @@ -76,64 +47,22 @@ $(SECP256K1_SRC_20210801): make src/ecmult_static_pre_context.h src/ecmult_static_context.h -deps/mbedtls/library/libmbedcrypto.a: - cp deps/mbedtls-config-template.h deps/mbedtls/include/mbedtls/config.h - make -C deps/mbedtls/library CC=${CC} LD=${LD} CFLAGS="${PASSED_MBEDTLS_CFLAGS}" libmbedcrypto.a - build/impl.o: deps/ckb-c-std-lib/libc/src/impl.c $(CC) -c $(filter-out -DCKB_DECLARATION_ONLY, $(CFLAGS_MBEDTLS)) $(LDFLAGS_MBEDTLS) -o $@ $^ -validate_signature_rsa-via-docker: - docker run --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make build/validate_signature_rsa" - -build/validate_signature_rsa: c/validate_signature_rsa.c deps/mbedtls/library/libmbedcrypto.a - $(CC) $(CFLAGS_MBEDTLS) $(LDFLAGS_MBEDTLS) -D__SHARED_LIBRARY__ -fPIC -fPIE -pie -Wl,--dynamic-list c/rsa.syms -o $@ $^ - $(OBJCOPY) --only-keep-debug $@ $@.debug - $(OBJCOPY) --strip-debug --strip-all $@ - -validate_signature_rsa_sim-via-docker: - docker run --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make build/validate_signature_rsa_sim" - -# for test only -CFLAGS_MBEDTLS2:=$(filter-out -Werror,$(CFLAGS_MBEDTLS)) -CFLAGS_MBEDTLS2:=$(filter-out -Wno-nonnull,$(CFLAGS_MBEDTLS2)) -CFLAGS_MBEDTLS2:=$(filter-out -Wno-nonnull-compare,$(CFLAGS_MBEDTLS2)) -CFLAGS_MBEDTLS2:=$(filter-out -Wno-unused-function,$(CFLAGS_MBEDTLS2)) -CFLAGS_MBEDTLS2:=$(filter-out -Wall,$(CFLAGS_MBEDTLS2)) -build/validate_signature_rsa_sim: tests/validate_signature_rsa/validate_signature_rsa_sim.c deps/mbedtls/library/libmbedcrypto.a - $(CC) $(CFLAGS_MBEDTLS2) $(LDFLAGS_MBEDTLS) -DCKB_RUN_IN_VM -o $@ $^ - - -validate_signature_rsa_clean: - make -C deps/mbedtls/library clean - rm -f build/validate_signature_rsa - rm -f build/*.o - ${PROTOCOL_SCHEMA}: curl -L -o $@ ${PROTOCOL_URL} ALL_C_SOURCE := $(wildcard c/omni_lock.c c/omni_lock_acp.h c/omni_lock_time_lock.h \ - tests/omni_lock/omni_lock_sim.c tests/omni_lock/ckb_syscall_omni_lock_sim.h tests/omni_lock/omni_lock_supply.h\ - c/rce_validator.c /always_success.c c/rce.h c/xudt_rce.c \ - c/rce_validator.c tests/xudt_rce/*.c tests/xudt_rce/*.h\ - c/validate_signature_rsa.h c/validate_signature_rsa.c) + tests/omni_lock/omni_lock_sim.c tests/omni_lock/ckb_syscall_omni_lock_sim.h tests/omni_lock/omni_lock_supply.h) fmt: docker run --rm -v `pwd`:/code ${CLANG_FORMAT_DOCKER} bash -c "cd code && clang-format -i -style=Google $(ALL_C_SOURCE)" git diff --exit-code $(ALL_C_SOURCE) mol: - rm -f c/xudt_rce_mol.h - rm -f c/xudt_rce_mol2.h - rm -f tests/xudt_rce_rust/src/xudt_rce_mol.rs - make c/xudt_rce_mol.h - make c/xudt_rce_mol2.h - make tests/xudt_rce_rust/src/xudt_rce_mol.rs make omni_lock_mol -tests/xudt_rce_rust/src/xudt_rce_mol.rs: c/xudt_rce.mol - ${MOLC} --language rust --schema-file $< | rustfmt > $@ - c/xudt_rce_mol.h: c/xudt_rce.mol ${MOLC} --language c --schema-file $< > $@ @@ -147,56 +76,18 @@ omni_lock_mol: ${MOLC} --language - --schema-file c/omni_lock.mol --format json > build/omni_lock_mol2.json moleculec-c2 --input build/omni_lock_mol2.json | clang-format -style=Google > c/omni_lock_mol2.h -build/xudt_rce: c/xudt_rce.c c/rce.h - $(CC) $(XUDT_RCE_CFLAGS) $(LDFLAGS) -o $@ $< - $(OBJCOPY) --only-keep-debug $@ $@.debug - $(OBJCOPY) --strip-debug --strip-all $@ - -build/rce_validator: c/rce_validator.c c/rce.h - $(CC) $(XUDT_RCE_CFLAGS) $(LDFLAGS) -o $@ $< - $(OBJCOPY) --only-keep-debug $@ $@.debug - $(OBJCOPY) --strip-debug --strip-all $@ - -build/omni_lock: c/omni_lock.c c/omni_lock_supply.h c/omni_lock_acp.h c/rce.h c/secp256k1_lock.h build/secp256k1_data_info_20210801.h $(SECP256K1_SRC_20210801) c/ckb_identity.h +build/omni_lock: c/omni_lock.c c/omni_lock_supply.h c/omni_lock_acp.h c/secp256k1_lock.h build/secp256k1_data_info_20210801.h $(SECP256K1_SRC_20210801) c/ckb_identity.h $(CC) $(OMNI_LOCK_CFLAGS) $(LDFLAGS) -o $@ $< cp $@ $@.debug $(OBJCOPY) --strip-debug --strip-all $@ -publish: - git diff --exit-code Cargo.toml - sed -i.bak 's/.*git =/# &/' Cargo.toml - cargo publish --allow-dirty - git checkout Cargo.toml Cargo.lock - rm -f Cargo.toml.bak - -package: - git diff --exit-code Cargo.toml - sed -i.bak 's/.*git =/# &/' Cargo.toml - cargo package --allow-dirty - git checkout Cargo.toml Cargo.lock - rm -f Cargo.toml.bak - -package-clean: - git checkout Cargo.toml Cargo.lock - rm -rf Cargo.toml.bak target/package/ clean: - rm -rf build/simple_udt - rm -rf build/anyone_can_pay - rm -rf build/secp256k1_data_info.h build/dump_secp256k1_data rm -rf build/secp256k1_data_info_20210801.h build/dump_secp256k1_data_20210801 - rm -rf build/secp256k1_data rm -rf build/secp256k1_data_20210801 rm -rf build/*.debug - rm -f build/xudt_rce - rm -f build/rce_validator rm -f build/omni_lock - cd deps/secp256k1 && [ -f "Makefile" ] && make clean cd deps/secp256k1-20210801 && [ -f "Makefile" ] && make clean - make -C deps/mbedtls/library clean - rm -f build/validate_signature_rsa - rm -f build/validate_signature_rsa_sim - cargo clean install-tools: if [ ! -x "$$(command -v "${MOLC}")" ] \ diff --git a/README.md b/README.md index 1b7fd77..9c80f45 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# ckb production scripts +# Omnilock -CKB scripts used in production. +## Document +See [RFC](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) + +## Build + +``` +git submodule update --init +make all-via-docker +``` + +## Test + +``` +cd tests/omni_lock_rust && cargo test +``` + +## Deployment + +See [RFC](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) diff --git a/build/simple_udt b/build/simple_udt new file mode 100755 index 0000000..e092e8d Binary files /dev/null and b/build/simple_udt differ diff --git a/build/validate_signature_rsa b/build/validate_signature_rsa new file mode 100755 index 0000000..28ed0b3 Binary files /dev/null and b/build/validate_signature_rsa differ diff --git a/c/anyone_can_pay.c b/c/anyone_can_pay.c deleted file mode 100644 index 889c069..0000000 --- a/c/anyone_can_pay.c +++ /dev/null @@ -1,328 +0,0 @@ -/* UDT anyone-can-pay lock script - * For simplify, we call a cell with anyone-can-pay lock a wallet cell. - * - * Wallet cell can be unlocked without a signature, if: - * - * 1. There is 1 output wallet cell that has the same type hash with the - * unlocked wallet cell. - * 2. The UDT or CKB(if type script is none) in the output wallet is more than - * the unlocked wallet. - * 3. if the type script is none, the cell data is empty. - * - * otherwise, the script perform secp256k1_blake160_sighash_all verification. - */ - -#include "blake2b.h" -#include "blockchain.h" -#include "ckb_syscalls.h" -#include "defs.h" -#include "overflow_add.h" -#include "quick_pow10.h" -#include "secp256k1_helper.h" -#include "secp256k1_lock.h" - -#define BLAKE2B_BLOCK_SIZE 32 -#define SCRIPT_SIZE 32768 -#define CKB_LEN 8 -#define UDT_LEN 16 -#define MAX_WITNESS_SIZE 32768 -#define MAX_TYPE_HASH 256 - -/* anyone can pay errors */ -#define ERROR_OVERFLOW -41 -#define ERROR_OUTPUT_AMOUNT_NOT_ENOUGH -42 -#define ERROR_TOO_MUCH_TYPE_HASH_INPUTS -43 -#define ERROR_NO_PAIR -44 -#define ERROR_DUPLICATED_INPUTS -45 -#define ERROR_DUPLICATED_OUTPUTS -46 - -typedef struct { - int is_ckb_only; - unsigned char type_hash[BLAKE2B_BLOCK_SIZE]; - uint64_t ckb_amount; - uint128_t udt_amount; - uint32_t output_cnt; -} InputWallet; - -int load_type_hash_and_amount(uint64_t cell_index, uint64_t cell_source, - uint8_t type_hash[BLAKE2B_BLOCK_SIZE], - uint64_t *ckb_amount, uint128_t *udt_amount, - int *is_ckb_only) { - uint64_t len = BLAKE2B_BLOCK_SIZE; - int ret = ckb_checked_load_cell_by_field( - type_hash, &len, 0, cell_index, cell_source, CKB_CELL_FIELD_TYPE_HASH); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - return ret; - } - - if (ret == CKB_SUCCESS) { - if (len != BLAKE2B_BLOCK_SIZE) { - return ERROR_ENCODING; - } - } else if (ret != CKB_ITEM_MISSING) { - return ERROR_SYSCALL; - } - - *is_ckb_only = ret == CKB_ITEM_MISSING; - - /* load amount */ - len = CKB_LEN; - ret = - ckb_checked_load_cell_by_field((uint8_t *)ckb_amount, &len, 0, cell_index, - cell_source, CKB_CELL_FIELD_CAPACITY); - if (ret != CKB_SUCCESS) { - *ckb_amount = 0; - return ERROR_SYSCALL; - } - if (len != CKB_LEN) { - return ERROR_ENCODING; - } - len = UDT_LEN; - ret = ckb_load_cell_data((uint8_t *)udt_amount, &len, 0, cell_index, - cell_source); - if (ret != CKB_SUCCESS) { - *udt_amount = 0; - if (ret != CKB_ITEM_MISSING) { - return ERROR_SYSCALL; - } - - return CKB_SUCCESS; - } - - /* check data length */ - if (*is_ckb_only) { - /* ckb only wallet should has no data */ - if (len != 0) { - return ERROR_ENCODING; - } - } else { - if (len < UDT_LEN) { - return ERROR_ENCODING; - } - } - - return CKB_SUCCESS; -} - -int check_payment_unlock(uint64_t min_ckb_amount, uint128_t min_udt_amount) { - unsigned char lock_hash[BLAKE2B_BLOCK_SIZE] = {0}; - InputWallet input_wallets[MAX_TYPE_HASH] = {0}; - uint64_t len = BLAKE2B_BLOCK_SIZE; - /* load wallet lock hash */ - int ret = ckb_load_script_hash(lock_hash, &len, 0); - if (ret != CKB_SUCCESS) { - return ERROR_SYSCALL; - } - if (len > BLAKE2B_BLOCK_SIZE) { - return ERROR_SCRIPT_TOO_LONG; - } - - /* iterate inputs and find input wallet cell */ - int i = 0; - len = BLAKE2B_BLOCK_SIZE; - while (1) { - if (i >= MAX_TYPE_HASH) { - return ERROR_TOO_MUCH_TYPE_HASH_INPUTS; - } - - ret = load_type_hash_and_amount( - i, CKB_SOURCE_GROUP_INPUT, input_wallets[i].type_hash, - &input_wallets[i].ckb_amount, &input_wallets[i].udt_amount, - &input_wallets[i].is_ckb_only); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } else if (ret != CKB_SUCCESS) { - return ret; - } - - i++; - } - - int input_wallets_cnt = i; - - /* iterate outputs wallet cell */ - i = 0; - while (1) { - uint8_t output_lock_hash[BLAKE2B_BLOCK_SIZE] = {0}; - uint8_t output_type_hash[BLAKE2B_BLOCK_SIZE] = {0}; - uint64_t len = BLAKE2B_BLOCK_SIZE; - /* check lock hash */ - ret = ckb_checked_load_cell_by_field(output_lock_hash, &len, 0, i, - CKB_SOURCE_OUTPUT, - CKB_CELL_FIELD_LOCK_HASH); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - if (ret != CKB_SUCCESS) { - return ret; - } - if (len != BLAKE2B_BLOCK_SIZE) { - return ERROR_ENCODING; - } - int has_same_lock = - memcmp(output_lock_hash, lock_hash, BLAKE2B_BLOCK_SIZE) == 0; - - /* skip non ACP lock cells*/ - if (!has_same_lock) { - i++; - continue; - } - - /* load output cell */ - int is_ckb_only = 0; - uint64_t ckb_amount = 0; - uint128_t udt_amount = 0; - ret = load_type_hash_and_amount(i, CKB_SOURCE_OUTPUT, output_type_hash, - &ckb_amount, &udt_amount, &is_ckb_only); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } else if (ret != CKB_SUCCESS) { - return ret; - } - - /* find input wallet which has same type hash */ - int found_inputs = 0; - for (int j = 0; j < input_wallets_cnt; j++) { - int has_same_type = 0; - /* check type hash */ - if (is_ckb_only) { - has_same_type = input_wallets[j].is_ckb_only; - } else { - has_same_type = memcmp(output_type_hash, input_wallets[j].type_hash, - BLAKE2B_BLOCK_SIZE) == 0; - } - if (!has_same_type) { - continue; - } - /* compare amount */ - uint64_t min_output_ckb_amount = 0; - uint128_t min_output_udt_amount = 0; - int overflow = 0; - overflow = uint64_overflow_add( - &min_output_ckb_amount, input_wallets[j].ckb_amount, min_ckb_amount); - int meet_ckb_cond = !overflow && ckb_amount >= min_output_ckb_amount; - overflow = uint128_overflow_add( - &min_output_udt_amount, input_wallets[j].udt_amount, min_udt_amount); - int meet_udt_cond = !overflow && udt_amount >= min_output_udt_amount; - - /* fail if can't meet both conditions */ - if (!(meet_ckb_cond || meet_udt_cond)) { - return ERROR_OUTPUT_AMOUNT_NOT_ENOUGH; - } - /* output coins must meet condition, or remain the old amount */ - if ((!meet_ckb_cond && ckb_amount != input_wallets[j].ckb_amount) || - (!meet_udt_cond && udt_amount != input_wallets[j].udt_amount)) { - - return ERROR_OUTPUT_AMOUNT_NOT_ENOUGH; - } - - /* increase counter */ - found_inputs++; - input_wallets[j].output_cnt += 1; - if (found_inputs > 1) { - return ERROR_DUPLICATED_INPUTS; - } - if (input_wallets[j].output_cnt > 1) { - return ERROR_DUPLICATED_OUTPUTS; - } - } - - /* one output should pair with one input */ - if (found_inputs == 0) { - return ERROR_NO_PAIR; - } else if (found_inputs > 1) { - return ERROR_DUPLICATED_INPUTS; - } - - i++; - } - - /* check inputs wallet, one input should pair with one output */ - for (int j = 0; j < input_wallets_cnt; j++) { - if (input_wallets[j].output_cnt == 0) { - return ERROR_NO_PAIR; - } else if (input_wallets[j].output_cnt > 1) { - return ERROR_DUPLICATED_OUTPUTS; - } - } - - return CKB_SUCCESS; -} - -int read_args(unsigned char *pubkey_hash, uint64_t *min_ckb_amount, - uint128_t *min_udt_amount) { - int ret; - uint64_t len = 0; - - /* Load args */ - unsigned char script[SCRIPT_SIZE]; - len = SCRIPT_SIZE; - ret = ckb_load_script(script, &len, 0); - if (ret != CKB_SUCCESS) { - return ERROR_SYSCALL; - } - if (len > SCRIPT_SIZE) { - return ERROR_SCRIPT_TOO_LONG; - } - mol_seg_t script_seg; - script_seg.ptr = (uint8_t *)script; - script_seg.size = len; - - if (MolReader_Script_verify(&script_seg, false) != MOL_OK) { - return ERROR_ENCODING; - } - - mol_seg_t args_seg = MolReader_Script_get_args(&script_seg); - mol_seg_t args_bytes_seg = MolReader_Bytes_raw_bytes(&args_seg); - if (args_bytes_seg.size < BLAKE160_SIZE || - args_bytes_seg.size > BLAKE160_SIZE + 2) { - return ERROR_ARGUMENTS_LEN; - } - memcpy(pubkey_hash, args_bytes_seg.ptr, BLAKE160_SIZE); - *min_ckb_amount = 0; - *min_udt_amount = 0; - if (args_bytes_seg.size > BLAKE160_SIZE) { - int x = args_bytes_seg.ptr[BLAKE160_SIZE]; - int is_overflow = quick_pow10(x, min_ckb_amount); - if (is_overflow) { - *min_ckb_amount = MAX_UINT64; - } - } - if (args_bytes_seg.size > BLAKE160_SIZE + 1) { - int x = args_bytes_seg.ptr[BLAKE160_SIZE + 1]; - int is_overflow = uint128_quick_pow10(x, min_udt_amount); - if (is_overflow) { - *min_udt_amount = MAX_UINT128; - } - } - return CKB_SUCCESS; -} - -int main() { - int ret; - /* read script args */ - unsigned char pubkey_hash[BLAKE160_SIZE] = {0}; - uint64_t min_ckb_amount = 0; - uint128_t min_udt_amount = 0; - ret = read_args(pubkey_hash, &min_ckb_amount, &min_udt_amount); - if (ret != CKB_SUCCESS) { - return ret; - } - - /* try load signature */ - unsigned char first_witness[MAX_WITNESS_SIZE]; - uint64_t first_witness_len = 0; - ret = load_secp256k1_first_witness_and_check_signature(first_witness, - &first_witness_len); - int has_sig = ret == CKB_SUCCESS; - - /* ACP verification */ - if (has_sig) { - /* unlock via signature */ - return verify_secp256k1_blake160_sighash_all_with_witness( - pubkey_hash, first_witness, first_witness_len); - } else { - /* unlock via payment */ - return check_payment_unlock(min_ckb_amount, min_udt_amount); - } -} diff --git a/c/omni_lock.c b/c/omni_lock.c index 7199bfc..81081aa 100644 --- a/c/omni_lock.c +++ b/c/omni_lock.c @@ -27,7 +27,6 @@ int ckb_exit(signed char); // An upgraded version is provided. #include "secp256k1_helper_20210801.h" #include "ckb_swappable_signatures.h" -#include "validate_signature_rsa.h" #include "ckb_identity.h" #include "ckb_smt.h" diff --git a/c/rce_validator.c b/c/rce_validator.c deleted file mode 100644 index 9d79191..0000000 --- a/c/rce_validator.c +++ /dev/null @@ -1,314 +0,0 @@ -// # RCE Validator -// -// A type script used to ensure *RCE cell* is correctly formatted. -// For more details on RCE cell, please refer to this post: -// https://talk.nervos.org/t/rfc-regulation-compliance-extension/5338 - -// it's used by blockchain-api2.h, the behavior when panic -#ifndef MOL2_EXIT -#define MOL2_EXIT ckb_exit -#endif -int ckb_exit(signed char); - -#include -#include - -#include "blockchain-api2.h" -#include "ckb_consts.h" -#if defined(CKB_USE_SIM) -#include "ckb_syscall_rce_validator_sim.h" -#else -#include "ckb_syscalls.h" -#endif -#include "ckb_type_id.h" -#include "rce.h" - -#define FLAG_APPEND_ONLY 0x1 -#define FLAG_FREEZE_TYPE 0x2 - -#define CACHE_SIZE 256 -#define MAX_UPDATES_PER_TX 1024 -#define MAX_PROOF_LENGTH (33 * MAX_UPDATES_PER_TX) -#define SCRIPT_SIZE 32768 - -static uint32_t read_from_cell_data(uintptr_t *arg, uint8_t *ptr, uint32_t len, - uint32_t offset) { - int err; - uint64_t output_len = len; - err = ckb_load_cell_data(ptr, &output_len, offset, arg[0], arg[1]); - if (err != 0) { - DEBUG("Error reading cell data!"); - ckb_exit(ERROR_EOF); - } - return output_len < len ? output_len : len; -} - -static uint32_t read_from_witness(uintptr_t *arg, uint8_t *ptr, uint32_t len, - uint32_t offset) { - int err; - uint64_t output_len = len; - err = ckb_load_witness(ptr, &output_len, offset, arg[0], arg[1]); - if (err != 0) { - DEBUG("Error reading witness!"); - ckb_exit(ERROR_EOF); - } - return output_len < len ? output_len : len; -} - -static int make_data_cursor(uint8_t *buffer, uint32_t cache_size, size_t index, - size_t source, mol2_cursor_t *cursor) { - mol2_data_source_t *ptr = (mol2_data_source_t *)buffer; - - uint64_t len = cache_size; - int err = ckb_load_cell_data(ptr->cache, &len, 0, index, source); - CHECK(err); - CHECK2(len > 0, ERROR_INVALID_MOL_FORMAT); - - ptr->read = read_from_cell_data; - ptr->total_size = len; - ptr->args[0] = (uintptr_t)index; - ptr->args[1] = (uintptr_t)source; - ptr->cache_size = (len > cache_size) ? cache_size : len; - ptr->start_point = 0; - ptr->max_cache_size = cache_size; - - cursor->offset = 0; - cursor->size = len; - cursor->data_source = ptr; - - err = CKB_SUCCESS; -exit: - return err; -} - -static int make_witness_cursor(uint8_t *buffer, uint32_t cache_size, - size_t index, size_t source, - mol2_cursor_t *cursor) { - mol2_data_source_t *ptr = (mol2_data_source_t *)buffer; - - uint64_t len = cache_size; - int err = ckb_load_witness(ptr->cache, &len, 0, index, source); - CHECK(err); - CHECK2(len > 0, ERROR_INVALID_MOL_FORMAT); - - ptr->read = read_from_witness; - ptr->total_size = len; - ptr->args[0] = (uintptr_t)index; - ptr->args[1] = (uintptr_t)source; - ptr->cache_size = (len > cache_size) ? cache_size : len; - ptr->start_point = 0; - ptr->max_cache_size = cache_size; - - cursor->offset = 0; - cursor->size = len; - cursor->data_source = ptr; - - err = CKB_SUCCESS; -exit: - return err; -} - -#ifdef CKB_USE_SIM -int simulator_main() { -#else -int main() { -#endif - // Load Script args first. - // - // | Script Args | Type ID | Flags | - // | ------------- |---------| ------| - // | Length(Byte) | 32 | 1 | - - uint8_t current_script[SCRIPT_SIZE]; - uint64_t len = SCRIPT_SIZE; - int err = ckb_checked_load_script(current_script, &len, 0); - CHECK(err); - CHECK2(len <= SCRIPT_SIZE, ERROR_SCRIPT_TOO_LONG); - mol_seg_t script_seg; - script_seg.ptr = (uint8_t *)current_script; - script_seg.size = len; - mol_errno mol_err = MolReader_Script_verify(&script_seg, false); - CHECK2(mol_err == MOL_OK, ERROR_ENCODING); - mol_seg_t args_seg = MolReader_Script_get_args(&script_seg); - mol_seg_t args_bytes_seg = MolReader_Bytes_raw_bytes(&args_seg); - CHECK2(args_bytes_seg.size == 33, ERROR_ARGUMENTS_LEN); - - uint8_t type_id[32]; - uint8_t flags; - memcpy(type_id, &args_bytes_seg.ptr[0], 32); - flags = args_bytes_seg.ptr[32]; - - err = ckb_validate_type_id(type_id); - if (err != CKB_SUCCESS) { - return err; - } - bool append_only = (flags & FLAG_APPEND_ONLY) != 0; - - uint8_t input_hash[SMT_KEY_BYTES]; - memset(input_hash, 0, SMT_KEY_BYTES); - bool has_input = false, input_is_rule = false; - - if (_ckb_has_type_id_cell(0, 1) == 1) { - has_input = true; - uint8_t input_data_buffer[MOL2_DATA_SOURCE_LEN(CACHE_SIZE)]; - mol2_cursor_t input_cell_data; - err = make_data_cursor(input_data_buffer, CACHE_SIZE, 0, - CKB_SOURCE_GROUP_INPUT, &input_cell_data); - CHECK(err); - - RCDataType rc_data = make_RCData(&input_cell_data); - uint32_t item_id = rc_data.t->item_id(&rc_data); - if (item_id == RCDataUnionRule) { - RCRuleType rule = rc_data.t->as_RCRule(&rc_data); - mol2_cursor_t smt_root = rule.t->smt_root(&rule); - uint32_t read = mol2_read_at(&smt_root, input_hash, SMT_KEY_BYTES); - CHECK2(read == SMT_KEY_BYTES, ERROR_INVALID_MOL_FORMAT); - input_is_rule = true; - } else if (item_id == RCDataUnionCellVec) { - input_is_rule = false; - } else { - return ERROR_INVALID_MOL_FORMAT; - } - } - - uint8_t output_data_buffer[MOL2_DATA_SOURCE_LEN(CACHE_SIZE)]; - mol2_cursor_t output_cell_data; - err = make_data_cursor(output_data_buffer, CACHE_SIZE, 0, - CKB_SOURCE_GROUP_OUTPUT, &output_cell_data); - CHECK(err); - - RCDataType rc_data = make_RCData(&output_cell_data); - uint32_t item_id = rc_data.t->item_id(&rc_data); - if (item_id == RCDataUnionRule) { - if (((flags & FLAG_FREEZE_TYPE) != 0) && (has_input) && (!input_is_rule)) { - return ERROR_TYPE_FREEZED; - } - RCRuleType rule = rc_data.t->as_RCRule(&rc_data); - mol2_cursor_t smt_root = rule.t->smt_root(&rule); - uint8_t output_hash[SMT_KEY_BYTES]; - uint32_t read = mol2_read_at(&smt_root, output_hash, SMT_KEY_BYTES); - CHECK2(read == SMT_KEY_BYTES, ERROR_INVALID_MOL_FORMAT); - - // SMT update validation - uint8_t witness_buffer[MOL2_DATA_SOURCE_LEN(CACHE_SIZE)]; - mol2_cursor_t witness_data; - size_t witness_source = CKB_SOURCE_GROUP_INPUT; - if (ckb_load_cell_by_field(NULL, &len, 0, 0, CKB_SOURCE_GROUP_INPUT, - CKB_CELL_FIELD_CAPACITY) == - CKB_INDEX_OUT_OF_BOUND) { - witness_source = CKB_SOURCE_GROUP_OUTPUT; - } - err = make_witness_cursor(witness_buffer, CACHE_SIZE, 0, witness_source, - &witness_data); - CHECK(err); - - WitnessArgsType witness_args = make_WitnessArgs(&witness_data); - BytesOptType anytype; - if (witness_source == CKB_SOURCE_GROUP_INPUT) { - anytype = witness_args.t->input_type(&witness_args); - } else { - anytype = witness_args.t->output_type(&witness_args); - } - CHECK2(!anytype.t->is_none(&anytype), ERROR_INVALID_MOL_FORMAT); - mol2_cursor_t bytes = anytype.t->unwrap(&anytype); - // Bytes stored here are in fact SmtUpdate type - SmtUpdateActionType smt_update_action = make_SmtUpdateAction(&bytes); - SmtUpdateItemVecType smt_items = - smt_update_action.t->updates(&smt_update_action); - - smt_pair_t entries[MAX_UPDATES_PER_TX]; - smt_pair_t old_entries[MAX_UPDATES_PER_TX]; - smt_state_t states; - smt_state_t old_states; - smt_state_init(&states, entries, MAX_UPDATES_PER_TX); - smt_state_init(&old_states, old_entries, MAX_UPDATES_PER_TX); - for (uint32_t i = 0; i < smt_items.t->len(&smt_items); i++) { - bool exists = false; - SmtUpdateItemType item = smt_items.t->get(&smt_items, i, &exists); - if (!exists) { - return ERROR_INVALID_MOL_FORMAT; - } - - mol2_cursor_t key_cursor = item.t->key(&item); - uint8_t values = item.t->packed_values(&item); - - uint8_t key[SMT_KEY_BYTES]; - uint8_t *old_value; - uint8_t *value; - - /* - High 4 bits of values : old_value - Low 4 bits of values: new_value - They can be either 0(SMT_VALUE_NOT_EXISTING) or 1(SMT_VALUE_EXISTING). - Other values like 2, 3, .. 0xF are not allowed. - */ - if ((values & 0xF0) == 0x10) { - old_value = SMT_VALUE_EXISTING; - } else { - old_value = SMT_VALUE_NOT_EXISTING; - CHECK2((values & 0xF0) == 0, ERROR_INVALID_MOL_FORMAT); - } - if ((values & 0x0F) == 0x01) { - value = SMT_VALUE_EXISTING; - } else { - value = SMT_VALUE_NOT_EXISTING; - CHECK2((values & 0x0F) == 0, ERROR_INVALID_MOL_FORMAT); - } - - uint32_t read = mol2_read_at(&key_cursor, key, SMT_KEY_BYTES); - CHECK2(read == SMT_KEY_BYTES, ERROR_INVALID_MOL_FORMAT); - - if (append_only) { - if (memcmp(value, SMT_VALUE_EXISTING, SMT_VALUE_BYTES) != 0) { - return ERROR_APPEND_ONLY; - } - } - - err = smt_state_insert(&states, key, value); - CHECK(err); - err = smt_state_insert(&old_states, key, old_value); - CHECK(err); - } - - mol2_cursor_t proof_cursor = smt_update_action.t->proof(&smt_update_action); - if (proof_cursor.size > MAX_PROOF_LENGTH) { - return ERROR_INVALID_MOL_FORMAT; - } - uint8_t proof[MAX_PROOF_LENGTH]; - uint32_t proof_length = - mol2_read_at(&proof_cursor, proof, MAX_PROOF_LENGTH); - CHECK2(proof_length == proof_cursor.size, ERROR_INVALID_MOL_FORMAT); - - smt_state_normalize(&states); - smt_state_normalize(&old_states); - - // First validate old values & proof are correct - err = smt_verify(input_hash, &old_states, proof, proof_length); - CHECK2(err == 0, ERROR_SMT_VERIFY_FAILED); - // Now validate new hash - err = smt_verify(output_hash, &states, proof, proof_length); - CHECK2(err == 0, ERROR_SMT_VERIFY_FAILED); - } else if (item_id == RCDataUnionCellVec) { - if (((flags & FLAG_FREEZE_TYPE) != 0) && (has_input) && (input_is_rule)) { - return ERROR_TYPE_FREEZED; - } - RCCellVecType cell_vec = rc_data.t->as_RCCellVec(&rc_data); - uint32_t len = cell_vec.t->len(&cell_vec); - bool item_existing = false; - for (uint32_t i = 0; i < len; i++) { - uint8_t hash[BLAKE2B_BLOCK_SIZE]; - mol2_cursor_t item = cell_vec.t->get(&cell_vec, i, &item_existing); - CHECK2(item_existing, ERROR_INVALID_MOL_FORMAT); - CHECK2(item.size == BLAKE2B_BLOCK_SIZE, ERROR_INVALID_MOL_FORMAT); - uint32_t read_len = mol2_read_at(&item, hash, sizeof(hash)); - CHECK2(read_len == sizeof(hash), ERROR_INVALID_MOL_FORMAT); - } - - } else { - return ERROR_INVALID_MOL_FORMAT; - } - - err = CKB_SUCCESS; -exit: - return err; -} diff --git a/c/rsa.syms b/c/rsa.syms deleted file mode 100644 index 586711b..0000000 --- a/c/rsa.syms +++ /dev/null @@ -1,6 +0,0 @@ -{ - load_prefilled_data; - validate_signature; -}; - - diff --git a/c/simple_udt.c b/c/simple_udt.c deleted file mode 100644 index aa4c48b..0000000 --- a/c/simple_udt.c +++ /dev/null @@ -1,197 +0,0 @@ -// # Simple UDT -// -// A simple UDT script using 128 bit unsigned integer range -// -// This UDT has 2 unlocking modes: -// -// 1. If one of the transaction input has a lock script matching the UDT -// script argument, the UDT script will be in owner mode. In owner mode no -// checks is performed, the owner can perform any operations such as issuing -// more UDTs or burning UDTs. By ensuring at least one transaction input has -// a matching lock script, the ownership of UDT can be ensured. -// 2. Otherwise, the UDT script will be in normal mode, where it ensures the -// sum of all input tokens is not smaller than the sum of all output tokens. -// -// Notice one caveat of this UDT script is that only one UDT can be issued -// for each unique lock script. A more sophisticated UDT script might include -// other arguments(such as the hash of the first input) as a unique identifier, -// however for the sake of simplicity, we are happy with this limitation. - -// First, let's include header files used to interact with CKB. -#include "blockchain.h" -#include "ckb_syscalls.h" - -// We are limiting the script size loaded to be 32KB at most. This should be -// more than enough. We are also using blake2b with 256-bit hash here, which is -// the same as CKB. -#define BLAKE2B_BLOCK_SIZE 32 -#define SCRIPT_SIZE 32768 - -// Common error codes that might be returned by the script. -#define ERROR_ARGUMENTS_LEN -1 -#define ERROR_ENCODING -2 -#define ERROR_SYSCALL -3 -#define ERROR_SCRIPT_TOO_LONG -21 -#define ERROR_OVERFLOWING -51 -#define ERROR_AMOUNT -52 - -// We will leverage gcc's 128-bit integer extension here for number crunching. -typedef unsigned __int128 uint128_t; - -int main() { - // First, let's load current running script, so we can extract owner lock - // script hash from script args. - unsigned char script[SCRIPT_SIZE]; - uint64_t len = SCRIPT_SIZE; - int ret = ckb_load_script(script, &len, 0); - if (ret != CKB_SUCCESS) { - return ERROR_SYSCALL; - } - if (len > SCRIPT_SIZE) { - return ERROR_SCRIPT_TOO_LONG; - } - mol_seg_t script_seg; - script_seg.ptr = (uint8_t *)script; - script_seg.size = len; - - if (MolReader_Script_verify(&script_seg, false) != MOL_OK) { - return ERROR_ENCODING; - } - - mol_seg_t args_seg = MolReader_Script_get_args(&script_seg); - mol_seg_t args_bytes_seg = MolReader_Bytes_raw_bytes(&args_seg); - if (args_bytes_seg.size != BLAKE2B_BLOCK_SIZE) { - return ERROR_ARGUMENTS_LEN; - } - - // With owner lock script extracted, we will look through each input in the - // current transaction to see if any unlocked cell uses owner lock. - int owner_mode = 0; - size_t i = 0; - while (1) { - uint8_t buffer[BLAKE2B_BLOCK_SIZE]; - uint64_t len = BLAKE2B_BLOCK_SIZE; - // There are 2 points worth mentioning here: - // - // * First, we are using the checked version of CKB syscalls, the checked - // versions will return an error if our provided buffer is not enough to - // hold all returned data. This can help us ensure that we are processing - // enough data here. - // * Second, `CKB_CELL_FIELD_LOCK_HASH` is used here to directly load the - // lock script hash, so we don't have to manually calculate the hash again - // here. - ret = ckb_checked_load_cell_by_field(buffer, &len, 0, i, CKB_SOURCE_INPUT, - CKB_CELL_FIELD_LOCK_HASH); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - if (ret != CKB_SUCCESS) { - return ret; - } - if (len != BLAKE2B_BLOCK_SIZE) { - return ERROR_ENCODING; - } - if (memcmp(buffer, args_bytes_seg.ptr, BLAKE2B_BLOCK_SIZE) == 0) { - owner_mode = 1; - break; - } - i += 1; - } - - // When owner mode is triggered, we won't perform any checks here, the owner - // is free to make any changes here, including token issurance, minting, etc. - if (owner_mode) { - return CKB_SUCCESS; - } - - // When the owner mode is not enabled, however, we will then need to ensure - // the sum of all input tokens is not smaller than the sum of all output - // tokens. First, let's loop through all input cells containing current UDTs, - // and gather the sum of all input tokens. - uint128_t input_amount = 0; - i = 0; - while (1) { - uint128_t current_amount = 0; - len = 16; - // The implementation here does not require that the transaction only - // contains UDT cells for the current UDT type. It's perfectly fine to mix - // the cells for multiple different types of UDT together in one - // transaction. But that also means we need a way to tell one UDT type from - // another UDT type. The trick is in the `CKB_SOURCE_GROUP_INPUT` value used - // here. When using it as the source part of the syscall, the syscall would - // only iterate through cells with the same script as the current running - // script. Since different UDT types will naturally have different - // script(the args part will be different), we can be sure here that this - // loop would only iterate through UDTs that are of the same type as the one - // identified by the current running script. - // - // In the case that multiple UDT types are included in the same transaction, - // this simple UDT script will be run multiple times to validate the - // transaction, each time with a different script containing different - // script args, representing different UDT types. - // - // A different trick used here, is that our current implementation assumes - // that the amount of UDT is stored as unsigned 128-bit little endian - // integer in the first 16 bytes of cell data. Since RISC-V also uses little - // endian format, we can just read the first 16 bytes of cell data into - // `current_amount`, which is just an unsigned 128-bit integer in C. The - // memory layout of a C program will ensure that the value is set correctly. - ret = ckb_load_cell_data((uint8_t *)¤t_amount, &len, 0, i, - CKB_SOURCE_GROUP_INPUT); - // When `CKB_INDEX_OUT_OF_BOUND` is reached, we know we have iterated - // through all cells of current type. - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - if (ret != CKB_SUCCESS) { - return ret; - } - if (len < 16) { - return ERROR_ENCODING; - } - input_amount += current_amount; - // Like any serious smart contract out there, we will need to check for - // overflows. - if (input_amount < current_amount) { - return ERROR_OVERFLOWING; - } - i += 1; - } - - // With the sum of all input UDT tokens gathered, let's now iterate through - // output cells to grab the sum of all output UDT tokens. - uint128_t output_amount = 0; - i = 0; - while (1) { - uint128_t current_amount = 0; - len = 16; - // Similar to the above code piece, we are also looping through output cells - // with the same script as current running script here by using - // `CKB_SOURCE_GROUP_OUTPUT`. - ret = ckb_load_cell_data((uint8_t *)¤t_amount, &len, 0, i, - CKB_SOURCE_GROUP_OUTPUT); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - if (ret != CKB_SUCCESS) { - return ret; - } - if (len < 16) { - return ERROR_ENCODING; - } - output_amount += current_amount; - // Like any serious smart contract out there, we will need to check for - // overflows. - if (output_amount < current_amount) { - return ERROR_OVERFLOWING; - } - i += 1; - } - - // When both value are gathered, we can perform the final check here to - // prevent non-authorized token issurance. - if (input_amount < output_amount) { - return ERROR_AMOUNT; - } - return CKB_SUCCESS; -} diff --git a/c/validate_signature_rsa.c b/c/validate_signature_rsa.c deleted file mode 100644 index c0b6d5c..0000000 --- a/c/validate_signature_rsa.c +++ /dev/null @@ -1,621 +0,0 @@ - -#ifndef ASSERT -#define ASSERT(s) (void)0 -#endif - -#include "validate_signature_rsa.h" - -#include -#include - -#include "blake2b.h" -#include "mbedtls/md.h" -#include "mbedtls/md_internal.h" -#include "mbedtls/memory_buffer_alloc.h" -#include "mbedtls/rsa.h" - -#if defined(CKB_USE_SIM) -#include -#define mbedtls_printf printf -#else -#define mbedtls_printf(x, ...) (void)0 -#endif - -#define BLAKE160_SIZE 20 -#define BLAKE2B_BLOCK_SIZE 32 - -enum ErrorCode { - // 0 is the only success code. We can use 0 directly. - CKB_SUCCESS = 0, - // error code is starting from 40, to avoid conflict with - // common error code in other scripts. - ERROR_RSA_INVALID_PARAM1 = 40, - ERROR_RSA_INVALID_PARAM2, - ERROR_RSA_VERIFY_FAILED, - ERROR_RSA_ONLY_INIT, - ERROR_RSA_INVALID_KEY_SIZE, - ERROR_RSA_INVALID_MD_TYPE2, - ERROR_RSA_INVALID_ID, - ERROR_BAD_MEMORY_LAYOUT, - ERROR_INVALID_MD_TYPE, - ERROR_INVALID_PADDING, - ERROR_MD_FAILED, - ERROR_MBEDTLS_ERROR_1, - ERROR_ISO97962_MISMATCH_HASH, - ERROR_ISO97962_INVALID_ARG1, - ERROR_ISO97962_INVALID_ARG2, - ERROR_ISO97962_INVALID_ARG3, - ERROR_ISO97962_INVALID_ARG4, - ERROR_ISO97962_INVALID_ARG5, - ERROR_ISO97962_INVALID_ARG6, - ERROR_ISO97962_INVALID_ARG7, - ERROR_ISO97962_INVALID_ARG8, - ERROR_ISO97962_INVALID_ARG9, - ERROR_ISO97962_INVALID_ARG10, - ERROR_ISO97962_INVALID_ARG11, - ERROR_ISO97962_INVALID_ARG12, - ERROR_ISO97962_INVALID_ARG13, - ERROR_WRONG_PUBKEY, -}; - -#define CHECK2(cond, code) \ - do { \ - if (!(cond)) { \ - err = code; \ - ASSERT(0); \ - goto exit; \ - } \ - } while (0) - -#define CHECK(code) \ - do { \ - if (code != 0) { \ - err = code; \ - ASSERT(0); \ - goto exit; \ - } \ - } while (0) - -int md_string(const mbedtls_md_info_t *md_info, const uint8_t *buf, size_t n, - unsigned char *output); -int validate_signature_iso9796_2(void *, const uint8_t *sig_buf, - size_t sig_size, const uint8_t *msg_buf, - size_t msg_size, uint8_t *out, - size_t *out_len); -int validate_signature_iso9796_2_batch(void *_p, const uint8_t *sig_buf, - size_t sig_len, const uint8_t *msg_buf, - size_t msg_len, uint8_t *out, - size_t *out_len); - -bool is_valid_iso97962_md_type(uint8_t md) { - return md == CKB_MD_SHA1 || md == CKB_MD_SHA224 || md == CKB_MD_SHA256 || - md == CKB_MD_SHA384 || md == CKB_MD_SHA512; -} - -// remove SHA1 and RIPEMD160 as options for the message digest hash functions. -bool is_valid_rsa_md_type(uint8_t md) { - return md == CKB_MD_SHA224 || md == CKB_MD_SHA256 || md == CKB_MD_SHA384 || - md == CKB_MD_SHA512; -} - -bool is_valid_key_size(uint8_t size) { - return size == CKB_KEYSIZE_1024 || size == CKB_KEYSIZE_2048 || - size == CKB_KEYSIZE_4096; -} - -bool is_valid_key_size_in_bit(uint32_t size) { - return size == 1024 || size == 2048 || size == 4096; -} - -bool is_valid_padding(uint8_t padding) { - return padding == CKB_PKCS_15 || padding == CKB_PKCS_21; -} - -uint32_t get_key_size(uint8_t key_size_enum) { - if (key_size_enum == CKB_KEYSIZE_1024) { - return 1024; - } else if (key_size_enum == CKB_KEYSIZE_2048) { - return 2048; - } else if (key_size_enum == CKB_KEYSIZE_4096) { - return 4096; - } else { - ASSERT(false); - return 0; - } -} - -void get_pubkey_hash(RsaInfo *info, uint8_t *hash) { - uint8_t temp[BLAKE2B_BLOCK_SIZE]; - - uint32_t key_size = get_key_size(info->key_size); - uint32_t total = calculate_rsa_info_length(key_size); - uint32_t pubkey_size = total - key_size / 8; - - blake2b_state ctx; - blake2b_init(&ctx, BLAKE2B_BLOCK_SIZE); - blake2b_update(&ctx, info, pubkey_size); - blake2b_final(&ctx, temp, BLAKE2B_BLOCK_SIZE); - - memcpy(hash, temp, BLAKE160_SIZE); -} - -int check_pubkey(mbedtls_mpi *N, mbedtls_mpi *E) { - int err = 0; - size_t key_size = mbedtls_mpi_size(N) * 8; - CHECK2(is_valid_key_size_in_bit(key_size), ERROR_WRONG_PUBKEY); - - mbedtls_mpi two; - mbedtls_mpi_init(&two); - err = mbedtls_mpi_lset(&two, 2); - CHECK(err); - CHECK2(mbedtls_mpi_cmp_mpi(&two, E) < 0 && mbedtls_mpi_cmp_mpi(E, N) < 0, - ERROR_WRONG_PUBKEY); - - err = 0; -exit: - return err; -} - -mbedtls_md_type_t convert_md_type(uint8_t type) { - mbedtls_md_type_t result = MBEDTLS_MD_NONE; - switch (type) { - case CKB_MD_SHA224: - result = MBEDTLS_MD_SHA224; - break; - case CKB_MD_SHA256: - result = MBEDTLS_MD_SHA256; - break; - case CKB_MD_SHA384: - result = MBEDTLS_MD_SHA384; - break; - case CKB_MD_SHA512: - result = MBEDTLS_MD_SHA512; - break; - case CKB_MD_SHA1: - result = MBEDTLS_MD_SHA1; - break; - default: - ASSERT(0); - result = MBEDTLS_MD_NONE; - } - return result; -} - -int convert_padding(uint8_t padding) { - if (padding == CKB_PKCS_15) { - return MBEDTLS_RSA_PKCS_V15; - } else if (padding == CKB_PKCS_21) { - return MBEDTLS_RSA_PKCS_V21; - } else { - ASSERT(0); - } - return -1; -} - -__attribute__((visibility("default"))) int load_prefilled_data(void *data, - size_t *len) { - (void)data; - *len = 0; - return CKB_SUCCESS; -} - -uint8_t *get_rsa_signature(RsaInfo *info) { - int length = get_key_size(info->key_size) / 8; - // note: sanitizer reports error: - // Index 256 out of bounds for type 'uint8_t [128]' - // It's intended. RsaInfo is actually an variable length buffer. - return (uint8_t *)&info->N[length]; -} - -uint32_t calculate_rsa_info_length(int key_size) { return 8 + key_size / 4; } - -int validate_signature_rsa(void *prefilled_data, - const uint8_t *signature_buffer, - size_t signature_size, const uint8_t *msg_buf, - size_t msg_size, uint8_t *output, - size_t *output_len) { - (void)prefilled_data; - int err = ERROR_RSA_ONLY_INIT; - uint8_t hash_buf[MBEDTLS_MD_MAX_SIZE] = {0}; - uint32_t hash_size = 0; - uint32_t key_size = 0; - bool is_rsa_inited = false; - mbedtls_rsa_context rsa; - - RsaInfo *input_info = (RsaInfo *)signature_buffer; - - // for key size with 1024 and 2048 bits, it uses up to 7K bytes. - int alloc_buff_size = 1024 * 7; - // for key size with 4096 bits, it uses 12K bytes at most. - if (input_info->key_size == CKB_KEYSIZE_4096) alloc_buff_size = 1024 * 12; - unsigned char alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - CHECK2(is_valid_rsa_md_type(input_info->md_type), ERROR_INVALID_MD_TYPE); - CHECK2(is_valid_padding(input_info->padding), ERROR_INVALID_PADDING); - CHECK2(is_valid_key_size(input_info->key_size), ERROR_RSA_INVALID_KEY_SIZE); - key_size = get_key_size(input_info->key_size); - CHECK2(key_size > 0, ERROR_RSA_INVALID_KEY_SIZE); - CHECK2(signature_buffer != NULL, ERROR_RSA_INVALID_PARAM1); - CHECK2(msg_buf != NULL, ERROR_RSA_INVALID_PARAM1); - CHECK2(signature_size == (size_t)calculate_rsa_info_length(key_size), - ERROR_RSA_INVALID_PARAM2); - - mbedtls_md_type_t md_type = convert_md_type(input_info->md_type); - const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type(md_type); - CHECK2(md_info != NULL, ERROR_RSA_INVALID_MD_TYPE2); - - hash_size = md_info->size; - int padding = convert_padding(input_info->padding); - - is_rsa_inited = true; - mbedtls_rsa_init(&rsa, padding, 0); - - err = mbedtls_mpi_read_binary_le( - &rsa.E, (const unsigned char *)&input_info->E, sizeof(uint32_t)); - CHECK2(err == 0, ERROR_MBEDTLS_ERROR_1); - - err = mbedtls_mpi_read_binary_le(&rsa.N, input_info->N, key_size / 8); - CHECK2(err == 0, ERROR_MBEDTLS_ERROR_1); - - CHECK(check_pubkey(&rsa.N, &rsa.E)); - - rsa.len = (mbedtls_mpi_bitlen(&rsa.N) + 7) >> 3; - CHECK2(is_valid_key_size_in_bit(rsa.len * 8), ERROR_WRONG_PUBKEY); - - err = md_string(md_info, msg_buf, msg_size, hash_buf); - CHECK2(err == 0, ERROR_MD_FAILED); - - err = mbedtls_rsa_pkcs1_verify(&rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, md_type, - hash_size, hash_buf, - get_rsa_signature(input_info)); - if (err != 0) { - err = ERROR_RSA_VERIFY_FAILED; - goto exit; - } - - if (output != NULL && output_len != NULL && *output_len >= BLAKE160_SIZE) { - get_pubkey_hash(input_info, output); - *output_len = BLAKE160_SIZE; - } - - err = CKB_SUCCESS; - -exit: - if (is_rsa_inited) mbedtls_rsa_free(&rsa); - return err; -} - -/** - * entry for different algorithms - * The fist byte of signature_buffer is the algorithm_id, it can be: - * #define CKB_VERIFY_RSA 1 - * #define CKB_VERIFY_ISO9796_2 2 -s */ -__attribute__((visibility("default"))) int validate_signature( - void *prefilled_data, const uint8_t *sig_buf, size_t sig_len, - const uint8_t *msg_buf, size_t msg_len, uint8_t *output, - size_t *output_len) { - // we have 4 bytes common header at the beginning of RsaInfo, - // need to make sure they occupy exactly 4 bytes. - if (sizeof(RsaInfo) != (PLACEHOLDER_SIZE * 2 + 8)) { - ASSERT(0); - return ERROR_BAD_MEMORY_LAYOUT; - } - if (sig_buf == NULL) { - ASSERT(0); - return ERROR_RSA_INVALID_PARAM1; - } - - uint8_t id = ((RsaInfo *)sig_buf)->algorithm_id; - - if (id == CKB_VERIFY_RSA) { - return validate_signature_rsa(prefilled_data, sig_buf, sig_len, msg_buf, - msg_len, output, output_len); - } else if (id == CKB_VERIFY_ISO9796_2) { - return validate_signature_iso9796_2(prefilled_data, sig_buf, sig_len, - msg_buf, msg_len, output, output_len); - } else if (id == CKB_VERIFY_ISO9796_2_BATCH) { - return validate_signature_iso9796_2_batch( - prefilled_data, sig_buf, sig_len, msg_buf, msg_len, output, output_len); - } else { - return ERROR_RSA_INVALID_ID; - } -} - -int md_string(const mbedtls_md_info_t *md_info, const uint8_t *buf, size_t n, - unsigned char *output) { - int err = 0; - mbedtls_md_context_t ctx; - mbedtls_md_init(&ctx); - - CHECK2(md_info != NULL, MBEDTLS_ERR_MD_BAD_INPUT_DATA); - err = mbedtls_md_setup(&ctx, md_info, 0); - CHECK(err); - err = mbedtls_md_starts(&ctx); - CHECK(err); - err = mbedtls_md_update(&ctx, (const unsigned char *)buf, n); - CHECK(err); - err = mbedtls_md_finish(&ctx, output); - CHECK(err); - err = 0; -exit: - mbedtls_md_free(&ctx); - return err; -} - -// ISO 9796-2, scheme #1 -// some hash functions are not implemented but we still list them here according -// to the spec. -enum Trailer { - TRAILER_IMPLICIT = 0xBC, - TRAILER_RIPEMD160 = 0x31CC, - TRAILER_RIPEMD128 = 0x32CC, - TRAILER_SHA1 = 0x33CC, - TRAILER_SHA256 = 0x34CC, - TRAILER_SHA512 = 0x35CC, - TRAILER_SHA384 = 0x36CC, - TRAILER_WHIRLPOOL = 0x37CC, - TRAILER_SHA224 = 0x38CC, - TRAILER_SHA512_224 = 0x39CC, - TRAILER_SHA512_256 = 0x3aCC -}; - -uint16_t get_trailer_by_md(mbedtls_md_type_t md) { - if (md == MBEDTLS_MD_NONE) { - return TRAILER_IMPLICIT; - } else if (md == MBEDTLS_MD_SHA1) { - return TRAILER_SHA1; - } else if (md == MBEDTLS_MD_SHA224) { - return TRAILER_SHA224; - } else if (md == MBEDTLS_MD_SHA256) { - return TRAILER_SHA256; - } else if (md == MBEDTLS_MD_SHA384) { - return TRAILER_SHA384; - } else if (md == MBEDTLS_MD_SHA512) { - return TRAILER_SHA512; - } else if (md == MBEDTLS_MD_RIPEMD160) { - return TRAILER_RIPEMD160; - } else { - ASSERT(false); - return 0; - } -} - -typedef struct ISO97962Encoding { - uint32_t key_size; // RSA key size 1024, 2048, 4096, etc - mbedtls_md_type_t md; - bool implicity; - - uint32_t trailer; -} ISO97962Encoding; - -void iso97962_init(ISO97962Encoding *enc, uint32_t key_size_byte, - mbedtls_md_type_t md, bool implicity) { - enc->key_size = key_size_byte * 8; - enc->md = md; - enc->implicity = implicity; - - enc->trailer = get_trailer_by_md(md); -} - -int iso97962_verify(ISO97962Encoding *enc, const uint8_t *block, - uint32_t block_len, const uint8_t *origin, - uint32_t origin_len, uint8_t *msg, uint32_t *msg_len) { - int err = 0; - const mbedtls_md_info_t *digest = mbedtls_md_info_from_type(enc->md); - if (digest == NULL) { - return ERROR_ISO97962_INVALID_ARG6; - } - int hash_len = digest->size; - uint8_t hash[MBEDTLS_MD_MAX_SIZE] = {0}; - - int alloc_buff_size = 20 * 1024; - uint8_t alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - CHECK2(block != NULL && msg != NULL, ERROR_ISO97962_INVALID_ARG1); - CHECK2(*msg_len >= block_len, ERROR_ISO97962_INVALID_ARG1); - CHECK2(block_len == enc->key_size / 8, ERROR_ISO97962_INVALID_ARG1); - - if (((block[0] & 0xC0) ^ 0x40) != 0) { - return ERROR_ISO97962_INVALID_ARG2; - } - - if (((block[block_len - 1] & 0xF) ^ 0xC) != 0) { - return ERROR_ISO97962_INVALID_ARG3; - } - - int delta = 0; - - if (((block[block_len - 1] & 0xFF) ^ 0xBC) == 0) { - delta = 1; - } else { - int sig_trail = - ((block[block_len - 2] & 0xFF) << 8) | (block[block_len - 1] & 0xFF); - int trailer_obj = get_trailer_by_md(enc->md); - - if (trailer_obj != 0) { - if (sig_trail != trailer_obj) { - if (!(trailer_obj == TRAILER_SHA512_256 && sig_trail == 0x40CC)) { - return ERROR_ISO97962_INVALID_ARG4; - } - } - } else { - // this branch can't be reached due to "if (digest == NULL)" above. - // but still keep it here for defensive purpose - return ERROR_ISO97962_INVALID_ARG4; - } - - delta = 2; - } - - // find out how much padding we've got - int msg_start = 0; - - for (msg_start = 0; msg_start != block_len; msg_start++) { - if (((block[msg_start] & 0x0f) ^ 0x0a) == 0) { - break; - } - } - msg_start++; - - int off = block_len - delta - digest->size; - if ((off - msg_start) <= 0) { - return ERROR_ISO97962_INVALID_ARG5; - } - - if ((block[0] & 0x20) == 0) { - mbedtls_md(digest, block + msg_start, off - msg_start, hash); - - *msg_len = off - msg_start; - memcpy(msg, block + msg_start, *msg_len); - - for (int i = 0; i != hash_len; i++) { - if (block[off + i] != hash[i]) { - err = ERROR_ISO97962_MISMATCH_HASH; - goto exit; - } - } - - } else { - mbedtls_md(digest, origin, origin_len, hash); - - *msg_len = off - msg_start; - memcpy(msg, block + msg_start, *msg_len); - - for (int i = 0; i != hash_len; i++) { - if (block[off + i] != hash[i]) { - err = ERROR_ISO97962_MISMATCH_HASH; - goto exit; - } - } - } - err = 0; -exit: - return err; -} - -int validate_signature_iso9796_2(void *_p, const uint8_t *sig_buf, - size_t sig_len, const uint8_t *msg_buf, - size_t msg_len, uint8_t *out, - size_t *out_len) { - int err = 0; - - (void)_p; - RsaInfo *info = (RsaInfo *)sig_buf; - mbedtls_rsa_context rsa; - mbedtls_mpi N; - mbedtls_mpi E; - - if (sig_len < sizeof(RsaInfo)) { - return ERROR_ISO97962_INVALID_ARG12; - } - - uint32_t key_size_byte = get_key_size(info->key_size) / 8; - - uint8_t *sig = NULL; - uint8_t block[key_size_byte]; - uint8_t m1[key_size_byte]; - uint32_t m1_len = key_size_byte; - uint8_t full_msg[key_size_byte * 2]; - uint8_t new_msg[key_size_byte * 2]; - uint32_t new_msg_len = key_size_byte; - - int alloc_buff_size = 20 * 1024; - unsigned char alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - CHECK2(key_size_byte > 0, ERROR_ISO97962_INVALID_ARG7); - CHECK2(msg_buf != NULL, ERROR_ISO97962_INVALID_ARG8); - CHECK2(out != NULL, ERROR_ISO97962_INVALID_ARG8); - CHECK2(out_len != NULL, ERROR_ISO97962_INVALID_ARG8); - CHECK2(key_size_byte > 0, ERROR_ISO97962_INVALID_ARG8); - CHECK2(is_valid_iso97962_md_type(info->md_type), ERROR_INVALID_MD_TYPE); - - mbedtls_mpi_init(&N); - mbedtls_mpi_init(&E); - - err = mbedtls_mpi_read_binary_le(&N, (uint8_t *)info->N, key_size_byte); - CHECK2(err == 0, ERROR_ISO97962_INVALID_ARG9); - err = mbedtls_mpi_read_binary_le(&E, (uint8_t *)&info->E, 4); - CHECK2(err == 0, ERROR_ISO97962_INVALID_ARG10); - - CHECK(check_pubkey(&N, &E)); - - mbedtls_rsa_init(&rsa, MBEDTLS_RSA_PKCS_V15, 0); - err = mbedtls_rsa_import(&rsa, &N, NULL, NULL, NULL, &E); - CHECK2(err == 0, ERROR_ISO97962_INVALID_ARG11); - - sig = get_rsa_signature(info); - - err = mbedtls_rsa_public(&rsa, sig, block); - CHECK2(err == 0, ERROR_ISO97962_INVALID_ARG12); - - ISO97962Encoding enc = {0}; - mbedtls_md_type_t md_type = convert_md_type(info->md_type); - - iso97962_init(&enc, key_size_byte, md_type, false); - err = iso97962_verify(&enc, block, key_size_byte, msg_buf, msg_len, m1, - &m1_len); - CHECK2(err == 0 || err == ERROR_ISO97962_MISMATCH_HASH, - ERROR_ISO97962_INVALID_ARG9); - - memcpy(full_msg, m1, m1_len); - memcpy(full_msg + m1_len, msg_buf, msg_len); - - err = iso97962_verify(&enc, block, sizeof(block), full_msg, m1_len + msg_len, - new_msg, &new_msg_len); - CHECK(err); - - if (out != NULL && out_len != NULL && *out_len >= BLAKE160_SIZE) { - get_pubkey_hash(info, out); - *out_len = BLAKE160_SIZE; - } - - err = 0; -exit: - if (err == 0) { - mbedtls_printf("validate_signature_iso9796_2() passed.\n"); - } else { - mbedtls_printf("validate_signature_iso9796_2() failed: %d\n", err); - } - return err; -} - -// It costs 4 calls to validate full 32-bytes message. -// The layout of buffer "sig" should be: -// RsaInfo + sig[key_size/8] + sig[key_size/8] + sig[key_size/8] -int validate_signature_iso9796_2_batch(void *_p, const uint8_t *sig_buf, - size_t sig_len, const uint8_t *msg_buf, - size_t msg_len, uint8_t *out, - size_t *out_len) { - (void)_p; - int err = 0; - - RsaInfo *info = (RsaInfo *)sig_buf; - uint32_t key_size = get_key_size(info->key_size); - CHECK2(key_size != 0, ERROR_ISO97962_INVALID_ARG9); - uint32_t one_sig_len = calculate_rsa_info_length(key_size); - uint32_t raw_sig_len = key_size / 8; - - uint32_t expected_sig_len = one_sig_len + 3 * raw_sig_len; - CHECK2(sig_len == expected_sig_len, ERROR_ISO97962_INVALID_ARG9); - - for (int index = 0; index < 4; index++) { - uint8_t sig_shard[one_sig_len]; - const uint8_t *msg_shard = msg_buf + index * 8; - uint32_t sig_shard_len = one_sig_len; - - memcpy(sig_shard, sig_buf, 8); - memcpy(sig_shard + 8, sig_buf + 8 + index * raw_sig_len, raw_sig_len); - - err = validate_signature_iso9796_2(NULL, sig_shard, sig_shard_len, - msg_shard, 8, out, out_len); - CHECK(err); - CHECK2(*out_len >= BLAKE160_SIZE, ERROR_WRONG_PUBKEY); - } - -exit: - return err; -} diff --git a/c/validate_signature_rsa.h b/c/validate_signature_rsa.h deleted file mode 100644 index 313508e..0000000 --- a/c/validate_signature_rsa.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef CKB_MISCELLANEOUS_SCRIPTS_RSA_ALL_H -#define CKB_MISCELLANEOUS_SCRIPTS_RSA_ALL_H - -#include - -// used as algorithm_id, see below -// when algorithm_id is CKB_VERIFY_RSA, use RsaInfo structure -#define CKB_VERIFY_RSA 1 -// when algorithm_id is CKB_VERIFY_ISO9796_2, use RsaInfo structure -#define CKB_VERIFY_ISO9796_2 2 -// when algorithm_id is CKB_VERIFY_ISO9796_2_BATCH, use modified RsaInfo -// structure -#define CKB_VERIFY_ISO9796_2_BATCH 3 - -// used as key_size enum values: their "KeySize" are 1024, 2048, 4098 bits. -// The term "KeySize" has same meaning below. -#define CKB_KEYSIZE_1024 1 -#define CKB_KEYSIZE_2048 2 -#define CKB_KEYSIZE_4096 3 - -// used as padding value -// PKCS# 1.5 -#define CKB_PKCS_15 0 -// PKCS# 2.1 -#define CKB_PKCS_21 1 - -// used as md_type value (message digest), it has same value as -// mbedtls_md_type_t -#define CKB_MD_NONE 0 -// very weak hash function -//#define CKB_MD_MD2 1 /**< The MD2 message digest. */ -//#define CKB_MD_MD4 2 /**< The MD4 message digest. */ -//#define CKB_MD_MD5 3 /**< The MD5 message digest. */ -// SHA1 is weak too, but it's already used by ISO 9796-2 -// It's not allowed to set SHA1 while using RSA -#define CKB_MD_SHA1 4 /**< The SHA-1 message digest. */ -#define CKB_MD_SHA224 5 /**< The SHA-224 message digest. */ -#define CKB_MD_SHA256 6 /**< The SHA-256 message digest. */ -#define CKB_MD_SHA384 7 /**< The SHA-384 message digest. */ -#define CKB_MD_SHA512 8 /**< The SHA-512 message digest. */ -// #define CKB_MD_RIPEMD160 9 /**< The RIPEMD-160 message digest. */ - -#define PLACEHOLDER_SIZE (128) - -/** signature (in witness, or passed as arguments) memory layout - * This structure contains the following information: - * 1) Common header, 4 bytes, see RsaInfo - * 2) RSA Public Key - * 3) RSA Signature data - * ------------------------------------------------------------------------------ -|common header| E | N (KeySize/8 bytes) | RSA Signature (KeySize/8 bytes)| ------------------------------------------------------------------------------ -The common header, E both occupy 4 bytes. E is in little endian(uint32_t). -So the total length in byte is: 4 + 4 + KeySize/8 + KeySize/8. - -The public key hash is calculated by: blake160(common header + E + N), Note: RSA -signature part is dropped. Here function blake160 returns the first 20 bytes of -blake2b result. -*/ -typedef struct RsaInfo { - // common header part, 4 bytes - // if it doesn't take 4 bytes in memory, ERROR_BAD_MEMORY_LAYOUT returned - // from validate_signature - uint8_t algorithm_id; - uint8_t key_size; - uint8_t padding; - uint8_t md_type; - - // RSA public key, part E. It's normally very small, OK to use uint32_to hold - // it. https://eprint.iacr.org/2008/510.pdf The choice e = 65537 = 2^16 + 1 is - // especially widespread. Of the certificates observed in the UCSD TLS Corpus - // [23] (which was obtained by surveying frequently-used TLS servers), 99.5% - // had e = 65537, and all had e at most 32 bits. - uint32_t E; - - // The following parts are with variable length. We give it a placeholder. - // The real length are both KeySize/8. - - // RSA public key, part N. - // The public key is the combination of E and N. - // But N is a very large number and need to use array to represent it. - // The total length in byte is (KeySize)/8. - // The memory layout is the same as the field "p" of mbedtls_mpi type. - uint8_t N[PLACEHOLDER_SIZE]; - - // pointer to RSA signature - uint8_t sig[PLACEHOLDER_SIZE]; -} RsaInfo; - -/** - * get offset of signature based on key size. - */ -uint8_t *get_rsa_signature(RsaInfo *info); -/** - * get total length of RsaInfo based on key size. - */ -uint32_t calculate_rsa_info_length(int key_size); - -/* - * get real "KeySize" in bits according to the CKB_KEYSIZE_1024, - * CKB_KEYSIZE_2048 and CKB_KEYSIZE_4096 - */ -uint32_t get_key_size(uint8_t key_size_enum); - -/** - * - * @param prefilled_data ignore. Not used. - * @param signature_buffer pointer to signature buffer. It is casted to type - * "RsaInfo*" - * @param signature_size size of signature_buffer. - * @param message_buffer pointer to message buffer. - * @param message_size size of message_buffer. - * @param output blake160 hash of pubkey; NULL if not needed. - * @param output_len length of output buffer size, should be >= 20. NULL if not - * needed. - * @return 0 succeed; otherwise fail. - */ -int validate_signature(void *prefilled_data, const uint8_t *signature_buffer, - size_t signature_size, const uint8_t *msg_buf, - size_t msg_size, uint8_t *output, size_t *output_len); - -/** - * Note: there is no prefilled data for RSA. - * Always succeed. - * @param data not used. - * @param len not used. - * @return always succeed. - */ -int load_prefilled_data(void *data, size_t *len); - -#endif // CKB_MISCELLANEOUS_SCRIPTS_RSA_ALL_H diff --git a/c/xudt_rce.c b/c/xudt_rce.c deleted file mode 100644 index b1c0110..0000000 --- a/c/xudt_rce.c +++ /dev/null @@ -1,706 +0,0 @@ - -// uncomment to enable printf in CKB-VM -//#define CKB_C_STDLIB_PRINTF -//#include - -// it's used by blockchain-api2.h, the behavior when panic -#ifndef MOL2_EXIT -#define MOL2_EXIT ckb_exit -#endif -int ckb_exit(signed char); - -#include -#include - -#include "blake2b.h" -#include "blockchain-api2.h" -#include "ckb_consts.h" - -#if defined(CKB_USE_SIM) -#include - -#include "ckb_syscall_xudt_sim.h" -#define xudt_printf printf -#else -// it will be re-defined in ckb_dlfcn.h -#undef MAX -#undef MIN -#include "ckb_dlfcn.h" -#include "ckb_syscalls.h" -#define xudt_printf(x, ...) (void)0 -#endif - -#define BLAKE160_SIZE 20 -#define SCRIPT_SIZE 32768 -#define RAW_EXTENSION_SIZE 65536 -#define EXPORTED_FUNC_NAME "validate" -// here we reserve a lot of memory for dynamic libraries. The enhanced owner -// mode may also checked via dynamic library. It might consume much memory, e.g. -// precomputed table (about 1 M) in secp256k1 -#define MAX_CODE_SIZE (1024 * 1800) -#define FLAGS_SIZE 4 -#define MAX_LOCK_SCRIPT_HASH_COUNT 2048 - -#define OWNER_MODE_INPUT_TYPE_MASK 0x80000000 -#define OWNER_MODE_OUTPUT_TYPE_MASK 0x40000000 -#define OWNER_MODE_INPUT_LOCK_NOT_MASK 0x20000000 -#define OWNER_MODE_MASK \ - (OWNER_MODE_INPUT_TYPE_MASK | OWNER_MODE_OUTPUT_TYPE_MASK | \ - OWNER_MODE_INPUT_LOCK_NOT_MASK) - -#include "rce.h" - -// global variables, type definitions, etc - -// We will leverage gcc's 128-bit integer extension here for number crunching. -typedef unsigned __int128 uint128_t; - -uint8_t g_script[SCRIPT_SIZE] = {0}; -uint8_t g_raw_extension_data[RAW_EXTENSION_SIZE] = {0}; -WitnessArgsType g_witness_args; - -uint8_t g_code_buff[MAX_CODE_SIZE] __attribute__((aligned(RISCV_PGSIZE))); -uint32_t g_code_used = 0; - -/* -is_owner_mode indicates if current xUDT is unlocked via owner mode(as -described by sUDT), extension_index refers to the index of current extension in -the ScriptVec structure. args and args_length are set to the script args -included in Script structure of current extension script. - -If this function returns 0, the validation for current extension script is -consider successful. - */ -typedef int (*ValidateFuncType)(int is_owner_mode, size_t extension_index, - const uint8_t *args, size_t args_len); - -typedef enum XUDTFlags { - XUDTFlagsPlain = 0, - XUDTFlagsInArgs = 1, - XUDTFlagsInWitness = 2, -} XUDTFlags; - -typedef enum XUDTValidateFuncCategory { - CateNormal = 0, // normal extension script - CateRce = 1, // Regulation Compliance Extension -} XUDTValidateFuncCategory; - -uint8_t RCE_HASH[32] = {1}; - -// functions -int load_validate_func(uint8_t *g_code_buff, uint32_t *g_code_used, - const uint8_t *hash, uint8_t hash_type, - ValidateFuncType *func, XUDTValidateFuncCategory *cat) { - int err = 0; - void *handle = NULL; - size_t consumed_size = 0; - - if (memcmp(RCE_HASH, hash, 32) == 0 && hash_type == 1) { - *cat = CateRce; - *func = rce_validate; - return 0; - } - - CHECK2(MAX_CODE_SIZE > *g_code_used, ERROR_NOT_ENOUGH_BUFF); - err = ckb_dlopen2(hash, hash_type, &g_code_buff[*g_code_used], - MAX_CODE_SIZE - *g_code_used, &handle, &consumed_size); - CHECK(err); - CHECK2(handle != NULL, ERROR_CANT_LOAD_LIB); - ASSERT(consumed_size % RISCV_PGSIZE == 0); - *g_code_used += consumed_size; - - *func = (ValidateFuncType)ckb_dlsym(handle, EXPORTED_FUNC_NAME); - CHECK2(*func != NULL, ERROR_CANT_FIND_SYMBOL); - - *cat = CateNormal; - err = 0; -exit: - return err; -} - -int verify_script_vec(uint8_t *ptr, uint32_t size, uint32_t *real_size) { - int err = 0; - - CHECK2(size >= MOL_NUM_T_SIZE, ERROR_INVALID_MOL_FORMAT); - mol_num_t full_size = mol_unpack_number(ptr); - *real_size = full_size; - CHECK2(*real_size <= size, ERROR_INVALID_MOL_FORMAT); - err = 0; -exit: - return err; -} - -static uint32_t read_from_witness(uintptr_t arg[], uint8_t *ptr, uint32_t len, - uint32_t offset) { - int err; - uint64_t output_len = len; - err = ckb_load_witness(ptr, &output_len, offset, arg[0], arg[1]); - if (err != 0) { - return 0; - } - if (output_len > len) { - return len; - } else { - return output_len; - } -} - -uint8_t g_witness_data_source[DEFAULT_DATA_SOURCE_LENGTH]; -// due to the "static" data (s_witness_data_source), the "WitnessArgsType" is a -// singleton. note: mol2_data_source_t consumes a lot of memory due to the -// "cache" field (default 2K) -int make_cursor_from_witness(WitnessArgsType *witness, bool *use_input_type) { - int err = 0; - uint64_t witness_len = 0; - // at the beginning of the transactions including RCE, - // there is no "witness" in CKB_SOURCE_GROUP_INPUT - // here we use the first witness of CKB_SOURCE_GROUP_OUTPUT - // same logic is applied to rce_validator - size_t source = CKB_SOURCE_GROUP_INPUT; - err = ckb_load_witness(NULL, &witness_len, 0, 0, source); - if (err == CKB_INDEX_OUT_OF_BOUND) { - source = CKB_SOURCE_GROUP_OUTPUT; - err = ckb_load_witness(NULL, &witness_len, 0, 0, source); - *use_input_type = false; - } else { - *use_input_type = true; - } - CHECK(err); - CHECK2(witness_len > 0, ERROR_INVALID_MOL_FORMAT); - - mol2_cursor_t cur; - - cur.offset = 0; - cur.size = witness_len; - - mol2_data_source_t *ptr = (mol2_data_source_t *)g_witness_data_source; - - ptr->read = read_from_witness; - ptr->total_size = witness_len; - // pass index and source as args - ptr->args[0] = 0; - ptr->args[1] = source; - - ptr->cache_size = 0; - ptr->start_point = 0; - ptr->max_cache_size = MAX_CACHE_SIZE; - cur.data_source = ptr; - - *witness = make_WitnessArgs(&cur); - - err = 0; -exit: - return err; -} - -int get_extension_data(uint32_t index, uint8_t *buff, uint32_t buff_len, - uint32_t *out_len) { - int err = 0; - bool use_input_type = true; - err = make_cursor_from_witness(&g_witness_args, &use_input_type); - CHECK(err); - - BytesOptType input; - if (use_input_type) - input = g_witness_args.t->input_type(&g_witness_args); - else - input = g_witness_args.t->output_type(&g_witness_args); - - CHECK2(!input.t->is_none(&input), ERROR_INVALID_MOL_FORMAT); - - mol2_cursor_t bytes = input.t->unwrap(&input); - // convert Bytes to XudtWitnessInputType - XudtWitnessInputType witness_input = make_XudtWitnessInput(&bytes); - BytesVecType extension_data_vec = - witness_input.t->extension_data(&witness_input); - - bool existing = false; - mol2_cursor_t extension_data = - extension_data_vec.t->get(&extension_data_vec, index, &existing); - CHECK2(existing, ERROR_INVALID_MOL_FORMAT); - CHECK2(buff_len >= extension_data.size, ERROR_INVALID_MOL_FORMAT); - - *out_len = mol2_read_at(&extension_data, buff, buff_len); - CHECK2(*out_len == extension_data.size, ERROR_INVALID_MOL_FORMAT); - - err = 0; -exit: - return err; -} - -int get_owner_script(uint8_t *buff, uint32_t buff_len, uint32_t *out_len) { - int err = 0; - bool use_input_type = true; - err = make_cursor_from_witness(&g_witness_args, &use_input_type); - CHECK(err); - BytesOptType input = use_input_type - ? g_witness_args.t->input_type(&g_witness_args) - : g_witness_args.t->output_type(&g_witness_args); - CHECK2(!input.t->is_none(&input), ERROR_INVALID_MOL_FORMAT); - - mol2_cursor_t bytes = input.t->unwrap(&input); - // convert Bytes to XudtWitnessInputType - XudtWitnessInputType witness_input = make_XudtWitnessInput(&bytes); - ScriptOptType owner_script = witness_input.t->owner_script(&witness_input); - CHECK2(!owner_script.t->is_none(&owner_script), ERROR_INVALID_MOL_FORMAT); - ScriptType owner_script2 = owner_script.t->unwrap(&owner_script); - *out_len = mol2_read_at(&owner_script2.cur, buff, buff_len); - CHECK2(*out_len == owner_script2.cur.size, ERROR_INVALID_MOL_FORMAT); - - err = 0; -exit: - return err; -} - -// the *var_len may be bigger than real length of raw extension data -int load_raw_extension_data(uint8_t **var_data, uint32_t *var_len) { - int err = 0; - bool use_input_type = true; - err = make_cursor_from_witness(&g_witness_args, &use_input_type); - CHECK(err); - - BytesOptType input; - if (use_input_type) { - input = g_witness_args.t->input_type(&g_witness_args); - } else { - input = g_witness_args.t->output_type(&g_witness_args); - } - - CHECK2(!input.t->is_none(&input), ERROR_INVALID_MOL_FORMAT); - - struct mol2_cursor_t bytes = input.t->unwrap(&input); - // convert Bytes to XudtWitnessInputType - XudtWitnessInputType witness_input = make_XudtWitnessInput(&bytes); - ScriptVecOptType script_vec = - witness_input.t->raw_extension_data(&witness_input); - - uint32_t read_len = - mol2_read_at(&script_vec.cur, g_raw_extension_data, RAW_EXTENSION_SIZE); - CHECK2(read_len == script_vec.cur.size, ERROR_INVALID_MOL_FORMAT); - - *var_data = g_raw_extension_data; - *var_len = read_len; - - err = 0; -exit: - return err; -} - -int check_owner_mode(size_t source, size_t field, mol_seg_t args_bytes_seg, - int *owner_mode) { - int err = 0; - size_t i = 0; - uint8_t buffer[BLAKE2B_BLOCK_SIZE]; - - while (1) { - uint64_t len = BLAKE2B_BLOCK_SIZE; - err = ckb_checked_load_cell_by_field(buffer, &len, 0, i, source, field); - if (err == CKB_INDEX_OUT_OF_BOUND) { - err = 0; - break; - } - if (err == CKB_ITEM_MISSING) { - i += 1; - err = 0; - continue; - } - CHECK(err); - if (args_bytes_seg.size >= BLAKE2B_BLOCK_SIZE && - memcmp(buffer, args_bytes_seg.ptr, BLAKE2B_BLOCK_SIZE) == 0) { - *owner_mode = 1; - break; - } - i += 1; - } - -exit: - return err; -} - -int check_enhanced_owner_mode(int *owner_mode) { - int err = 0; - uint8_t owner_script[SCRIPT_SIZE]; - uint32_t owner_script_len = 0; - uint8_t owner_script_hash[BLAKE2B_BLOCK_SIZE] = {0}; - - err = get_owner_script(owner_script, SCRIPT_SIZE, &owner_script_len); - CHECK(err); - - err = blake2b(owner_script_hash, BLAKE2B_BLOCK_SIZE, owner_script, - owner_script_len, NULL, 0); - CHECK2(err == 0, ERROR_BLAKE2B_ERROR); - - // get 32 bytes hash from args and compare it to owner script hash - { - uint64_t len = SCRIPT_SIZE; - int ret = ckb_checked_load_script(g_script, &len, 0); - CHECK(ret); - CHECK2(len <= SCRIPT_SIZE, ERROR_SCRIPT_TOO_LONG); - - mol_seg_t script_seg; - script_seg.ptr = g_script; - script_seg.size = len; - - mol_errno mol_err = MolReader_Script_verify(&script_seg, false); - CHECK2(mol_err == MOL_OK, ERROR_ENCODING); - - mol_seg_t args_seg = MolReader_Script_get_args(&script_seg); - mol_seg_t args_bytes_seg = MolReader_Bytes_raw_bytes(&args_seg); - CHECK2(args_bytes_seg.size >= BLAKE2B_BLOCK_SIZE, ERROR_ARGUMENTS_LEN); - - if (memcmp(owner_script_hash, args_bytes_seg.ptr, BLAKE2B_BLOCK_SIZE) != - 0) { - CHECK2(false, ERROR_HASH_MISMATCHED); - } - } - - // execute owner script - mol_seg_t owner_script_seg = {.ptr = owner_script, .size = owner_script_len}; - mol_errno mol_err = MolReader_Script_verify(&owner_script_seg, false); - CHECK2(mol_err == MOL_OK, ERROR_ENCODING); - mol_seg_t code_hash = MolReader_Script_get_code_hash(&owner_script_seg); - mol_seg_t hash_type = MolReader_Script_get_hash_type(&owner_script_seg); - - mol_seg_t owner_args_seg = MolReader_Script_get_args(&owner_script_seg); - mol_seg_t owner_args_bytes_seg = MolReader_Bytes_raw_bytes(&owner_args_seg); - - ValidateFuncType func = NULL; - XUDTValidateFuncCategory cat = CateNormal; - err = load_validate_func(g_code_buff, &g_code_used, code_hash.ptr, - *(uint8_t *)hash_type.ptr, &func, &cat); - CHECK(err); - - err = func(0, 0, owner_args_bytes_seg.ptr, owner_args_bytes_seg.size); - CHECK(err); - *owner_mode = 1; - -exit: - return err; -} - -// *var_data will point to "Raw Extension Data", which can be in args or witness -// *var_data will refer to a memory location of g_script or g_raw_extension_data -int parse_args(int *owner_mode, XUDTFlags *flags, uint8_t **var_data, - uint32_t *var_len, uint8_t *hashes, uint32_t *hashes_count) { - int err = 0; - bool owner_mode_for_input_type = false; - bool owner_mode_for_output_type = false; - // default is on - bool owner_mode_for_input_lock = true; - - uint64_t len = SCRIPT_SIZE; - int ret = ckb_checked_load_script(g_script, &len, 0); - CHECK(ret); - CHECK2(len <= SCRIPT_SIZE, ERROR_SCRIPT_TOO_LONG); - - mol_seg_t script_seg; - script_seg.ptr = g_script; - script_seg.size = len; - - mol_errno mol_err = MolReader_Script_verify(&script_seg, false); - CHECK2(mol_err == MOL_OK, ERROR_ENCODING); - - mol_seg_t args_seg = MolReader_Script_get_args(&script_seg); - mol_seg_t args_bytes_seg = MolReader_Bytes_raw_bytes(&args_seg); - CHECK2(args_bytes_seg.size >= BLAKE2B_BLOCK_SIZE, ERROR_ARGUMENTS_LEN); - - if (args_bytes_seg.size >= (FLAGS_SIZE + BLAKE2B_BLOCK_SIZE)) { - uint32_t val = *(uint32_t *)(args_bytes_seg.ptr + BLAKE2B_BLOCK_SIZE); - if (val & OWNER_MODE_INPUT_TYPE_MASK) { - owner_mode_for_input_type = true; - } - if (val & OWNER_MODE_OUTPUT_TYPE_MASK) { - owner_mode_for_output_type = true; - } - if (val & OWNER_MODE_INPUT_LOCK_NOT_MASK) { - owner_mode_for_input_lock = false; - } - } - - *hashes_count = 0; - - // collect hashes - size_t i = 0; - while (1) { - uint8_t buffer[BLAKE2B_BLOCK_SIZE]; - uint64_t len2 = BLAKE2B_BLOCK_SIZE; - ret = ckb_checked_load_cell_by_field(buffer, &len2, 0, i, CKB_SOURCE_INPUT, - CKB_CELL_FIELD_LOCK_HASH); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - CHECK(ret); - CHECK2(*hashes_count < MAX_LOCK_SCRIPT_HASH_COUNT, ERROR_TOO_MANY_LOCK); - - memcpy(&hashes[(*hashes_count) * BLAKE2B_BLOCK_SIZE], buffer, - BLAKE2B_BLOCK_SIZE); - *hashes_count += 1; - i += 1; - } - - *owner_mode = 0; - - if (owner_mode_for_input_lock && *owner_mode == 0) { - err = check_owner_mode(CKB_SOURCE_INPUT, CKB_CELL_FIELD_LOCK_HASH, - args_bytes_seg, owner_mode); - CHECK(err); - } - - if (owner_mode_for_input_type && *owner_mode == 0) { - err = check_owner_mode(CKB_SOURCE_INPUT, CKB_CELL_FIELD_TYPE_HASH, - args_bytes_seg, owner_mode); - CHECK(err); - } - if (owner_mode_for_output_type && *owner_mode == 0) { - err = check_owner_mode(CKB_SOURCE_OUTPUT, CKB_CELL_FIELD_TYPE_HASH, - args_bytes_seg, owner_mode); - CHECK(err); - } - - // parse xUDT args - if (args_bytes_seg.size < (FLAGS_SIZE + BLAKE2B_BLOCK_SIZE)) { - *var_data = NULL; - *var_len = 0; - *flags = XUDTFlagsPlain; - } else { - uint32_t temp_flags = - (*(uint32_t *)(args_bytes_seg.ptr + BLAKE2B_BLOCK_SIZE)) & - ~OWNER_MODE_MASK; - if (temp_flags == XUDTFlagsPlain) { - *flags = XUDTFlagsPlain; - } else if (temp_flags == XUDTFlagsInArgs) { - uint32_t real_size = 0; - *flags = XUDTFlagsInArgs; - *var_len = args_bytes_seg.size - BLAKE2B_BLOCK_SIZE - FLAGS_SIZE; - *var_data = args_bytes_seg.ptr + BLAKE2B_BLOCK_SIZE + FLAGS_SIZE; - - err = verify_script_vec(*var_data, *var_len, &real_size); - CHECK(err); - // note, it's different than "flag = 2" - CHECK2(real_size == *var_len, ERROR_INVALID_ARGS_FORMAT); - } else if (temp_flags == XUDTFlagsInWitness) { - *flags = XUDTFlagsInWitness; - uint32_t hash_size = - args_bytes_seg.size - BLAKE2B_BLOCK_SIZE - FLAGS_SIZE; - CHECK2(hash_size == BLAKE160_SIZE, ERROR_INVALID_FLAG); - - err = load_raw_extension_data(var_data, var_len); - CHECK(err); - CHECK2(var_len > 0, ERROR_INVALID_MOL_FORMAT); - // verify the hash - uint8_t hash[BLAKE2B_BLOCK_SIZE] = {0}; - uint8_t *blake160_hash = - args_bytes_seg.ptr + BLAKE2B_BLOCK_SIZE + FLAGS_SIZE; - err = blake2b(hash, BLAKE2B_BLOCK_SIZE, *var_data, *var_len, NULL, 0); - CHECK2(err == 0, ERROR_BLAKE2B_ERROR); - CHECK2(memcmp(blake160_hash, hash, BLAKE160_SIZE) == 0, - ERROR_HASH_MISMATCHED); - } else { - CHECK2(false, ERROR_INVALID_FLAG); - } - } - err = 0; -exit: - return err; -} - -// copied from simple_udt.c -int simple_udt(int owner_mode) { - if (owner_mode) - return CKB_SUCCESS; - - int ret = 0; - // When the owner mode is not enabled, however, we will then need to ensure - // the sum of all input tokens is not smaller than the sum of all output - // tokens. First, let's loop through all input cells containing current UDTs, - // and gather the sum of all input tokens. - uint128_t input_amount = 0; - size_t i = 0; - uint64_t len = 0; - while (1) { - uint128_t current_amount = 0; - len = 16; - // The implementation here does not require that the transaction only - // contains UDT cells for the current UDT type. It's perfectly fine to mix - // the cells for multiple different types of UDT together in one - // transaction. But that also means we need a way to tell one UDT type from - // another UDT type. The trick is in the `CKB_SOURCE_GROUP_INPUT` value used - // here. When using it as the source part of the syscall, the syscall would - // only iterate through cells with the same script as the current running - // script. Since different UDT types will naturally have different - // script(the args part will be different), we can be sure here that this - // loop would only iterate through UDTs that are of the same type as the one - // identified by the current running script. - // - // In the case that multiple UDT types are included in the same transaction, - // this simple UDT script will be run multiple times to validate the - // transaction, each time with a different script containing different - // script args, representing different UDT types. - // - // A different trick used here, is that our current implementation assumes - // that the amount of UDT is stored as unsigned 128-bit little endian - // integer in the first 16 bytes of cell data. Since RISC-V also uses little - // endian format, we can just read the first 16 bytes of cell data into - // `current_amount`, which is just an unsigned 128-bit integer in C. The - // memory layout of a C program will ensure that the value is set correctly. - ret = ckb_load_cell_data((uint8_t *)¤t_amount, &len, 0, i, - CKB_SOURCE_GROUP_INPUT); - // When `CKB_INDEX_OUT_OF_BOUND` is reached, we know we have iterated - // through all cells of current type. - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - if (ret != CKB_SUCCESS) { - return ret; - } - if (len < 16) { - return ERROR_ENCODING; - } - input_amount += current_amount; - // Like any serious smart contract out there, we will need to check for - // overflows. - if (input_amount < current_amount) { - return ERROR_OVERFLOWING; - } - i += 1; - } - - // With the sum of all input UDT tokens gathered, let's now iterate through - // output cells to grab the sum of all output UDT tokens. - uint128_t output_amount = 0; - i = 0; - while (1) { - uint128_t current_amount = 0; - len = 16; - // Similar to the above code piece, we are also looping through output cells - // with the same script as current running script here by using - // `CKB_SOURCE_GROUP_OUTPUT`. - ret = ckb_load_cell_data((uint8_t *)¤t_amount, &len, 0, i, - CKB_SOURCE_GROUP_OUTPUT); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - break; - } - if (ret != CKB_SUCCESS) { - return ret; - } - if (len < 16) { - return ERROR_ENCODING; - } - output_amount += current_amount; - // Like any serious smart contract out there, we will need to check for - // overflows. - if (output_amount < current_amount) { - return ERROR_OVERFLOWING; - } - i += 1; - } - - // When both value are gathered, we can perform the final check here to - // prevent non-authorized token issuance. - if (input_amount < output_amount) { - return ERROR_AMOUNT; - } - return CKB_SUCCESS; -} - -// If the extension script is identical to a lock script of one input cell in -// current transaction, we consider the extension script to be already -// validated, no additional check is needed for current extension -int is_extension_script_validated(mol_seg_t extension_script, - uint8_t *input_lock_script_hash, - uint32_t input_lock_script_hash_count) { - int err = 0; - uint8_t hash[BLAKE2B_BLOCK_SIZE]; - err = blake2b(hash, BLAKE2B_BLOCK_SIZE, extension_script.ptr, - extension_script.size, NULL, 0); - CHECK2(err == 0, ERROR_BLAKE2B_ERROR); - - for (uint32_t i = 0; i < input_lock_script_hash_count; i++) { - if (memcmp(&input_lock_script_hash[i * BLAKE2B_BLOCK_SIZE], hash, - BLAKE2B_BLOCK_SIZE) == 0) { - return 0; - } - } - err = ERROR_NOT_VALIDATED; -exit: - return err; -} - -#ifdef CKB_USE_SIM -int simulator_main() { -#else -int main() { -#endif - int err = 0; - int owner_mode = 0; - uint8_t *raw_extension_data = NULL; - uint32_t raw_extension_len = 0; - XUDTFlags flags = XUDTFlagsPlain; - uint8_t - input_lock_script_hashes[MAX_LOCK_SCRIPT_HASH_COUNT * BLAKE2B_BLOCK_SIZE]; - uint32_t input_lock_script_hash_count = 0; - err = parse_args(&owner_mode, &flags, &raw_extension_data, &raw_extension_len, - input_lock_script_hashes, &input_lock_script_hash_count); - CHECK(err); - CHECK2(owner_mode == 1 || owner_mode == 0, ERROR_INVALID_ARGS_FORMAT); - // check enhanced mode here - if (!owner_mode) { - check_enhanced_owner_mode(&owner_mode); - // don't need to check the return result from this function - // if failed, owner mode is still false - } - - if (flags != XUDTFlagsPlain) { - CHECK2(raw_extension_data != NULL, ERROR_INVALID_ARGS_FORMAT); - CHECK2(raw_extension_len > 0, ERROR_INVALID_ARGS_FORMAT); - } - err = simple_udt(owner_mode); - if (err != 0) { - goto exit; - } - - if (flags == XUDTFlagsPlain) { - err = 0; - goto exit; - } - - mol_seg_t raw_extension_seg = {0}; - raw_extension_seg.ptr = raw_extension_data; - raw_extension_seg.size = raw_extension_len; - CHECK2(MolReader_ScriptVec_verify(&raw_extension_seg, true) == MOL_OK, - ERROR_INVALID_ARGS_FORMAT); - uint32_t size = MolReader_ScriptVec_length(&raw_extension_seg); - for (uint32_t i = 0; i < size; i++) { - ValidateFuncType func; - mol_seg_res_t res = MolReader_ScriptVec_get(&raw_extension_seg, i); - CHECK2(res.errno == 0, ERROR_INVALID_MOL_FORMAT); - CHECK2(MolReader_Script_verify(&res.seg, false) == MOL_OK, - ERROR_INVALID_MOL_FORMAT); - - mol_seg_t code_hash = MolReader_Script_get_code_hash(&res.seg); - mol_seg_t hash_type = MolReader_Script_get_hash_type(&res.seg); - mol_seg_t args = MolReader_Script_get_args(&res.seg); - - uint8_t hash_type2 = *((uint8_t *)hash_type.ptr); - XUDTValidateFuncCategory cat = CateNormal; - err = load_validate_func(g_code_buff, &g_code_used, code_hash.ptr, - hash_type2, &func, &cat); - CHECK(err); - // RCE is with high priority, must be checked - if (cat != CateRce) { - int err2 = is_extension_script_validated( - res.seg, input_lock_script_hashes, input_lock_script_hash_count); - if (err2 == 0) { - continue; - } - } - mol_seg_t args_raw_bytes = MolReader_Bytes_raw_bytes(&args); - - err = func(owner_mode, i, args_raw_bytes.ptr, args_raw_bytes.size); - CHECK(err); - } - - err = 0; -exit: - return err; -} diff --git a/deps/ckb-c-std-lib b/deps/ckb-c-std-lib deleted file mode 160000 index c056b00..0000000 --- a/deps/ckb-c-std-lib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c056b00fedebff527900586848e2d8fdb53ed317 diff --git a/deps/ckb-c-stdlib-20210413 b/deps/ckb-c-stdlib-20210413 deleted file mode 160000 index a15837b..0000000 --- a/deps/ckb-c-stdlib-20210413 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a15837b92c3d004b0fe28b69e6154874da5cf76c diff --git a/deps/ckb-c-stdlib-20210713 b/deps/ckb-c-stdlib-20210713 deleted file mode 160000 index f263167..0000000 --- a/deps/ckb-c-stdlib-20210713 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f2631670b655d23630de384245062cf6e121710d diff --git a/deps/mbedtls b/deps/mbedtls deleted file mode 160000 index 1c54b54..0000000 --- a/deps/mbedtls +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1c54b5410fd48d6bcada97e30cac417c5c7eea67 diff --git a/deps/mbedtls-config-template.h b/deps/mbedtls-config-template.h deleted file mode 100644 index 863259d..0000000 --- a/deps/mbedtls-config-template.h +++ /dev/null @@ -1,3873 +0,0 @@ -/** - * \file config.h - * - * \brief Configuration options (set of defines) - * - * This set of compile-time options may be used to enable - * or disable features selectively, and reduce the global - * memory footprint. - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif -#define NULL ((void*)0) - - -/** - * \name SECTION: System support - * - * This section sets system specific settings. - * \{ - */ - -/** - * \def MBEDTLS_HAVE_ASM - * - * The compiler has support for asm(). - * - * Requires support for asm() in compiler. - * - * Used in: - * library/aria.c - * library/timing.c - * include/mbedtls/bn_mul.h - * - * Required by: - * MBEDTLS_AESNI_C - * MBEDTLS_PADLOCK_C - * - * Comment to disable the use of assembly code. - */ -//#define MBEDTLS_HAVE_ASM - -/** - * \def MBEDTLS_NO_UDBL_DIVISION - * - * The platform lacks support for double-width integer division (64-bit - * division on a 32-bit platform, 128-bit division on a 64-bit platform). - * - * Used in: - * include/mbedtls/bignum.h - * library/bignum.c - * - * The bignum code uses double-width division to speed up some operations. - * Double-width division is often implemented in software that needs to - * be linked with the program. The presence of a double-width integer - * type is usually detected automatically through preprocessor macros, - * but the automatic detection cannot know whether the code needs to - * and can be linked with an implementation of division for that type. - * By default division is assumed to be usable if the type is present. - * Uncomment this option to prevent the use of double-width division. - * - * Note that division for the native integer type is always required. - * Furthermore, a 64-bit type is always required even on a 32-bit - * platform, but it need not support multiplication or division. In some - * cases it is also desirable to disable some double-width operations. For - * example, if double-width division is implemented in software, disabling - * it can reduce code size in some embedded targets. - */ -//#define MBEDTLS_NO_UDBL_DIVISION - -/** - * \def MBEDTLS_NO_64BIT_MULTIPLICATION - * - * The platform lacks support for 32x32 -> 64-bit multiplication. - * - * Used in: - * library/poly1305.c - * - * Some parts of the library may use multiplication of two unsigned 32-bit - * operands with a 64-bit result in order to speed up computations. On some - * platforms, this is not available in hardware and has to be implemented in - * software, usually in a library provided by the toolchain. - * - * Sometimes it is not desirable to have to link to that library. This option - * removes the dependency of that library on platforms that lack a hardware - * 64-bit multiplier by embedding a software implementation in Mbed TLS. - * - * Note that depending on the compiler, this may decrease performance compared - * to using the library function provided by the toolchain. - */ -//#define MBEDTLS_NO_64BIT_MULTIPLICATION - -/** - * \def MBEDTLS_HAVE_SSE2 - * - * CPU supports SSE2 instruction set. - * - * Uncomment if the CPU supports SSE2 (IA-32 specific). - */ -//#define MBEDTLS_HAVE_SSE2 - -/** - * \def MBEDTLS_HAVE_TIME - * - * System has time.h and time(). - * The time does not need to be correct, only time differences are used, - * by contrast with MBEDTLS_HAVE_TIME_DATE - * - * Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT, - * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and - * MBEDTLS_PLATFORM_STD_TIME. - * - * Comment if your system does not support time functions - */ -// #define MBEDTLS_HAVE_TIME - -/** - * \def MBEDTLS_HAVE_TIME_DATE - * - * System has time.h, time(), and an implementation for - * mbedtls_platform_gmtime_r() (see below). - * The time needs to be correct (not necessarily very accurate, but at least - * the date should be correct). This is used to verify the validity period of - * X.509 certificates. - * - * Comment if your system does not have a correct clock. - * - * \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that - * behaves similarly to the gmtime_r() function from the C standard. Refer to - * the documentation for mbedtls_platform_gmtime_r() for more information. - * - * \note It is possible to configure an implementation for - * mbedtls_platform_gmtime_r() at compile-time by using the macro - * MBEDTLS_PLATFORM_GMTIME_R_ALT. - */ -//#define MBEDTLS_HAVE_TIME_DATE - -/** - * \def MBEDTLS_PLATFORM_MEMORY - * - * Enable the memory allocation layer. - * - * By default mbed TLS uses the system-provided calloc() and free(). - * This allows different allocators (self-implemented or provided) to be - * provided to the platform abstraction layer. - * - * Enabling MBEDTLS_PLATFORM_MEMORY without the - * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide - * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and - * free() function pointer at runtime. - * - * Enabling MBEDTLS_PLATFORM_MEMORY and specifying - * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the - * alternate function at compile time. - * - * Requires: MBEDTLS_PLATFORM_C - * - * Enable this layer to allow use of alternative memory allocators. - */ -#define MBEDTLS_PLATFORM_MEMORY - -/** - * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS - * - * Do not assign standard functions in the platform layer (e.g. calloc() to - * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) - * - * This makes sure there are no linking errors on platforms that do not support - * these functions. You will HAVE to provide alternatives, either at runtime - * via the platform_set_xxx() functions or at compile time by setting - * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a - * MBEDTLS_PLATFORM_XXX_MACRO. - * - * Requires: MBEDTLS_PLATFORM_C - * - * Uncomment to prevent default assignment of standard functions in the - * platform layer. - */ -#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS - -/** - * \def MBEDTLS_PLATFORM_EXIT_ALT - * - * MBEDTLS_PLATFORM_XXX_ALT: Uncomment a macro to let mbed TLS support the - * function in the platform abstraction layer. - * - * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will - * provide a function "mbedtls_platform_set_printf()" that allows you to set an - * alternative printf function pointer. - * - * All these define require MBEDTLS_PLATFORM_C to be defined! - * - * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; - * it will be enabled automatically by check_config.h - * - * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as - * MBEDTLS_PLATFORM_XXX_MACRO! - * - * Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME - * - * Uncomment a macro to enable alternate implementation of specific base - * platform function - */ -#define MBEDTLS_PLATFORM_EXIT_ALT -//#define MBEDTLS_PLATFORM_TIME_ALT -//#define MBEDTLS_PLATFORM_FPRINTF_ALT -#define MBEDTLS_PLATFORM_PRINTF_ALT -#define MBEDTLS_PLATFORM_SNPRINTF_ALT -#define MBEDTLS_PLATFORM_VSNPRINTF_ALT -//#define MBEDTLS_PLATFORM_NV_SEED_ALT -//#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT - -/** - * \def MBEDTLS_DEPRECATED_WARNING - * - * Mark deprecated functions and features so that they generate a warning if - * used. Functionality deprecated in one version will usually be removed in the - * next version. You can enable this to help you prepare the transition to a - * new major version by making sure your code is not using this functionality. - * - * This only works with GCC and Clang. With other compilers, you may want to - * use MBEDTLS_DEPRECATED_REMOVED - * - * Uncomment to get warnings on using deprecated functions and features. - */ -//#define MBEDTLS_DEPRECATED_WARNING - -/** - * \def MBEDTLS_DEPRECATED_REMOVED - * - * Remove deprecated functions and features so that they generate an error if - * used. Functionality deprecated in one version will usually be removed in the - * next version. You can enable this to help you prepare the transition to a - * new major version by making sure your code is not using this functionality. - * - * Uncomment to get errors on using deprecated functions and features. - */ -//#define MBEDTLS_DEPRECATED_REMOVED - -/** - * \def MBEDTLS_CHECK_PARAMS - * - * This configuration option controls whether the library validates more of - * the parameters passed to it. - * - * When this flag is not defined, the library only attempts to validate an - * input parameter if: (1) they may come from the outside world (such as the - * network, the filesystem, etc.) or (2) not validating them could result in - * internal memory errors such as overflowing a buffer controlled by the - * library. On the other hand, it doesn't attempt to validate parameters whose - * values are fully controlled by the application (such as pointers). - * - * When this flag is defined, the library additionally attempts to validate - * parameters that are fully controlled by the application, and should always - * be valid if the application code is fully correct and trusted. - * - * For example, when a function accepts as input a pointer to a buffer that may - * contain untrusted data, and its documentation mentions that this pointer - * must not be NULL: - * - The pointer is checked to be non-NULL only if this option is enabled. - * - The content of the buffer is always validated. - * - * When this flag is defined, if a library function receives a parameter that - * is invalid: - * 1. The function will invoke the macro MBEDTLS_PARAM_FAILED(). - * 2. If MBEDTLS_PARAM_FAILED() did not terminate the program, the function - * will immediately return. If the function returns an Mbed TLS error code, - * the error code in this case is MBEDTLS_ERR_xxx_BAD_INPUT_DATA. - * - * When defining this flag, you also need to arrange a definition for - * MBEDTLS_PARAM_FAILED(). You can do this by any of the following methods: - * - By default, the library defines MBEDTLS_PARAM_FAILED() to call a - * function mbedtls_param_failed(), but the library does not define this - * function. If you do not make any other arrangements, you must provide - * the function mbedtls_param_failed() in your application. - * See `platform_util.h` for its prototype. - * - If you enable the macro #MBEDTLS_CHECK_PARAMS_ASSERT, then the - * library defines MBEDTLS_PARAM_FAILED(\c cond) to be `assert(cond)`. - * You can still supply an alternative definition of - * MBEDTLS_PARAM_FAILED(), which may call `assert`. - * - If you define a macro MBEDTLS_PARAM_FAILED() before including `config.h` - * or you uncomment the definition of MBEDTLS_PARAM_FAILED() in `config.h`, - * the library will call the macro that you defined and will not supply - * its own version. Note that if MBEDTLS_PARAM_FAILED() calls `assert`, - * you need to enable #MBEDTLS_CHECK_PARAMS_ASSERT so that library source - * files include ``. - * - * Uncomment to enable validation of application-controlled parameters. - */ -//#define MBEDTLS_CHECK_PARAMS - -/** - * \def MBEDTLS_CHECK_PARAMS_ASSERT - * - * Allow MBEDTLS_PARAM_FAILED() to call `assert`, and make it default to - * `assert`. This macro is only used if #MBEDTLS_CHECK_PARAMS is defined. - * - * If this macro is not defined, then MBEDTLS_PARAM_FAILED() defaults to - * calling a function mbedtls_param_failed(). See the documentation of - * #MBEDTLS_CHECK_PARAMS for details. - * - * Uncomment to allow MBEDTLS_PARAM_FAILED() to call `assert`. - */ -//#define MBEDTLS_CHECK_PARAMS_ASSERT - -/* \} name SECTION: System support */ - -/** - * \name SECTION: mbed TLS feature support - * - * This section sets support for features that are or are not needed - * within the modules that are enabled. - * \{ - */ - -/** - * \def MBEDTLS_TIMING_ALT - * - * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), - * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() - * - * Only works if you have MBEDTLS_TIMING_C enabled. - * - * You will need to provide a header "timing_alt.h" and an implementation at - * compile time. - */ -//#define MBEDTLS_TIMING_ALT - -/** - * \def MBEDTLS_AES_ALT - * - * MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your - * alternate core implementation of a symmetric crypto, an arithmetic or hash - * module (e.g. platform specific assembly optimized implementations). Keep - * in mind that the function prototypes should remain the same. - * - * This replaces the whole module. If you only want to replace one of the - * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. - * - * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer - * provide the "struct mbedtls_aes_context" definition and omit the base - * function declarations and implementations. "aes_alt.h" will be included from - * "aes.h" to include the new function definitions. - * - * Uncomment a macro to enable alternate implementation of the corresponding - * module. - * - * \warning MD2, MD4, MD5, ARC4, DES and SHA-1 are considered weak and their - * use constitutes a security risk. If possible, we recommend - * avoiding dependencies on them, and considering stronger message - * digests and ciphers instead. - * - */ -//#define MBEDTLS_AES_ALT -//#define MBEDTLS_ARC4_ALT -//#define MBEDTLS_ARIA_ALT -//#define MBEDTLS_BLOWFISH_ALT -//#define MBEDTLS_CAMELLIA_ALT -//#define MBEDTLS_CCM_ALT -//#define MBEDTLS_CHACHA20_ALT -//#define MBEDTLS_CHACHAPOLY_ALT -//#define MBEDTLS_CMAC_ALT -//#define MBEDTLS_DES_ALT -//#define MBEDTLS_DHM_ALT -//#define MBEDTLS_ECJPAKE_ALT -//#define MBEDTLS_GCM_ALT -//#define MBEDTLS_NIST_KW_ALT -//#define MBEDTLS_MD2_ALT -//#define MBEDTLS_MD4_ALT -//#define MBEDTLS_MD5_ALT -//#define MBEDTLS_POLY1305_ALT -//#define MBEDTLS_RIPEMD160_ALT -//#define MBEDTLS_RSA_ALT -//#define MBEDTLS_SHA1_ALT -//#define MBEDTLS_SHA256_ALT -//#define MBEDTLS_SHA512_ALT -//#define MBEDTLS_XTEA_ALT - -/* - * When replacing the elliptic curve module, pleace consider, that it is - * implemented with two .c files: - * - ecp.c - * - ecp_curves.c - * You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT - * macros as described above. The only difference is that you have to make sure - * that you provide functionality for both .c files. - */ -//#define MBEDTLS_ECP_ALT - -/** - * \def MBEDTLS_MD2_PROCESS_ALT - * - * MBEDTLS__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use you - * alternate core implementation of symmetric crypto or hash function. Keep in - * mind that function prototypes should remain the same. - * - * This replaces only one function. The header file from mbed TLS is still - * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. - * - * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will - * no longer provide the mbedtls_sha1_process() function, but it will still provide - * the other function (using your mbedtls_sha1_process() function) and the definition - * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible - * with this definition. - * - * \note Because of a signature change, the core AES encryption and decryption routines are - * currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt, - * respectively. When setting up alternative implementations, these functions should - * be overridden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt - * must stay untouched. - * - * \note If you use the AES_xxx_ALT macros, then is is recommended to also set - * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES - * tables. - * - * Uncomment a macro to enable alternate implementation of the corresponding - * function. - * - * \warning MD2, MD4, MD5, DES and SHA-1 are considered weak and their use - * constitutes a security risk. If possible, we recommend avoiding - * dependencies on them, and considering stronger message digests - * and ciphers instead. - * - * \warning If both MBEDTLS_ECDSA_SIGN_ALT and MBEDTLS_ECDSA_DETERMINISTIC are - * enabled, then the deterministic ECDH signature functions pass the - * the static HMAC-DRBG as RNG to mbedtls_ecdsa_sign(). Therefore - * alternative implementations should use the RNG only for generating - * the ephemeral key and nothing else. If this is not possible, then - * MBEDTLS_ECDSA_DETERMINISTIC should be disabled and an alternative - * implementation should be provided for mbedtls_ecdsa_sign_det_ext() - * (and for mbedtls_ecdsa_sign_det() too if backward compatibility is - * desirable). - * - */ -//#define MBEDTLS_MD2_PROCESS_ALT -//#define MBEDTLS_MD4_PROCESS_ALT -//#define MBEDTLS_MD5_PROCESS_ALT -//#define MBEDTLS_RIPEMD160_PROCESS_ALT -//#define MBEDTLS_SHA1_PROCESS_ALT -//#define MBEDTLS_SHA256_PROCESS_ALT -//#define MBEDTLS_SHA512_PROCESS_ALT -//#define MBEDTLS_DES_SETKEY_ALT -//#define MBEDTLS_DES_CRYPT_ECB_ALT -//#define MBEDTLS_DES3_CRYPT_ECB_ALT -//#define MBEDTLS_AES_SETKEY_ENC_ALT -//#define MBEDTLS_AES_SETKEY_DEC_ALT -//#define MBEDTLS_AES_ENCRYPT_ALT -//#define MBEDTLS_AES_DECRYPT_ALT -//#define MBEDTLS_ECDH_GEN_PUBLIC_ALT -//#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT -//#define MBEDTLS_ECDSA_VERIFY_ALT -//#define MBEDTLS_ECDSA_SIGN_ALT -//#define MBEDTLS_ECDSA_GENKEY_ALT - -/** - * \def MBEDTLS_ECP_INTERNAL_ALT - * - * Expose a part of the internal interface of the Elliptic Curve Point module. - * - * MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your - * alternative core implementation of elliptic curve arithmetic. Keep in mind - * that function prototypes should remain the same. - * - * This partially replaces one function. The header file from mbed TLS is still - * used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation - * is still present and it is used for group structures not supported by the - * alternative. - * - * Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT - * and implementing the following functions: - * unsigned char mbedtls_internal_ecp_grp_capable( - * const mbedtls_ecp_group *grp ) - * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ) - * void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ) - * The mbedtls_internal_ecp_grp_capable function should return 1 if the - * replacement functions implement arithmetic for the given group and 0 - * otherwise. - * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_free are - * called before and after each point operation and provide an opportunity to - * implement optimized set up and tear down instructions. - * - * Example: In case you uncomment MBEDTLS_ECP_INTERNAL_ALT and - * MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac - * function, but will use your mbedtls_internal_ecp_double_jac if the group is - * supported (your mbedtls_internal_ecp_grp_capable function returns 1 when - * receives it as an argument). If the group is not supported then the original - * implementation is used. The other functions and the definition of - * mbedtls_ecp_group and mbedtls_ecp_point will not change, so your - * implementation of mbedtls_internal_ecp_double_jac and - * mbedtls_internal_ecp_grp_capable must be compatible with this definition. - * - * Uncomment a macro to enable alternate implementation of the corresponding - * function. - */ -/* Required for all the functions in this section */ -//#define MBEDTLS_ECP_INTERNAL_ALT -/* Support for Weierstrass curves with Jacobi representation */ -//#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT -//#define MBEDTLS_ECP_ADD_MIXED_ALT -//#define MBEDTLS_ECP_DOUBLE_JAC_ALT -//#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT -//#define MBEDTLS_ECP_NORMALIZE_JAC_ALT -/* Support for curves with Montgomery arithmetic */ -//#define MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT -//#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT -//#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT - -/** - * \def MBEDTLS_TEST_NULL_ENTROPY - * - * Enables testing and use of mbed TLS without any configured entropy sources. - * This permits use of the library on platforms before an entropy source has - * been integrated (see for example the MBEDTLS_ENTROPY_HARDWARE_ALT or the - * MBEDTLS_ENTROPY_NV_SEED switches). - * - * WARNING! This switch MUST be disabled in production builds, and is suitable - * only for development. - * Enabling the switch negates any security provided by the library. - * - * Requires MBEDTLS_ENTROPY_C, MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES - * - */ -// #define MBEDTLS_TEST_NULL_ENTROPY - -/** - * \def MBEDTLS_ENTROPY_HARDWARE_ALT - * - * Uncomment this macro to let mbed TLS use your own implementation of a - * hardware entropy collector. - * - * Your function must be called \c mbedtls_hardware_poll(), have the same - * prototype as declared in entropy_poll.h, and accept NULL as first argument. - * - * Uncomment to use your own hardware entropy collector. - */ -#define MBEDTLS_ENTROPY_HARDWARE_ALT - -/** - * \def MBEDTLS_AES_ROM_TABLES - * - * Use precomputed AES tables stored in ROM. - * - * Uncomment this macro to use precomputed AES tables stored in ROM. - * Comment this macro to generate AES tables in RAM at runtime. - * - * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb - * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the - * initialization time before the first AES operation can be performed. - * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c - * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded - * performance if ROM access is slower than RAM access. - * - * This option is independent of \c MBEDTLS_AES_FEWER_TABLES. - * - */ -//#define MBEDTLS_AES_ROM_TABLES - -/** - * \def MBEDTLS_AES_FEWER_TABLES - * - * Use less ROM/RAM for AES tables. - * - * Uncommenting this macro omits 75% of the AES tables from - * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES) - * by computing their values on the fly during operations - * (the tables are entry-wise rotations of one another). - * - * Tradeoff: Uncommenting this reduces the RAM / ROM footprint - * by ~6kb but at the cost of more arithmetic operations during - * runtime. Specifically, one has to compare 4 accesses within - * different tables to 4 accesses with additional arithmetic - * operations within the same table. The performance gain/loss - * depends on the system and memory details. - * - * This option is independent of \c MBEDTLS_AES_ROM_TABLES. - * - */ -//#define MBEDTLS_AES_FEWER_TABLES - -/** - * \def MBEDTLS_CAMELLIA_SMALL_MEMORY - * - * Use less ROM for the Camellia implementation (saves about 768 bytes). - * - * Uncomment this macro to use less memory for Camellia. - */ -//#define MBEDTLS_CAMELLIA_SMALL_MEMORY - -/** - * \def MBEDTLS_CIPHER_MODE_CBC - * - * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_CBC - -/** - * \def MBEDTLS_CIPHER_MODE_CFB - * - * Enable Cipher Feedback mode (CFB) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_CFB - -/** - * \def MBEDTLS_CIPHER_MODE_CTR - * - * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_CTR - -/** - * \def MBEDTLS_CIPHER_MODE_OFB - * - * Enable Output Feedback mode (OFB) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_OFB - -/** - * \def MBEDTLS_CIPHER_MODE_XTS - * - * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. - */ -#define MBEDTLS_CIPHER_MODE_XTS - -/** - * \def MBEDTLS_CIPHER_NULL_CIPHER - * - * Enable NULL cipher. - * Warning: Only do so when you know what you are doing. This allows for - * encryption or channels without any security! - * - * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable - * the following ciphersuites: - * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA - * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 - * MBEDTLS_TLS_RSA_WITH_NULL_SHA - * MBEDTLS_TLS_RSA_WITH_NULL_MD5 - * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA - * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 - * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 - * MBEDTLS_TLS_PSK_WITH_NULL_SHA - * - * Uncomment this macro to enable the NULL cipher and ciphersuites - */ -//#define MBEDTLS_CIPHER_NULL_CIPHER - -/** - * \def MBEDTLS_CIPHER_PADDING_PKCS7 - * - * MBEDTLS_CIPHER_PADDING_XXX: Uncomment or comment macros to add support for - * specific padding modes in the cipher layer with cipher modes that support - * padding (e.g. CBC) - * - * If you disable all padding modes, only full blocks can be used with CBC. - * - * Enable padding modes in the cipher layer. - */ -#define MBEDTLS_CIPHER_PADDING_PKCS7 -#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS -#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -#define MBEDTLS_CIPHER_PADDING_ZEROS - -/** \def MBEDTLS_CTR_DRBG_USE_128_BIT_KEY - * - * Uncomment this macro to use a 128-bit key in the CTR_DRBG module. - * By default, CTR_DRBG uses a 256-bit key. - */ -//#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY - -/** - * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES - * - * Enable weak ciphersuites in SSL / TLS. - * Warning: Only do so when you know what you are doing. This allows for - * channels with virtually no security at all! - * - * This enables the following ciphersuites: - * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA - * - * Uncomment this macro to enable weak ciphersuites - * - * \warning DES is considered a weak cipher and its use constitutes a - * security risk. We recommend considering stronger ciphers instead. - */ -//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES - -/** - * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES - * - * Remove RC4 ciphersuites by default in SSL / TLS. - * This flag removes the ciphersuites based on RC4 from the default list as - * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to - * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them - * explicitly. - * - * Uncomment this macro to remove RC4 ciphersuites by default. - */ -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES - -/** - * \def MBEDTLS_REMOVE_3DES_CIPHERSUITES - * - * Remove 3DES ciphersuites by default in SSL / TLS. - * This flag removes the ciphersuites based on 3DES from the default list as - * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible - * to enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including - * them explicitly. - * - * A man-in-the-browser attacker can recover authentication tokens sent through - * a TLS connection using a 3DES based cipher suite (see "On the Practical - * (In-)Security of 64-bit Block Ciphers" by Karthikeyan Bhargavan and Gaëtan - * Leurent, see https://sweet32.info/SWEET32_CCS16.pdf). If this attack falls - * in your threat model or you are unsure, then you should keep this option - * enabled to remove 3DES based cipher suites. - * - * Comment this macro to keep 3DES in the default ciphersuite list. - */ -#define MBEDTLS_REMOVE_3DES_CIPHERSUITES - -/** - * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED - * - * MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve - * module. By default all supported curves are enabled. - * - * Comment macros to disable the curve and functions for it - */ -/* Short Weierstrass curves (supporting ECP, ECDH, ECDSA) */ -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define MBEDTLS_ECP_DP_SECP384R1_ENABLED -#define MBEDTLS_ECP_DP_SECP521R1_ENABLED -#define MBEDTLS_ECP_DP_SECP192K1_ENABLED -#define MBEDTLS_ECP_DP_SECP224K1_ENABLED -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED -#define MBEDTLS_ECP_DP_BP256R1_ENABLED -#define MBEDTLS_ECP_DP_BP384R1_ENABLED -#define MBEDTLS_ECP_DP_BP512R1_ENABLED -/* Montgomery curves (supporting ECP) */ -#define MBEDTLS_ECP_DP_CURVE25519_ENABLED -#define MBEDTLS_ECP_DP_CURVE448_ENABLED - -/** - * \def MBEDTLS_ECP_NIST_OPTIM - * - * Enable specific 'modulo p' routines for each NIST prime. - * Depending on the prime and architecture, makes operations 4 to 8 times - * faster on the corresponding curve. - * - * Comment this macro to disable NIST curves optimisation. - */ -#define MBEDTLS_ECP_NIST_OPTIM - -/** - * \def MBEDTLS_ECP_NO_INTERNAL_RNG - * - * When this option is disabled, mbedtls_ecp_mul() will make use of an - * internal RNG when called with a NULL \c f_rng argument, in order to protect - * against some side-channel attacks. - * - * This protection introduces a dependency of the ECP module on one of the - * DRBG modules. For very constrained implementations that don't require this - * protection (for example, because you're only doing signature verification, - * so not manipulating any secret, or because local/physical side-channel - * attacks are outside your threat model), it might be desirable to get rid of - * that dependency. - * - * \warning Enabling this option makes some uses of ECP vulnerable to some - * side-channel attacks. Only enable it if you know that's not a problem for - * your use case. - * - * Uncomment this macro to disable some counter-measures in ECP. - */ -//#define MBEDTLS_ECP_NO_INTERNAL_RNG - -/** - * \def MBEDTLS_ECP_RESTARTABLE - * - * Enable "non-blocking" ECC operations that can return early and be resumed. - * - * This allows various functions to pause by returning - * #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module, - * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in - * order to further progress and eventually complete their operation. This is - * controlled through mbedtls_ecp_set_max_ops() which limits the maximum - * number of ECC operations a function may perform before pausing; see - * mbedtls_ecp_set_max_ops() for more information. - * - * This is useful in non-threaded environments if you want to avoid blocking - * for too long on ECC (and, hence, X.509 or SSL/TLS) operations. - * - * Uncomment this macro to enable restartable ECC computations. - * - * \note This option only works with the default software implementation of - * elliptic curve functionality. It is incompatible with - * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT, MBEDTLS_ECDSA_XXX_ALT - * and MBEDTLS_ECDH_LEGACY_CONTEXT. - */ -//#define MBEDTLS_ECP_RESTARTABLE - -/** - * \def MBEDTLS_ECDH_LEGACY_CONTEXT - * - * Use a backward compatible ECDH context. - * - * Mbed TLS supports two formats for ECDH contexts (#mbedtls_ecdh_context - * defined in `ecdh.h`). For most applications, the choice of format makes - * no difference, since all library functions can work with either format, - * except that the new format is incompatible with MBEDTLS_ECP_RESTARTABLE. - - * The new format used when this option is disabled is smaller - * (56 bytes on a 32-bit platform). In future versions of the library, it - * will support alternative implementations of ECDH operations. - * The new format is incompatible with applications that access - * context fields directly and with restartable ECP operations. - * - * Define this macro if you enable MBEDTLS_ECP_RESTARTABLE or if you - * want to access ECDH context fields directly. Otherwise you should - * comment out this macro definition. - * - * This option has no effect if #MBEDTLS_ECDH_C is not enabled. - * - * \note This configuration option is experimental. Future versions of the - * library may modify the way the ECDH context layout is configured - * and may modify the layout of the new context type. - */ -#define MBEDTLS_ECDH_LEGACY_CONTEXT - -/** - * \def MBEDTLS_ECDSA_DETERMINISTIC - * - * Enable deterministic ECDSA (RFC 6979). - * Standard ECDSA is "fragile" in the sense that lack of entropy when signing - * may result in a compromise of the long-term signing key. This is avoided by - * the deterministic variant. - * - * Requires: MBEDTLS_HMAC_DRBG_C, MBEDTLS_ECDSA_C - * - * Comment this macro to disable deterministic ECDSA. - */ -#define MBEDTLS_ECDSA_DETERMINISTIC - -/** - * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED - * - * Enable the PSK based ciphersuite modes in SSL / TLS. - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA - */ -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED - * - * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_DHM_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA - * - * \warning Using DHE constitutes a security risk as it - * is not possible to validate custom DH parameters. - * If possible, it is recommended users should consider - * preferring other methods of key exchange. - * See dhm.h for more details. - * - */ -#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED - * - * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA - */ -#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED - * - * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA - */ -#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED - * - * Enable the RSA-only based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 - */ -#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED - * - * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - * - * \warning Using DHE constitutes a security risk as it - * is not possible to validate custom DH parameters. - * If possible, it is recommended users should consider - * preferring other methods of key exchange. - * See dhm.h for more details. - * - */ -#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED - * - * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA - */ -#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED - * - * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA - */ -#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED - * - * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - */ -#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED - * - * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 - */ -#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED - * - * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. - * - * \warning This is currently experimental. EC J-PAKE support is based on the - * Thread v1.0.0 specification; incompatible changes to the specification - * might still happen. For this reason, this is disabled by default. - * - * Requires: MBEDTLS_ECJPAKE_C - * MBEDTLS_SHA256_C - * MBEDTLS_ECP_DP_SECP256R1_ENABLED - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 - */ -//#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED - -/** - * \def MBEDTLS_PK_PARSE_EC_EXTENDED - * - * Enhance support for reading EC keys using variants of SEC1 not allowed by - * RFC 5915 and RFC 5480. - * - * Currently this means parsing the SpecifiedECDomain choice of EC - * parameters (only known groups are supported, not arbitrary domains, to - * avoid validation issues). - * - * Disable if you only need to support RFC 5915 + 5480 key formats. - */ -#define MBEDTLS_PK_PARSE_EC_EXTENDED - -/** - * \def MBEDTLS_ERROR_STRERROR_DUMMY - * - * Enable a dummy error function to make use of mbedtls_strerror() in - * third party libraries easier when MBEDTLS_ERROR_C is disabled - * (no effect when MBEDTLS_ERROR_C is enabled). - * - * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're - * not using mbedtls_strerror() or error_strerror() in your application. - * - * Disable if you run into name conflicts and want to really remove the - * mbedtls_strerror() - */ -#define MBEDTLS_ERROR_STRERROR_DUMMY - -/** - * \def MBEDTLS_GENPRIME - * - * Enable the prime-number generation code. - * - * Requires: MBEDTLS_BIGNUM_C - */ -#define MBEDTLS_GENPRIME - -/** - * \def MBEDTLS_FS_IO - * - * Enable functions that use the filesystem. - */ -// #define MBEDTLS_FS_IO - -/** - * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES - * - * Do not add default entropy sources. These are the platform specific, - * mbedtls_timing_hardclock and HAVEGE based poll functions. - * - * This is useful to have more control over the added entropy sources in an - * application. - * - * Uncomment this macro to prevent loading of default entropy functions. - */ -#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES - -/** - * \def MBEDTLS_NO_PLATFORM_ENTROPY - * - * Do not use built-in platform entropy functions. - * This is useful if your platform does not support - * standards like the /dev/urandom or Windows CryptoAPI. - * - * Uncomment this macro to disable the built-in platform entropy functions. - */ -#define MBEDTLS_NO_PLATFORM_ENTROPY - -/** - * \def MBEDTLS_ENTROPY_FORCE_SHA256 - * - * Force the entropy accumulator to use a SHA-256 accumulator instead of the - * default SHA-512 based one (if both are available). - * - * Requires: MBEDTLS_SHA256_C - * - * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option - * if you have performance concerns. - * - * This option is only useful if both MBEDTLS_SHA256_C and - * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. - */ -//#define MBEDTLS_ENTROPY_FORCE_SHA256 - -/** - * \def MBEDTLS_ENTROPY_NV_SEED - * - * Enable the non-volatile (NV) seed file-based entropy source. - * (Also enables the NV seed read/write functions in the platform layer) - * - * This is crucial (if not required) on systems that do not have a - * cryptographic entropy source (in hardware or kernel) available. - * - * Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C - * - * \note The read/write functions that are used by the entropy source are - * determined in the platform layer, and can be modified at runtime and/or - * compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used. - * - * \note If you use the default implementation functions that read a seedfile - * with regular fopen(), please make sure you make a seedfile with the - * proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at - * least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from - * and written to or you will get an entropy source error! The default - * implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE - * bytes from the file. - * - * \note The entropy collector will write to the seed file before entropy is - * given to an external source, to update it. - */ -//#define MBEDTLS_ENTROPY_NV_SEED - -/* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER - * - * Enable key identifiers that encode a key owner identifier. - * - * The owner of a key is identified by a value of type ::mbedtls_key_owner_id_t - * which is currently hard-coded to be int32_t. - * - * Note that this option is meant for internal use only and may be removed - * without notice. It is incompatible with MBEDTLS_USE_PSA_CRYPTO. - */ -//#define MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER - -/** - * \def MBEDTLS_MEMORY_DEBUG - * - * Enable debugging of buffer allocator memory issues. Automatically prints - * (to stderr) all (fatal) messages on memory allocation issues. Enables - * function for 'debug output' of allocated memory. - * - * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C - * - * Uncomment this macro to let the buffer allocator print out error messages. - */ -//#define MBEDTLS_MEMORY_DEBUG - -/** - * \def MBEDTLS_MEMORY_BACKTRACE - * - * Include backtrace information with each allocated block. - * - * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C - * GLIBC-compatible backtrace() an backtrace_symbols() support - * - * Uncomment this macro to include backtrace information - */ -//#define MBEDTLS_MEMORY_BACKTRACE - -/** - * \def MBEDTLS_PK_RSA_ALT_SUPPORT - * - * Support external private RSA keys (eg from a HSM) in the PK layer. - * - * Comment this macro to disable support for external private RSA keys. - */ -#define MBEDTLS_PK_RSA_ALT_SUPPORT - -/** - * \def MBEDTLS_PKCS1_V15 - * - * Enable support for PKCS#1 v1.5 encoding. - * - * Requires: MBEDTLS_RSA_C - * - * This enables support for PKCS#1 v1.5 operations. - */ -#define MBEDTLS_PKCS1_V15 - -/** - * \def MBEDTLS_PKCS1_V21 - * - * Enable support for PKCS#1 v2.1 encoding. - * - * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C - * - * This enables support for RSAES-OAEP and RSASSA-PSS operations. - */ -#define MBEDTLS_PKCS1_V21 - -/** \def MBEDTLS_PSA_CRYPTO_DRIVERS - * - * Enable support for the experimental PSA crypto driver interface. - * - * Requires: MBEDTLS_PSA_CRYPTO_C - * - * \warning This interface is experimental and may change or be removed - * without notice. - */ -//#define MBEDTLS_PSA_CRYPTO_DRIVERS - -/** - * \def MBEDTLS_PSA_CRYPTO_SPM - * - * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is built for SPM (Secure - * Partition Manager) integration which separates the code into two parts: a - * NSPE (Non-Secure Process Environment) and an SPE (Secure Process - * Environment). - * - * Module: library/psa_crypto.c - * Requires: MBEDTLS_PSA_CRYPTO_C - * - */ -//#define MBEDTLS_PSA_CRYPTO_SPM - -/** - * \def MBEDTLS_PSA_INJECT_ENTROPY - * - * Enable support for entropy injection at first boot. This feature is - * required on systems that do not have a built-in entropy source (TRNG). - * This feature is currently not supported on systems that have a built-in - * entropy source. - * - * Requires: MBEDTLS_PSA_CRYPTO_STORAGE_C, MBEDTLS_ENTROPY_NV_SEED - * - */ -//#define MBEDTLS_PSA_INJECT_ENTROPY - -/** - * \def MBEDTLS_RSA_NO_CRT - * - * Do not use the Chinese Remainder Theorem - * for the RSA private operation. - * - * Uncomment this macro to disable the use of CRT in RSA. - * - */ -//#define MBEDTLS_RSA_NO_CRT - -/** - * \def MBEDTLS_SELF_TEST - * - * Enable the checkup functions (*_self_test). - */ -#define MBEDTLS_SELF_TEST - -/** - * \def MBEDTLS_SHA256_SMALLER - * - * Enable an implementation of SHA-256 that has lower ROM footprint but also - * lower performance. - * - * The default implementation is meant to be a reasonnable compromise between - * performance and size. This version optimizes more aggressively for size at - * the expense of performance. Eg on Cortex-M4 it reduces the size of - * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about - * 30%. - * - * Uncomment to enable the smaller implementation of SHA256. - */ -//#define MBEDTLS_SHA256_SMALLER - -/** - * \def MBEDTLS_SHA512_SMALLER - * - * Enable an implementation of SHA-512 that has lower ROM footprint but also - * lower performance. - * - * Uncomment to enable the smaller implementation of SHA512. - */ -//#define MBEDTLS_SHA512_SMALLER - -/** - * \def MBEDTLS_SHA512_NO_SHA384 - * - * Disable the SHA-384 option of the SHA-512 module. Use this to save some - * code size on devices that don't use SHA-384. - * - * Requires: MBEDTLS_SHA512_C - * - * Uncomment to disable SHA-384 - */ -//#define MBEDTLS_SHA512_NO_SHA384 - -/** - * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES - * - * Enable sending of alert messages in case of encountered errors as per RFC. - * If you choose not to send the alert messages, mbed TLS can still communicate - * with other servers, only debugging of failures is harder. - * - * The advantage of not sending alert messages, is that no information is given - * about reasons for failures thus preventing adversaries of gaining intel. - * - * Enable sending of all alert messages - */ -#define MBEDTLS_SSL_ALL_ALERT_MESSAGES - -/** - * \def MBEDTLS_SSL_RECORD_CHECKING - * - * Enable the function mbedtls_ssl_check_record() which can be used to check - * the validity and authenticity of an incoming record, to verify that it has - * not been seen before. These checks are performed without modifying the - * externally visible state of the SSL context. - * - * See mbedtls_ssl_check_record() for more information. - * - * Uncomment to enable support for record checking. - */ -#define MBEDTLS_SSL_RECORD_CHECKING - -/** - * \def MBEDTLS_SSL_DTLS_CONNECTION_ID - * - * Enable support for the DTLS Connection ID extension - * (version draft-ietf-tls-dtls-connection-id-05, - * https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05) - * which allows to identify DTLS connections across changes - * in the underlying transport. - * - * Setting this option enables the SSL APIs `mbedtls_ssl_set_cid()`, - * `mbedtls_ssl_get_peer_cid()` and `mbedtls_ssl_conf_cid()`. - * See the corresponding documentation for more information. - * - * \warning The Connection ID extension is still in draft state. - * We make no stability promises for the availability - * or the shape of the API controlled by this option. - * - * The maximum lengths of outgoing and incoming CIDs can be configured - * through the options - * - MBEDTLS_SSL_CID_OUT_LEN_MAX - * - MBEDTLS_SSL_CID_IN_LEN_MAX. - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - * - * Uncomment to enable the Connection ID extension. - */ -//#define MBEDTLS_SSL_DTLS_CONNECTION_ID - -/** - * \def MBEDTLS_SSL_ASYNC_PRIVATE - * - * Enable asynchronous external private key operations in SSL. This allows - * you to configure an SSL connection to call an external cryptographic - * module to perform private key operations instead of performing the - * operation inside the library. - * - */ -//#define MBEDTLS_SSL_ASYNC_PRIVATE - -/** - * \def MBEDTLS_SSL_CONTEXT_SERIALIZATION - * - * Enable serialization of the TLS context structures, through use of the - * functions mbedtls_ssl_context_save() and mbedtls_ssl_context_load(). - * - * This pair of functions allows one side of a connection to serialize the - * context associated with the connection, then free or re-use that context - * while the serialized state is persisted elsewhere, and finally deserialize - * that state to a live context for resuming read/write operations on the - * connection. From a protocol perspective, the state of the connection is - * unaffected, in particular this is entirely transparent to the peer. - * - * Note: this is distinct from TLS session resumption, which is part of the - * protocol and fully visible by the peer. TLS session resumption enables - * establishing new connections associated to a saved session with shorter, - * lighter handshakes, while context serialization is a local optimization in - * handling a single, potentially long-lived connection. - * - * Enabling these APIs makes some SSL structures larger, as 64 extra bytes are - * saved after the handshake to allow for more efficient serialization, so if - * you don't need this feature you'll save RAM by disabling it. - * - * Comment to disable the context serialization APIs. - */ -#define MBEDTLS_SSL_CONTEXT_SERIALIZATION - -/** - * \def MBEDTLS_SSL_DEBUG_ALL - * - * Enable the debug messages in SSL module for all issues. - * Debug messages have been disabled in some places to prevent timing - * attacks due to (unbalanced) debugging function calls. - * - * If you need all error reporting you should enable this during debugging, - * but remove this for production servers that should log as well. - * - * Uncomment this macro to report all debug messages on errors introducing - * a timing side-channel. - * - */ -//#define MBEDTLS_SSL_DEBUG_ALL - -/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC - * - * Enable support for Encrypt-then-MAC, RFC 7366. - * - * This allows peers that both support it to use a more robust protection for - * ciphersuites using CBC, providing deep resistance against timing attacks - * on the padding or underlying cipher. - * - * This only affects CBC ciphersuites, and is useless if none is defined. - * - * Requires: MBEDTLS_SSL_PROTO_TLS1 or - * MBEDTLS_SSL_PROTO_TLS1_1 or - * MBEDTLS_SSL_PROTO_TLS1_2 - * - * Comment this macro to disable support for Encrypt-then-MAC - */ -#define MBEDTLS_SSL_ENCRYPT_THEN_MAC - -/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET - * - * Enable support for RFC 7627: Session Hash and Extended Master Secret - * Extension. - * - * This was introduced as "the proper fix" to the Triple Handshake familiy of - * attacks, but it is recommended to always use it (even if you disable - * renegotiation), since it actually fixes a more fundamental issue in the - * original SSL/TLS design, and has implications beyond Triple Handshake. - * - * Requires: MBEDTLS_SSL_PROTO_TLS1 or - * MBEDTLS_SSL_PROTO_TLS1_1 or - * MBEDTLS_SSL_PROTO_TLS1_2 - * - * Comment this macro to disable support for Extended Master Secret. - */ -#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET - -/** - * \def MBEDTLS_SSL_FALLBACK_SCSV - * - * Enable support for RFC 7507: Fallback Signaling Cipher Suite Value (SCSV) - * for Preventing Protocol Downgrade Attacks. - * - * For servers, it is recommended to always enable this, unless you support - * only one version of TLS, or know for sure that none of your clients - * implements a fallback strategy. - * - * For clients, you only need this if you're using a fallback strategy, which - * is not recommended in the first place, unless you absolutely need it to - * interoperate with buggy (version-intolerant) servers. - * - * Comment this macro to disable support for FALLBACK_SCSV - */ -#define MBEDTLS_SSL_FALLBACK_SCSV - -/** - * \def MBEDTLS_SSL_KEEP_PEER_CERTIFICATE - * - * This option controls the availability of the API mbedtls_ssl_get_peer_cert() - * giving access to the peer's certificate after completion of the handshake. - * - * Unless you need mbedtls_ssl_peer_cert() in your application, it is - * recommended to disable this option for reduced RAM usage. - * - * \note If this option is disabled, mbedtls_ssl_get_peer_cert() is still - * defined, but always returns \c NULL. - * - * \note This option has no influence on the protection against the - * triple handshake attack. Even if it is disabled, Mbed TLS will - * still ensure that certificates do not change during renegotiation, - * for exaple by keeping a hash of the peer's certificate. - * - * Comment this macro to disable storing the peer's certificate - * after the handshake. - */ -#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE - -/** - * \def MBEDTLS_SSL_HW_RECORD_ACCEL - * - * Enable hooking functions in SSL module for hardware acceleration of - * individual records. - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Uncomment this macro to enable hooking functions. - */ -//#define MBEDTLS_SSL_HW_RECORD_ACCEL - -/** - * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING - * - * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. - * - * This is a countermeasure to the BEAST attack, which also minimizes the risk - * of interoperability issues compared to sending 0-length records. - * - * Comment this macro to disable 1/n-1 record splitting. - */ -#define MBEDTLS_SSL_CBC_RECORD_SPLITTING - -/** - * \def MBEDTLS_SSL_RENEGOTIATION - * - * Enable support for TLS renegotiation. - * - * The two main uses of renegotiation are (1) refresh keys on long-lived - * connections and (2) client authentication after the initial handshake. - * If you don't need renegotiation, it's probably better to disable it, since - * it has been associated with security issues in the past and is easy to - * misuse/misunderstand. - * - * Comment this to disable support for renegotiation. - * - * \note Even if this option is disabled, both client and server are aware - * of the Renegotiation Indication Extension (RFC 5746) used to - * prevent the SSL renegotiation attack (see RFC 5746 Sect. 1). - * (See \c mbedtls_ssl_conf_legacy_renegotiation for the - * configuration of this extension). - * - */ -#define MBEDTLS_SSL_RENEGOTIATION - -/** - * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO - * - * Enable support for receiving and parsing SSLv2 Client Hello messages for the - * SSL Server module (MBEDTLS_SSL_SRV_C). - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Uncomment this macro to enable support for SSLv2 Client Hello messages. - */ -//#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO - -/** - * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE - * - * Pick the ciphersuite according to the client's preferences rather than ours - * in the SSL Server module (MBEDTLS_SSL_SRV_C). - * - * Uncomment this macro to respect client's ciphersuite order - */ -//#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE - -/** - * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH - * - * Enable support for RFC 6066 max_fragment_length extension in SSL. - * - * Comment this macro to disable support for the max_fragment_length extension - */ -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH - -/** - * \def MBEDTLS_SSL_PROTO_SSL3 - * - * Enable support for SSL 3.0. - * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Comment this macro to disable support for SSL 3.0 - */ -//#define MBEDTLS_SSL_PROTO_SSL3 - -/** - * \def MBEDTLS_SSL_PROTO_TLS1 - * - * Enable support for TLS 1.0. - * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C - * - * Comment this macro to disable support for TLS 1.0 - */ -#define MBEDTLS_SSL_PROTO_TLS1 - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_1 - * - * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). - * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C - * - * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 - */ -#define MBEDTLS_SSL_PROTO_TLS1_1 - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_2 - * - * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). - * - * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C - * (Depends on ciphersuites) - * - * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 - */ -#define MBEDTLS_SSL_PROTO_TLS1_2 - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL - * - * This macro is used to selectively enable experimental parts - * of the code that contribute to the ongoing development of - * the prototype TLS 1.3 and DTLS 1.3 implementation, and provide - * no other purpose. - * - * \warning TLS 1.3 and DTLS 1.3 aren't yet supported in Mbed TLS, - * and no feature exposed through this macro is part of the - * public API. In particular, features under the control - * of this macro are experimental and don't come with any - * stability guarantees. - * - * Uncomment this macro to enable experimental and partial - * functionality specific to TLS 1.3. - */ -//#define MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL - -/** - * \def MBEDTLS_SSL_PROTO_DTLS - * - * Enable support for DTLS (all available versions). - * - * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, - * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. - * - * Requires: MBEDTLS_SSL_PROTO_TLS1_1 - * or MBEDTLS_SSL_PROTO_TLS1_2 - * - * Comment this macro to disable support for DTLS - */ -#define MBEDTLS_SSL_PROTO_DTLS - -/** - * \def MBEDTLS_SSL_ALPN - * - * Enable support for RFC 7301 Application Layer Protocol Negotiation. - * - * Comment this macro to disable support for ALPN. - */ -#define MBEDTLS_SSL_ALPN - -/** - * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY - * - * Enable support for the anti-replay mechanism in DTLS. - * - * Requires: MBEDTLS_SSL_TLS_C - * MBEDTLS_SSL_PROTO_DTLS - * - * \warning Disabling this is often a security risk! - * See mbedtls_ssl_conf_dtls_anti_replay() for details. - * - * Comment this to disable anti-replay in DTLS. - */ -#define MBEDTLS_SSL_DTLS_ANTI_REPLAY - -/** - * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY - * - * Enable support for HelloVerifyRequest on DTLS servers. - * - * This feature is highly recommended to prevent DTLS servers being used as - * amplifiers in DoS attacks against other hosts. It should always be enabled - * unless you know for sure amplification cannot be a problem in the - * environment in which your server operates. - * - * \warning Disabling this can ba a security risk! (see above) - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - * - * Comment this to disable support for HelloVerifyRequest. - */ -#define MBEDTLS_SSL_DTLS_HELLO_VERIFY - -/** - * \def MBEDTLS_SSL_DTLS_SRTP - * - * Enable support for negotation of DTLS-SRTP (RFC 5764) - * through the use_srtp extension. - * - * \note This feature provides the minimum functionality required - * to negotiate the use of DTLS-SRTP and to allow the derivation of - * the associated SRTP packet protection key material. - * In particular, the SRTP packet protection itself, as well as the - * demultiplexing of RTP and DTLS packets at the datagram layer - * (see Section 5 of RFC 5764), are not handled by this feature. - * Instead, after successful completion of a handshake negotiating - * the use of DTLS-SRTP, the extended key exporter API - * mbedtls_ssl_conf_export_keys_ext_cb() should be used to implement - * the key exporter described in Section 4.2 of RFC 5764 and RFC 5705 - * (this is implemented in the SSL example programs). - * The resulting key should then be passed to an SRTP stack. - * - * Setting this option enables the runtime API - * mbedtls_ssl_conf_dtls_srtp_protection_profiles() - * through which the supported DTLS-SRTP protection - * profiles can be configured. You must call this API at - * runtime if you wish to negotiate the use of DTLS-SRTP. - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - * - * Uncomment this to enable support for use_srtp extension. - */ -//#define MBEDTLS_SSL_DTLS_SRTP - -/** - * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE - * - * Enable server-side support for clients that reconnect from the same port. - * - * Some clients unexpectedly close the connection and try to reconnect using the - * same source port. This needs special support from the server to handle the - * new connection securely, as described in section 4.2.8 of RFC 6347. This - * flag enables that support. - * - * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY - * - * Comment this to disable support for clients reusing the source port. - */ -#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE - -/** - * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT - * - * Enable support for a limit of records with bad MAC. - * - * See mbedtls_ssl_conf_dtls_badmac_limit(). - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - */ -#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT - -/** - * \def MBEDTLS_SSL_SESSION_TICKETS - * - * Enable support for RFC 5077 session tickets in SSL. - * Client-side, provides full support for session tickets (maintenance of a - * session store remains the responsibility of the application, though). - * Server-side, you also need to provide callbacks for writing and parsing - * tickets, including authenticated encryption and key management. Example - * callbacks are provided by MBEDTLS_SSL_TICKET_C. - * - * Comment this macro to disable support for SSL session tickets - */ -#define MBEDTLS_SSL_SESSION_TICKETS - -/** - * \def MBEDTLS_SSL_EXPORT_KEYS - * - * Enable support for exporting key block and master secret. - * This is required for certain users of TLS, e.g. EAP-TLS. - * - * Comment this macro to disable support for key export - */ -#define MBEDTLS_SSL_EXPORT_KEYS - -/** - * \def MBEDTLS_SSL_SERVER_NAME_INDICATION - * - * Enable support for RFC 6066 server name indication (SNI) in SSL. - * - * Requires: MBEDTLS_X509_CRT_PARSE_C - * - * Comment this macro to disable support for server name indication in SSL - */ -#define MBEDTLS_SSL_SERVER_NAME_INDICATION - -/** - * \def MBEDTLS_SSL_TRUNCATED_HMAC - * - * Enable support for RFC 6066 truncated HMAC in SSL. - * - * Comment this macro to disable support for truncated HMAC in SSL - */ -#define MBEDTLS_SSL_TRUNCATED_HMAC - -/** - * \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT - * - * Fallback to old (pre-2.7), non-conforming implementation of the truncated - * HMAC extension which also truncates the HMAC key. Note that this option is - * only meant for a transitory upgrade period and will be removed in a future - * version of the library. - * - * \warning The old implementation is non-compliant and has a security weakness - * (2^80 brute force attack on the HMAC key used for a single, - * uninterrupted connection). This should only be enabled temporarily - * when (1) the use of truncated HMAC is essential in order to save - * bandwidth, and (2) the peer is an Mbed TLS stack that doesn't use - * the fixed implementation yet (pre-2.7). - * - * \deprecated This option is deprecated and will be removed in a - * future version of Mbed TLS. - * - * Uncomment to fallback to old, non-compliant truncated HMAC implementation. - * - * Requires: MBEDTLS_SSL_TRUNCATED_HMAC - */ -//#define MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT - -/** - * \def MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH - * - * Enable modifying the maximum I/O buffer size. - */ -//#define MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH - -/** - * \def MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - * - * Enable testing of the constant-flow nature of some sensitive functions with - * clang's MemorySanitizer. This causes some existing tests to also test - * this non-functional property of the code under test. - * - * This setting requires compiling with clang -fsanitize=memory. The test - * suites can then be run normally. - * - * \warning This macro is only used for extended testing; it is not considered - * part of the library's API, so it may change or disappear at any time. - * - * Uncomment to enable testing of the constant-flow nature of selected code. - */ -//#define MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - -/** - * \def MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - * - * Enable testing of the constant-flow nature of some sensitive functions with - * valgrind's memcheck tool. This causes some existing tests to also test - * this non-functional property of the code under test. - * - * This setting requires valgrind headers for building, and is only useful for - * testing if the tests suites are run with valgrind's memcheck. This can be - * done for an individual test suite with 'valgrind ./test_suite_xxx', or when - * using CMake, this can be done for all test suites with 'make memcheck'. - * - * \warning This macro is only used for extended testing; it is not considered - * part of the library's API, so it may change or disappear at any time. - * - * Uncomment to enable testing of the constant-flow nature of selected code. - */ -//#define MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - -/** - * \def MBEDTLS_TEST_HOOKS - * - * Enable features for invasive testing such as introspection functions and - * hooks for fault injection. This enables additional unit tests. - * - * Merely enabling this feature should not change the behavior of the product. - * It only adds new code, and new branching points where the default behavior - * is the same as when this feature is disabled. - * However, this feature increases the attack surface: there is an added - * risk of vulnerabilities, and more gadgets that can make exploits easier. - * Therefore this feature must never be enabled in production. - * - * See `docs/architecture/testing/mbed-crypto-invasive-testing.md` for more - * information. - * - * Uncomment to enable invasive tests. - */ -//#define MBEDTLS_TEST_HOOKS - -/** - * \def MBEDTLS_THREADING_ALT - * - * Provide your own alternate threading implementation. - * - * Requires: MBEDTLS_THREADING_C - * - * Uncomment this to allow your own alternate threading implementation. - */ -//#define MBEDTLS_THREADING_ALT - -/** - * \def MBEDTLS_THREADING_PTHREAD - * - * Enable the pthread wrapper layer for the threading layer. - * - * Requires: MBEDTLS_THREADING_C - * - * Uncomment this to enable pthread mutexes. - */ -//#define MBEDTLS_THREADING_PTHREAD - -/** - * \def MBEDTLS_USE_PSA_CRYPTO - * - * Make the X.509 and TLS library use PSA for cryptographic operations, and - * enable new APIs for using keys handled by PSA Crypto. - * - * \note Development of this option is currently in progress, and parts of Mbed - * TLS's X.509 and TLS modules are not ported to PSA yet. However, these parts - * will still continue to work as usual, so enabling this option should not - * break backwards compatibility. - * - * \warning The PSA Crypto API is in beta stage. While you're welcome to - * experiment using it, incompatible API changes are still possible, and some - * parts may not have reached the same quality as the rest of Mbed TLS yet. - * - * \warning This option enables new Mbed TLS APIs that are dependent on the - * PSA Crypto API, so can't come with the same stability guarantees as the - * rest of the Mbed TLS APIs. You're welcome to experiment with them, but for - * now, access to these APIs is opt-in (via enabling the present option), in - * order to clearly differentiate them from the stable Mbed TLS APIs. - * - * Requires: MBEDTLS_PSA_CRYPTO_C. - * - * Uncomment this to enable internal use of PSA Crypto and new associated APIs. - */ -//#define MBEDTLS_USE_PSA_CRYPTO - -/** - * \def MBEDTLS_PSA_CRYPTO_CONFIG - * - * This setting allows support for cryptographic mechanisms through the PSA - * API to be configured separately from support through the mbedtls API. - * - * Uncomment this to enable use of PSA Crypto configuration settings which - * can be found in include/psa/crypto_config.h. - * - * If you enable this option and write your own configuration file, you must - * include mbedtls/config_psa.h in your configuration file. The default - * provided mbedtls/config.h contains the necessary inclusion. - * - * This feature is still experimental and is not ready for production since - * it is not completed. - */ -//#define MBEDTLS_PSA_CRYPTO_CONFIG - -/** - * \def MBEDTLS_VERSION_FEATURES - * - * Allow run-time checking of compile-time enabled features. Thus allowing users - * to check at run-time if the library is for instance compiled with threading - * support via mbedtls_version_check_feature(). - * - * Requires: MBEDTLS_VERSION_C - * - * Comment this to disable run-time checking and save ROM space - */ -#define MBEDTLS_VERSION_FEATURES - -/** - * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 - * - * If set, the X509 parser will not break-off when parsing an X509 certificate - * and encountering an extension in a v1 or v2 certificate. - * - * Uncomment to prevent an error. - */ -//#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 - -/** - * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION - * - * If set, the X509 parser will not break-off when parsing an X509 certificate - * and encountering an unknown critical extension. - * - * \warning Depending on your PKI use, enabling this can be a security risk! - * - * Uncomment to prevent an error. - */ -//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION - -/** - * \def MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK - * - * If set, this enables the X.509 API `mbedtls_x509_crt_verify_with_ca_cb()` - * and the SSL API `mbedtls_ssl_conf_ca_cb()` which allow users to configure - * the set of trusted certificates through a callback instead of a linked - * list. - * - * This is useful for example in environments where a large number of trusted - * certificates is present and storing them in a linked list isn't efficient - * enough, or when the set of trusted certificates changes frequently. - * - * See the documentation of `mbedtls_x509_crt_verify_with_ca_cb()` and - * `mbedtls_ssl_conf_ca_cb()` for more information. - * - * Uncomment to enable trusted certificate callbacks. - */ -//#define MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK - -/** - * \def MBEDTLS_X509_CHECK_KEY_USAGE - * - * Enable verification of the keyUsage extension (CA and leaf certificates). - * - * Disabling this avoids problems with mis-issued and/or misused - * (intermediate) CA and leaf certificates. - * - * \warning Depending on your PKI use, disabling this can be a security risk! - * - * Comment to skip keyUsage checking for both CA and leaf certificates. - */ -#define MBEDTLS_X509_CHECK_KEY_USAGE - -/** - * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - * - * Enable verification of the extendedKeyUsage extension (leaf certificates). - * - * Disabling this avoids problems with mis-issued and/or misused certificates. - * - * \warning Depending on your PKI use, disabling this can be a security risk! - * - * Comment to skip extendedKeyUsage checking for certificates. - */ -#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - -/** - * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT - * - * Enable parsing and verification of X.509 certificates, CRLs and CSRS - * signed with RSASSA-PSS (aka PKCS#1 v2.1). - * - * Comment this macro to disallow using RSASSA-PSS in certificates. - */ -#define MBEDTLS_X509_RSASSA_PSS_SUPPORT - -/** - * \def MBEDTLS_ZLIB_SUPPORT - * - * If set, the SSL/TLS module uses ZLIB to support compression and - * decompression of packet data. - * - * \warning TLS-level compression MAY REDUCE SECURITY! See for example the - * CRIME attack. Before enabling this option, you should examine with care if - * CRIME or similar exploits may be applicable to your use case. - * - * \note Currently compression can't be used with DTLS. - * - * \deprecated This feature is deprecated and will be removed - * in the next major revision of the library. - * - * Used in: library/ssl_tls.c - * library/ssl_cli.c - * library/ssl_srv.c - * - * This feature requires zlib library and headers to be present. - * - * Uncomment to enable use of ZLIB - */ -//#define MBEDTLS_ZLIB_SUPPORT -/* \} name SECTION: mbed TLS feature support */ - -/** - * \name SECTION: mbed TLS modules - * - * This section enables or disables entire modules in mbed TLS - * \{ - */ - -/** - * \def MBEDTLS_AESNI_C - * - * Enable AES-NI support on x86-64. - * - * Module: library/aesni.c - * Caller: library/aes.c - * - * Requires: MBEDTLS_HAVE_ASM - * - * This modules adds support for the AES-NI instructions on x86-64 - */ -// #define MBEDTLS_AESNI_C - -/** - * \def MBEDTLS_AES_C - * - * Enable the AES block cipher. - * - * Module: library/aes.c - * Caller: library/cipher.c - * library/pem.c - * library/ctr_drbg.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA - * - * PEM_PARSE uses AES for decrypting encrypted keys. - */ -#define MBEDTLS_AES_C - -/** - * \def MBEDTLS_ARC4_C - * - * Enable the ARCFOUR stream cipher. - * - * Module: library/arc4.c - * Caller: library/cipher.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA - * - * \warning ARC4 is considered a weak cipher and its use constitutes a - * security risk. If possible, we recommend avoidng dependencies on - * it, and considering stronger ciphers instead. - * - */ -#define MBEDTLS_ARC4_C - -/** - * \def MBEDTLS_ASN1_PARSE_C - * - * Enable the generic ASN1 parser. - * - * Module: library/asn1.c - * Caller: library/x509.c - * library/dhm.c - * library/pkcs12.c - * library/pkcs5.c - * library/pkparse.c - */ -#define MBEDTLS_ASN1_PARSE_C - -/** - * \def MBEDTLS_ASN1_WRITE_C - * - * Enable the generic ASN1 writer. - * - * Module: library/asn1write.c - * Caller: library/ecdsa.c - * library/pkwrite.c - * library/x509_create.c - * library/x509write_crt.c - * library/x509write_csr.c - */ -#define MBEDTLS_ASN1_WRITE_C - -/** - * \def MBEDTLS_BASE64_C - * - * Enable the Base64 module. - * - * Module: library/base64.c - * Caller: library/pem.c - * - * This module is required for PEM support (required by X.509). - */ -#define MBEDTLS_BASE64_C - -/** - * \def MBEDTLS_BIGNUM_C - * - * Enable the multi-precision integer library. - * - * Module: library/bignum.c - * Caller: library/dhm.c - * library/ecp.c - * library/ecdsa.c - * library/rsa.c - * library/rsa_internal.c - * library/ssl_tls.c - * - * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. - */ -#define MBEDTLS_BIGNUM_C - -/** - * \def MBEDTLS_BLOWFISH_C - * - * Enable the Blowfish block cipher. - * - * Module: library/blowfish.c - */ -#define MBEDTLS_BLOWFISH_C - -/** - * \def MBEDTLS_CAMELLIA_C - * - * Enable the Camellia block cipher. - * - * Module: library/camellia.c - * Caller: library/cipher.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 - */ -#define MBEDTLS_CAMELLIA_C - -/** - * \def MBEDTLS_ARIA_C - * - * Enable the ARIA block cipher. - * - * Module: library/aria.c - * Caller: library/cipher.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * - * MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 - */ -//#define MBEDTLS_ARIA_C - -/** - * \def MBEDTLS_CCM_C - * - * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. - * - * Module: library/ccm.c - * - * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C - * - * This module enables the AES-CCM ciphersuites, if other requisites are - * enabled as well. - */ -#define MBEDTLS_CCM_C - -/** - * \def MBEDTLS_CERTS_C - * - * Enable the test certificates. - * - * Module: library/certs.c - * Caller: - * - * This module is used for testing (ssl_client/server). - */ -#define MBEDTLS_CERTS_C - -/** - * \def MBEDTLS_CHACHA20_C - * - * Enable the ChaCha20 stream cipher. - * - * Module: library/chacha20.c - */ -#define MBEDTLS_CHACHA20_C - -/** - * \def MBEDTLS_CHACHAPOLY_C - * - * Enable the ChaCha20-Poly1305 AEAD algorithm. - * - * Module: library/chachapoly.c - * - * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C - */ -#define MBEDTLS_CHACHAPOLY_C - -/** - * \def MBEDTLS_CIPHER_C - * - * Enable the generic cipher layer. - * - * Module: library/cipher.c - * Caller: library/ssl_tls.c - * - * Uncomment to enable generic cipher wrappers. - */ -#define MBEDTLS_CIPHER_C - -/** - * \def MBEDTLS_CMAC_C - * - * Enable the CMAC (Cipher-based Message Authentication Code) mode for block - * ciphers. - * - * Module: library/cmac.c - * - * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C - * - */ -//#define MBEDTLS_CMAC_C - -/** - * \def MBEDTLS_CTR_DRBG_C - * - * Enable the CTR_DRBG AES-based random generator. - * The CTR_DRBG generator uses AES-256 by default. - * To use AES-128 instead, enable \c MBEDTLS_CTR_DRBG_USE_128_BIT_KEY above. - * - * \note To achieve a 256-bit security strength with CTR_DRBG, - * you must use AES-256 *and* use sufficient entropy. - * See ctr_drbg.h for more details. - * - * Module: library/ctr_drbg.c - * Caller: - * - * Requires: MBEDTLS_AES_C - * - * This module provides the CTR_DRBG AES random number generator. - */ -#define MBEDTLS_CTR_DRBG_C - -/** - * \def MBEDTLS_DEBUG_C - * - * Enable the debug functions. - * - * Module: library/debug.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * This module provides debugging functions. - */ -#define MBEDTLS_DEBUG_C - -/** - * \def MBEDTLS_DES_C - * - * Enable the DES block cipher. - * - * Module: library/des.c - * Caller: library/pem.c - * library/cipher.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA - * - * PEM_PARSE uses DES/3DES for decrypting encrypted keys. - * - * \warning DES is considered a weak cipher and its use constitutes a - * security risk. We recommend considering stronger ciphers instead. - */ -#define MBEDTLS_DES_C - -/** - * \def MBEDTLS_DHM_C - * - * Enable the Diffie-Hellman-Merkle module. - * - * Module: library/dhm.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * - * This module is used by the following key exchanges: - * DHE-RSA, DHE-PSK - * - * \warning Using DHE constitutes a security risk as it - * is not possible to validate custom DH parameters. - * If possible, it is recommended users should consider - * preferring other methods of key exchange. - * See dhm.h for more details. - * - */ -#define MBEDTLS_DHM_C - -/** - * \def MBEDTLS_ECDH_C - * - * Enable the elliptic curve Diffie-Hellman library. - * - * Module: library/ecdh.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * - * This module is used by the following key exchanges: - * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK - * - * Requires: MBEDTLS_ECP_C - */ -#define MBEDTLS_ECDH_C - -/** - * \def MBEDTLS_ECDSA_C - * - * Enable the elliptic curve DSA library. - * - * Module: library/ecdsa.c - * Caller: - * - * This module is used by the following key exchanges: - * ECDHE-ECDSA - * - * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C, - * and at least one MBEDTLS_ECP_DP_XXX_ENABLED for a - * short Weierstrass curve. - */ -#define MBEDTLS_ECDSA_C - -/** - * \def MBEDTLS_ECJPAKE_C - * - * Enable the elliptic curve J-PAKE library. - * - * \warning This is currently experimental. EC J-PAKE support is based on the - * Thread v1.0.0 specification; incompatible changes to the specification - * might still happen. For this reason, this is disabled by default. - * - * Module: library/ecjpake.c - * Caller: - * - * This module is used by the following key exchanges: - * ECJPAKE - * - * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C - */ -//#define MBEDTLS_ECJPAKE_C - -/** - * \def MBEDTLS_ECP_C - * - * Enable the elliptic curve over GF(p) library. - * - * Module: library/ecp.c - * Caller: library/ecdh.c - * library/ecdsa.c - * library/ecjpake.c - * - * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED - */ -#define MBEDTLS_ECP_C - -/** - * \def MBEDTLS_ENTROPY_C - * - * Enable the platform-specific entropy code. - * - * Module: library/entropy.c - * Caller: - * - * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C - * - * This module provides a generic entropy pool - */ -#define MBEDTLS_ENTROPY_C - -/** - * \def MBEDTLS_ERROR_C - * - * Enable error code to error string conversion. - * - * Module: library/error.c - * Caller: - * - * This module enables mbedtls_strerror(). - */ -#define MBEDTLS_ERROR_C - -/** - * \def MBEDTLS_GCM_C - * - * Enable the Galois/Counter Mode (GCM). - * - * Module: library/gcm.c - * - * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C or MBEDTLS_ARIA_C - * - * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other - * requisites are enabled as well. - */ -#define MBEDTLS_GCM_C - -/** - * \def MBEDTLS_HAVEGE_C - * - * Enable the HAVEGE random generator. - * - * Warning: the HAVEGE random generator is not suitable for virtualized - * environments - * - * Warning: the HAVEGE random generator is dependent on timing and specific - * processor traits. It is therefore not advised to use HAVEGE as - * your applications primary random generator or primary entropy pool - * input. As a secondary input to your entropy pool, it IS able add - * the (limited) extra entropy it provides. - * - * Module: library/havege.c - * Caller: - * - * Requires: MBEDTLS_TIMING_C - * - * Uncomment to enable the HAVEGE random generator. - */ -//#define MBEDTLS_HAVEGE_C - -/** - * \def MBEDTLS_HKDF_C - * - * Enable the HKDF algorithm (RFC 5869). - * - * Module: library/hkdf.c - * Caller: - * - * Requires: MBEDTLS_MD_C - * - * This module adds support for the Hashed Message Authentication Code - * (HMAC)-based key derivation function (HKDF). - */ -#define MBEDTLS_HKDF_C - -/** - * \def MBEDTLS_HMAC_DRBG_C - * - * Enable the HMAC_DRBG random generator. - * - * Module: library/hmac_drbg.c - * Caller: - * - * Requires: MBEDTLS_MD_C - * - * Uncomment to enable the HMAC_DRBG random number geerator. - */ -#define MBEDTLS_HMAC_DRBG_C - -/** - * \def MBEDTLS_NIST_KW_C - * - * Enable the Key Wrapping mode for 128-bit block ciphers, - * as defined in NIST SP 800-38F. Only KW and KWP modes - * are supported. At the moment, only AES is approved by NIST. - * - * Module: library/nist_kw.c - * - * Requires: MBEDTLS_AES_C and MBEDTLS_CIPHER_C - */ -//#define MBEDTLS_NIST_KW_C - -/** - * \def MBEDTLS_MD_C - * - * Enable the generic message digest layer. - * - * Module: library/md.c - * Caller: - * - * Uncomment to enable generic message digest wrappers. - */ -#define MBEDTLS_MD_C - -/** - * \def MBEDTLS_MD2_C - * - * Enable the MD2 hash algorithm. - * - * Module: library/md2.c - * Caller: - * - * Uncomment to enable support for (rare) MD2-signed X.509 certs. - * - * \warning MD2 is considered a weak message digest and its use constitutes a - * security risk. If possible, we recommend avoiding dependencies on - * it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_MD2_C - -/** - * \def MBEDTLS_MD4_C - * - * Enable the MD4 hash algorithm. - * - * Module: library/md4.c - * Caller: - * - * Uncomment to enable support for (rare) MD4-signed X.509 certs. - * - * \warning MD4 is considered a weak message digest and its use constitutes a - * security risk. If possible, we recommend avoiding dependencies on - * it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_MD4_C - -/** - * \def MBEDTLS_MD5_C - * - * Enable the MD5 hash algorithm. - * - * Module: library/md5.c - * Caller: library/md.c - * library/pem.c - * library/ssl_tls.c - * - * This module is required for SSL/TLS up to version 1.1, and for TLS 1.2 - * depending on the handshake parameters. Further, it is used for checking - * MD5-signed certificates, and for PBKDF1 when decrypting PEM-encoded - * encrypted keys. - * - * \warning MD5 is considered a weak message digest and its use constitutes a - * security risk. If possible, we recommend avoiding dependencies on - * it, and considering stronger message digests instead. - * - */ -#define MBEDTLS_MD5_C - -/** - * \def MBEDTLS_MEMORY_BUFFER_ALLOC_C - * - * Enable the buffer allocator implementation that makes use of a (stack) - * based buffer to 'allocate' dynamic memory. (replaces calloc() and free() - * calls) - * - * Module: library/memory_buffer_alloc.c - * - * Requires: MBEDTLS_PLATFORM_C - * MBEDTLS_PLATFORM_MEMORY (to use it within mbed TLS) - * - * Enable this module to enable the buffer memory allocator. - */ -#define MBEDTLS_MEMORY_BUFFER_ALLOC_C - -/** - * \def MBEDTLS_NET_C - * - * Enable the TCP and UDP over IPv6/IPv4 networking routines. - * - * \note This module only works on POSIX/Unix (including Linux, BSD and OS X) - * and Windows. For other platforms, you'll want to disable it, and write your - * own networking callbacks to be passed to \c mbedtls_ssl_set_bio(). - * - * \note See also our Knowledge Base article about porting to a new - * environment: - * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS - * - * Module: library/net_sockets.c - * - * This module provides networking routines. - */ -#define MBEDTLS_NET_C - -/** - * \def MBEDTLS_OID_C - * - * Enable the OID database. - * - * Module: library/oid.c - * Caller: library/asn1write.c - * library/pkcs5.c - * library/pkparse.c - * library/pkwrite.c - * library/rsa.c - * library/x509.c - * library/x509_create.c - * library/x509_crl.c - * library/x509_crt.c - * library/x509_csr.c - * library/x509write_crt.c - * library/x509write_csr.c - * - * This modules translates between OIDs and internal values. - */ -#define MBEDTLS_OID_C - -/** - * \def MBEDTLS_PADLOCK_C - * - * Enable VIA Padlock support on x86. - * - * Module: library/padlock.c - * Caller: library/aes.c - * - * Requires: MBEDTLS_HAVE_ASM - * - * This modules adds support for the VIA PadLock on x86. - */ -//#define MBEDTLS_PADLOCK_C - -/** - * \def MBEDTLS_PEM_PARSE_C - * - * Enable PEM decoding / parsing. - * - * Module: library/pem.c - * Caller: library/dhm.c - * library/pkparse.c - * library/x509_crl.c - * library/x509_crt.c - * library/x509_csr.c - * - * Requires: MBEDTLS_BASE64_C - * - * This modules adds support for decoding / parsing PEM files. - */ -#define MBEDTLS_PEM_PARSE_C - -/** - * \def MBEDTLS_PEM_WRITE_C - * - * Enable PEM encoding / writing. - * - * Module: library/pem.c - * Caller: library/pkwrite.c - * library/x509write_crt.c - * library/x509write_csr.c - * - * Requires: MBEDTLS_BASE64_C - * - * This modules adds support for encoding / writing PEM files. - */ -#define MBEDTLS_PEM_WRITE_C - -/** - * \def MBEDTLS_PK_C - * - * Enable the generic public (asymetric) key layer. - * - * Module: library/pk.c - * Caller: library/ssl_tls.c - * library/ssl_cli.c - * library/ssl_srv.c - * - * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C - * - * Uncomment to enable generic public key wrappers. - */ -#define MBEDTLS_PK_C - -/** - * \def MBEDTLS_PK_PARSE_C - * - * Enable the generic public (asymetric) key parser. - * - * Module: library/pkparse.c - * Caller: library/x509_crt.c - * library/x509_csr.c - * - * Requires: MBEDTLS_PK_C - * - * Uncomment to enable generic public key parse functions. - */ -#define MBEDTLS_PK_PARSE_C - -/** - * \def MBEDTLS_PK_WRITE_C - * - * Enable the generic public (asymetric) key writer. - * - * Module: library/pkwrite.c - * Caller: library/x509write.c - * - * Requires: MBEDTLS_PK_C - * - * Uncomment to enable generic public key write functions. - */ -#define MBEDTLS_PK_WRITE_C - -/** - * \def MBEDTLS_PKCS5_C - * - * Enable PKCS#5 functions. - * - * Module: library/pkcs5.c - * - * Requires: MBEDTLS_MD_C - * - * This module adds support for the PKCS#5 functions. - */ -#define MBEDTLS_PKCS5_C - -/** - * \def MBEDTLS_PKCS11_C - * - * Enable wrapper for PKCS#11 smartcard support via the pkcs11-helper library. - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Module: library/pkcs11.c - * Caller: library/pk.c - * - * Requires: MBEDTLS_PK_C - * - * This module enables SSL/TLS PKCS #11 smartcard support. - * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) - */ -//#define MBEDTLS_PKCS11_C - -/** - * \def MBEDTLS_PKCS12_C - * - * Enable PKCS#12 PBE functions. - * Adds algorithms for parsing PKCS#8 encrypted private keys - * - * Module: library/pkcs12.c - * Caller: library/pkparse.c - * - * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C - * Can use: MBEDTLS_ARC4_C - * - * This module enables PKCS#12 functions. - */ -#define MBEDTLS_PKCS12_C - -/** - * \def MBEDTLS_PLATFORM_C - * - * Enable the platform abstraction layer that allows you to re-assign - * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). - * - * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT - * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned - * above to be specified at runtime or compile time respectively. - * - * \note This abstraction layer must be enabled on Windows (including MSYS2) - * as other module rely on it for a fixed snprintf implementation. - * - * Module: library/platform.c - * Caller: Most other .c files - * - * This module enables abstraction of common (libc) functions. - */ -#define MBEDTLS_PLATFORM_C - -/** - * \def MBEDTLS_POLY1305_C - * - * Enable the Poly1305 MAC algorithm. - * - * Module: library/poly1305.c - * Caller: library/chachapoly.c - */ -#define MBEDTLS_POLY1305_C - -/** - * \def MBEDTLS_PSA_CRYPTO_C - * - * Enable the Platform Security Architecture cryptography API. - * - * \warning The PSA Crypto API is still beta status. While you're welcome to - * experiment using it, incompatible API changes are still possible, and some - * parts may not have reached the same quality as the rest of Mbed TLS yet. - * - * Module: library/psa_crypto.c - * - * Requires: MBEDTLS_CTR_DRBG_C, MBEDTLS_ENTROPY_C - * - */ -//#define MBEDTLS_PSA_CRYPTO_C - -/** - * \def MBEDTLS_PSA_CRYPTO_SE_C - * - * Enable secure element support in the Platform Security Architecture - * cryptography API. - * - * \warning This feature is not yet suitable for production. It is provided - * for API evaluation and testing purposes only. - * - * Module: library/psa_crypto_se.c - * - * Requires: MBEDTLS_PSA_CRYPTO_C, MBEDTLS_PSA_CRYPTO_STORAGE_C - * - */ -//#define MBEDTLS_PSA_CRYPTO_SE_C - -/** - * \def MBEDTLS_PSA_CRYPTO_STORAGE_C - * - * Enable the Platform Security Architecture persistent key storage. - * - * Module: library/psa_crypto_storage.c - * - * Requires: MBEDTLS_PSA_CRYPTO_C, - * either MBEDTLS_PSA_ITS_FILE_C or a native implementation of - * the PSA ITS interface - */ -//#define MBEDTLS_PSA_CRYPTO_STORAGE_C - -/** - * \def MBEDTLS_PSA_ITS_FILE_C - * - * Enable the emulation of the Platform Security Architecture - * Internal Trusted Storage (PSA ITS) over files. - * - * Module: library/psa_its_file.c - * - * Requires: MBEDTLS_FS_IO - */ -// #define MBEDTLS_PSA_ITS_FILE_C - -/** - * \def MBEDTLS_RIPEMD160_C - * - * Enable the RIPEMD-160 hash algorithm. - * - * Module: library/ripemd160.c - * Caller: library/md.c - * - */ -#define MBEDTLS_RIPEMD160_C - -/** - * \def MBEDTLS_RSA_C - * - * Enable the RSA public-key cryptosystem. - * - * Module: library/rsa.c - * library/rsa_internal.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * library/x509.c - * - * This module is used by the following key exchanges: - * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK - * - * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C - */ -#define MBEDTLS_RSA_C - -/** - * \def MBEDTLS_SHA1_C - * - * Enable the SHA1 cryptographic hash algorithm. - * - * Module: library/sha1.c - * Caller: library/md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * library/x509write_crt.c - * - * This module is required for SSL/TLS up to version 1.1, for TLS 1.2 - * depending on the handshake parameters, and for SHA1-signed certificates. - * - * \warning SHA-1 is considered a weak message digest and its use constitutes - * a security risk. If possible, we recommend avoiding dependencies - * on it, and considering stronger message digests instead. - * - */ -#define MBEDTLS_SHA1_C - -/** - * \def MBEDTLS_SHA256_C - * - * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. - * - * Module: library/sha256.c - * Caller: library/entropy.c - * library/md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * This module adds support for SHA-224 and SHA-256. - * This module is required for the SSL/TLS 1.2 PRF function. - */ -#define MBEDTLS_SHA256_C - -/** - * \def MBEDTLS_SHA512_C - * - * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. - * - * Module: library/sha512.c - * Caller: library/entropy.c - * library/md.c - * library/ssl_cli.c - * library/ssl_srv.c - * - * This module adds support for SHA-384 and SHA-512. - */ -#define MBEDTLS_SHA512_C - -/** - * \def MBEDTLS_SSL_CACHE_C - * - * Enable simple SSL cache implementation. - * - * Module: library/ssl_cache.c - * Caller: - * - * Requires: MBEDTLS_SSL_CACHE_C - */ -#define MBEDTLS_SSL_CACHE_C - -/** - * \def MBEDTLS_SSL_COOKIE_C - * - * Enable basic implementation of DTLS cookies for hello verification. - * - * Module: library/ssl_cookie.c - * Caller: - */ -#define MBEDTLS_SSL_COOKIE_C - -/** - * \def MBEDTLS_SSL_TICKET_C - * - * Enable an implementation of TLS server-side callbacks for session tickets. - * - * Module: library/ssl_ticket.c - * Caller: - * - * Requires: MBEDTLS_CIPHER_C - */ -#define MBEDTLS_SSL_TICKET_C - -/** - * \def MBEDTLS_SSL_CLI_C - * - * Enable the SSL/TLS client code. - * - * Module: library/ssl_cli.c - * Caller: - * - * Requires: MBEDTLS_SSL_TLS_C - * - * This module is required for SSL/TLS client support. - */ -#define MBEDTLS_SSL_CLI_C - -/** - * \def MBEDTLS_SSL_SRV_C - * - * Enable the SSL/TLS server code. - * - * Module: library/ssl_srv.c - * Caller: - * - * Requires: MBEDTLS_SSL_TLS_C - * - * This module is required for SSL/TLS server support. - */ -#define MBEDTLS_SSL_SRV_C - -/** - * \def MBEDTLS_SSL_TLS_C - * - * Enable the generic SSL/TLS code. - * - * Module: library/ssl_tls.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * - * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C - * and at least one of the MBEDTLS_SSL_PROTO_XXX defines - * - * This module is required for SSL/TLS. - */ -#define MBEDTLS_SSL_TLS_C - -/** - * \def MBEDTLS_THREADING_C - * - * Enable the threading abstraction layer. - * By default mbed TLS assumes it is used in a non-threaded environment or that - * contexts are not shared between threads. If you do intend to use contexts - * between threads, you will need to enable this layer to prevent race - * conditions. See also our Knowledge Base article about threading: - * https://tls.mbed.org/kb/development/thread-safety-and-multi-threading - * - * Module: library/threading.c - * - * This allows different threading implementations (self-implemented or - * provided). - * - * You will have to enable either MBEDTLS_THREADING_ALT or - * MBEDTLS_THREADING_PTHREAD. - * - * Enable this layer to allow use of mutexes within mbed TLS - */ -//#define MBEDTLS_THREADING_C - -/** - * \def MBEDTLS_TIMING_C - * - * Enable the semi-portable timing interface. - * - * \note The provided implementation only works on POSIX/Unix (including Linux, - * BSD and OS X) and Windows. On other platforms, you can either disable that - * module and provide your own implementations of the callbacks needed by - * \c mbedtls_ssl_set_timer_cb() for DTLS, or leave it enabled and provide - * your own implementation of the whole module by setting - * \c MBEDTLS_TIMING_ALT in the current file. - * - * \note See also our Knowledge Base article about porting to a new - * environment: - * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS - * - * Module: library/timing.c - * Caller: library/havege.c - * - * This module is used by the HAVEGE random number generator. - */ -// #define MBEDTLS_TIMING_C - -/** - * \def MBEDTLS_VERSION_C - * - * Enable run-time version information. - * - * Module: library/version.c - * - * This module provides run-time version information. - */ -#define MBEDTLS_VERSION_C - -/** - * \def MBEDTLS_X509_USE_C - * - * Enable X.509 core for using certificates. - * - * Module: library/x509.c - * Caller: library/x509_crl.c - * library/x509_crt.c - * library/x509_csr.c - * - * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, - * MBEDTLS_PK_PARSE_C - * - * This module is required for the X.509 parsing modules. - */ -#define MBEDTLS_X509_USE_C - -/** - * \def MBEDTLS_X509_CRT_PARSE_C - * - * Enable X.509 certificate parsing. - * - * Module: library/x509_crt.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * Requires: MBEDTLS_X509_USE_C - * - * This module is required for X.509 certificate parsing. - */ -#define MBEDTLS_X509_CRT_PARSE_C - -/** - * \def MBEDTLS_X509_CRL_PARSE_C - * - * Enable X.509 CRL parsing. - * - * Module: library/x509_crl.c - * Caller: library/x509_crt.c - * - * Requires: MBEDTLS_X509_USE_C - * - * This module is required for X.509 CRL parsing. - */ -#define MBEDTLS_X509_CRL_PARSE_C - -/** - * \def MBEDTLS_X509_CSR_PARSE_C - * - * Enable X.509 Certificate Signing Request (CSR) parsing. - * - * Module: library/x509_csr.c - * Caller: library/x509_crt_write.c - * - * Requires: MBEDTLS_X509_USE_C - * - * This module is used for reading X.509 certificate request. - */ -#define MBEDTLS_X509_CSR_PARSE_C - -/** - * \def MBEDTLS_X509_CREATE_C - * - * Enable X.509 core for creating certificates. - * - * Module: library/x509_create.c - * - * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C - * - * This module is the basis for creating X.509 certificates and CSRs. - */ -#define MBEDTLS_X509_CREATE_C - -/** - * \def MBEDTLS_X509_CRT_WRITE_C - * - * Enable creating X.509 certificates. - * - * Module: library/x509_crt_write.c - * - * Requires: MBEDTLS_X509_CREATE_C - * - * This module is required for X.509 certificate creation. - */ -#define MBEDTLS_X509_CRT_WRITE_C - -/** - * \def MBEDTLS_X509_CSR_WRITE_C - * - * Enable creating X.509 Certificate Signing Requests (CSR). - * - * Module: library/x509_csr_write.c - * - * Requires: MBEDTLS_X509_CREATE_C - * - * This module is required for X.509 certificate request writing. - */ -#define MBEDTLS_X509_CSR_WRITE_C - -/** - * \def MBEDTLS_XTEA_C - * - * Enable the XTEA block cipher. - * - * Module: library/xtea.c - * Caller: - */ -#define MBEDTLS_XTEA_C - -/* \} name SECTION: mbed TLS modules */ - -/** - * \name SECTION: Module configuration options - * - * This section allows for the setting of module specific sizes and - * configuration options. The default values are already present in the - * relevant header files and should suffice for the regular use cases. - * - * Our advice is to enable options and change their values here - * only if you have a good reason and know the consequences. - * - * Please check the respective header file for documentation on these - * parameters (to prevent duplicate documentation). - * \{ - */ - -/* MPI / BIGNUM options */ -//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum window size used. */ -//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ - -/* CTR_DRBG options */ -//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ -//#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ -//#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ -//#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ -//#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ - -/* HMAC_DRBG options */ -//#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ -//#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ -//#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ -//#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ - -/* ECP options */ -//#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ -//#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ -//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ - -/* Entropy options */ -//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ -//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ -//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */ - -/* Memory buffer allocator options */ -//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ - -/* Platform options */ -//#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ -//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ -//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ -/* Note: your snprintf must correctly zero-terminate the buffer! */ -//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" /**< Seed file to read/write with default implementation */ - -/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ -/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ -//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ -//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ -//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ -/* Note: your snprintf must correctly zero-terminate the buffer! */ -//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_VSNPRINTF_MACRO vsnprintf /**< Default vsnprintf macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ -//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ - -/** - * \brief This macro is invoked by the library when an invalid parameter - * is detected that is only checked with #MBEDTLS_CHECK_PARAMS - * (see the documentation of that option for context). - * - * When you leave this undefined here, the library provides - * a default definition. If the macro #MBEDTLS_CHECK_PARAMS_ASSERT - * is defined, the default definition is `assert(cond)`, - * otherwise the default definition calls a function - * mbedtls_param_failed(). This function is declared in - * `platform_util.h` for the benefit of the library, but - * you need to define in your application. - * - * When you define this here, this replaces the default - * definition in platform_util.h (which no longer declares the - * function mbedtls_param_failed()) and it is your responsibility - * to make sure this macro expands to something suitable (in - * particular, that all the necessary declarations are visible - * from within the library - you can ensure that by providing - * them in this file next to the macro definition). - * If you define this macro to call `assert`, also define - * #MBEDTLS_CHECK_PARAMS_ASSERT so that library source files - * include ``. - * - * Note that you may define this macro to expand to nothing, in - * which case you don't have to worry about declarations or - * definitions. However, you will then be notified about invalid - * parameters only in non-void functions, and void function will - * just silently return early on invalid parameters, which - * partially negates the benefits of enabling - * #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged. - * - * \param cond The expression that should evaluate to true, but doesn't. - */ -//#define MBEDTLS_PARAM_FAILED( cond ) assert( cond ) - -/* SSL Cache options */ -//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ -//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ - -/* SSL options */ - -/** \def MBEDTLS_SSL_MAX_CONTENT_LEN - * - * Maximum length (in bytes) of incoming and outgoing plaintext fragments. - * - * This determines the size of both the incoming and outgoing TLS I/O buffers - * in such a way that both are capable of holding the specified amount of - * plaintext data, regardless of the protection mechanism used. - * - * To configure incoming and outgoing I/O buffers separately, use - * #MBEDTLS_SSL_IN_CONTENT_LEN and #MBEDTLS_SSL_OUT_CONTENT_LEN, - * which overwrite the value set by this option. - * - * \note When using a value less than the default of 16KB on the client, it is - * recommended to use the Maximum Fragment Length (MFL) extension to - * inform the server about this limitation. On the server, there - * is no supported, standardized way of informing the client about - * restriction on the maximum size of incoming messages, and unless - * the limitation has been communicated by other means, it is recommended - * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN - * while keeping the default value of 16KB for the incoming buffer. - * - * Uncomment to set the maximum plaintext size of both - * incoming and outgoing I/O buffers. - */ -//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 - -/** \def MBEDTLS_SSL_IN_CONTENT_LEN - * - * Maximum length (in bytes) of incoming plaintext fragments. - * - * This determines the size of the incoming TLS I/O buffer in such a way - * that it is capable of holding the specified amount of plaintext data, - * regardless of the protection mechanism used. - * - * If this option is undefined, it inherits its value from - * #MBEDTLS_SSL_MAX_CONTENT_LEN. - * - * \note When using a value less than the default of 16KB on the client, it is - * recommended to use the Maximum Fragment Length (MFL) extension to - * inform the server about this limitation. On the server, there - * is no supported, standardized way of informing the client about - * restriction on the maximum size of incoming messages, and unless - * the limitation has been communicated by other means, it is recommended - * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN - * while keeping the default value of 16KB for the incoming buffer. - * - * Uncomment to set the maximum plaintext size of the incoming I/O buffer - * independently of the outgoing I/O buffer. - */ -//#define MBEDTLS_SSL_IN_CONTENT_LEN 16384 - -/** \def MBEDTLS_SSL_CID_IN_LEN_MAX - * - * The maximum length of CIDs used for incoming DTLS messages. - * - */ -//#define MBEDTLS_SSL_CID_IN_LEN_MAX 32 - -/** \def MBEDTLS_SSL_CID_OUT_LEN_MAX - * - * The maximum length of CIDs used for outgoing DTLS messages. - * - */ -//#define MBEDTLS_SSL_CID_OUT_LEN_MAX 32 - -/** \def MBEDTLS_SSL_CID_PADDING_GRANULARITY - * - * This option controls the use of record plaintext padding - * when using the Connection ID extension in DTLS 1.2. - * - * The padding will always be chosen so that the length of the - * padded plaintext is a multiple of the value of this option. - * - * Note: A value of \c 1 means that no padding will be used - * for outgoing records. - * - * Note: On systems lacking division instructions, - * a power of two should be preferred. - * - */ -//#define MBEDTLS_SSL_CID_PADDING_GRANULARITY 16 - -/** \def MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY - * - * This option controls the use of record plaintext padding - * in TLS 1.3. - * - * The padding will always be chosen so that the length of the - * padded plaintext is a multiple of the value of this option. - * - * Note: A value of \c 1 means that no padding will be used - * for outgoing records. - * - * Note: On systems lacking division instructions, - * a power of two should be preferred. - */ -//#define MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY 1 - -/** \def MBEDTLS_SSL_OUT_CONTENT_LEN - * - * Maximum length (in bytes) of outgoing plaintext fragments. - * - * This determines the size of the outgoing TLS I/O buffer in such a way - * that it is capable of holding the specified amount of plaintext data, - * regardless of the protection mechanism used. - * - * If this option undefined, it inherits its value from - * #MBEDTLS_SSL_MAX_CONTENT_LEN. - * - * It is possible to save RAM by setting a smaller outward buffer, while keeping - * the default inward 16384 byte buffer to conform to the TLS specification. - * - * The minimum required outward buffer size is determined by the handshake - * protocol's usage. Handshaking will fail if the outward buffer is too small. - * The specific size requirement depends on the configured ciphers and any - * certificate data which is sent during the handshake. - * - * Uncomment to set the maximum plaintext size of the outgoing I/O buffer - * independently of the incoming I/O buffer. - */ -//#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384 - -/** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING - * - * Maximum number of heap-allocated bytes for the purpose of - * DTLS handshake message reassembly and future message buffering. - * - * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN - * to account for a reassembled handshake message of maximum size, - * together with its reassembly bitmap. - * - * A value of 2 * MBEDTLS_SSL_IN_CONTENT_LEN (32768 by default) - * should be sufficient for all practical situations as it allows - * to reassembly a large handshake message (such as a certificate) - * while buffering multiple smaller handshake messages. - * - */ -//#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 - -//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ -//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ -//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ - -/** - * Complete list of ciphersuites to use, in order of preference. - * - * \warning No dependency checking is done on that field! This option can only - * be used to restrict the set of available ciphersuites. It is your - * responsibility to make sure the needed modules are active. - * - * Use this to save a few hundred bytes of ROM (default ordering of all - * available ciphersuites) and a few to a few hundred bytes of RAM. - * - * The value below is only an example, not the default. - */ -//#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - -/* X509 options */ -//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ -//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */ - -/** - * Allow SHA-1 in the default TLS configuration for certificate signing. - * Without this build-time option, SHA-1 support must be activated explicitly - * through mbedtls_ssl_conf_cert_profile. Turning on this option is not - * recommended because of it is possible to generate SHA-1 collisions, however - * this may be safe for legacy infrastructure where additional controls apply. - * - * \warning SHA-1 is considered a weak message digest and its use constitutes - * a security risk. If possible, we recommend avoiding dependencies - * on it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES - -/** - * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake - * signature and ciphersuite selection. Without this build-time option, SHA-1 - * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes. - * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by - * default. At the time of writing, there is no practical attack on the use - * of SHA-1 in handshake signatures, hence this option is turned on by default - * to preserve compatibility with existing peers, but the general - * warning applies nonetheless: - * - * \warning SHA-1 is considered a weak message digest and its use constitutes - * a security risk. If possible, we recommend avoiding dependencies - * on it, and considering stronger message digests instead. - * - */ -#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE - -/** - * Uncomment the macro to let mbed TLS use your alternate implementation of - * mbedtls_platform_zeroize(). This replaces the default implementation in - * platform_util.c. - * - * mbedtls_platform_zeroize() is a widely used function across the library to - * zero a block of memory. The implementation is expected to be secure in the - * sense that it has been written to prevent the compiler from removing calls - * to mbedtls_platform_zeroize() as part of redundant code elimination - * optimizations. However, it is difficult to guarantee that calls to - * mbedtls_platform_zeroize() will not be optimized by the compiler as older - * versions of the C language standards do not provide a secure implementation - * of memset(). Therefore, MBEDTLS_PLATFORM_ZEROIZE_ALT enables users to - * configure their own implementation of mbedtls_platform_zeroize(), for - * example by using directives specific to their compiler, features from newer - * C standards (e.g using memset_s() in C11) or calling a secure memset() from - * their system (e.g explicit_bzero() in BSD). - */ -//#define MBEDTLS_PLATFORM_ZEROIZE_ALT - -/** - * Uncomment the macro to let Mbed TLS use your alternate implementation of - * mbedtls_platform_gmtime_r(). This replaces the default implementation in - * platform_util.c. - * - * gmtime() is not a thread-safe function as defined in the C standard. The - * library will try to use safer implementations of this function, such as - * gmtime_r() when available. However, if Mbed TLS cannot identify the target - * system, the implementation of mbedtls_platform_gmtime_r() will default to - * using the standard gmtime(). In this case, calls from the library to - * gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex - * if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the - * library are also guarded with this mutex to avoid race conditions. However, - * if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will - * unconditionally use the implementation for mbedtls_platform_gmtime_r() - * supplied at compile time. - */ -//#define MBEDTLS_PLATFORM_GMTIME_R_ALT - -/** - * Enable the verified implementations of ECDH primitives from Project Everest - * (currently only Curve25519). This feature changes the layout of ECDH - * contexts and therefore is a compatibility break for applications that access - * fields of a mbedtls_ecdh_context structure directly. See also - * MBEDTLS_ECDH_LEGACY_CONTEXT in include/mbedtls/ecdh.h. - */ -//#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED - -/* \} name SECTION: Customisation configuration options */ - -/* Target and application specific configurations - * - * Allow user to override any previous default. - * - */ -#if defined(MBEDTLS_USER_CONFIG_FILE) -#include MBEDTLS_USER_CONFIG_FILE -#endif - -#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) -#include "mbedtls/config_psa.h" -#endif - -#define MBEDTLS_HAVE_INT64 - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/deps/secp256k1 b/deps/secp256k1 deleted file mode 160000 index 3ffde18..0000000 --- a/deps/secp256k1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3ffde18a060aaf4df5b81e7d88355f1e99874650 diff --git a/docs/ckb-anyone-can-pay.md b/docs/ckb-anyone-can-pay.md deleted file mode 100644 index aa8d113..0000000 --- a/docs/ckb-anyone-can-pay.md +++ /dev/null @@ -1,94 +0,0 @@ -# ckb-anyone-can-pay - -CKB anyone-can-pay lock. - -[RFC Draft](https://talk.nervos.org/t/rfc-anyone-can-pay-lock/4438) - -## Build - -``` sh -make all-via-docker && cargo test -``` - -## Quick start - -### Create - -1, create a cell to receive UDT and CKB: - -``` -Cell { - lock: { - code_hash: - args: - } - data: - type: -} -``` - -2, create a cell to receive only CKB: - -``` -Cell { - lock: { - code_hash: - args: - } - data: - type: -} -``` - -3, we can add minimum amount transfer condition: - -``` -Cell { - lock: { - code_hash: - args: | | - } - data: - type: -} -``` - -`minimum CKB` and `minimum UDT` are two optional args, each occupied a byte, and represent `10 ^ x` minimal amount. The default value is `0` which means anyone can transfer any amount to the cell. A transfer must satisfy the `minimum CKB` **or** `minimum UDT`. - -If the owner only wants to receive `UDT`, the owner can set `minimum CKB` to `255`. - -### Send UDT and CKB - -To transfer coins to an anyone-can-pay lock cell, the sender must build an output cell that has the same `lock_hash` and `type_hash` to the input anyone-can-pay lock cell; if the input anyone-can-pay cell has no `data`, the output cell must also be empty. - -``` -# inputs -Cell { - lock: { - code_hash: - args: | - } - data: - type: - capacity: 100 -} -... - -# outputs -Cell { - lock: { - code_hash: - args: | - } - data: - type: - capacity: 200 -} -... -``` - -### Signature - -The owner can provide a secp256k1 signature to unlock the cell, the signature method is the same as the [P2PH](https://github.com/nervosnetwork/ckb-system-scripts/wiki/How-to-sign-transaction#p2ph). - -Unlock a cell with a signature has no restrictions, which helps owner to manage the cell as he wants. diff --git a/docs/validate-signature-rsa.md b/docs/validate-signature-rsa.md deleted file mode 100644 index f73e996..0000000 --- a/docs/validate-signature-rsa.md +++ /dev/null @@ -1,22 +0,0 @@ -# validate-signature-rsa - -Swappable Signature Verification Protocol: RSA library. - -[RFC: Swappable Signature Verification Protocol Spec](https://talk.nervos.org/t/rfc-swappable-signature-verification-protocol-spec/4802) - -## Build - -```shell script -make validate_signature_rsa-via-docker -bash tests/validate_signature_rsa/run.sh -``` - -## Use library - -Can find a lot of examples in tests/validate_signature_rsa/validate_signature_rsa_sim.c. -More details are described in c/validate_signature_rsa.h. - - -## Testing results - -Check out the testing report in tests/testing_results.md diff --git a/examples/validate-signature-rsa/.gitignore b/examples/validate-signature-rsa/.gitignore deleted file mode 100644 index 55ac8d1..0000000 --- a/examples/validate-signature-rsa/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# Rust -target/* -.cache/.cargo/* -contracts/**/target/* - -# C -contracts/c/build/* - -# others -build/* -!.gitkeep -.tmp/ diff --git a/examples/validate-signature-rsa/Cargo.lock b/examples/validate-signature-rsa/Cargo.lock deleted file mode 100644 index 1672da5..0000000 --- a/examples/validate-signature-rsa/Cargo.lock +++ /dev/null @@ -1,3738 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - -[[package]] -name = "ahash" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" - -[[package]] -name = "aho-corasick" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "async-compression" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72c1f1154e234325b50864a349b9c8e56939e266a4c307c0f159812df2f9537" -dependencies = [ - "bytes 0.5.6", - "flate2", - "futures-core", - "memchr", - "pin-project-lite 0.2.4", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" -dependencies = [ - "addr2line", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "bit-vec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "blake2b-ref" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f6b7b71e3097ed6ee470bab30e1025dd1327eee94ab1e3040b5b5c3f992117" - -[[package]] -name = "blake2b-rs" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e35e362830ef90ecea16f09b21b75d22d33a8562a679c74ab4f4fa49b4fcb87" -dependencies = [ - "cc", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bs58" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" - -[[package]] -name = "buddy-alloc" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff9f338986406db85e2b5deb40a9255b796ca03a194c7457403d215173f3fd5" - -[[package]] -name = "bumpalo" -version = "3.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "either", - "iovec", -] - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" -dependencies = [ - "serde", -] - -[[package]] -name = "bytes" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" - -[[package]] -name = "cc" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" -dependencies = [ - "rayon", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "serde", - "time", - "winapi 0.3.9", -] - -[[package]] -name = "ckb-always-success-script" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3b72a38c9920a29990df12002c4d069a147c8782f0c211f8a01b2df8f42bfd" - -[[package]] -name = "ckb-app-config" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64126761cb90351ac4436ea9884fc9f5771d2ccb19f724241ec63dae93ed9b0f" -dependencies = [ - "ckb-build-info", - "ckb-chain-spec", - "ckb-fee-estimator", - "ckb-jsonrpc-types", - "ckb-logger", - "ckb-logger-config", - "ckb-metrics-config", - "ckb-pow", - "ckb-resource", - "ckb-types", - "clap", - "path-clean", - "rand 0.6.5", - "sentry", - "serde", - "serde_plain", - "tentacle-multiaddr", - "tentacle-secio", - "toml", -] - -[[package]] -name = "ckb-async-runtime" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc49f7578388b937dd06ddc2c463937dc19d679aa91b265bef7d4c1bf6ea64d" -dependencies = [ - "tokio 0.2.25", -] - -[[package]] -name = "ckb-build-info" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee62666aa39c90895c531c9b9f94cffb811eb9d592f3a7d0690c74dd9a7590e0" - -[[package]] -name = "ckb-chain-spec" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b54264449a3642cc50edf1d270c8d640182a59054f2bf0b0c7fe8d28a141f1c7" -dependencies = [ - "ckb-crypto", - "ckb-dao-utils", - "ckb-error", - "ckb-hash", - "ckb-jsonrpc-types", - "ckb-pow", - "ckb-rational", - "ckb-resource", - "ckb-types", - "failure", - "serde", - "toml", -] - -[[package]] -name = "ckb-channel" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aefd7441d8ce6c6b1ba2b00aa954dccab06b2071fda8ee1501dd7adcb8a7b" -dependencies = [ - "crossbeam-channel 0.3.9", -] - -[[package]] -name = "ckb-crypto" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e75b1663db3cfc33c8ceeafff530789dbe6863b8b0ac5709e9cdfb48ad21e86" -dependencies = [ - "ckb-fixed-hash", - "failure", - "faster-hex 0.4.1", - "lazy_static", - "rand 0.6.5", - "secp256k1", -] - -[[package]] -name = "ckb-dao" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b45d97d0dd3a43d5b47ba4ea5ae8a8b77c1de75b4492880cc8be196e1e66ae" -dependencies = [ - "byteorder", - "ckb-chain-spec", - "ckb-dao-utils", - "ckb-error", - "ckb-store", - "ckb-traits", - "ckb-types", -] - -[[package]] -name = "ckb-dao-utils" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18be0c7895191f8ad2b8fa0b5cd838cce9fbfb9bb25bfc273a28cdd79936bb0" -dependencies = [ - "byteorder", - "ckb-error", - "ckb-types", - "enum-display-derive", - "failure", -] - -[[package]] -name = "ckb-db" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d310656c7c957d580f01234a8bc6fecbdb424ec8282333e8908d51a3ecfcbbd8" -dependencies = [ - "ckb-app-config", - "ckb-error", - "ckb-logger", - "ckb-rocksdb", - "libc", - "tempfile", -] - -[[package]] -name = "ckb-error" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdbaad9ab524b5fe37ee1c9e83b8668e7eba0027ef05ad8b3d3305c99d3cebe" -dependencies = [ - "ckb-occupied-capacity", - "enum-display-derive", - "failure", - "quote 1.0.8", -] - -[[package]] -name = "ckb-fee-estimator" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dac5221e327aa3eb9a4a0c8627311afaff7f6d3509baa3201397987261e0c7f" -dependencies = [ - "ckb-logger", - "ckb-types", - "serde", -] - -[[package]] -name = "ckb-fixed-hash" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f629a4199407c8ab70585aa7c565c6e121334b268689ab5cf2dadaefe941cd" -dependencies = [ - "ckb-fixed-hash-core", - "ckb-fixed-hash-macros", -] - -[[package]] -name = "ckb-fixed-hash-core" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e29663e41aedddff7875ad0be8a57934da6ab7a942627713c9a4d34f1493196c" -dependencies = [ - "failure", - "faster-hex 0.4.1", - "serde", -] - -[[package]] -name = "ckb-fixed-hash-macros" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab08726ca4fa3db89fbb730167bd8fdb0756dd0098b475fe95a811ed83becb7d" -dependencies = [ - "ckb-fixed-hash-core", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "ckb-hash" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7508217d38998e44b783e1d6fdf2a5d77f1ae2c425a1bca0dd08ac9b22e3bac5" -dependencies = [ - "blake2b-rs", -] - -[[package]] -name = "ckb-jsonrpc-types" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd22d5b3bd84812df783c60ad9a08c80fa34604507df9cde37601be922fcdf5" -dependencies = [ - "ckb-types", - "faster-hex 0.4.1", - "jsonrpc-core", - "serde", - "serde_json", -] - -[[package]] -name = "ckb-librocksdb-sys" -version = "6.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995341a6dea5f0d8ff4570bebbde3691349842d2c671472e09ea2ee2e3e0b083" -dependencies = [ - "cc", - "glob", - "libc", -] - -[[package]] -name = "ckb-logger" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7113116c74dbbd2f345def8a13b336d096654796f8a0eff1ce59d581a4fe365" -dependencies = [ - "log", -] - -[[package]] -name = "ckb-logger-config" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c025fb0a9fe3696e628b61faec460b58f8ac995dbbd34a26a3ab6f6105b94" -dependencies = [ - "serde", -] - -[[package]] -name = "ckb-metrics-config" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071d38006be2cedbfde204ca261d1dfcef20f6c1592642aa4a90b1e1048f15a7" -dependencies = [ - "log", - "serde", -] - -[[package]] -name = "ckb-occupied-capacity" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9a4cdc68f65dc7912e8b156264ad577ba9e8ef88896433d135cd9f9db3e4343" -dependencies = [ - "ckb-occupied-capacity-core", - "ckb-occupied-capacity-macros", -] - -[[package]] -name = "ckb-occupied-capacity-core" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4faafd6eea713be008efbca13c467f466a4d0345e2edfa44b533427d67ab7ff5" -dependencies = [ - "serde", -] - -[[package]] -name = "ckb-occupied-capacity-macros" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f8106882d3afae8a93282078ccc817c79249cf5091bfd3bbb5daae8fa0555cd" -dependencies = [ - "ckb-occupied-capacity-core", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "ckb-pow" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a56ba754ed40e90abff0aaf77ac922f787ba5c5485b12137264ab5148f853f" -dependencies = [ - "byteorder", - "ckb-hash", - "ckb-types", - "eaglesong", - "log", - "serde", -] - -[[package]] -name = "ckb-rational" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f846cfc62dc5e68a55d3dded0d442f34027747aa759b89598727a43c8f8aaef" -dependencies = [ - "numext-fixed-uint", -] - -[[package]] -name = "ckb-resource" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f0a932cec00aa6880f97d6b72b523f14121cbc4e29ee9be4d85cf41c988a19e" -dependencies = [ - "ckb-system-scripts", - "ckb-types", - "includedir", - "includedir_codegen", - "phf", - "serde", - "tempfile", - "walkdir", -] - -[[package]] -name = "ckb-reward-calculator" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b501dc45dd32867a68ec7b9747f929ae0e0964d813553ad683e2bcd990e1d0" -dependencies = [ - "ckb-chain-spec", - "ckb-dao", - "ckb-error", - "ckb-logger", - "ckb-store", - "ckb-types", -] - -[[package]] -name = "ckb-rocksdb" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809a3a50c82a5fd7429c5141e64d8c4c37451ceb25fe3b51fce7fd5d929ad521" -dependencies = [ - "ckb-librocksdb-sys", - "libc", - "tempfile", -] - -[[package]] -name = "ckb-script" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37519e161fe6d46fe440d0bd32822e6074a02d000483d4f8d97f76d786b20fec" -dependencies = [ - "byteorder", - "ckb-chain-spec", - "ckb-error", - "ckb-hash", - "ckb-logger", - "ckb-traits", - "ckb-types", - "ckb-vm", - "ckb-vm-definitions", - "failure", - "faster-hex 0.4.1", - "goblin", - "serde", -] - -[[package]] -name = "ckb-standalone-types" -version = "0.0.1-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2cdbdf65ee5b1da71504f5a03d6984bce77d0b4b46daff63f4ba4a3b0eef08" -dependencies = [ - "cfg-if 0.1.10", - "molecule", -] - -[[package]] -name = "ckb-std" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f16c4f7efbf13f060dcd7a916f353936daf5eaccb411fcc255033eabde92155" -dependencies = [ - "buddy-alloc", - "cc", - "ckb-standalone-types", -] - -[[package]] -name = "ckb-store" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77caa96a9c41bb3811184f3a03cbf17bfdd9f986a0b2f2348bd6591500c3c892" -dependencies = [ - "ckb-app-config", - "ckb-chain-spec", - "ckb-db", - "ckb-error", - "ckb-traits", - "ckb-types", - "ckb-util", - "lru", -] - -[[package]] -name = "ckb-system-scripts" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261dd95a93c09ea24397c85b4fbca061e1da2d6573189749aeb99fe840aaf0c9" -dependencies = [ - "blake2b-rs", - "faster-hex 0.3.1", - "includedir", - "includedir_codegen", - "phf", -] - -[[package]] -name = "ckb-testtool" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "892ef39bff5d388b3d198b9f2d29f7301ce2d767fc6a1be3bb22f3531373e271" -dependencies = [ - "ckb-always-success-script", - "ckb-tool", - "lazy_static", - "linked_hash_set", - "rand 0.7.3", -] - -[[package]] -name = "ckb-tool" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3207d19ab709e0d97bb0c112d57268126f5f9cee033bda9a5c00f1c017337" -dependencies = [ - "ckb-chain-spec", - "ckb-crypto", - "ckb-error", - "ckb-hash", - "ckb-jsonrpc-types", - "ckb-resource", - "ckb-script", - "ckb-traits", - "ckb-types", - "ckb-verification", - "faster-hex 0.4.1", - "serde", - "serde_derive", - "serde_json", - "simple-jsonrpc-client", -] - -[[package]] -name = "ckb-traits" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72c1f49c61e3fb8d1ce33fd0602b6e3197c7d98a2e908c136182335b5fe4d3b" -dependencies = [ - "ckb-types", -] - -[[package]] -name = "ckb-types" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ae7c315751f98ef09dffd89a9c1bc149c1a5542ab77d85ca95818ba7d90b55" -dependencies = [ - "bit-vec", - "bytes 0.5.6", - "ckb-channel", - "ckb-error", - "ckb-fixed-hash", - "ckb-hash", - "ckb-occupied-capacity", - "ckb-rational", - "failure", - "merkle-cbt", - "molecule", - "numext-fixed-uint", - "once_cell", -] - -[[package]] -name = "ckb-util" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c5f2ed5dcd17131f7c0a132a03c6b29bf3864e2ce1dc8972ffd3d3aa9963f1" -dependencies = [ - "linked-hash-map", - "parking_lot 0.7.1", - "regex", -] - -[[package]] -name = "ckb-verification" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f1c0f2db0912a3c61d22b3ffc9ec206a1cb90fef805071c4cdba2cea35419a" -dependencies = [ - "ckb-async-runtime", - "ckb-chain-spec", - "ckb-dao", - "ckb-dao-utils", - "ckb-error", - "ckb-logger", - "ckb-pow", - "ckb-reward-calculator", - "ckb-script", - "ckb-store", - "ckb-traits", - "ckb-types", - "enum-display-derive", - "failure", - "faketime", - "lru", - "rayon", - "tokio 0.2.25", -] - -[[package]] -name = "ckb-vm" -version = "0.19.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc2fb181a6653bb13315dc7f60fbe32cd3d697553b24687613da984faf2a2c5" -dependencies = [ - "byteorder", - "bytes 0.5.6", - "cc", - "ckb-vm-definitions", - "derive_more", - "goblin", - "libc", - "mapr", - "scroll", -] - -[[package]] -name = "ckb-vm-definitions" -version = "0.19.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea76d3867d00736c64876ab0cd304be73691b91990a90ebbf100d36af85fdb05" - -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "const_fn" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" - -[[package]] -name = "cookie" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" -dependencies = [ - "time", - "url 1.7.2", -] - -[[package]] -name = "cookie_store" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" -dependencies = [ - "cookie", - "failure", - "idna 0.1.5", - "log", - "publicsuffix", - "serde", - "serde_json", - "time", - "try_from", - "url 1.7.2", -] - -[[package]] -name = "core-foundation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" - -[[package]] -name = "crc32fast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" -dependencies = [ - "crossbeam-utils 0.6.6", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.1", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -dependencies = [ - "crossbeam-epoch 0.8.2", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch 0.9.1", - "crossbeam-utils 0.8.1", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg 1.0.1", - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "lazy_static", - "maybe-uninit", - "memoffset 0.5.6", - "scopeguard 1.1.0", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" -dependencies = [ - "cfg-if 1.0.0", - "const_fn", - "crossbeam-utils 0.8.1", - "lazy_static", - "memoffset 0.6.1", - "scopeguard 1.1.0", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -dependencies = [ - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg 1.0.1", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" -dependencies = [ - "autocfg 1.0.1", - "cfg-if 1.0.0", - "lazy_static", -] - -[[package]] -name = "debugid" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088c9627adec1e494ff9dea77377f1e69893023d631254a0ec68b16ee20be3e9" -dependencies = [ - "lazy_static", - "regex", - "serde", - "uuid", -] - -[[package]] -name = "derive_more" -version = "0.99.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "dtoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" - -[[package]] -name = "eaglesong" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d978bd5d343e8ab9b5c0fc8d93ff9c602fdc96616ffff9c05ac7a155419b824" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "encoding_rs" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "enum-display-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53f76eb63c4bfc6fce5000f106254701b741fc9a65ee08445fde0ff39e583f1c" -dependencies = [ - "quote 0.3.15", - "syn 0.11.11", -] - -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "version_check", -] - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "faketime" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdcfc2bfe63c760bba09679ed6cb3a001d409c5195b4490dced0dc0aa800582b" -dependencies = [ - "js-sys", - "tempfile", -] - -[[package]] -name = "faster-hex" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b8cccaafb5aae8c282692e5590f341925edea6c696e8715ff0d973320b2646" - -[[package]] -name = "faster-hex" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348138dd23e03bb0018caef99647fb1a5befec5ff4b501991de88f09854d4c28" - -[[package]] -name = "flate2" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" -dependencies = [ - "cfg-if 1.0.0", - "crc32fast", - "libc", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" -dependencies = [ - "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" - -[[package]] -name = "futures" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" - -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures 0.1.30", - "num_cpus", -] - -[[package]] -name = "futures-executor" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" - -[[package]] -name = "futures-macro" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" -dependencies = [ - "proc-macro-hack", - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "futures-sink" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" - -[[package]] -name = "futures-task" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" -dependencies = [ - "once_cell", -] - -[[package]] -name = "futures-util" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite 0.2.4", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.10.2+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" - -[[package]] -name = "glob" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" - -[[package]] -name = "goblin" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884" -dependencies = [ - "log", - "plain", - "scroll", -] - -[[package]] -name = "h2" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" -dependencies = [ - "byteorder", - "bytes 0.4.12", - "fnv", - "futures 0.1.30", - "http 0.1.21", - "indexmap", - "log", - "slab", - "string", - "tokio-io", -] - -[[package]] -name = "h2" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" -dependencies = [ - "bytes 0.5.6", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.3", - "indexmap", - "slab", - "tokio 0.2.25", - "tokio-util", - "tracing", - "tracing-futures", -] - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "hermit-abi" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" -dependencies = [ - "libc", -] - -[[package]] -name = "hostname" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" -dependencies = [ - "libc", - "winutil", -] - -[[package]] -name = "http" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" -dependencies = [ - "bytes 0.4.12", - "fnv", - "itoa", -] - -[[package]] -name = "http" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" -dependencies = [ - "bytes 1.0.1", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "http 0.1.21", - "tokio-buf", -] - -[[package]] -name = "http-body" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" -dependencies = [ - "bytes 0.5.6", - "http 0.2.3", -] - -[[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" - -[[package]] -name = "httpdate" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "hyper" -version = "0.12.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "futures-cpupool", - "h2 0.1.26", - "http 0.1.21", - "http-body 0.1.0", - "httparse", - "iovec", - "itoa", - "log", - "net2", - "rustc_version", - "time", - "tokio 0.1.22", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "want 0.2.0", -] - -[[package]] -name = "hyper" -version = "0.13.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf" -dependencies = [ - "bytes 0.5.6", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.2.7", - "http 0.2.3", - "http-body 0.3.1", - "httparse", - "httpdate", - "itoa", - "pin-project 1.0.4", - "socket2", - "tokio 0.2.25", - "tower-service", - "tracing", - "want 0.3.0", -] - -[[package]] -name = "hyper-tls" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "hyper 0.12.35", - "native-tls", - "tokio-io", -] - -[[package]] -name = "hyper-tls" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" -dependencies = [ - "bytes 0.5.6", - "hyper 0.13.9", - "native-tls", - "tokio 0.2.25", - "tokio-tls", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "im" -version = "12.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de38d1511a0ce7677538acb1e31b5df605147c458e061b2cdb89858afb1cd182" -dependencies = [ - "rustc_version", - "sized-chunks", - "typenum", -] - -[[package]] -name = "includedir" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97402f770a519ebea51b27131c3b6558cfd2375aff21294bad806bad91bf0b6" -dependencies = [ - "flate2", - "phf", -] - -[[package]] -name = "includedir_codegen" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7d542be113fd84855692fb536c16cc4c09527724d1dca8953047d71cccadef" -dependencies = [ - "flate2", - "phf_codegen", - "walkdir", -] - -[[package]] -name = "indexmap" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" -dependencies = [ - "autocfg 1.0.1", - "hashbrown", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "ipnet" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" - -[[package]] -name = "itoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "js-sys" -version = "0.3.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpc-core" -version = "14.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0747307121ffb9703afd93afbd0fb4f854c38fb873f2c8b90e0e902f27c7b62" -dependencies = [ - "futures 0.1.30", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff" - -[[package]] -name = "linked-hash-map" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" - -[[package]] -name = "linked_hash_set" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "owning_ref", - "scopeguard 0.3.3", -] - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard 1.1.0", -] - -[[package]] -name = "log" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "lru" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3aae342b73d57ad0b8b364bd12584819f2c1fe9114285dfcf8b0722607671635" -dependencies = [ - "hashbrown", -] - -[[package]] -name = "mapr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a28a55dbc005b2f6f123c4058933d57add373d362f6fd3a76aab4fe6973500" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" - -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg 1.0.1", -] - -[[package]] -name = "memoffset" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" -dependencies = [ - "autocfg 1.0.1", -] - -[[package]] -name = "merkle-cbt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f1ac8428ec02d6caa5a79c15e851d84d5dc7a00df0429a8aa860d104f0a81be" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mime_guess" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" -dependencies = [ - "mime", - "unicase", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" -dependencies = [ - "adler", - "autocfg 1.0.1", -] - -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "molecule" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "663f76cc52219e5957e2f5563cce9d89f98aa8503c9c898b5c412d97df663998" -dependencies = [ - "bytes 0.5.6", - "cfg-if 0.1.10", - "faster-hex 0.4.1", -] - -[[package]] -name = "native-tls" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg 1.0.1", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg 1.0.1", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "numext-constructor" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "621fe0f044729f810c6815cdd77e8f5e0cd803ce4f6a38380ebfc1322af98661" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "numext-fixed-uint" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c68c76f96d589d1009a666c5072f37f3114d682696505f2cf445f27766c7d70" -dependencies = [ - "numext-fixed-uint-core", - "numext-fixed-uint-hack", -] - -[[package]] -name = "numext-fixed-uint-core" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aab1d6457b97b49482f22a92f0f58a2f39bdd7f3b2f977eae67e8bc206aa980" -dependencies = [ - "heapsize", - "numext-constructor", - "rand 0.7.3", - "serde", - "thiserror", -] - -[[package]] -name = "numext-fixed-uint-hack" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200f8d55c36ec1b6a8cf810115be85d4814f045e0097dfd50033ba25adb4c9e" -dependencies = [ - "numext-fixed-uint-core", - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "object" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" - -[[package]] -name = "once_cell" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "openssl" -version = "0.10.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" -dependencies = [ - "autocfg 1.0.1", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "rustc_version", - "smallvec", - "winapi 0.3.9", -] - -[[package]] -name = "path-clean" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -dependencies = [ - "phf_shared", - "rand 0.6.5", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - -[[package]] -name = "pin-project" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" -dependencies = [ - "pin-project-internal 1.0.4", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - -[[package]] -name = "pin-project-lite" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "ppv-lite86" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" - -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid 0.2.1", -] - -[[package]] -name = "publicsuffix" -version = "1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b" -dependencies = [ - "error-chain", - "idna 0.2.0", - "lazy_static", - "regex", - "url 2.2.0", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" -dependencies = [ - "proc-macro2 1.0.24", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" -dependencies = [ - "libc", - "rand_chacha 0.3.0", - "rand_core 0.6.1", - "rand_hc 0.3.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" -dependencies = [ - "getrandom 0.2.2", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_hc" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" -dependencies = [ - "rand_core 0.6.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rayon" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" -dependencies = [ - "autocfg 1.0.1", - "crossbeam-deque 0.8.0", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" -dependencies = [ - "crossbeam-channel 0.5.0", - "crossbeam-deque 0.8.0", - "crossbeam-utils 0.8.1", - "lazy_static", - "num_cpus", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "reqwest" -version = "0.9.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" -dependencies = [ - "base64 0.10.1", - "bytes 0.4.12", - "cookie", - "cookie_store", - "encoding_rs", - "flate2", - "futures 0.1.30", - "http 0.1.21", - "hyper 0.12.35", - "hyper-tls 0.3.2", - "log", - "mime", - "mime_guess", - "native-tls", - "serde", - "serde_json", - "serde_urlencoded 0.5.5", - "time", - "tokio 0.1.22", - "tokio-executor", - "tokio-io", - "tokio-threadpool", - "tokio-timer", - "url 1.7.2", - "uuid", - "winreg 0.6.2", -] - -[[package]] -name = "reqwest" -version = "0.10.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c" -dependencies = [ - "async-compression", - "base64 0.13.0", - "bytes 0.5.6", - "encoding_rs", - "futures-core", - "futures-util", - "http 0.2.3", - "http-body 0.3.1", - "hyper 0.13.9", - "hyper-tls 0.4.3", - "ipnet", - "js-sys", - "lazy_static", - "log", - "mime", - "mime_guess", - "native-tls", - "percent-encoding 2.1.0", - "pin-project-lite 0.2.4", - "serde", - "serde_json", - "serde_urlencoded 0.7.0", - "tokio 0.2.25", - "tokio-tls", - "url 2.2.0", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg 0.7.0", -] - -[[package]] -name = "ring" -version = "0.16.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" -dependencies = [ - "cc", - "lazy_static", - "libc", - "spin", - "untrusted", - "web-sys", - "winapi 0.3.9", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "scroll" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "secp256k1" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2932dc07acd2066ff2e3921a4419606b220ba6cd03a9935123856cc534877056" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab2c26f0d3552a0f12e639ae8a64afc2e3db9c52fe32f5fc6c289d38519f220" -dependencies = [ - "cc", -] - -[[package]] -name = "security-framework" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "sentry" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4ea18f306c959be49f1bea8f3911a454e5d09d2dc43307215729e636bfbf4b" -dependencies = [ - "backtrace", - "env_logger", - "failure", - "hostname", - "httpdate", - "im", - "lazy_static", - "libc", - "log", - "rand 0.6.5", - "regex", - "reqwest 0.9.24", - "rustc_version", - "sentry-types", - "uname", - "url 1.7.2", -] - -[[package]] -name = "sentry-types" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b23e3d9c8c6e4a1523f24df6753c4088bfe16c44a73c8881c1d23c70f28ae280" -dependencies = [ - "chrono", - "debugid", - "failure", - "serde", - "serde_json", - "url 1.7.2", - "url_serde", - "uuid", -] - -[[package]] -name = "serde" -version = "1.0.123" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.123" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "serde_json" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_plain" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625fb0da2b006092b426a94acc1611bec52f2ec27bb27b266a9f93c29ee38eda" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -dependencies = [ - "dtoa", - "itoa", - "serde", - "url 1.7.2", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "simple-jsonrpc-client" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b737e351dd079e177a314959477627f53a6f928ec0ce37ded275e8363772c7c0" -dependencies = [ - "jsonrpc-core", - "reqwest 0.10.10", - "serde", - "serde_json", -] - -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" - -[[package]] -name = "sized-chunks" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d3e7f23bad2d6694e0f46f5e470ec27eb07b8f3e8b309a4b0dc17501928b9f2" -dependencies = [ - "typenum", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -dependencies = [ - "bytes 0.4.12", -] - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "syn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -dependencies = [ - "quote 0.3.15", - "synom", - "unicode-xid 0.0.4", -] - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "unicode-xid 0.2.1", -] - -[[package]] -name = "synom" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -dependencies = [ - "unicode-xid 0.0.4", -] - -[[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", - "unicode-xid 0.2.1", -] - -[[package]] -name = "tempfile" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "rand 0.8.3", - "redox_syscall 0.2.4", - "remove_dir_all", - "winapi 0.3.9", -] - -[[package]] -name = "tentacle-multiaddr" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d216ab77a6719cbcdf9d10ae35d825d29c2920090c2cb5d6179d953f9e4dfc3" -dependencies = [ - "bs58", - "bytes 0.5.6", - "serde", - "sha2", - "unsigned-varint", -] - -[[package]] -name = "tentacle-secio" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea9c3062e6f891618a720befb4caef3e4ce650e21f23b4e718d80adcc483ccc" -dependencies = [ - "bs58", - "bytes 0.5.6", - "futures 0.3.12", - "log", - "molecule", - "openssl", - "openssl-sys", - "rand 0.7.3", - "ring", - "secp256k1", - "tokio 0.2.25", - "tokio-util", - "unsigned-varint", -] - -[[package]] -name = "termcolor" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "tests" -version = "0.1.0" -dependencies = [ - "ckb-system-scripts", - "ckb-testtool", - "ckb-tool", - "openssl", - "rand 0.7.3", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - -[[package]] -name = "thread_local" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915" -dependencies = [ - "once_cell", -] - -[[package]] -name = "time" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "tinyvec" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "mio", - "num_cpus", - "tokio-current-thread", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", -] - -[[package]] -name = "tokio" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" -dependencies = [ - "bytes 0.5.6", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "memchr", - "mio", - "num_cpus", - "pin-project-lite 0.1.11", - "slab", -] - -[[package]] -name = "tokio-buf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" -dependencies = [ - "bytes 0.4.12", - "either", - "futures 0.1.30", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.30", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.30", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "log", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.30", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.30", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque 0.7.3", - "crossbeam-queue", - "crossbeam-utils 0.7.2", - "futures 0.1.30", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.30", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" -dependencies = [ - "native-tls", - "tokio 0.2.25", -] - -[[package]] -name = "tokio-util" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" -dependencies = [ - "bytes 0.5.6", - "futures-core", - "futures-sink", - "log", - "pin-project-lite 0.1.11", - "tokio 0.2.25", -] - -[[package]] -name = "toml" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" -dependencies = [ - "serde", -] - -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - -[[package]] -name = "tracing" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" -dependencies = [ - "cfg-if 1.0.0", - "log", - "pin-project-lite 0.2.4", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -dependencies = [ - "pin-project 0.4.27", - "tracing", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "try_from" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "typenum" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" - -[[package]] -name = "uname" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" -dependencies = [ - "libc", -] - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" - -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "unsigned-varint" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67332660eb59a6f1eb24ff1220c9e8d01738a8503c6002e30bcfe4bd9f2b4a9" - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - -[[package]] -name = "url" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" -dependencies = [ - "form_urlencoded", - "idna 0.2.0", - "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "url_serde" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea" -dependencies = [ - "serde", - "url 1.7.2", -] - -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", - "serde", -] - -[[package]] -name = "validate-signature-rsa" -version = "0.1.0" -dependencies = [ - "blake2b-ref", - "blake2b-rs", - "ckb-std", -] - -[[package]] -name = "vcpkg" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[package]] -name = "walkdir" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -dependencies = [ - "same-file", - "winapi 0.3.9", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" -dependencies = [ - "futures 0.1.30", - "log", - "try-lock", -] - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] -name = "wasm-bindgen" -version = "0.2.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" -dependencies = [ - "cfg-if 1.0.0", - "serde", - "serde_json", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" -dependencies = [ - "quote 1.0.8", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" - -[[package]] -name = "web-sys" -version = "0.3.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "winreg" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winreg" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winutil" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/examples/validate-signature-rsa/Cargo.toml b/examples/validate-signature-rsa/Cargo.toml deleted file mode 100644 index 6942675..0000000 --- a/examples/validate-signature-rsa/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[workspace] -members = ["tests", "contracts/validate-signature-rsa"] - -[profile.release] -overflow-checks = true -opt-level = 's' -lto = true -codegen-units = 1 -panic = 'abort' diff --git a/examples/validate-signature-rsa/README.md b/examples/validate-signature-rsa/README.md deleted file mode 100644 index 62d96fd..0000000 --- a/examples/validate-signature-rsa/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Demo for validate_signature_rsa -This document describes how to use dynamic library "validate_signature_rsa" to write a lock script. -It uses RSA instead of secp256k1. It's just a demo, don't use it without improvement for product directly. - - -## Build contract - -```bash -make validate_signature_rsa-via-docker -``` -then copy the binary to the target folder: -```bash -cp build/validate_signature_rsa examples/validate-signature-rsa/dynamic-libray/ -``` -Do it only once. - - -## Build with Capsule -You need to install [Capsule](https://github.com/nervosnetwork/capsule) first. - -Build contracts: - -``` sh -cd examples/validate-signature-rsa -capsule build -``` - -Run tests: - -``` sh -capsule test -``` - -## Build without capsule -Capsule use docker to build the contracts and run tests. Feel free to do it without it. -Please read this script: ```examples/validate-signature-rsa/build-without-capsule.sh``` -You need to install [GNU toolchain for RISC-V](https://github.com/nervosnetwork/ckb-riscv-gnu-toolchain) first. diff --git a/examples/validate-signature-rsa/build-without-capsule.sh b/examples/validate-signature-rsa/build-without-capsule.sh deleted file mode 100644 index 85da799..0000000 --- a/examples/validate-signature-rsa/build-without-capsule.sh +++ /dev/null @@ -1,37 +0,0 @@ - -# -# This script is compatible with Capsule. -# - -# Before you run this script, make sure the following are done: -# 1. install ckb-binary-patcher -# cargo install --git https://github.com/xxuejie/ckb-binary-patcher.git -# 2. install Rust nightly toolchain -# rustup toolchain install nightly-2020-09-28 -# 3. if you want to use this script to your own project, don't forget to copy the following files -# * contracts/validate-signature-rsa/rust-toolchain -# * contracts/validate-signature-rsa/.cargo/config -# They make contracts built with nightly tool chain and proper options. -# 4. add target -# rustup target add riscv64imac-unknown-none-elf - -set -e -BIN=./target/riscv64imac-unknown-none-elf/debug/validate-signature-rsa - -cd "$(dirname "${BASH_SOURCE[0]}")" -mkdir -p build/debug - -cd contracts/validate-signature-rsa - -echo "cargo build the contract ..." -cargo build --target riscv64imac-unknown-none-elf -cd ../../ - -echo "patch the binary ..." -ckb-binary-patcher -i ${BIN} -o ${BIN} - -echo "copy the binary to build folder ..." -cp ${BIN} ./build/debug/validate-signature-rsa - -echo "build contract done!" -echo "trying 'cargo test -p tests' to run tests." diff --git a/examples/validate-signature-rsa/capsule.toml b/examples/validate-signature-rsa/capsule.toml deleted file mode 100644 index 6efcd2a..0000000 --- a/examples/validate-signature-rsa/capsule.toml +++ /dev/null @@ -1,16 +0,0 @@ -# [rust] -# # path of rust contracts workspace directory, -# # a `Cargo.toml` file is expected under the directory. -# workspace_dir = "." -# toolchain = "nightly-2020-09-28" -# docker_image = "jjy0/ckb-capsule-recipe-rust:2020-9-28" - -# capsule version -version = "0.4.5" - -# path of deployment config file -deployment = "deployment.toml" - -[[contracts]] -name = "validate-signature-rsa" -template_type = "Rust" diff --git a/examples/validate-signature-rsa/contracts/.gitkeep b/examples/validate-signature-rsa/contracts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/.cargo/config b/examples/validate-signature-rsa/contracts/validate-signature-rsa/.cargo/config deleted file mode 100644 index c79a073..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[build] -target = "riscv64imac-unknown-none-elf" -[target.riscv64imac-unknown-none-elf] -rustflags = [ "-Zpre-link-arg=-zseparate-code", "-Zpre-link-arg=-zseparate-loadable-segments"] diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/Cargo.toml b/examples/validate-signature-rsa/contracts/validate-signature-rsa/Cargo.toml deleted file mode 100644 index da6601e..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "validate-signature-rsa" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ckb-std = {version = "0.7.3" } -blake2b-ref = { version = "0.1", default-features = false } - - -[build-dependencies] -blake2b-rs = "0.1.5" diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/build.rs b/examples/validate-signature-rsa/contracts/validate-signature-rsa/build.rs deleted file mode 100644 index 4387d99..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/build.rs +++ /dev/null @@ -1,49 +0,0 @@ -pub use blake2b_rs::{Blake2b, Blake2bBuilder}; - -use std::{ - fs::File, - io::{BufWriter, Read, Write}, - path::Path, -}; - -const BUF_SIZE: usize = 8 * 1024; -const CKB_HASH_PERSONALIZATION: &[u8] = b"ckb-default-hash"; - -fn main() { - let out_path = Path::new("src").join("code_hashes.rs"); - let mut out_file = BufWriter::new(File::create(&out_path).expect("create code_hashes.rs")); - - let name = "SHARED_LIB"; - let path = "../../dynamic-libray/validate_signature_rsa"; - - let mut buf = [0u8; BUF_SIZE]; - - // build hash - let mut blake2b = new_blake2b(); - let mut fd = File::open(&path).expect("open file"); - loop { - let read_bytes = fd.read(&mut buf).expect("read file"); - if read_bytes > 0 { - blake2b.update(&buf[..read_bytes]); - } else { - break; - } - } - - let mut hash = [0u8; 32]; - blake2b.finalize(&mut hash); - - write!( - &mut out_file, - "pub const {}: [u8; 32] = {:?};\n", - format!("CODE_HASH_{}", name.to_uppercase().replace("-", "_")), - hash - ) - .expect("write to code_hashes.rs"); -} - -pub fn new_blake2b() -> Blake2b { - Blake2bBuilder::new(32) - .personal(CKB_HASH_PERSONALIZATION) - .build() -} \ No newline at end of file diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/rust-toolchain b/examples/validate-signature-rsa/contracts/validate-signature-rsa/rust-toolchain deleted file mode 100644 index 35312fc..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2020-09-28 diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/code_hashes.rs b/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/code_hashes.rs deleted file mode 100644 index 4638fb1..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/code_hashes.rs +++ /dev/null @@ -1 +0,0 @@ -pub const CODE_HASH_SHARED_LIB: [u8; 32] = [0, 163, 255, 146, 155, 228, 58, 221, 152, 77, 112, 21, 28, 220, 148, 206, 55, 96, 157, 156, 75, 240, 229, 111, 195, 91, 144, 128, 243, 41, 203, 10]; diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/entry.rs b/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/entry.rs deleted file mode 100644 index 21ef447..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/entry.rs +++ /dev/null @@ -1,176 +0,0 @@ -use alloc::vec::Vec; -// Import from `core` instead of from `std` since we are in no-std mode -use core::result::Result; - -use blake2b_ref::{Blake2b, Blake2bBuilder}; -use ckb_std::ckb_constants::*; -use ckb_std::ckb_types::bytes::Bytes; -// Import CKB syscalls and structures -// https://nervosnetwork.github.io/ckb-std/riscv64imac-unknown-none-elf/doc/ckb_std/index.html -use ckb_std::ckb_types::prelude::*; -use ckb_std::debug; -use ckb_std::dynamic_loading_c_impl; -use ckb_std::error::SysError; -use ckb_std::high_level::*; - -use crate::{code_hashes, error::Error}; - -const BLAKE2B_BLOCK_SIZE: usize = 32; -const BLAKE2B160_BLOCK_SIZE: usize = 20; - -fn new_blake2b() -> Blake2b { - const CKB_HASH_PERSONALIZATION: &[u8] = b"ckb-default-hash"; - Blake2bBuilder::new(32) - .personal(CKB_HASH_PERSONALIZATION) - .build() -} - -fn get_key_size(key_size_enum: u8) -> usize { - let key_size = match key_size_enum { - 1 => 1024, - 2 => 2048, - 3 => 4096, - _ => 0, - }; - if key_size == 0 { - panic!("wrong key size"); - }; - key_size -} - -fn calculate_pub_key_hash(signature: &Bytes, key_size: usize) -> Vec { - let mut hash: Vec = Default::default(); - hash.resize(BLAKE2B_BLOCK_SIZE, 0); - - let mut blake2b = new_blake2b(); - blake2b.update(&signature.slice(4..8)); - blake2b.update(&signature.slice(8..(8 + key_size / 8))); - blake2b.finalize(hash.as_mut_slice()); - hash.truncate(BLAKE2B160_BLOCK_SIZE); - hash -} - - -fn calculate_rsa_info_length(key_size_enum: u8) -> usize { - 8 + get_key_size(key_size_enum) / 4 -} - -type DlContextType = dynamic_loading_c_impl::CKBDLContext<[u8; 128 * 1024]>; -/* -int validate_signature(void *prefilled_data, const uint8_t *signature_buffer, - size_t signature_size, const uint8_t *msg_buf, - size_t msg_size, uint8_t *output, size_t *output_len); -*/ -type DlFnType = unsafe extern "C" fn(fill: *const u8, signature: *const u8, - signature_size: usize, msg_buf: *const u8, msg_size: usize, - output: *const u8, output_len: *const usize) -> isize; - -pub fn main() -> Result<(), Error> { - let validate_signature_fn: dynamic_loading_c_impl::Symbol; - unsafe { - let mut ctx = DlContextType::new(); - let lib = ctx - .load(&code_hashes::CODE_HASH_SHARED_LIB) - .expect("load shared lib"); - validate_signature_fn = lib.get(b"validate_signature").expect("get function symbol validate_signature from dyanmic library"); - } - - let script = load_script()?; - let args: Bytes = script.args().unpack(); - - if args.is_empty() { - debug!("args is empty"); - return Err(Error::InvalidArgs0); - } - - let tx_hash = load_tx_hash()?; - - let signature: Bytes = load_witness_args(0, Source::GroupInput)?.lock() - .to_opt() - .ok_or(Error::InvalidArgs1)? - .unpack(); - let signature_len = signature.len(); - - // typedef struct RsaInfo { - // uint8_t algorithm_id; - // uint8_t key_size; - // uint8_t padding; - // uint8_t md_type; - // uint32_t E; - // uint8_t N[PLACEHOLDER_SIZE]; - // uint8_t sig[PLACEHOLDER_SIZE]; - // } RsaInfo; - let algorithm_id = signature[0]; - assert_eq!(algorithm_id, 1); - - let key_size_enum = signature[1]; - let padding = signature[2]; - assert!(padding == 0 || padding == 1); - let md_type = signature[3]; - assert!(md_type > 0); - - let key_size = get_key_size(key_size_enum); - assert_eq!(key_size % 1024, 0); - - let info_len = calculate_rsa_info_length(key_size_enum); - if signature.len() != info_len { - return Err(Error::InvalidArgs1); - } - let mut blake2b = new_blake2b(); - // hash, step 1 - blake2b.update(&tx_hash); - // hash, step 2 - blake2b.update(&signature_len.to_le_bytes()); - let mut index = 1; - loop { - let result = load_witness_args(index, Source::Input); - match result { - Ok(args) => { - let buff: Bytes = args.lock().to_opt().ok_or(Error::InvalidArgs1)?.unpack(); - let buff_size = buff.len(); - // hash, step 3 - blake2b.update(&buff_size.to_le_bytes()); - blake2b.update(&buff); - } - Err(err) if err == SysError::IndexOutOfBound => break, - Err(_) => { - debug!("load_witness_args() failed"); - return Err(Error::SyscallError); - } - } - index += 1; - } - let mut message = [0 as u8; BLAKE2B_BLOCK_SIZE]; - blake2b.finalize(&mut message); - - // dummy, not used - let dummy_len: usize = 4; - let dummy_output = [0 as u8; 4]; - let dummy = [0 as u8; 4]; - - unsafe { - let rsa_info = signature.as_ptr(); - let ret = validate_signature_fn(&dummy as *const u8, rsa_info, signature_len, &message as *const u8, BLAKE2B_BLOCK_SIZE, - &dummy_output as *const u8, &dummy_len as *const usize); - if ret != 0 { - debug!("validate_signature() failed: {}", ret); - return Err(Error::ValidateSignatureError); - } - } - let pub_key_hash = calculate_pub_key_hash(&signature, key_size); - let args_hash: Vec = args.into(); - if pub_key_hash.len() != args_hash.len() { - debug!("pub_key_hash.len() != args_hash.len() "); - return Err(Error::ArgsMismatched); - } else { - let len = pub_key_hash.len(); - for i in 0..len { - if pub_key_hash[i] != args_hash[i] { - debug!("pub_key_hash != args_hash "); - return Err(Error::ArgsMismatched); - } - } - } - return Ok(()); -} - diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/error.rs b/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/error.rs deleted file mode 100644 index 968684e..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/error.rs +++ /dev/null @@ -1,31 +0,0 @@ -use ckb_std::error::SysError; - -/// Error -#[repr(i8)] -pub enum Error { - IndexOutOfBound = 1, - ItemMissing, - LengthNotEnough, - Encoding, - // Add customized errors here... - SyscallError, - InvalidArgs0, - InvalidArgs1, - - ValidateSignatureError, - ArgsMismatched, -} - -impl From for Error { - fn from(err: SysError) -> Self { - use SysError::*; - match err { - IndexOutOfBound => Self::IndexOutOfBound, - ItemMissing => Self::ItemMissing, - LengthNotEnough(_) => Self::LengthNotEnough, - Encoding => Self::Encoding, - Unknown(err_code) => panic!("unexpected sys error {}", err_code), - } - } -} - diff --git a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/main.rs b/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/main.rs deleted file mode 100644 index 40314a3..0000000 --- a/examples/validate-signature-rsa/contracts/validate-signature-rsa/src/main.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! Generated by capsule -//! -//! `main.rs` is used to define rust lang items and modules. -//! See `entry.rs` for the `main` function. -//! See `error.rs` for the `Error` type. - -#![no_std] -#![no_main] -#![feature(lang_items)] -#![feature(alloc_error_handler)] -#![feature(panic_info_message)] - -// define modules -mod entry; -mod error; -mod code_hashes; - -use ckb_std::{ - default_alloc, -}; - -ckb_std::entry!(program_entry); -default_alloc!(); - -/// program entry -fn program_entry() -> i8 { - // Call main function and return error code - match entry::main() { - Ok(_) => 0, - Err(err) => err as i8, - } -} - diff --git a/examples/validate-signature-rsa/deployment.toml b/examples/validate-signature-rsa/deployment.toml deleted file mode 100644 index 62d23d4..0000000 --- a/examples/validate-signature-rsa/deployment.toml +++ /dev/null @@ -1,27 +0,0 @@ -# [[cells]] -# name = "my_cell" -# enable_type_id = false -# location = { file = "build/release/my_cell" } -# -# # reference to on-chain cells -# [[cells]] -# name = "genesis_cell" -# enable_type_id = false -# location = { tx_hash = "0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c", index = 0 } - - -# # Dep group cells -# [[dep_groups]] -# name = "my_dep_group" -# cells = [ -# "my_cell", -# "genesis_cell" -# ] - -# # Replace with your own lock if you want to unlock deployed cells. -# # For example the secp256k1 lock -# [lock] -# code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" -# args = "0x0000000000000000000000000000000000000000" -# hash_type = "type" - diff --git a/examples/validate-signature-rsa/dynamic-libray/.gitignore b/examples/validate-signature-rsa/dynamic-libray/.gitignore deleted file mode 100644 index 2bb4e2c..0000000 --- a/examples/validate-signature-rsa/dynamic-libray/.gitignore +++ /dev/null @@ -1 +0,0 @@ -validate_signature_rsa diff --git a/examples/validate-signature-rsa/migrations/.gitkeep b/examples/validate-signature-rsa/migrations/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/validate-signature-rsa/rust-toolchain b/examples/validate-signature-rsa/rust-toolchain deleted file mode 100644 index 35312fc..0000000 --- a/examples/validate-signature-rsa/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2020-09-28 diff --git a/examples/validate-signature-rsa/tests/Cargo.toml b/examples/validate-signature-rsa/tests/Cargo.toml deleted file mode 100644 index 8133493..0000000 --- a/examples/validate-signature-rsa/tests/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "tests" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ckb-tool = "0.2" -ckb-testtool = "0.2" -ckb-system-scripts = "0.5" -rand = "0.7.3" -openssl = "0.10.4" diff --git a/examples/validate-signature-rsa/tests/src/lib.rs b/examples/validate-signature-rsa/tests/src/lib.rs deleted file mode 100644 index 81397ea..0000000 --- a/examples/validate-signature-rsa/tests/src/lib.rs +++ /dev/null @@ -1,61 +0,0 @@ -use ckb_tool::ckb_types::bytes::Bytes; -use std::env; -use std::fs; -use std::path::PathBuf; -use std::str::FromStr; - -#[cfg(test)] -mod rsa_tests; - -const TEST_ENV_VAR: &str = "CAPSULE_TEST_ENV"; - -pub enum TestEnv { - Debug, - Release, -} - -impl FromStr for TestEnv { - type Err = &'static str; - - fn from_str(s: &str) -> Result { - match s.to_lowercase().as_str() { - "debug" => Ok(TestEnv::Debug), - "release" => Ok(TestEnv::Release), - _ => Err("no match"), - } - } -} - -pub struct Loader(PathBuf); - -impl Default for Loader { - fn default() -> Self { - let test_env = match env::var(TEST_ENV_VAR) { - Ok(val) => val.parse().expect("test env"), - Err(_) => TestEnv::Debug, - }; - Self::with_test_env(test_env) - } -} - -impl Loader { - fn with_test_env(env: TestEnv) -> Self { - let load_prefix = match env { - TestEnv::Debug => "debug", - TestEnv::Release => "release", - }; - let dir = env::current_dir().unwrap(); - let mut base_path = PathBuf::new(); - base_path.push(dir); - base_path.push(".."); - base_path.push("build"); - base_path.push(load_prefix); - Loader(base_path) - } - - pub fn load_binary(&self, name: &str) -> Bytes { - let mut path = self.0.clone(); - path.push(name); - fs::read(path).expect("binary").into() - } -} diff --git a/examples/validate-signature-rsa/tests/src/rsa_tests.rs b/examples/validate-signature-rsa/tests/src/rsa_tests.rs deleted file mode 100644 index 18a64c0..0000000 --- a/examples/validate-signature-rsa/tests/src/rsa_tests.rs +++ /dev/null @@ -1,196 +0,0 @@ -#![allow(unused_imports)] -#![allow(dead_code)] - -use super::*; -use ckb_testtool::context::Context; -use ckb_tool::ckb_hash::{new_blake2b, blake2b_256}; -use ckb_tool::ckb_types::{ - bytes::Bytes, - core::{TransactionBuilder, TransactionView}, - packed::{self, *}, - prelude::*, -}; -use openssl::hash::MessageDigest; -use openssl::pkey::{PKey, Private, Public}; -use openssl::rsa::Rsa; -use openssl::sign::{Signer, Verifier}; -use std::fs; - -const MAX_CYCLES: u64 = 40_000_000; - -fn blake160(data: &[u8]) -> [u8; 20] { - let mut buf = [0u8; 20]; - let hash = blake2b_256(data); - buf.clone_from_slice(&hash[..20]); - buf -} - -fn sign_tx( - tx: TransactionView, - private_key: &PKey, - public_key: &PKey, -) -> TransactionView { - // see "signature (in witness) memory layout" - let signature_size = (private_key.bits()/8*2+8) as usize; - - let witnesses_len = tx.witnesses().len(); - let tx_hash = tx.hash(); - - let mut signed_witnesses: Vec = Vec::new(); - let mut blake2b = new_blake2b(); - let mut message = [0u8; 32]; - // hash, step 1 - blake2b.update(&tx_hash.raw_data()); - // digest the first witness - let witness = WitnessArgs::default(); - // hash, step 2 - blake2b.update(&signature_size.to_le_bytes()); - (1..witnesses_len).for_each(|n| { - let witness = tx.witnesses().get(n).unwrap(); - let witness_len = witness.raw_data().len() as u64; - // hash, step 3 - blake2b.update(&witness_len.to_le_bytes()); - blake2b.update(&witness.raw_data()); - }); - blake2b.finalize(&mut message); - - // openssl - let mut signer = Signer::new(MessageDigest::sha256(), &private_key).unwrap(); - signer.update(&message).unwrap(); - let rsa_signature = signer.sign_to_vec().unwrap(); - - // see "signature (in witness) memory layout" - let (mut rsa_info, _) = calculate_pub_key_hash(public_key); - rsa_info.extend_from_slice(&rsa_signature); - rsa_info.insert(0, 0); - rsa_info.insert(0, 0); - rsa_info.insert(0, 0); - rsa_info.insert(0, 0); - // common header - rsa_info[0] = 1; // algorithm id - rsa_info[1] = 1; // key size, 1024 - rsa_info[2] = 0; // padding, PKCS# 1.5 - rsa_info[3] = 6; // hash type SHA256 - - // verify it locally - let mut verifier = Verifier::new(MessageDigest::sha256(), &public_key).unwrap(); - verifier.update(&message).unwrap(); - assert!(verifier.verify(&rsa_signature).unwrap()); - - signed_witnesses.push( - witness - .as_builder() - .lock(Some(Bytes::from(rsa_info)).pack()) - .build() - .as_bytes() - .pack(), - ); - for i in 1..witnesses_len { - signed_witnesses.push(tx.witnesses().get(i).unwrap()); - } - tx.as_advanced_builder() - .set_witnesses(signed_witnesses) - .build() -} - -fn calculate_pub_key_hash(public_key: &PKey) -> (Vec, Vec) { - let mut result: Vec = vec![]; - - let rsa_public_key = public_key.rsa().unwrap(); - - let mut e = rsa_public_key.e().to_vec(); - let mut n = rsa_public_key.n().to_vec(); - e.reverse(); - n.reverse(); - - while e.len() < 4 { - e.push(0); - } - while n.len() < 128 { - n.push(0); - } - - result.append(&mut e); - result.append(&mut n); - - let h = blake160(&result).into(); - (result, h) -} - -fn generate_random_key(bits: u32) -> (PKey, PKey) { - assert!(bits == 1024 || bits == 2048 || bits == 4096); - let rsa = Rsa::generate(bits).unwrap(); - let private_key = PKey::from_rsa(rsa).unwrap(); - - let public_key_pem: Vec = private_key.public_key_to_pem().unwrap(); - let public_key = PKey::public_key_from_pem(&public_key_pem).unwrap(); - (private_key, public_key) -} - -#[test] -fn test_rsa_random_1024() { - let (private_key, public_key) = generate_random_key(1024); - test_rsa(private_key, public_key); -} - -fn test_rsa(private_key: PKey , public_key: PKey ) { - // deploy contract - let mut context = Context::default(); - let contract_bin: Bytes = Loader::default().load_binary("validate-signature-rsa"); - let out_point = context.deploy_cell(contract_bin); - - let rsa_bin: Bytes = fs::read("../dynamic-libray/validate_signature_rsa") - .expect("load ../dynamic-libray/validate_signature_rsa") - .into(); - let rsa_out_point = context.deploy_cell(rsa_bin); - let rsa_dep = CellDep::new_builder().out_point(rsa_out_point).build(); - - let (_public_key_binary, public_key_hash) = calculate_pub_key_hash(&public_key); - // prepare scripts - let lock_script = context - .build_script(&out_point, public_key_hash.into()) - .expect("script"); - let lock_script_dep = CellDep::new_builder().out_point(out_point).build(); - - // prepare cells - let input_out_point = context.create_cell( - CellOutput::new_builder() - .capacity(1000u64.pack()) - .lock(lock_script.clone()) - .build(), - Bytes::new(), - ); - let input = CellInput::new_builder() - .previous_output(input_out_point) - .build(); - let outputs = vec![ - CellOutput::new_builder() - .capacity(500u64.pack()) - .lock(lock_script.clone()) - .build(), - CellOutput::new_builder() - .capacity(500u64.pack()) - .lock(lock_script) - .build(), - ]; - - let outputs_data = vec![Bytes::new(); 2]; - - // build transaction - let tx = TransactionBuilder::default() - .input(input) - .outputs(outputs) - .outputs_data(outputs_data.pack()) - .cell_dep(lock_script_dep) - .cell_dep(rsa_dep) - .build(); - let tx = context.complete_tx(tx); - - // sign - let tx = sign_tx(tx, &private_key, &public_key); - - // run - let cycles = context - .verify_tx(&tx, MAX_CYCLES).expect("pass verification"); - println!("consume cycles: {}", cycles); -} diff --git a/examples/validate-signature-rsa/tests/src/tests.rs b/examples/validate-signature-rsa/tests/src/tests.rs deleted file mode 100644 index fba511b..0000000 --- a/examples/validate-signature-rsa/tests/src/tests.rs +++ /dev/null @@ -1,130 +0,0 @@ -use super::*; -use ckb_testtool::context::Context; -use ckb_tool::ckb_types::{ - bytes::Bytes, - core::TransactionBuilder, - packed::*, - prelude::*, -}; -use ckb_tool::ckb_error::assert_error_eq; -use ckb_tool::ckb_script::ScriptError; - -const MAX_CYCLES: u64 = 10_000_000; - -// error numbers -const ERROR_EMPTY_ARGS: i8 = 5; - -#[test] -fn test_success() { - // deploy contract - let mut context = Context::default(); - let contract_bin: Bytes = Loader::default().load_binary("validate-signature-rsa"); - let out_point = context.deploy_cell(contract_bin); - - // prepare scripts - let lock_script = context - .build_script(&out_point, Bytes::from(vec![42])) - .expect("script"); - let lock_script_dep = CellDep::new_builder() - .out_point(out_point) - .build(); - - // prepare cells - let input_out_point = context.create_cell( - CellOutput::new_builder() - .capacity(1000u64.pack()) - .lock(lock_script.clone()) - .build(), - Bytes::new(), - ); - let input = CellInput::new_builder() - .previous_output(input_out_point) - .build(); - let outputs = vec![ - CellOutput::new_builder() - .capacity(500u64.pack()) - .lock(lock_script.clone()) - .build(), - CellOutput::new_builder() - .capacity(500u64.pack()) - .lock(lock_script) - .build(), - ]; - - let outputs_data = vec![Bytes::new(); 2]; - - // build transaction - let tx = TransactionBuilder::default() - .input(input) - .outputs(outputs) - .outputs_data(outputs_data.pack()) - .cell_dep(lock_script_dep) - .build(); - let tx = context.complete_tx(tx); - - // run - let cycles = context - .verify_tx(&tx, MAX_CYCLES) - .expect("pass verification"); - println!("consume cycles: {}", cycles); -} - -#[test] -fn test_empty_args() { - // deploy contract - let mut context = Context::default(); - let contract_bin: Bytes = Loader::default().load_binary("validate-signature-rsa"); - let out_point = context.deploy_cell(contract_bin); - - // prepare scripts - let lock_script = context - .build_script(&out_point, Default::default()) - .expect("script"); - let lock_script_dep = CellDep::new_builder() - .out_point(out_point) - .build(); - - // prepare cells - let input_out_point = context.create_cell( - CellOutput::new_builder() - .capacity(1000u64.pack()) - .lock(lock_script.clone()) - .build(), - Bytes::new(), - ); - let input = CellInput::new_builder() - .previous_output(input_out_point) - .build(); - let outputs = vec![ - CellOutput::new_builder() - .capacity(500u64.pack()) - .lock(lock_script.clone()) - .build(), - CellOutput::new_builder() - .capacity(500u64.pack()) - .lock(lock_script) - .build(), - ]; - - let outputs_data = vec![Bytes::new(); 2]; - - // build transaction - let tx = TransactionBuilder::default() - .input(input) - .outputs(outputs) - .outputs_data(outputs_data.pack()) - .cell_dep(lock_script_dep) - .build(); - let tx = context.complete_tx(tx); - - // run - let err = context - .verify_tx(&tx, MAX_CYCLES) - .unwrap_err(); - // we expect an error raised from 0-indexed cell's lock script - let script_cell_index = 0; - assert_error_eq!( - err, - ScriptError::ValidationFailure(ERROR_EMPTY_ARGS).input_lock_script(script_cell_index) - ); -} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index d5b0154..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! pub use const BUNDLED_CELL: Files -//! pub use const CODE_HASH_DAO: [u8; 32] -//! pub use const CODE_HASH_SECP256K1_BLAKE160_SIGHASH_ALL: [u8; 32] -//! pub use const CODE_HASH_SECP256K1_RIPEMD160_SHA256_SIGHASH_ALL: [u8; 32] - -#![allow(clippy::unreadable_literal)] - -include!(concat!(env!("OUT_DIR"), "/bundled.rs")); -include!(concat!(env!("OUT_DIR"), "/code_hashes.rs")); - -#[cfg(test)] -mod tests; diff --git a/src/tests/anyone_can_pay.rs b/src/tests/anyone_can_pay.rs deleted file mode 100644 index 060c7a6..0000000 --- a/src/tests/anyone_can_pay.rs +++ /dev/null @@ -1,534 +0,0 @@ -use super::{ - blake160, build_resolved_tx, gen_tx, gen_tx_with_grouped_args, DummyDataLoader, ALWAYS_SUCCESS, - ANYONE_CAN_PAY, ERROR_DUPLICATED_INPUTS, ERROR_DUPLICATED_OUTPUTS, ERROR_ENCODING, - ERROR_NO_PAIR, ERROR_OUTPUT_AMOUNT_NOT_ENOUGH, MAX_CYCLES, -}; -use ckb_crypto::secp::Generator; -use ckb_error::assert_error_eq; -use ckb_script::{ScriptError, TransactionScriptsVerifier}; -use ckb_types::{ - bytes::Bytes, - core::ScriptHashType, - packed::{CellOutput, Script}, - prelude::*, -}; -use rand::thread_rng; - -fn build_anyone_can_pay_script(args: Bytes) -> Script { - let sighash_all_cell_data_hash = CellOutput::calc_data_hash(&ANYONE_CAN_PAY); - Script::new_builder() - .args(args.pack()) - .code_hash(sighash_all_cell_data_hash.clone()) - .hash_type(ScriptHashType::Data.into()) - .build() -} - -fn build_udt_script() -> Script { - let data_hash = CellOutput::calc_data_hash(&ALWAYS_SUCCESS); - Script::new_builder() - .code_hash(data_hash.clone()) - .hash_type(ScriptHashType::Data.into()) - .build() -} - -#[test] -fn test_unlock_by_anyone() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.expect("pass"); -} - -#[test] -fn test_put_output_data() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .build()]) - .set_outputs_data(vec![Bytes::from(vec![42u8]).pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_ENCODING), - ); -} - -#[test] -fn test_wrong_output_args() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash.to_owned()); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock({ - let mut args = pubkey_hash.to_vec(); - // a valid args - args.push(0); - script.as_builder().args(Bytes::from(args).pack()).build() - }) - .capacity(44u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_NO_PAIR), - ); -} - -#[test] -fn test_split_cell() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash.to_owned()); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![ - output - .clone() - .as_builder() - .lock(script.clone()) - .capacity(44u64.pack()) - .build(), - output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .build(), - ]) - .set_outputs_data(vec![ - Bytes::from(Vec::new()).pack(), - Bytes::from(Vec::new()).pack(), - ]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_DUPLICATED_OUTPUTS), - ); -} - -#[test] -fn test_merge_cell() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let mut rng = thread_rng(); - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(pubkey_hash, 2)], &mut rng); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .clone() - .as_builder() - .lock(script.clone()) - .capacity(88u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_DUPLICATED_INPUTS), - ); -} - -#[test] -fn test_insufficient_pay() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .clone() - .as_builder() - .lock(script.clone()) - .capacity(41u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_OUTPUT_AMOUNT_NOT_ENOUGH), - ); -} - -#[test] -fn test_payment_not_meet_requirement() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let mut args = pubkey_hash.to_vec(); - args.push(1); - let args = Bytes::from(args); - let script = build_anyone_can_pay_script(args.clone()); - let tx = gen_tx(&mut data_loader, args); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .clone() - .as_builder() - .lock(script.clone()) - .capacity(44u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_OUTPUT_AMOUNT_NOT_ENOUGH), - ); -} - -#[test] -fn test_no_pair() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let another_script = build_anyone_can_pay_script(vec![42].into()); - let tx = gen_tx(&mut data_loader, pubkey_hash.to_owned()); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .clone() - .as_builder() - .lock(another_script.clone()) - .capacity(44u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_NO_PAIR), - ); -} - -#[test] -fn test_overflow() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let mut args = pubkey_hash.to_vec(); - args.push(255); - let args = Bytes::from(args); - - let script = build_anyone_can_pay_script(args.to_owned()); - let tx = gen_tx(&mut data_loader, args); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .build()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_OUTPUT_AMOUNT_NOT_ENOUGH), - ); -} - -#[test] -fn test_only_pay_ckb() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let mut args = pubkey_hash.to_vec(); - args.push(0); - // do not accept UDT transfer - args.push(255); - let args = Bytes::from(args); - - let script = build_anyone_can_pay_script(args.to_owned()); - let tx = gen_tx(&mut data_loader, args); - let input = tx.inputs().get(0).unwrap(); - let (prev_output, _) = data_loader.cells.remove(&input.previous_output()).unwrap(); - let prev_output = prev_output - .as_builder() - .type_(Some(build_udt_script()).pack()) - .build(); - let prev_data = 44u128.to_le_bytes().to_vec().into(); - data_loader - .cells - .insert(input.previous_output(), (prev_output, prev_data)); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .type_(Some(build_udt_script()).pack()) - .build()]) - .set_outputs_data(vec![Bytes::from(44u128.to_le_bytes().to_vec()).pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.unwrap(); -} - -#[test] -fn test_only_pay_udt() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let mut args = { - let pubkey_hash = blake160(&pubkey.serialize()); - pubkey_hash.to_vec() - }; - args.push(255); - let args = Bytes::from(args); - - let script = build_anyone_can_pay_script(args.to_owned()); - let tx = gen_tx(&mut data_loader, args); - let input = tx.inputs().get(0).unwrap(); - let (prev_output, _) = data_loader.cells.remove(&input.previous_output()).unwrap(); - let input_capacity = prev_output.capacity(); - let prev_output = prev_output - .as_builder() - .type_(Some(build_udt_script()).pack()) - .build(); - let prev_data = 44u128.to_le_bytes().to_vec().into(); - data_loader - .cells - .insert(input.previous_output(), (prev_output, prev_data)); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(input_capacity) - .type_(Some(build_udt_script()).pack()) - .build()]) - .set_outputs_data(vec![Bytes::from(44u128.to_le_bytes().to_vec()).pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.expect("pass"); -} - -#[test] -fn test_udt_unlock_by_anyone() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let input = tx.inputs().get(0).unwrap(); - let (prev_output, _) = data_loader.cells.remove(&input.previous_output()).unwrap(); - let prev_output = prev_output - .as_builder() - .type_(Some(build_udt_script()).pack()) - .build(); - let prev_data = 44u128.to_le_bytes().to_vec().into(); - data_loader - .cells - .insert(input.previous_output(), (prev_output, prev_data)); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .type_(Some(build_udt_script()).pack()) - .build()]) - .set_outputs_data(vec![Bytes::from(44u128.to_le_bytes().to_vec()).pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.expect("pass"); -} - -#[test] -fn test_udt_overflow() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let mut args = pubkey_hash.to_vec(); - args.push(1); - args.push(255); - let args = Bytes::from(args); - - let script = build_anyone_can_pay_script(args.to_owned()); - let tx = gen_tx(&mut data_loader, args); - let input = tx.inputs().get(0).unwrap(); - let (prev_output, _) = data_loader.cells.remove(&input.previous_output()).unwrap(); - let prev_output = prev_output - .as_builder() - .type_(Some(build_udt_script()).pack()) - .build(); - let prev_data = 44u128.to_le_bytes().to_vec().into(); - data_loader - .cells - .insert(input.previous_output(), (prev_output, prev_data)); - let output = tx.outputs().get(0).unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .type_(Some(build_udt_script()).pack()) - .build()]) - .set_outputs_data(vec![Bytes::from(44u128.to_le_bytes().to_vec()).pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_OUTPUT_AMOUNT_NOT_ENOUGH), - ); -} - -#[test] -fn test_extended_udt() { - // we assume the first 16 bytes data represent token amount - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let script = build_anyone_can_pay_script(pubkey_hash.to_owned()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let input = tx.inputs().get(0).unwrap(); - let (prev_output, _) = data_loader.cells.remove(&input.previous_output()).unwrap(); - let prev_output = prev_output - .as_builder() - .type_(Some(build_udt_script()).pack()) - .build(); - let mut prev_data = 44u128.to_le_bytes().to_vec(); - // push junk data - prev_data.push(42); - data_loader - .cells - .insert(input.previous_output(), (prev_output, prev_data.into())); - let output = tx.outputs().get(0).unwrap(); - let mut output_udt = 44u128.to_le_bytes().to_vec(); - // push junk data - output_udt.push(42); - let tx = tx - .as_advanced_builder() - .set_witnesses(Vec::new()) - .set_outputs(vec![output - .as_builder() - .lock(script) - .capacity(44u64.pack()) - .type_(Some(build_udt_script()).pack()) - .build()]) - .set_outputs_data(vec![Bytes::from(output_udt).pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.expect("pass"); -} diff --git a/src/tests/mod.rs b/src/tests/mod.rs deleted file mode 100644 index 5839073..0000000 --- a/src/tests/mod.rs +++ /dev/null @@ -1,334 +0,0 @@ -mod anyone_can_pay; -mod secp256k1_compatibility; - -use ckb_crypto::secp::Privkey; -use ckb_script::DataLoader; -use ckb_types::{ - bytes::Bytes, - core::{ - cell::{CellMeta, CellMetaBuilder, ResolvedTransaction}, - BlockExt, Capacity, DepType, EpochExt, HeaderView, ScriptHashType, TransactionBuilder, - TransactionView, - }, - packed::{ - self, Byte32, CellDep, CellInput, CellOutput, OutPoint, Script, WitnessArgs, - WitnessArgsBuilder, - }, - prelude::*, - H256, -}; -use lazy_static::lazy_static; -use rand::{thread_rng, Rng}; -use std::collections::HashMap; - -pub const MAX_CYCLES: u64 = std::u64::MAX; -pub const SIGNATURE_SIZE: usize = 65; - -// errors -pub const ERROR_ENCODING: i8 = -2; -pub const ERROR_PUBKEY_BLAKE160_HASH: i8 = -31; -pub const ERROR_OUTPUT_AMOUNT_NOT_ENOUGH: i8 = -42; -pub const ERROR_NO_PAIR: i8 = -44; -pub const ERROR_DUPLICATED_INPUTS: i8 = -45; -pub const ERROR_DUPLICATED_OUTPUTS: i8 = -46; - -lazy_static! { - pub static ref ANYONE_CAN_PAY: Bytes = - Bytes::from(&include_bytes!("../../build/anyone_can_pay")[..]); - pub static ref SECP256K1_DATA_BIN: Bytes = - Bytes::from(&include_bytes!("../../build/secp256k1_data")[..]); - pub static ref ALWAYS_SUCCESS: Bytes = - Bytes::from(&include_bytes!("../../build/always_success")[..]); -} - -#[derive(Default)] -pub struct DummyDataLoader { - pub cells: HashMap, - pub headers: HashMap, - pub epoches: HashMap, -} - -impl DummyDataLoader { - fn new() -> Self { - Self::default() - } -} - -impl DataLoader for DummyDataLoader { - // load Cell Data - fn load_cell_data(&self, cell: &CellMeta) -> Option<(Bytes, Byte32)> { - cell.mem_cell_data.clone().or_else(|| { - self.cells - .get(&cell.out_point) - .map(|(_, data)| (data.clone(), CellOutput::calc_data_hash(&data))) - }) - } - // load BlockExt - fn get_block_ext(&self, _hash: &Byte32) -> Option { - unreachable!() - } - - // load header - fn get_header(&self, block_hash: &Byte32) -> Option { - self.headers.get(block_hash).cloned() - } - - // load EpochExt - fn get_block_epoch(&self, block_hash: &Byte32) -> Option { - self.epoches.get(block_hash).cloned() - } -} - -pub fn blake160(message: &[u8]) -> Bytes { - Bytes::from(&ckb_hash::blake2b_256(message)[..20]) -} - -pub fn sign_tx(tx: TransactionView, key: &Privkey) -> TransactionView { - let witnesses_len = tx.witnesses().len(); - sign_tx_by_input_group(tx, key, 0, witnesses_len) -} - -pub fn sign_tx_by_input_group( - tx: TransactionView, - key: &Privkey, - begin_index: usize, - len: usize, -) -> TransactionView { - let tx_hash = tx.hash(); - let mut signed_witnesses: Vec = tx - .inputs() - .into_iter() - .enumerate() - .map(|(i, _)| { - if i == begin_index { - let mut blake2b = ckb_hash::new_blake2b(); - let mut message = [0u8; 32]; - blake2b.update(&tx_hash.raw_data()); - // digest the first witness - let witness = WitnessArgs::new_unchecked(tx.witnesses().get(i).unwrap().unpack()); - let zero_lock: Bytes = { - let mut buf = Vec::new(); - buf.resize(SIGNATURE_SIZE, 0); - buf.into() - }; - let witness_for_digest = - witness.clone().as_builder().lock(zero_lock.pack()).build(); - let witness_len = witness_for_digest.as_bytes().len() as u64; - blake2b.update(&witness_len.to_le_bytes()); - blake2b.update(&witness_for_digest.as_bytes()); - ((i + 1)..(i + len)).for_each(|n| { - let witness = tx.witnesses().get(n).unwrap(); - let witness_len = witness.raw_data().len() as u64; - blake2b.update(&witness_len.to_le_bytes()); - blake2b.update(&witness.raw_data()); - }); - blake2b.finalize(&mut message); - let message = H256::from(message); - let sig = key.sign_recoverable(&message).expect("sign"); - witness - .as_builder() - .lock(sig.serialize().pack()) - .build() - .as_bytes() - .pack() - } else { - tx.witnesses().get(i).unwrap_or_default() - } - }) - .collect(); - for i in signed_witnesses.len()..tx.witnesses().len() { - signed_witnesses.push(tx.witnesses().get(i).unwrap()); - } - // calculate message - tx.as_advanced_builder() - .set_witnesses(signed_witnesses) - .build() -} - -pub fn gen_tx(dummy: &mut DummyDataLoader, lock_args: Bytes) -> TransactionView { - let mut rng = thread_rng(); - gen_tx_with_grouped_args(dummy, vec![(lock_args, 1)], &mut rng) -} - -pub fn gen_tx_with_grouped_args( - dummy: &mut DummyDataLoader, - grouped_args: Vec<(Bytes, usize)>, - rng: &mut R, -) -> TransactionView { - // setup sighash_all dep - let sighash_all_out_point = { - let contract_tx_hash = { - let mut buf = [0u8; 32]; - rng.fill(&mut buf); - buf.pack() - }; - OutPoint::new(contract_tx_hash.clone(), 0) - }; - // dep contract code - let sighash_all_cell = CellOutput::new_builder() - .capacity( - Capacity::bytes(ANYONE_CAN_PAY.len()) - .expect("script capacity") - .pack(), - ) - .build(); - let sighash_all_cell_data_hash = CellOutput::calc_data_hash(&ANYONE_CAN_PAY); - dummy.cells.insert( - sighash_all_out_point.clone(), - (sighash_all_cell, ANYONE_CAN_PAY.clone()), - ); - // always success - let always_success_out_point = { - let contract_tx_hash = { - let mut buf = [0u8; 32]; - rng.fill(&mut buf); - buf.pack() - }; - OutPoint::new(contract_tx_hash.clone(), 0) - }; - let always_success_cell = CellOutput::new_builder() - .capacity( - Capacity::bytes(ALWAYS_SUCCESS.len()) - .expect("script capacity") - .pack(), - ) - .build(); - dummy.cells.insert( - always_success_out_point.clone(), - (always_success_cell, ALWAYS_SUCCESS.clone()), - ); - // setup secp256k1_data dep - let secp256k1_data_out_point = { - let tx_hash = { - let mut buf = [0u8; 32]; - rng.fill(&mut buf); - buf.pack() - }; - OutPoint::new(tx_hash, 0) - }; - let secp256k1_data_cell = CellOutput::new_builder() - .capacity( - Capacity::bytes(SECP256K1_DATA_BIN.len()) - .expect("data capacity") - .pack(), - ) - .build(); - dummy.cells.insert( - secp256k1_data_out_point.clone(), - (secp256k1_data_cell, SECP256K1_DATA_BIN.clone()), - ); - // setup default tx builder - let dummy_capacity = Capacity::shannons(42); - let mut tx_builder = TransactionBuilder::default() - .cell_dep( - CellDep::new_builder() - .out_point(sighash_all_out_point) - .dep_type(DepType::Code.into()) - .build(), - ) - .cell_dep( - CellDep::new_builder() - .out_point(always_success_out_point) - .dep_type(DepType::Code.into()) - .build(), - ) - .cell_dep( - CellDep::new_builder() - .out_point(secp256k1_data_out_point) - .dep_type(DepType::Code.into()) - .build(), - ) - .output( - CellOutput::new_builder() - .capacity(dummy_capacity.pack()) - .build(), - ) - .output_data(Bytes::new().pack()); - - for (args, inputs_size) in grouped_args { - // setup dummy input unlock script - for _ in 0..inputs_size { - let previous_tx_hash = { - let mut buf = [0u8; 32]; - rng.fill(&mut buf); - buf.pack() - }; - let previous_out_point = OutPoint::new(previous_tx_hash, 0); - let script = Script::new_builder() - .args(args.pack()) - .code_hash(sighash_all_cell_data_hash.clone()) - .hash_type(ScriptHashType::Data.into()) - .build(); - let previous_output_cell = CellOutput::new_builder() - .capacity(dummy_capacity.pack()) - .lock(script) - .build(); - dummy.cells.insert( - previous_out_point.clone(), - (previous_output_cell.clone(), Bytes::new()), - ); - let mut random_extra_witness = [0u8; 32]; - rng.fill(&mut random_extra_witness); - let witness_args = WitnessArgsBuilder::default() - .extra(Bytes::from(random_extra_witness.to_vec()).pack()) - .build(); - tx_builder = tx_builder - .input(CellInput::new(previous_out_point, 0)) - .witness(witness_args.as_bytes().pack()); - } - } - - tx_builder.build() -} - -pub fn sign_tx_hash(tx: TransactionView, key: &Privkey, tx_hash: &[u8]) -> TransactionView { - // calculate message - let mut blake2b = ckb_hash::new_blake2b(); - let mut message = [0u8; 32]; - blake2b.update(tx_hash); - blake2b.finalize(&mut message); - let message = H256::from(message); - let sig = key.sign_recoverable(&message).expect("sign"); - let witness_args = WitnessArgsBuilder::default() - .lock(Bytes::from(sig.serialize()).pack()) - .build(); - tx.as_advanced_builder() - .set_witnesses(vec![witness_args.as_bytes().pack()]) - .build() -} - -pub fn build_resolved_tx( - data_loader: &DummyDataLoader, - tx: &TransactionView, -) -> ResolvedTransaction { - let resolved_cell_deps = tx - .cell_deps() - .into_iter() - .map(|dep| { - let deps_out_point = dep.clone(); - let (dep_output, dep_data) = - data_loader.cells.get(&deps_out_point.out_point()).unwrap(); - CellMetaBuilder::from_cell_output(dep_output.to_owned(), dep_data.to_owned()) - .out_point(deps_out_point.out_point().clone()) - .build() - }) - .collect(); - - let mut resolved_inputs = Vec::new(); - for i in 0..tx.inputs().len() { - let previous_out_point = tx.inputs().get(i).unwrap().previous_output(); - let (input_output, input_data) = data_loader.cells.get(&previous_out_point).unwrap(); - resolved_inputs.push( - CellMetaBuilder::from_cell_output(input_output.to_owned(), input_data.to_owned()) - .out_point(previous_out_point) - .build(), - ); - } - - ResolvedTransaction { - transaction: tx.clone(), - resolved_cell_deps, - resolved_inputs, - resolved_dep_groups: vec![], - } -} diff --git a/src/tests/secp256k1_compatibility.rs b/src/tests/secp256k1_compatibility.rs deleted file mode 100644 index 1227351..0000000 --- a/src/tests/secp256k1_compatibility.rs +++ /dev/null @@ -1,439 +0,0 @@ -use super::{ - blake160, build_resolved_tx, gen_tx, gen_tx_with_grouped_args, sign_tx, sign_tx_by_input_group, - sign_tx_hash, DummyDataLoader, ERROR_NO_PAIR, ERROR_PUBKEY_BLAKE160_HASH, MAX_CYCLES, -}; -use ckb_crypto::secp::Generator; -use ckb_error::assert_error_eq; -use ckb_script::{ScriptError, TransactionScriptsVerifier}; -use ckb_types::{bytes::Bytes, packed::WitnessArgs, prelude::*, H256}; -use rand::{thread_rng, Rng, SeedableRng}; - -#[test] -fn test_sighash_all_unlock() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let tx = sign_tx(tx, &privkey); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - verify_result.expect("pass verification"); -} - -#[test] -fn test_sighash_all_unlock_with_args() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let lock_args = { - let mut args = blake160(&pubkey.serialize()).to_vec(); - args.push(42); - args.push(255); - Bytes::from(args) - }; - let mut rng = thread_rng(); - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(lock_args, 1)], &mut rng); - let tx = sign_tx(tx, &privkey); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - verify_result.expect("pass verification"); -} - -#[test] -fn test_sighash_all_with_extra_witness_unlock() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let extract_witness = vec![1, 2, 3, 4]; - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![WitnessArgs::new_builder() - .extra(Bytes::from(extract_witness).pack()) - .build() - .as_bytes() - .pack()]) - .build(); - { - let tx = sign_tx(tx.clone(), &privkey); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - verify_result.expect("pass verification"); - } - { - let tx = sign_tx(tx, &privkey); - let wrong_witness = tx - .witnesses() - .get(0) - .map(|w| { - WitnessArgs::new_unchecked(w.unpack()) - .as_builder() - .extra(Bytes::from(vec![0]).pack()) - .build() - }) - .unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![wrong_witness.as_bytes().pack()]) - .build(); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); - } -} - -#[test] -fn test_sighash_all_with_grouped_inputs_unlock() { - let mut rng = thread_rng(); - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(pubkey_hash, 2)], &mut rng); - { - let tx = sign_tx(tx.clone(), &privkey); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - verify_result.expect("pass verification"); - } - { - let tx = sign_tx(tx.clone(), &privkey); - let wrong_witness = tx - .witnesses() - .get(1) - .map(|w| { - WitnessArgs::new_unchecked(w.unpack()) - .as_builder() - .extra(Bytes::from(vec![0]).pack()) - .build() - }) - .unwrap(); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![ - tx.witnesses().get(0).unwrap(), - wrong_witness.as_bytes().pack(), - ]) - .build(); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); - } -} - -#[test] -fn test_sighash_all_with_2_different_inputs_unlock() { - let mut rng = thread_rng(); - let mut data_loader = DummyDataLoader::new(); - // key1 - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - // key2 - let privkey2 = Generator::random_privkey(); - let pubkey2 = privkey2.pubkey().expect("pubkey"); - let pubkey_hash2 = blake160(&pubkey2.serialize()); - - // sign with 2 keys - let tx = gen_tx_with_grouped_args( - &mut data_loader, - vec![(pubkey_hash, 2), (pubkey_hash2, 2)], - &mut rng, - ); - let tx = sign_tx_by_input_group(tx, &privkey, 0, 2); - let tx = sign_tx_by_input_group(tx, &privkey2, 2, 2); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - verify_result.expect("pass verification"); -} - -#[test] -fn test_signing_with_wrong_key() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let wrong_privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let tx = sign_tx(tx, &wrong_privkey); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); -} - -#[test] -fn test_signing_wrong_tx_hash() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let tx = { - let mut rand_tx_hash = [0u8; 32]; - let mut rng = thread_rng(); - rng.fill(&mut rand_tx_hash); - sign_tx_hash(tx, &privkey, &rand_tx_hash[..]) - }; - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); -} - -#[test] -fn test_super_long_witness() { - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - let tx = gen_tx(&mut data_loader, pubkey_hash); - let tx_hash = tx.hash(); - - let mut buffer: Vec = vec![]; - buffer.resize(40000, 1); - let super_long_message = Bytes::from(&buffer[..]); - - let mut blake2b = ckb_hash::new_blake2b(); - let mut message = [0u8; 32]; - blake2b.update(&tx_hash.raw_data()); - blake2b.update(&super_long_message[..]); - blake2b.finalize(&mut message); - let message = H256::from(message); - let sig = privkey.sign_recoverable(&message).expect("sign"); - let witness = WitnessArgs::new_builder() - .lock(Bytes::from(sig.serialize()).pack()) - .extra(super_long_message.pack()) - .build(); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![witness.as_bytes().pack()]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_NO_PAIR), - ); -} - -#[test] -fn test_sighash_all_2_in_2_out_cycles() { - const CONSUME_CYCLES: u64 = 3377980; - - let mut data_loader = DummyDataLoader::new(); - let mut generator = Generator::non_crypto_safe_prng(42); - let mut rng = rand::rngs::SmallRng::seed_from_u64(42); - - // key1 - let privkey = generator.gen_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - // key2 - let privkey2 = generator.gen_privkey(); - let pubkey2 = privkey2.pubkey().expect("pubkey"); - let pubkey_hash2 = blake160(&pubkey2.serialize()); - - // sign with 2 keys - let tx = gen_tx_with_grouped_args( - &mut data_loader, - vec![(pubkey_hash, 1), (pubkey_hash2, 1)], - &mut rng, - ); - let tx = sign_tx_by_input_group(tx, &privkey, 0, 1); - let tx = sign_tx_by_input_group(tx, &privkey2, 1, 1); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - let cycles = verify_result.expect("pass verification"); - assert_eq!(CONSUME_CYCLES, cycles) -} - -#[test] -fn test_sighash_all_witness_append_junk_data() { - let mut rng = thread_rng(); - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - // sign with 2 keys - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(pubkey_hash, 2)], &mut rng); - let tx = sign_tx_by_input_group(tx, &privkey, 0, 2); - let mut witnesses: Vec<_> = Unpack::>::unpack(&tx.witnesses()); - // append junk data to first witness - let mut witness = Vec::new(); - witness.resize(witnesses[0].len(), 0); - witness.copy_from_slice(&witnesses[0]); - witness.push(0); - witnesses[0] = witness.into(); - - let tx = tx - .as_advanced_builder() - .set_witnesses(witnesses.into_iter().map(|w| w.pack()).collect()) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_NO_PAIR), - ); -} - -#[test] -fn test_sighash_all_witness_args_ambiguity() { - // This test case build tx with WitnessArgs(lock, data, "") - // and try unlock with WitnessArgs(lock, "", data) - // - // this case will fail if contract use a naive function to digest witness. - - let mut rng = thread_rng(); - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(pubkey_hash, 2)], &mut rng); - let tx = sign_tx_by_input_group(tx, &privkey, 0, 2); - let witnesses: Vec<_> = Unpack::>::unpack(&tx.witnesses()); - // move extra data to type_ - let witnesses: Vec<_> = witnesses - .into_iter() - .map(|witness| { - let witness = WitnessArgs::new_unchecked(witness); - let data = witness.extra().clone(); - witness - .as_builder() - .extra(Bytes::new().pack()) - .type_(data) - .build() - }) - .collect(); - - let tx = tx - .as_advanced_builder() - .set_witnesses(witnesses.into_iter().map(|w| w.as_bytes().pack()).collect()) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); -} - -#[test] -fn test_sighash_all_witnesses_ambiguity() { - // This test case sign tx with [witness1, "", witness2] - // and try unlock with [witness1, witness2, ""] - // - // this case will fail if contract use a naive function to digest witness. - - let mut rng = thread_rng(); - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(pubkey_hash, 3)], &mut rng); - let witness = Unpack::>::unpack(&tx.witnesses()).remove(0); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![ - witness.pack(), - Bytes::new().pack(), - Bytes::from(vec![42]).pack(), - ]) - .build(); - let tx = sign_tx_by_input_group(tx, &privkey, 0, 3); - - // exchange witness position - let witness = Unpack::>::unpack(&tx.witnesses()).remove(0); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![ - witness.pack(), - Bytes::from(vec![42]).pack(), - Bytes::new().pack(), - ]) - .build(); - - assert_eq!(tx.witnesses().len(), tx.inputs().len()); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(MAX_CYCLES); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); -} - -#[test] -fn test_sighash_all_cover_extra_witnesses() { - let mut rng = thread_rng(); - let mut data_loader = DummyDataLoader::new(); - let privkey = Generator::random_privkey(); - let pubkey = privkey.pubkey().expect("pubkey"); - let pubkey_hash = blake160(&pubkey.serialize()); - - let tx = gen_tx_with_grouped_args(&mut data_loader, vec![(pubkey_hash, 2)], &mut rng); - let witness = Unpack::>::unpack(&tx.witnesses()).remove(0); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![ - witness.pack(), - Bytes::from(vec![42]).pack(), - Bytes::new().pack(), - ]) - .build(); - let tx = sign_tx_by_input_group(tx, &privkey, 0, 3); - assert!(tx.witnesses().len() > tx.inputs().len()); - - // change last witness - let mut witnesses = Unpack::>::unpack(&tx.witnesses()); - let tx = tx - .as_advanced_builder() - .set_witnesses(vec![ - witnesses.remove(0).pack(), - witnesses.remove(1).pack(), - Bytes::from(vec![0]).pack(), - ]) - .build(); - - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let verify_result = - TransactionScriptsVerifier::new(&resolved_tx, &data_loader).verify(60000000); - assert_error_eq!( - verify_result.unwrap_err(), - ScriptError::ValidationFailure(ERROR_PUBKEY_BLAKE160_HASH), - ); -} diff --git a/tests/omni_lock/CMakeLists.txt b/tests/omni_lock/CMakeLists.txt index 1ed8f16..12b1630 100644 --- a/tests/omni_lock/CMakeLists.txt +++ b/tests/omni_lock/CMakeLists.txt @@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 3.12) project(omni_lock_simulator C) set(CMAKE_C_STANDARD 11) + # uncomment it for sanitize -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined") +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined") # uncomment it for coverage test #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") @@ -14,14 +15,15 @@ set(CMAKE_C_STANDARD 11) add_definitions(-D__SHARED_LIBRARY__) add_definitions(-DCKB_DECLARATION_ONLY) add_definitions(-DCKB_USE_SIM) +add_definitions(-DSECP256K1_BUILD) include_directories(../../tests/omni_lock) include_directories(../../deps/ckb-c-stdlib-20210801) include_directories(../../deps/sparse-merkle-tree/c) # include_directories(deps/ckb-c-stdlib/libc) # on simulator, we don't use own "libc" -include_directories(../../deps/secp256k1/src) -include_directories(../../deps/secp256k1) +include_directories(../../deps/secp256k1-20210801/src) +include_directories(../../deps/secp256k1-20210801) include_directories(../../deps/ckb-c-stdlib-20210801/molecule) include_directories(../../c) include_directories(../../build) diff --git a/tests/omni_lock/ckb_syscall_omni_lock_sim.h b/tests/omni_lock/ckb_syscall_omni_lock_sim.h index a393668..ff9b8a4 100644 --- a/tests/omni_lock/ckb_syscall_omni_lock_sim.h +++ b/tests/omni_lock/ckb_syscall_omni_lock_sim.h @@ -664,7 +664,7 @@ int ckb_load_cell_data(void* addr, uint64_t* len, size_t offset, size_t index, size_t source) { if (source == CKB_SOURCE_CELL_DEP && index == SPECIAL_SECP256K1_INDEX) { ASSERT(*len == 1048576); - FILE* input = fopen("build/secp256k1_data", "rb"); + FILE* input = fopen("build/secp256k1_data_20210801", "rb"); size_t read_item = fread(addr, *len, 1, input); ASSERT(read_item == 1); @@ -785,7 +785,7 @@ int ckb_checked_load_cell_by_field(void* addr, uint64_t* len, size_t offset, int ckb_look_for_dep_with_hash2(const uint8_t* code_hash, uint8_t hash_type, size_t* index) { - *index = *(uint16_t*)code_hash; + memcpy(index, code_hash, 2); return 0; } diff --git a/tests/omni_lock/omni_lock_sim.c b/tests/omni_lock/omni_lock_sim.c index 1f94ed9..42c9770 100644 --- a/tests/omni_lock/omni_lock_sim.c +++ b/tests/omni_lock/omni_lock_sim.c @@ -573,7 +573,7 @@ UTEST(exec, random) { int err = 0; CkbBinaryArgsType bin = {0}; ckb_exec_reset(&bin); - for (int i = 0; i < 64; i++) { + for (int i = 1; i < 64; i++) { uint32_t len = i; uint8_t buff[len]; for (int j = 0; j < len; j++) { diff --git a/tests/omni_lock_rust/Cargo.lock b/tests/omni_lock_rust/Cargo.lock index 96e126b..52df3a4 100644 --- a/tests/omni_lock_rust/Cargo.lock +++ b/tests/omni_lock_rust/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "adler" version = "1.0.2" @@ -12,26 +14,29 @@ version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" dependencies = [ - "memchr 2.4.1", + "memchr 2.7.1", ] [[package]] name = "anyhow" -version = "1.0.42" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "autocfg" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bit-vec" @@ -41,9 +46,15 @@ checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "blake2b-ref" @@ -78,24 +89,27 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.0.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" dependencies = [ "serde", ] [[package]] name = "cc" -version = "1.0.69" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -152,7 +166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c69f679e843fae7294679efdbe6239aaf9469a40f0b3145e075708879b26513" dependencies = [ "ckb-fixed-hash", - "faster-hex", + "faster-hex 0.6.1", "lazy_static", "rand 0.7.3", "secp256k1", @@ -198,7 +212,7 @@ version = "0.100.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b845d71fee1b55f68453c8db69b54a43db1370147f0f79909324eaf030a28e2e" dependencies = [ - "faster-hex", + "faster-hex 0.6.1", "serde", "thiserror", ] @@ -211,8 +225,8 @@ checksum = "ff13f0f845ae9fb1073239094e6cadaf7af213181e7462df4f73cdb81d6b5ee6" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 1.0.109", ] [[package]] @@ -232,7 +246,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9b11f78288ab8f299caf7b316706ca41d8b7a67a5e20719245d584230dce003" dependencies = [ "ckb-types", - "faster-hex", + "faster-hex 0.6.1", "serde", "serde_json", ] @@ -243,7 +257,7 @@ version = "0.100.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14feffc8b90fd0e5dead8b8c0609faf5e6b5f3c06ceb487b8f0c91f378dc92cf" dependencies = [ - "log 0.4.14", + "log 0.4.20", ] [[package]] @@ -272,8 +286,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bab646c39f21c297ce0fd274bfe27361830adf2d64d0f15b2ef320dea2001cb5" dependencies = [ "ckb-occupied-capacity-core", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 1.0.109", ] [[package]] @@ -286,7 +300,7 @@ dependencies = [ "ckb-hash", "ckb-types", "eaglesong", - "log 0.4.14", + "log 0.4.20", "serde", ] @@ -331,7 +345,7 @@ dependencies = [ "ckb-types", "ckb-vm", "ckb-vm-definitions", - "faster-hex", + "faster-hex 0.6.1", "goblin 0.2.3", "serde", ] @@ -343,7 +357,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfbce46ad2de7563c7e456888d4a29df3d461106a989836c08627d044409e928" dependencies = [ "blake2b-rs", - "faster-hex", + "faster-hex 0.6.1", "includedir", "includedir_codegen", "phf", @@ -365,7 +379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31588d3154ce8e3bd7d815b6e8223afecbcf3ca05a58a26db371393eb0ffe42a" dependencies = [ "bit-vec", - "bitflags", + "bitflags 1.3.2", "bytes", "ckb-channel", "ckb-error", @@ -411,15 +425,15 @@ dependencies = [ "env_logger", "gdb-remote-protocol", "libc", - "log 0.4.14", + "log 0.4.20", "nix", ] [[package]] name = "ckb-vm-definitions" -version = "0.20.0-rc5" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb44cd2753aaeb2dc8a3df7b293ddfc3cbaaf8232d819650c0fc365cacda34f" +checksum = "45af9be584526f91e1517739802d0ebf82eb8d14853c45128ce930144a171ddd" [[package]] name = "cloudabi" @@ -427,7 +441,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -436,11 +450,20 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if 1.0.0", ] @@ -466,15 +489,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.16" +version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case", "proc-macro2", - "quote 1.0.9", + "quote 1.0.35", "rustc_version", - "syn 1.0.74", + "syn 1.0.109", ] [[package]] @@ -504,19 +527,23 @@ dependencies = [ [[package]] name = "faster-hex" -version = "0.6.0" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5b8cccaafb5aae8c282692e5590f341925edea6c696e8715ff0d973320b2646" + +[[package]] +name = "faster-hex" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b02a61fea82de8484f9d7ce99b698b0e190ef8de71035690a961a43d7b18a2ad" +checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" [[package]] name = "flate2" -version = "1.0.20" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ - "cfg-if 1.0.0", "crc32fast", - "libc", "miniz_oxide", ] @@ -546,7 +573,7 @@ name = "gdb-remote-protocol" version = "0.1.0" source = "git+https://github.com/luser/rust-gdb-remote-protocol?rev=565ab0c#565ab0c0ac189c82b0e7df217860599fc1ae6287" dependencies = [ - "log 0.4.14", + "log 0.4.20", "nom", "strum", "strum_macros", @@ -554,9 +581,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -579,7 +606,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884" dependencies = [ - "log 0.4.14", + "log 0.4.20", "plain", "scroll", ] @@ -590,7 +617,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "532a09cd3df2c6bbfc795fb0434bff8f22255d1d07328180e918a2e6ce122d4d" dependencies = [ - "log 0.4.14", + "log 0.4.20", "plain", "scroll", ] @@ -627,15 +654,18 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" @@ -645,9 +675,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "log" @@ -655,17 +685,14 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" dependencies = [ - "log 0.4.14", + "log 0.4.20", ] [[package]] name = "log" -version = "0.4.14" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "mapr" @@ -688,27 +715,26 @@ dependencies = [ [[package]] name = "memchr" -version = "2.4.1" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "merkle-cbt" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f1ac8428ec02d6caa5a79c15e851d84d5dc7a00df0429a8aa860d104f0a81be" +checksum = "171d2f700835121c3b04ccf0880882987a050fd5c7ae88148abf537d33dd3a56" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", - "autocfg 1.0.1", ] [[package]] @@ -719,7 +745,7 @@ checksum = "c58d1147f4d0d51ce72c56a6099ae5dbfd007b250271bb965f82dd10fca2bf02" dependencies = [ "bytes", "cfg-if 1.0.0", - "faster-hex", + "faster-hex 0.6.1", ] [[package]] @@ -728,7 +754,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 0.1.10", "libc", @@ -751,8 +777,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "621fe0f044729f810c6815cdd77e8f5e0cd803ce4f6a38380ebfc1322af98661" dependencies = [ "proc-macro2", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 1.0.109", ] [[package]] @@ -786,8 +812,8 @@ checksum = "0200f8d55c36ec1b6a8cf810115be85d4814f045e0097dfd50033ba25adb4c9e" dependencies = [ "numext-fixed-uint-core", "proc-macro2", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 1.0.109", ] [[package]] @@ -804,7 +830,9 @@ dependencies = [ "ckb-types", "ckb-vm", "ckb-vm-debug-utils", + "faster-hex 0.3.1", "gdb-remote-protocol", + "includedir_codegen", "lazy_static", "openssl", "rand 0.6.5", @@ -814,9 +842,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -826,38 +854,40 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.35" +version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885" +checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ - "bitflags", + "bitflags 2.4.1", "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", + "openssl-macros", "openssl-sys", ] [[package]] -name = "openssl-sys" -version = "0.9.65" +name = "openssl-macros" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "autocfg 1.0.1", - "cc", - "libc", - "pkg-config", - "vcpkg", + "proc-macro2", + "quote 1.0.35", + "syn 2.0.48", ] [[package]] -name = "pest" -version = "2.1.3" +name = "openssl-sys" +version = "0.9.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" dependencies = [ - "ucd-trie", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] @@ -900,9 +930,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" [[package]] name = "plain" @@ -912,17 +942,17 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ - "unicode-xid 0.2.2", + "unicode-ident", ] [[package]] @@ -933,9 +963,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.9" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -946,7 +976,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ - "autocfg 0.1.7", + "autocfg 0.1.8", "libc", "rand_chacha 0.1.1", "rand_core 0.4.2", @@ -979,7 +1009,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ - "autocfg 0.1.7", + "autocfg 0.1.8", "rand_core 0.3.1", ] @@ -1075,7 +1105,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" dependencies = [ - "autocfg 0.1.7", + "autocfg 0.1.8", "rand_core 0.4.2", ] @@ -1119,7 +1149,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" dependencies = [ "aho-corasick", - "memchr 2.4.1", + "memchr 2.7.1", "regex-syntax", "thread_local", "utf8-ranges", @@ -1145,18 +1175,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ "semver", ] [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "same-file" @@ -1183,8 +1213,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" dependencies = [ "proc-macro2", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 1.0.109", ] [[package]] @@ -1207,47 +1237,35 @@ dependencies = [ [[package]] name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.126" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -1305,18 +1323,29 @@ checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" dependencies = [ "quote 0.3.15", "synom", - "unicode-xid 0.0.4", + "unicode-xid", ] [[package]] name = "syn" -version = "1.0.74" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote 1.0.9", - "unicode-xid 0.2.2", + "quote 1.0.35", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "unicode-ident", ] [[package]] @@ -1325,7 +1354,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" dependencies = [ - "unicode-xid 0.0.4", + "unicode-xid", ] [[package]] @@ -1344,22 +1373,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", - "quote 1.0.9", - "syn 1.0.74", + "quote 1.0.35", + "syn 2.0.48", ] [[package]] @@ -1373,30 +1402,30 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] [[package]] name = "typenum" -version = "1.13.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "ucd-trie" -version = "0.1.3" +name = "ucd-util" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "abd2fc5d32b590614af8b0a20d837f32eca055edd0bbead59a9cfe80858be003" [[package]] -name = "ucd-util" -version = "0.1.8" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85f514e095d348c279b1e5cd76795082cf15bd59b93207832abe0b1d8fed236" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-xid" @@ -1404,17 +1433,11 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - [[package]] name = "utf8-ranges" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" +checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba" [[package]] name = "vcpkg" @@ -1424,9 +1447,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -1436,12 +1459,11 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -1469,9 +1491,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/tests/omni_lock_rust/Cargo.toml b/tests/omni_lock_rust/Cargo.toml index 86fe702..0efb60c 100644 --- a/tests/omni_lock_rust/Cargo.toml +++ b/tests/omni_lock_rust/Cargo.toml @@ -30,3 +30,8 @@ sha3 = "0.9.1" ckb-vm-debug-utils = { git = "https://github.com/nervosnetwork/ckb-vm-debug-utils.git", rev = "f72995f" } gdb-remote-protocol = { git = "https://github.com/luser/rust-gdb-remote-protocol", rev = "565ab0c" } ckb-vm = { version = "=0.20.0-rc2", features = ["detect-asm"] } + +[build-dependencies] +includedir_codegen = "0.5.0" +blake2b-rs = "0.1.5" +faster-hex = "0.3" diff --git a/build.rs b/tests/omni_lock_rust/build.rs similarity index 75% rename from build.rs rename to tests/omni_lock_rust/build.rs index c86c201..e368581 100644 --- a/build.rs +++ b/tests/omni_lock_rust/build.rs @@ -8,35 +8,11 @@ use std::{ path::Path, }; -const PATH_PREFIX: &str = "build/"; +const PATH_PREFIX: &str = "../../build/"; const BUF_SIZE: usize = 8 * 1024; const CKB_HASH_PERSONALIZATION: &[u8] = b"ckb-default-hash"; const BINARIES: &[(&str, &str)] = &[ - ( - "secp256k1_data", - "9799bee251b975b82c45a02154ce28cec89c5853ecc14d12b7b8cccfc19e0af4", - ), - ( - "anyone_can_pay", - "cd69ba816f7471e59110058aa37387c362ed9a240cd178f7bb1ecee386cb31e6", - ), - ( - "simple_udt", - "e1e354d6d643ad42724d40967e334984534e0367405c5ae42a9d7d63d77df419", - ), - ( - "validate_signature_rsa", - "a638f65f650bdac13bf91134ed7eec8feded1dac5e6add9e26cf658b2a693066", - ), - ( - "xudt_rce", - "50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95", - ), - ( - "rce_validator", - "d9476d96e0f5d41eca88bbc5e8c819ac38592a33285a4828a58d17873f278b3c", - ), ( "omni_lock", "86ea7ee58a0ecacfb1f7f2675a06d96223e0597dfe06a2474f9c06a72a7ccabc", diff --git a/tests/omni_lock_rust/rust-toolchain b/tests/omni_lock_rust/rust-toolchain index ba0a719..4934985 100644 --- a/tests/omni_lock_rust/rust-toolchain +++ b/tests/omni_lock_rust/rust-toolchain @@ -1 +1 @@ -1.51.0 +1.69.0 diff --git a/tests/omni_lock_rust/tests/misc.rs b/tests/omni_lock_rust/tests/misc.rs index 62bcc4c..531dbce 100644 --- a/tests/omni_lock_rust/tests/misc.rs +++ b/tests/omni_lock_rust/tests/misc.rs @@ -83,12 +83,14 @@ pub const ERROR_NO_INFO_CELL: i8 = 93; lazy_static! { pub static ref OMNI_LOCK: Bytes = Bytes::from(&include_bytes!("../../../build/omni_lock")[..]); + // this binary from https://github.com/nervosnetwork/ckb-production-scripts pub static ref SIMPLE_UDT: Bytes = Bytes::from(&include_bytes!("../../../build/simple_udt")[..]); pub static ref SECP256K1_DATA_BIN: Bytes = Bytes::from(&include_bytes!("../../../build/secp256k1_data_20210801")[..]); pub static ref ALWAYS_SUCCESS: Bytes = Bytes::from(&include_bytes!("../../../build/always_success")[..]); + // this binary from https://github.com/nervosnetwork/ckb-production-scripts pub static ref VALIDATE_SIGNATURE_RSA: Bytes = Bytes::from(&include_bytes!("../../../build/validate_signature_rsa")[..]); pub static ref SMT_EXISTING: H256 = H256::from([ diff --git a/tests/validate_signature_rsa/Makefile b/tests/validate_signature_rsa/Makefile deleted file mode 100644 index c03cdda..0000000 --- a/tests/validate_signature_rsa/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -OS = Unknown -ifneq ($(shell uname -a | grep -i Darwin),) - OS = MacOS -endif -ifneq ($(shell uname -a | grep -i Linux),) - OS = Linux -endif -ifeq ($(OS),Unknown) - echo "error: unsupported OS"; exit 1 -endif - -NPROC?=4 -CC=clang -LLVM_PROFDATA=llvm-profdata -LLVM_COV=llvm-cov - -CORPUS_DIR=corpus - -FUZZER_FLAGS=-g -O1 -fsanitize=fuzzer,address,undefined -I ../../deps/ckb-c-stdlib-20210413 -Wno-incompatible-pointer-types - -COVERAGE_DIR=coverage -COVERAGE_FLAGS=-fprofile-instr-generate -fcoverage-mapping -I ../../deps/ckb-c-stdlib-20210413 -Wno-incompatible-pointer-types - -ifeq ($(OS),MacOS) - COVERAGE_FLAGS+=-Wl,-U,_LLVMFuzzerCustomMutator -Wl,-U,_LLVMFuzzerInitialize -endif - -EXTERNAL_HEADERS=../../deps/ckb-c-stdlib-20210413/ckb_dlfcn.h ../../deps/ckb-c-stdlib-20210413/ckb_consts.h ../../deps/ckb-c-stdlib-20210413/ckb_syscall_apis.h - -all: fuzzer coverage - -show: $(COVERAGE_DIR)/fuzzer.profdata - $(LLVM_COV) show --instr-profile=$(COVERAGE_DIR)/fuzzer.profdata dlopen_coverage - -report: $(COVERAGE_DIR)/fuzzer.profdata coverage $(EXTERNAL_HEADERS) - $(LLVM_COV) report --show-functions --instr-profile=$(COVERAGE_DIR)/fuzzer.profdata dlopen_coverage $(EXTERNAL_HEADERS) - -fuzzer: - clang $(FUZZER_FLAGS) dlopen_fuzzer.c -o dlopen_fuzzer - -coverage: $(EXTERNAL_HEADERS) - clang $(COVERAGE_FLAGS) dlopen_coverage.c dlopen_fuzzer.c -o dlopen_coverage - -start-fuzzer: fuzzer - ./dlopen_fuzzer -workers=$(NPROC) -jobs=$(NPROC) corpus - -clean: - rm -rf dlopen_fuzzer dlopen_coverage dlopen_fuzzer.dSYM - -#%.h: -# ln -s $(CURDIR)/../$@ $(CURDIR)/$@ - -%.profraw: coverage - echo "start dlopen_coverage" - LLVM_PROFILE_FILE=$@ ./dlopen_coverage $(CORPUS_DIR)/* - -%.profdata: %.profraw - $(LLVM_PROFDATA) merge --sparse $< -o $@ - -.PHONY: all fuzzer coverage report - -.PRECIOUS: $(COVERAGE_DIR)/fuzzer.profraw $(COVERAGE_DIR)/fuzzer.profdata diff --git a/tests/validate_signature_rsa/ckb_syscall_dlopen_sim.h b/tests/validate_signature_rsa/ckb_syscall_dlopen_sim.h deleted file mode 100644 index 6522963..0000000 --- a/tests/validate_signature_rsa/ckb_syscall_dlopen_sim.h +++ /dev/null @@ -1,58 +0,0 @@ - -#ifndef CKB_C_STDLIB_CKB_SYSCALLS_H_ -#define CKB_C_STDLIB_CKB_SYSCALLS_H_ - -#include - -static FILE* g_file = NULL; - -int dlopen_init_riscv_binary(const char* path) { - g_file = fopen(path, "rb"); - ASSERT(g_file); - if (g_file == NULL) return -1; - return 0; -} - -int ckb_load_cell_data(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source) { - int err = fseek(g_file, offset, SEEK_SET); - if (err != 0) return err; - size_t read_bytes = fread(addr, 1, *len, g_file); - *len = read_bytes; - if (read_bytes == 0) { - err = ferror(g_file); - if (err != 0) return err; - } - return 0; -} - -/* -int _ckb_load_cell_code(void *addr, size_t memory_size, size_t content_offset, - size_t content_size, size_t index, size_t source) -note:content_size is not available in ckb_load_cell_data - */ -static long __internal_syscall(long n, long _a0, long _a1, long _a2, long _a3, - long _a4, long _a5) { - ASSERT(n == SYS_ckb_load_cell_data_as_code); - void* addr = (void*)_a0; - uint64_t memory_size = (uint64_t)_a1; - size_t content_offset = (size_t)_a2; - size_t content_size = (size_t)_a3; - size_t index = (size_t)_a4; - size_t source = (size_t)_a5; - - uint64_t to_read_size = - ((memory_size < content_size) ? memory_size : content_size); - return ckb_load_cell_data(addr, &to_read_size, content_offset, index, source); -} - -#define syscall(n, a, b, c, d, e, f) \ - __internal_syscall(n, (long)(a), (long)(b), (long)(c), (long)(d), (long)(e), \ - (long)(f)) - -int ckb_look_for_dep_with_hash2(const uint8_t* code_hash, uint8_t hash_type, - size_t* index) { - *index = 0; - return 0; -} -#endif diff --git a/tests/validate_signature_rsa/ckb_syscalls.h b/tests/validate_signature_rsa/ckb_syscalls.h deleted file mode 100644 index bddbf23..0000000 --- a/tests/validate_signature_rsa/ckb_syscalls.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef CKB_C_STDLIB_MOCK_SYSCALLS_H_ -#define CKB_C_STDLIB_MOCK_SYSCALLS_H_ - -#include -#include -#include - -#include "ckb_consts.h" -#include "ckb_syscall_apis.h" - -#ifndef MIN -#define MIN(a, b) ((a > b) ? (b) : (a)) -#endif - -size_t s_INPUT_SIZE = 0; -uint8_t* s_INPUT_DATA = NULL; - -// Mock implementation of ckb_look_for_dep_with_hash2. -int ckb_look_for_dep_with_hash2(const uint8_t* code_hash, uint8_t hash_type, - size_t* index) { - *index = 0; - return CKB_SUCCESS; -} - -// Mock implementation of ckb_load_cell_data. -int ckb_load_cell_data(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source) { - if (offset < s_INPUT_SIZE) { - *len = MIN(*len, s_INPUT_SIZE - offset); - if (offset <= offset + *len) { - memcpy(addr, s_INPUT_DATA + offset, *len); - return CKB_SUCCESS; - } - } - return CKB_INVALID_DATA; -} - -// Mock implementation of ckb_load_cell_data_as_code. -int ckb_load_cell_data_as_code(void* addr, size_t memory_size, - size_t content_offset, size_t content_size, - size_t index, size_t source) { - if ((content_size <= memory_size) && - (content_offset + content_size < s_INPUT_SIZE) && - (content_offset <= content_offset + content_size)) { - memcpy(addr, s_INPUT_DATA + content_offset, content_size); - return CKB_SUCCESS; - } - return CKB_INVALID_DATA; -} - -// Mock implementation for the SYS_ckb_load_cell_data_as_code syscall in -// _ckb_load_cell_code. -#define syscall(n, a0, a1, a2, a3, a4, a5) \ - __internal_syscall(n, (long)(a0), (long)(a1), (long)(a2), (long)(a3), \ - (long)(a4), (long)(a5)) - -static int inline __internal_syscall(long n, long _a0, long _a1, long _a2, - long _a3, long _a4, long _a5) { - if (n == SYS_ckb_load_cell_data_as_code) { - return ckb_load_cell_data_as_code((void*)_a0, (size_t)_a1, (size_t)_a2, - (size_t)_a3, (size_t)_a4, (size_t)_a5); - } else { - return CKB_INVALID_DATA; - } -} - -#undef MIN - -#endif /* CKB_C_STDLIB_MOCK_SYSCALLS_H_ */ diff --git a/tests/validate_signature_rsa/ckb_syscalls_fuzzer.h b/tests/validate_signature_rsa/ckb_syscalls_fuzzer.h deleted file mode 100644 index bddbf23..0000000 --- a/tests/validate_signature_rsa/ckb_syscalls_fuzzer.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef CKB_C_STDLIB_MOCK_SYSCALLS_H_ -#define CKB_C_STDLIB_MOCK_SYSCALLS_H_ - -#include -#include -#include - -#include "ckb_consts.h" -#include "ckb_syscall_apis.h" - -#ifndef MIN -#define MIN(a, b) ((a > b) ? (b) : (a)) -#endif - -size_t s_INPUT_SIZE = 0; -uint8_t* s_INPUT_DATA = NULL; - -// Mock implementation of ckb_look_for_dep_with_hash2. -int ckb_look_for_dep_with_hash2(const uint8_t* code_hash, uint8_t hash_type, - size_t* index) { - *index = 0; - return CKB_SUCCESS; -} - -// Mock implementation of ckb_load_cell_data. -int ckb_load_cell_data(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source) { - if (offset < s_INPUT_SIZE) { - *len = MIN(*len, s_INPUT_SIZE - offset); - if (offset <= offset + *len) { - memcpy(addr, s_INPUT_DATA + offset, *len); - return CKB_SUCCESS; - } - } - return CKB_INVALID_DATA; -} - -// Mock implementation of ckb_load_cell_data_as_code. -int ckb_load_cell_data_as_code(void* addr, size_t memory_size, - size_t content_offset, size_t content_size, - size_t index, size_t source) { - if ((content_size <= memory_size) && - (content_offset + content_size < s_INPUT_SIZE) && - (content_offset <= content_offset + content_size)) { - memcpy(addr, s_INPUT_DATA + content_offset, content_size); - return CKB_SUCCESS; - } - return CKB_INVALID_DATA; -} - -// Mock implementation for the SYS_ckb_load_cell_data_as_code syscall in -// _ckb_load_cell_code. -#define syscall(n, a0, a1, a2, a3, a4, a5) \ - __internal_syscall(n, (long)(a0), (long)(a1), (long)(a2), (long)(a3), \ - (long)(a4), (long)(a5)) - -static int inline __internal_syscall(long n, long _a0, long _a1, long _a2, - long _a3, long _a4, long _a5) { - if (n == SYS_ckb_load_cell_data_as_code) { - return ckb_load_cell_data_as_code((void*)_a0, (size_t)_a1, (size_t)_a2, - (size_t)_a3, (size_t)_a4, (size_t)_a5); - } else { - return CKB_INVALID_DATA; - } -} - -#undef MIN - -#endif /* CKB_C_STDLIB_MOCK_SYSCALLS_H_ */ diff --git a/tests/validate_signature_rsa/dlopen_coverage.c b/tests/validate_signature_rsa/dlopen_coverage.c deleted file mode 100644 index 1b44764..0000000 --- a/tests/validate_signature_rsa/dlopen_coverage.c +++ /dev/null @@ -1,41 +0,0 @@ -/*===- StandaloneFuzzTargetMain.c - standalone main() for fuzz targets. ---===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// This main() function can be linked to a fuzz target (i.e. a library -// that exports LLVMFuzzerTestOneInput() and possibly LLVMFuzzerInitialize()) -// instead of libFuzzer. This main() function will not perform any fuzzing -// but will simply feed all input files one by one to the fuzz target. -// -// Use this file to provide reproducers for bugs when linking against libFuzzer -// or other fuzzing engine is undesirable. -//===----------------------------------------------------------------------===*/ -#include -#include -#include - -extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); -__attribute__((weak)) extern int LLVMFuzzerInitialize(int *argc, char ***argv); - -int main(int argc, char **argv) { - fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1); - if (LLVMFuzzerInitialize) LLVMFuzzerInitialize(&argc, &argv); - for (int i = 1; i < argc; i++) { - fprintf(stderr, "Running: %s\n", argv[i]); - FILE *f = fopen(argv[i], "r"); - assert(f); - fseek(f, 0, SEEK_END); - size_t len = ftell(f); - fseek(f, 0, SEEK_SET); - unsigned char *buf = (unsigned char *)malloc(len); - size_t n_read = fread(buf, 1, len, f); - fclose(f); - assert(n_read == len); - LLVMFuzzerTestOneInput(buf, len); - free(buf); - fprintf(stderr, "Done: %s: (%zd bytes)\n", argv[i], n_read); - } -} diff --git a/tests/validate_signature_rsa/dlopen_fuzzer.c b/tests/validate_signature_rsa/dlopen_fuzzer.c deleted file mode 100644 index 46863ef..0000000 --- a/tests/validate_signature_rsa/dlopen_fuzzer.c +++ /dev/null @@ -1,51 +0,0 @@ - -#include -#include -#include -#include - -#include "ckb_consts.h" -#include "ckb_syscalls_fuzzer.h" -#define CKB_C_STDLIB_CKB_SYSCALLS_H_ -#include "ckb_dlfcn.h" - -#define OUTPUT_SIZE (64 * 1024 * 1024) -#define ALIGNED_SIZE (OUTPUT_SIZE - RISCV_PGSIZE) -#define ROUNDUP(a, b) ((((a)-1) / (b) + 1) * (b)) -#define ROUNDDOWN(a, b) ((a) / (b) * (b)) - -int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { - // Save random input from libFuzzer so it is reachable from the invoked - // ckb_syscalls. - s_INPUT_DATA = data; - s_INPUT_SIZE = size; - - // Allocate output buffer and ensure that the pointer is aligned to the - // RISCV_PGSIZE. - uint8_t *output_data = (uint8_t *)malloc(OUTPUT_SIZE); - assert(output_data != NULL); - uint8_t *aligned_data = - (uint8_t *)ROUNDUP((uint64_t)output_data, (uint64_t)RISCV_PGSIZE); - - // Invoke ckb_dlopen. Since data is loaded directly from s_INPUT_DATA, the - // dep_cell_data_hash (NULL here) is ignored by the mock implementations of - // the CKB syscalls. - void *handle = NULL; - size_t used_size = 0; - int result = - ckb_dlopen(aligned_data, aligned_data, ALIGNED_SIZE, &handle, &used_size); - - // If the call succeeded we expect handle to be non-null and the used_size to - // be in the range (0, ALIGNED_SIZE]. - if (result == 0) { - assert(handle != NULL); - assert((0 < used_size) && (used_size <= ALIGNED_SIZE)); - - // Invoke ckb_dlsym and attempt to load the symbol "validate". - ckb_dlsym(handle, "validate_signature"); - } - - // Free output buffer and return. - free(output_data); - return 0; -} diff --git a/tests/validate_signature_rsa/dlopen_sim.c b/tests/validate_signature_rsa/dlopen_sim.c deleted file mode 100644 index 71786f0..0000000 --- a/tests/validate_signature_rsa/dlopen_sim.c +++ /dev/null @@ -1,77 +0,0 @@ -// uncomment to enable printf in CKB-VM -//#define CKB_C_STDLIB_PRINTF -//#include -#define CKB_COVERAGE -#if defined(CKB_COVERAGE) -#define ASSERT(s) (void)0 -#else -#include -#define ASSERT assert -#endif - -#include -#include -#include - -#include "ckb_consts.h" - -#if defined(CKB_USE_SIM) -#include - -#include "ckb_syscall_dlopen_sim.h" -#define dlopen_printf printf -#else -#include "ckb_dlfcn.h" -#include "ckb_syscalls.h" -#define dlopen_printf(x, ...) (void)0 -#endif - -#define CHECK2(cond, code) \ - do { \ - if (!(cond)) { \ - err = code; \ - ASSERT(0); \ - goto exit; \ - } \ - } while (0) - -#define CHECK(code) \ - do { \ - if (code != 0) { \ - err = code; \ - ASSERT(0); \ - goto exit; \ - } \ - } while (0) - -int ckb_dlopen2(const uint8_t *dep_cell_hash, uint8_t hash_type, - uint8_t *aligned_addr, size_t aligned_size, void **handle, - size_t *consumed_size); - -#include "ckb_dlfcn.h" - -int main(int argc, const char *argv[]) { - int err = 0; - if (argc != 2) { - printf("usage: dlopen_sim \n"); - } - err = dlopen_init_riscv_binary(argv[1]); - if (err != 0) { - printf("the file path of RISCV binary is invalid: %s\n", argv[1]); - return err; - } - uint8_t hash[32] = {0}; - uint8_t hash_type = 1; - size_t code_size = 1024 * 1024; - uint8_t code_buff[code_size]; - void *handle = NULL; - size_t consumed_size = 0; - err = ckb_dlopen2(hash, hash_type, code_buff, code_size, &handle, - &consumed_size); - CHECK(err); - CHECK2(handle != NULL, 1); - CHECK2(consumed_size > 0 && consumed_size < code_size, 2); - err = 0; -exit: - return err; -} diff --git a/tests/validate_signature_rsa/run-in-vm.sh b/tests/validate_signature_rsa/run-in-vm.sh deleted file mode 100644 index 732f32d..0000000 --- a/tests/validate_signature_rsa/run-in-vm.sh +++ /dev/null @@ -1,90 +0,0 @@ -set -e -cd "$(dirname "${BASH_SOURCE[0]}")" - -ASM64=~/projects/ckb-vm-test-suite/binary/target/release/asm64 - -function run_rsa () { - $ASM64 ../../build/validate_signature_rsa_sim ckbvm -rsa "$1" "$2" -} - -function run () { - $ASM64 ../../build/validate_signature_rsa_sim ckbvm "$1" "$2" -} - -make -C ../.. validate_signature_rsa_sim-via-docker - -run -iso97962_test2 -run -iso97962_test3 - -run_rsa 01010004010001005F8F64A56A5F659712D79D777C0AF463999F7DAA7682991DEC11EE68C603E5973A6A76442D04FE4641E2399B78D640505D92FE4FED4E278C0AB18171A77AD172A1D64D932149A89CF618BDCA8977821B79686BF8BF7603C26F1FCA0E3F0AED2D8430DDA0B3A993518E8DD78DDC0835A354CC27BDDFC9810ADADC99EF2C15389E34B19EDFD2F2701476BBF5EEA352406E313926CCAA971FCE1D855644A4D16ADEF5FF6DE30FDF59F2479866E1FF087418FD3ECDD54A02941FCF01C80FE21020C24DA9D1CB7DE8066932C69ECA37FD5DF12B1A879F65320A96E804AC8428552693EB4861E612046F730E5999EAC55FD1E8D8525C9167B9C9F7CE908DAE78E4DF7E 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 4, padding = 0 -run_rsa 0101010401000100654BEC5375B04E317151960C3B2D39DF06530386D1F3971766C2E3027530E76271B478F0B7A92172633ED540B780E1BC2E16AAECAB15AF265766AFF2CF55249C1DEB21AC5713679FA0AD202C311B7FEB2D042E632174C0F42C5DF35B49B461F0AFC704E64771808E5625F75057C05F137787BBC78A7EA5455FC981BA8916C39828405D4BB0441943D8F2B9B515DD7E0CD8BE4BA9C4532F1B2FF7D669B937561C195A77501104FD13C910B39B10A4C86349056B48A3E1003185DA0048ED5F06B97C5AD9A9F0165088218EF14402AB33DF6B6D2C1051B227E203424E2C980BF342D3D6A7519D71A61FE58544CC0CB36C7A46941D50F81BBE9EAD51CB45E8766DA1 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 4, padding = 1 -run_rsa 010100050100010079D5B3986C6265CCB23C4EC0326601EE533A37B7D6C3319670128E41736CC43F17032A462C1F8D3BD8777E9966A9A4BBCE7DDA964F0CBD95529298207E3F001FC746A24F1C4AFC61283E213A8AE570591FD57A86C088CD4E01DB9214EB8567E20D0DF47C4038382E076B1C8BBB4680C70299092B5F48C799E8960435AFF045AD2C9A3AA65FF060A12A9F2FA51FC9B3274C2057193A067CE25E5A532E8B3EE2860C84A22788AB96F05FFC5C27C2567C4805F920A2661071EFD64FC4E435F80959ED01C245195AAE70EB64CCF16BBA63DB520D8ED16292F9BE653460133905AD1ABD8B40508931DB34849437F6643794B2609E573FF807F9D74B6EB36EFBF835E9 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 5, padding = 0 -run_rsa 010101050100010043D7AE39AA735FFAA4DB3B1C9F6C245A3E6CDC2ACB2912D8DA1B054BE490F6C73317F7C1EF8944D6089E1DD8BBBB16E49A29057A3AA91BE9744A43BC4D5C5162F353E601E91AB16E70F6409EF0E3D5E338F1B0B3ED66A687018B23C4CADB443F77C84771A536B22D7E4B162959A3F84A8CF4654640F489B1BBB21DE3BB51CDBB570EB7CD22549A99C06EE45C6241B978C027AFE85EEDA3C269E266764B63CD682B6B1AB4786D5A9A1AB35B7BFD17813D44B3E576A8F396A2956E33AFF482D951FD0848F48FB09D0BEB0F136F1807CA0EA7FA15DAF184BC93A61A480F0155466C6F9ADE71D95B4B1276599F5E1CFCC66AC3DAF7C01E69C9CADCE35530D279A2A6 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 5, padding = 1 -run_rsa 0101000601000100DDB573665F698B026EE56359D6F5AEF0CC8F5CE1269B038DA823DD5259D761264B633C9F4FD673714531F2C731F9E63C4DC7F4B6672F630E2A30490703F523FA630FF90FE3FDB7726FCA2D0A64ACD31EFCC16824323F7C8EC69EDB5DCDE18A6D50B55466D6746D4A5BED80D623D5894CAE8ABC05A11BB6BD1D2BD4243CBB9EE35CD122ED4187DCFA0278487442B9F67F0681E9F92097213FF647C4DDA9312DAE57B1A01F5A9DA3755376F74D917BFF7706C9618F93D23F743FC25F77F25E61D9AA8205AB540E55D8223C67AF4C5563926CBF51064C51B48B60C1EDFD0F95C077913798F0326D6AD5798B47E0880AE5098874D3555C58FB97881B432DBB472C40 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 6, padding = 0 -run_rsa 01010106010001002DA7EE89BA01C26B7AE14B2C48431E3304D85006BF2D31ABF261905EE49A3286D5BD08C73998286496FD2607320AFE61621AB3EB8BC87541EF8C17F68426127DB5DC0C83317D710C103E8222511673F15249B037F86AAEBC4798D90E7E3BE54A8C243CC88D21F1E233968E8024A2361B868070388449A19A474B0DABE1515FBD75F2D4B2B577A00E35A461900F6689DD2EDC75D4C497757B79841D154C81B07454E4CA405E2CB5121E10F54A10924D9346E57FD4C8873406B2F6985C58C83D03959839181C83E64EA05D1E7456281C07D09783551629A85A1DC701A61CAEF128A99B49558071C04DEC04BC5BAFB0418707CE2219D78B6AE457FF865C848C983D 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 6, padding = 1 -run_rsa 010100070100010005D2998EC01299AE9E84F3836D09CC762C6C7360AB3E10A78E8A6FF957395503A0B8AA7F8E15035C589112B881A583213FC7E44A652BBABAABC39F80B1A4E47B19B8513A3A36DD6DA397E419845B0FE91037E1735AB7EDBE232207E7E248B5BFF701340FFD563B6DABBE472C36DC76D7356D7FFB28736EF6AC9583955BB3F5AB8DF74501A053AA1D49F3446DF59F5C172B0A77B298934E944FEE883BF5740DDE26C6B8408FE57F9AC5774C96BD9DADE518B31BF483C409A1647F600578FB9ED3D1BF96A1D1B4EB7776C56225F188BDEF7C7ADCDF3B4312B015BA92A04C5DF7C5D5E0906080F3CF3808281DB59422F38D7F74B57353CC5790A08C04ED14FFEA81 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 7, padding = 0 -run_rsa 01010107010001002387C00FB6B4BB338B99FAB3202545C285C56D5FF7021766120C4D1493A1D703F12358F40E0803EDF001A940B2C3B106F3212C4E921CEBF7408DB747DBEF9C829674A27B95C1BF4C2E9AE42CDB9A6E18EA34F30E96F80C4FFFB749BFFD5ADE21D4E683A9A3900614945E7E707A44A4C21650F71C6931993D7271606263B1F1B6A82F4DAF89E57163BEC6F08600A785C89418E812990055C524BA1E6B2E8973FF442F49811A296F8B286D9496FC05E9BAE4781F02BF1BA06B1FB1ED7351358EE3B4ACE3248F0E55940B518C738AF9FF0D6921EC8ABD779B1A5E31C3F6A614E070E3D4EC77EA6BAB36F0F27C958E1F89321BCBBC77721C73E7716F733943473E3D 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 7, padding = 1 -run_rsa 010100080100010051CFC2DC6D8B20AB7B719114D37B90CF7FFE36A4AC4C5DF299A3106212A89E50B695FFE1AD6AB09158D72CF9CEDB05C5032ED24F4E91081BAD22639E003AD0F791F9A70BE36422C8BB35B9C6F2E6EB67434A21F6146A3FBAA214263B6069C810ED1AA31D4E876A8DE9F73057DEECF9EAB08171CC30F683A8790086044F7823CB320D5222067B8FB0E77E7ED0041BA4DC141F132954CE2F888D17B0DC40FB3015D45F3BB53AA3ABF4218FC70A400BDF6D9C460B9512DBCEB83741C6D159BFB294AC07A0DD474DD6B9DE07AC374D5432BCB8ED601F7EBA2618B5BDEDAC61A7A4BF5F28FF5B7850299428E35BC4DE00AB19E3C1FA3DFC28E926D8E0336EFDA5C29C 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 1024, md_type = 8, padding = 0 -run_rsa 01010108010001004B6272C7A753333D4EDDFE2A77A350EABAADD070FCC6B84F9A7E6BB2422CD74E2DCB51C4C9C9DF6C03E1F26CF93C156810711F792F46787C33939624D45492C63AEA81B7044A78141D0D8432EF34FCF9E59414A0C57840C42F19F7A059C27582AE899F45BBC701DC6138A0549BA7FFEC727A8D11D1A333A3D1E2C61B3CED21B4AABD0A6849E1953B30AEAB17FD6C7694F1687FDE4EC1AD313F50E437EA89C32889B45747DA385BD2D5B542D4E381D503E6933F469042A8AE894CB3FC5E078C55293AFFF5A967E3285EACE4EC4AC93E472FBB2B549C8FBF2278435A70BF982472949E056778B3C02FE65D57BBC4F2361D61A5EBB9B9B94A2CE3C76371140FFCB2 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 1024, md_type = 8, padding = 1 -run_rsa 0101000901000100B9D1D8C66C787676D808178EC59E516A79CF5D22A0BC7CAAF67BDE6E91BC32CC640FC6C3C2FE7B3B68D3EDFFF67D04FCBCC380FB2A58837BFB52ED5CB210F0C59D5CDD463F4CE840198B5A2E8D1B06D468CCAF8CE4212DEE891433DD9B6F04623FEDCF1A709948273B9CD0747BC275763976607A395F98F831BF4833746F50AF52A7F8DDB860F6DE4C306C3F5EDC4E749C68E485B4E34E11396C79158B5DE9CC83EFBC3268B535B9EEEC8A8E80E4645F61BDDD0585CB046C1C1B29C350804F89DFB9F6DA660D029B870ADE118A88E0AA07BFC56BE97419B3933C301712A3B98F81EEFAE3F2419A5B1EC0CA97D05DCE915F45E42CF0326598E8A8215257897138 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 1024, md_type = 9, padding = 0 -run_rsa 0101010901000100B5A6C045D7E710C1786FB12993CFF8010C39DAEFF15E5FD763B562C6088BFDEA19FCE3FAFFDB74BA0F9921208242ADCC36FEA9C44D09375C91C3CC05F18A3F9B50439DA7B4E76B9FC392DAB6FEE48288D7D6AC5D30E9298BF59CBD82318B8DD059C14D26654A9C969D2CDC14805578647EA49482A36FB045E46BC83ACB5D0D9B7FAD74DAC283CBFA3F31FA5649616EAEE925B4417C01A2EB26BBDF358351FA7B11A37E3C3EBD745FB62462817846D38444AFB196A5AB85EA553069A77AF8D860CBB56B1C50B501C63B30AC802347FFD3212399B60F4B05E80D2B602C168B8D44F3DB27A28ED64CA8D8A11D8CEC3D5FD175E24EBB31CCD61FBD3255585EB42AD1 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 1024, md_type = 9, padding = 1 -run_rsa 0102000401000100057A3158950D6FF14D173F4872C768DF67FFB1401DBA3E733291AC85A5FBBDFEBC1125A780A3D08E00325364A80F9A4EF3B8A81A3655A7D0A2CB462FF7E986F44CCFDB710C393204226DF7C0C777641321F9CAD06748B5DDABCF98EF7005AF107C8E9FBD983C954379398A79D5DB0BD76C9EA0B6FEB0CE1FBA2DA300D15835277A37AE7FAF42EEEA632F7DF9B3100DBD759E935C04E6925CAC673B69CEB258913461D389475E9AAE80394F1D61C47BBE17363691C669801D6AC33D3689E6E7C2FD5170441FBFC15C580BB7ACFB9D3DC5B36AFEAA45F197A690D5023AA2547804BD990B47E4B88A90BDB14E358342BE90DD77693AEB6E2F604751961ADFB084EC30EF4E87E218C9BA03BE6F453343576DEB1D3B4E7D7005041E5AC4FFA4E88ED8F7CD13A25BA163117FED97376DA0B56DCAEDB296C85DA75FB773E610E01521646FF9FDAFE6C1E29CA216514D1ABDB2F1045ACAB85674B0C9F4E4020CC23E3784E2FB76449AC6BB6C06D7274ACAACF5DF08AB880DFB5C1D535075DDEE1AEA611295435B4CFB75AEB318270D23FD1E8FF723AE50561E4E08936A59C8BED87580FE6B86094F80D59BBBAD53110869BE60C4D9BCF8B138A51D6E045F19CF59763C1B9971176FFD21EB249AED0004C97BB3BB4150111F1975875190A65711889ABB55BAAC7A033158D26E3E1402733865843379A97941BF9E7246FBCB03FBF147E48B 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 4, padding = 0 -run_rsa 01020104010001007500CA60DFDE24A83D20FE1E0C7AB5F4752F23DD4C5A3CABC2469B305FD9C0453E216F37F8DB4F3576D9B5EC0294696652AB5A3900C01BB5F42EE30347D0B49EA0828D4417C9760B2E4CF71E8CFEA0BA2FACCB4D7ED1C2096E8BFC7288CDFFEFF1248230ED30AEBD85DD3876794203054B0C3C68FEA9FD1DAA40AF7D5E837FA262981D7AFF0E43C3D63ADB0F9FBB53F9A72F338E3DF8D6FCA17CD3F054B73E909A9B974D817DECEB93FD79A030003EA9BB1EF5F8EC1FAD49296375ADC5DD6533E4F89988834A6FF54C3CA3684510ABF93A58912BE21B6903606F45F067A64914363149858F1847AFF232E7186ABDA07EC9041E46E50380B5282B9DD96AD052AF44AE1119AAC7D9274FEF1F9D0E427A9A342B6406FD25FD4F055871B3E77C7933CBBCCA7A775FEB1D71409954BDB3C17530C45D77FDD5CACD04DB649E6BDC4E2AEE17E8DD2ED2985FBED7AAEA02754F6F378652DB61475DCF46013E826419B0FC5F7EE25A34BFCE5DAC352797916A4216DB67334B9C9C17F48974A79F5411B1CA1FF519EC31A4F36400BF6A8667A7109B821488F33144514FC735E4110BDA72D8D28E63E4264B55D17C1673FA68ED2ACF8D5186A1AD9468DD2D60391E479711E16E9A8FF8D10FDEFDC4D60D74E87CFDB18B298A3AC623213AFACD03C87E973D0251B100D4EBCDF99D30ACD46798D273EBC7EBF6E059492F94A177BE2E5EB30110 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 4, padding = 1 -run_rsa 0102000501000100B3B1D71485BD6B1B6AB06EA72C703EF7A79EE4C47099965DBD9D11A7E694080D8FDDC50BD90A44CD3602405652B57E0ECEFF27259947440C44E3048ED4FEE711FF37A59FABE64041B0ADB7F4C6C99900F5A4772008C2C85B786ECB84C45B8137CCFB83267F3D7732D6BC3816AEBFADE953C09452B758AB9C6133980BB8598E13642D748F1C77DFDF75B1307EAAF6A3DC27F7D249EEE3D8D6B5CA0630738C8E683456DC6AF0A5D3850FF4E480D1C0C5BC18084B0A1CEEAF564E54E57B6B7DB65FD1029DA2D9705F9B5D9B74E24BF9ECA1A2E9876FBF218F5BF961A1CE4FAEDADC14AD347FCE1061545D0F7D806350175F49AF67DE3E4001CB4933BCDE565815A89CA8CD74E3FD62ED7A897F21640A7FA9DBCA77586E5E1BA6456BEE8785720EAFDEF98B826A5DCEFE0850566844F1C7B8E69D2A3C437439B2CEBB3D3D3BAE9CA6F26D209F2C432B9CA5F484177E67C60A0482E347A791B7AEDDCC02C73B2A31EEE8B789CEE40AE3D21B911710A8147E1A55406ED22906DC4278CECEBC77D743922D404493F66E7B4E82A929BC2543ABE13F779277AAF631845EB3BB6C6EDA3E2D173D79EAF8F75A94D819C3A269297917F183C6550C82BF51335DE18BD74E13D7F55266FEEF6C192ED39197A90F0AFE01C733A5B1706E253CC22BD0FB9C0F4A61A8DA1514B12EC1FF9F891653B06D2C63E60426AA946434D9271E343FA4AFB720 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 2048, md_type = 5, padding = 0 -run_rsa 01020105010001006B2048E2E0DB2BC0CA4B444D47D7090C2F7B07D3EA7F677D44BBBA83B4FA75761AFFEDB43EFF5005465E5FFB4D1742E5FFE62FACD682FF3E260161E20D6FF832C553A130FFAA0880A19CC7CEA10FCE607BE078C53487DD1C57DAF4EDF93AD139BA616D607E8C33DE8B884FAF9D0099AD73AD4748C83119A4EC6D3055B4C4E3622D8235E25B86E52037C3856220C91E0BAE10F30F3AF8B29A12FE9CAC62EDE55063E1719400A65634F3654155A1BA9ADCB13FF6948141C4DA5BAA8392F89FBDFAD886EBDA7E46612048FDDB56F646360FE0BB18F4BA90A2862DC4DBE8BBEFF31C1AE8C1309DF7840A5D42C8F9A48B233E8624293805C45CF2A71E762678B04AAD26D66C2E7DF2F3F2948CB6F53A026AB1DE81FAB3ADEDBCBEB0E88D44B299167E95661E63F3AF82C15950CB29192656343923121DC2155304835C1C0CF1F71FCF0EDB1B57CD3EED96BA9DF517C23D644E694D3821BC476328E4773A8E81E1477FC6BC4784C78A6F63919F499B193F647E446E690DA906AF8F778B79C79B0FA217BFAA475663B2210427F0F2EF78B91C52B07896AA550E86440203BFC937197F05EDDDE1BBCAD1671900874FB7CDAEE7592CAE5B87ADF5C11110DBBBE91448BB54E99ECB9A93808AE84CBE6FF8B30074E1DBF37F5247E85E162107E03BA62D5F0CDD71FB09F0CDAEFD790828AF835A2B0BA0265D22546CD2D6340FA3A2B02B06D6 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 5, padding = 1 -run_rsa 010200060100010079BDD050D772B853E16B3339B6FC5F55245EE44797DF44B0B3C5C64A7D2B69DCF23BAB1786D3D1085E26E12CD9D32B1D922950505E7E0B1E7C4B2424EF82CE2096CEC5FB272229588216ED34B6E375DE959BF611585DFDAC6CFECB608A678C9A42E581BDABFA46156A929A07E219F349A6A339A2AE6C1C778F61E6C08F8DED381E71F670178741B2FCE6E2F2E2F6F0E53E0FD7B85966AC943A4904F6B809CA910A597B743386EDCD1D5BAB17B8D1A0911DB902B69C2E3026EF52C885F03F2218A92197A753EEC387510CC3E7381B978E8EDC52C025192D7138A0200A3F856B2696D19F3293B07421526A4B6CE2B021CAF977D9150AD025E8546A531CBCDD46922E8A735E145770940E3EC6F55C621860FF23952899F018D73EAE72B18EFBF2E1C3DA21DD93732B97F21003DFE6BB59AD97F3F829C84642B2985742B7562D338643A362C6903573CE1517979128267F81256DB284DDA09F612BC86D64391E004569AD63FB122D0F11ABC2718CFC81CCD36D2D407758DFB9643D9A9C821F0574F37DB7032F1B7E82FCF0EE9501C367655FD8AA2A710938F8BFF735F8284171689CF8350FC6BBE5FB0C18C4DAFFB09891031FC66517052AF60E66EA267900C9956BD1ABA57A97521ED96F46C09DC4FBB86A45E2AA982AD6BE0B3AE79C6F38D6D5BD1B56428EAAC25423E5C7DBE8EA34208256BD7929C0B11605898C74F8AD806933 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 6, padding = 0 -run_rsa 01020106010001006F5519E6985DD45BCD77D23E74EC666645DB8F450F368A8D8A56E766832A94191DD2444CB47AE51034A38FA5D006B050C368C45AB539C1B12B9419BD9648C164107C02F8D978F02FC3B27A82B81F84C27DD550BA6F65111FDDF1F451D755B65F90084F36E5DD72F625697C8712960EB2EDFCE82634A4B7A24274DCE341B95AD595531F5C2B128D78F812F2ABA70BE79244006EC80166DD7DEC822A956E55BCF5EFF142362CA8ED8BDFECCA0C5211428199139773CAF279B49945CD443A38C77B1C8E3284409BA81FBC039E4A4DAFC21DF463343E44C173F0D0EDF3FDDF0607EB6B17B6610ABEF4D2B98B5BB6B071BEEA5F77FFAFF4D2B3293C4F951B9454DBC867F565D7F5F4CB3AC7242E37D59A8E018B9620B34F6BAD0EA0AE21117D06D36C4DA8CB89E34A9626D44FB31F3313FC118D5F147CC9CBAB2F9F21785D4B8BBAF552FC005C57D922D251EFF417CAA5F15DEF4DAC6CACD9773AA5E76BC20A692841002A5FAD8F37438074AE7109834183D02F41E53DF3A4CC398E672B2920224F843ACEDC792F14CE2F53DDF0D86224C9F465E84981598B25885C771DF282FDA39E6869400CD4DD3C5D245811B97C4BAB2211F2AAC560008608DF306D751CF652039094B11C1B0DBBCE5B01C0D89854BB9D24525F3BC81349DC7B972D06E4F56F11F25C2E2855221415E4323EE354C4D465AF86CB1E11CFA07C8662F207B481C03B 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 2048, md_type = 6, padding = 1 -run_rsa 0102000701000100954FA89634195F6CEE70B112661BDB716F999EE9758AEF3FBD0B26282E798C91BA63F6CF9D7A32795D8154EF65ACBE27A2C3C4738D83553ADD7057145627F4C042D05ED55B4AA7B65F0B79AA0000C77C4F9A5694D716EAA921138B74E71558AE841E210A0E6CB1F0FC550948C49691E7EAD14375CD4887043EF4CBA4B035DAE0A3B22AD12BD84B4EE407F85C1247D75AD710E6AC4070B92C4E7F88C85B26ADFA6CC69699FE9CE2EF7B8DCB9CF0EDAEFD1F028A5C1700A123A5B9FD4F2DF714A15B9E57B4531EF859E5B9852DF835BC66EB724BBD549AFA41A029FF9A61A67E4EDED6743864A7848E6E48EAD8BAB37C86AC4E0268DB313D217441132B9995EEA3900B7E4B4BD078291D751CF2270718B965B914F618881FAC91A2669AD67DD65D1786959DD9C13B8CABF84BEB668AAA094622E58F9D42C1E82419AAD2A42195610EAC42E900B6CA9CD2B7566FE65D0BE97E4A944587F9F5301A19BA4608767F9205D79FA86458F17EC72DA7C54AEE3CDDA60432410766A9FEFA126ED8E38248342ECE0369A75874B917DA31D89165873D7F469C8EED3DEC0813303DB4D51F2836A735D89C4128FBFBCAFEBD67DF0C99149AA21741BF15EBB1F8D20DACA0E371AA14C4149321794D7CA2E474786F4CF1A96DFB4C2309114F44E1D9DDBD2D56775DFD559787BE89FA54ECDB029C2B55EFEC40AB726027F2B5A593B1B195B7F405A6 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 7, padding = 0 -run_rsa 0102010701000100E97D35E5C65E7D950C50D679D523A50D32821652DD6533068C132E9DAE3848CAD30AC90CA6F99C22CD28C8A4979FA3196C8FD372C03564FFB8DAF8A72FDC70A6D8D91861867EBA2320EFAB7719AD31A5BCB5E5DF636A210982BD6FBBF6820D6385F39AD3FD706042BFB5041A577DA9EBB698556B11AB024741D27C9C4BA11F93A0215BBB5E538E74E1B46DDE2D6BF93B78F03BA8AD9268D998E815D4627186BE69265484BEC612F3837DA365478B5F73A67F7CAA6A0E36881BF3ABF511927867812E5D817637CFC5AE67F82CF301CA728E88815CEB03F26F386FF22BFF9811996682FAA874E9C15D551D92B556BFB93DF3C561D243546B68B744D1B700E341C77BD1FF697BA4224882B1906A34B42CA4715109849951D4196612BB89E31EF2803A76E935B46313A37849EC4F665CD088D34F6F953C85570EC64C1B8F7A8E1D34A336D05262CABF8FE35E318C90D11DC0B7680F3DC02207526C308373CFD86C9712F042F8107AF606F83FA8285F78A59755B5FE7BB1EFBCBF86DBF2E08DA109A106826EDEAC651F174724D82E9EB434C0868F89B1CB9D11D63ADD96FD104A510F61BBF7124932C7A8DC2DDEB7403A79D4060DF28383B95D1F33FDBFC755783B17421432CDAFB503E13803D09CC3C14E7FB4CA226260B1BF4AA18736A3A29DFC1F99D038FCA170CD9EA90D88C37818122B94835AC49179D2AFBDCD70E76BDE2276 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 7, padding = 1 -run_rsa 0102000801000100935B3788D35A5687BC58A406E9471C714B6D261C734213175674AE1B0D302F0575483B8DA358B5F0E22D19830ECC864AFC8D529F5C2B132F48BEEE66BC723375A45D56BFB413EB7A7FE7B3B1424C15197C6FB5CB0336088BA4C5D601FA6B737BCBD4910DC154CFDB7853B3F01DE87D7862E6C86032E7933DABE0F81D2CF45B2870DF2866DD67228AA3FB99F4215A2708ACD260DB1C6E543FD2F1980D0A56693C85C9F5B6C4E49343265CE85200905BA00A505B739339307A2C53772F2BB1CDD1D588E43EA7DD6ABA84F3B0FEB82339E21ADE09A81DEE61584EC5D95D4BAE0E02F829CA0E11FB4A8B2F38EECCF35B75B98D724974187190F4B20725D8049A0C9C41D068A1A4E0D9333E7A106841A79130C4438C2330790A5687F0F2155A800EB0982876545B874A3A6DE306E09AC92BE5E0D0AFEF6BEF055B1CDB1B9FA7C88BA4070C5E91D7E87520379D8C68E1313303B6E1595508444107169BD87D14D59F615055C0FD1B9ABB15E1D06AB52CCC00E39F2C2B102B54F506F14FD5663791205C0569BB65A2F6AAF2F00F9FC6F54E85715086779CD2058F54246A6AD9273929BCBACC5D8C25BB13022E54AE23CD651E058E23E8EFCFA33B346F886BA6BCCB82E39CED703F9CF657E2F4CDAB308D1F75F0BDD1F7B5FE6A92CBB6A9EA47B6083AC393875C3FF2207CDB7F5651C09975C22CB7AAA8969FCDBD20BB5637D0AC462E3B 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 8, padding = 0 -run_rsa 0102010801000100012359EE79DB941E0DC4AEAE1DD8E76A99109601A20E392CFDF9750743F130D5D1E18717D71E2E0BBA85036253265EB8D12FE72E6F02F7EA17DE2FDF12589D72E591750185F8381F555ED3317FB8EAD6FA33BD646691DEDB1DFCC310E5CC4B428F44E418CBFECDEC2ECC0A3758E10E39F23BEC3E39F75E7E8F47A1EC6D946E84345F4C3BF4EF5B8CCB981016B7C23CBB2E6210C3202E06A80B46A4B69AE0EF472C0C1C2B7634DF90718AF91D2CA2E6793D0CD508C37CE833E7E1BA5E0179E3757969B9E4C55B8C65A58911DD8A48597FA19D9AAE33992251B58D058930DEBCAB0EB79441B145866A7FB5CF6908CFCA8FCC710E792315C0611F8716A1F508CCA411B7FB350E491AA6D78D2E27FF7066D16E3D02EA4140116F8F874D7E09080C072EDC235E3F76C29E39485B2193CCB6C21D82B30A2930D6169F676926AD1C1625A882954C549D765EEA02D0F1985F0EE5BFB32DAF477D97C2DCA6076648540F123D03C19FD3F55C1D076C2E3FAFD8C2E3FEC3B9301ABC6B5C880CEBE7CD3E410720C31896CB34D6BC9C81CA571957222C63C83C4B05C1AB419B2E20DE1F681BB64CD4851A6E917A5EE1AD20F4A64671AA7110B2394FDFDDCB5DC24591E4E223D77DE8B8CD8AED9ABD8E1397B15888AC7647406C916ECAD7B1252796AE6988682EFE3A528957686229B6B8EF03FA43B87E45E424F35C8F799CA9182E4D98182E7B 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 8, padding = 1 -run_rsa 0102000901000100856BF44AC0741CA0E808A73403283A3965B7F57B810FA52A3D41DAA8E537F00A4B9143AE2CE9DD2354F3B0932AAC7429826A354D214ECE9E1398410BDFFE35083BD2631AFD2E09BAFFD77B83BD8D057968B5F698E7B1457D9B47571DFA42166FCFD1E1BA83363E1B6C2B6111EFB651F6BBFE2D58271750F0232C98727E85FCEEEFB93C492407556B1F118E0F354682AF593F70259A9896E7E3C5D54B3D7EE93B07CB16AE6230D9023924F2793E9C1EEC5B25C012BFDA4D9B3A9806C1F4194790080F913A4F35EB4669C8F5F259E7872C4926EC9AC3E81AF066FD608D06BCDEF514A277D305A053734E3089CEABE462294874EFAF95F0E2BEC907D3213EFC90A689921E8857D76ADB0617968DF039D1BC508F5A078CBCE60F6BF8E080D0EB9271C3853181A1C5201402D00B606F009EFBBB4884ADEA9222B0E3145C29085C583DF458A64BFDDED40DABA51A6A1993ABF24DF2E292978A093B0998B0FB77AC9F9AB7FB27D3D478545F5CEC6B08A93E70AF23B275404D1F912696FDFA1D270F901C1D827C96A88D5982341C32B58F5BF3158EF95199F07011933849EB1CF6FDC46F9B923BB254AB37B2A1266243BEF00DF4677EAE526BDFDCE7CAAD6E7032245ABE87B117B5DCB9114652C773C22233863268494820CC8CCA9249542E5924C644F92CF05D7B518519C41A183E47293FD590165F05CA797B368E3ED5CC8E4E3829DF 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 9, padding = 0 -run_rsa 0102010901000100A1E24E6FA8101BAF17CE80D20B8A0B09CEB572AB2F60A295E9C18E97B49CE4FC0A04B58A1EB5CAF767F9C743E9A8F81C45F0232D3B80FA756EAB8738233F8AF73F921657BB65AD3DB9528F9B5263A7844D8E98A878416BC6E92E40F3DF4C435D0179EEA64C3AE8C7EE59B1065DE655A9E367D40B451FF1EC89ACD1F8069E8DF0BE9FDDD7640FD7701CB40734F2F0E631A40C90EA93452D324AA6ED3E6FCB300710C0663C634738A0A776D4802FDC6165A88E3032AD2E02F8DFD4FC4560BD3D348C576187E412CB9C6C4471C987681BA1BCEC68260DB799B17015206D63CDC91B7E4BB2812987F781D64D72847E5304CF0EAE7BFE9826A61F7FE970D2AC85DFB107476902577BFEF4055FE7C405C958C6B142463E738FBD7477C6F48EA527666848660D6DF352D6BEE064E39EEDD4BC06096AC5F6E9A1645B4510BFAD3D2D6311A8D17970E655C1B8C7626A51F2A1F2B6328D89167E5FCD13948E0D2E34EB1C8421BA62E65CD2D97B264624C3699213A295829E2156BA4B8FB6D4D91469AF9BB45E32DA883C88B41B0009E35010C977B71DC4CFD97D046192AF91C8773D48169DB413087BD70F8949E0C58014995F2D969D08C3299964666840F3D510D516A53978259A214987DA1C842052481DA5753D1EBC1CF2651AE2BC593CECAF51690337E2B281C521F1A45F94E1AB297A7E644B3CD5E458AF26CE00E9E8D6B409A5088B 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 2048, md_type = 9, padding = 1 -run_rsa 0103000401000100ABB620F08FCB91D881D8028A333F774EB7A4C012119D2470F78FBA70BB32F3CC00A979CEC0CE60E62214F349F7279468F32A74973B1A79FF6016D42C1900875D5D3ECB57BE336CF55B7544794C0675F2746E199E469A0858A5FC431E746E9AF1CEEE64365D743EC523EAC853AF9820920DE2C7BCDD00D4C9900CB4ACD2B267013D4AD67826D97E0DF861DD9B70D0D7D83CB696A2FE231CF5BF0D32A860D7618E7FB987C4D3237C1A9619D89CD3342005C79E1DD656592C33ECA384F16E9EE687FFCDE54C2A7020AC8303C98F20FB8499FCD17E086F0B3A96CBCE5C4C2C7FC8B0274D89BC13671799D4D6C4D6E432150956943A466DD285F85C9861A385ECE2CD63E7D9933C429B81AC98F962C5656F5AFBA0886C727AE3D0EC8FEBACEAC81D4F92FA31ECBEF11B3A256E84178C86C714F7784681600B99B8B2896F8B3E8594A6312105AC9CA74ED9486A7F5E30B383E6FD79167AC6793D68B3EA9B3C7B4A3C68A22FB7D1A62B59CBF7A73EC5E054218F9D93F27251644B3369A0AF78F3408FA2F1983C9E16F5CF2520CD0735EB5CDC8AC8568D219B5FB6381CAA6DF97D5FE1166195F59A024D038E8624193FCFA5490BA10228F1DA3CC09EF5F38B91E35AEB82CFB138863AE9D21F08A445F171DDEA91F12B9112B262CF093D126A4FBFFE873BD08F9AA52585CFE89212837B69E64AE2485252F767C97D377DA355A1FB74EBAF30B31D65256F78E485E7DFD774E78538558BBCF1FD446875076C2C8F8EA063EB6F4BA05EA0830DB3BB488916AA5295A752680CB3DE5A416124E444B7C4A365D5E2ECB065BA79A65CAA99E7D7B4A447815C1582DC28DCEF2572F961E5B8E51D99C18AD64C6A1A19FA2665EA9581E7242F2E138AA93A0F3992F1EFD33F32C1020F8C62E028988BB4935E2840BDA7C6CA7A1F912B06EBC810A2E4C0312AB1DF6E5B101220C51A78FF09DF7F9DD9BFBA3EB0F6BFF0F53869E15120361F07A5B8CE636AF95125E6B7CD92EFA0190BD77901C172B66C2485F342A75E0361229E6F18AD94CA0595FBA5D574EB0749411AAE64D61C0D80DB6500372724FB1568A2A414998C93F4591B36088667A5859423A7504EDE07FF49746515ED5B205EEFB04ABF5173E04B9735288D0603CAB97DF0FAE84C7A9A8737F268398EA47961F4A48EB480909906BF720BB4DB6F67557256B3717E40A8036A4174285E34690C59E47B2035B373B8F96ACC50A453D71B4DF3292726B140233CBA5AD7DA94841BE869F9950406C786E5A3EBD7B5D9376FA0DD9EAF549947A401EEC3298F05281E8ED1840C5D36EA5FE80FE6EC1B340129D1717A554B3B1F49ED6AE44BA82B357B7C41C39C4582DCF9CBEDB22E7272EF76FAAEA4838DABBC3DE92A29DE5470F288782289E4BFC40C0B7220F853831961AD9B85ACDF16F1B036015E769E57720EC2376D7006B8 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 4, padding = 0 -run_rsa 01030104010001000979293FA236B0FC495AF04E1E1592E7F87E0A46AB7BD71F9C3A1D0EA0536BCC87C176FF39E82291C8F4574FD48539C2F82B115161F4302910C5DD6E4BBFAD9B87D4A1CC048135E262CFEF1A77973C5B399AB9843104E15B7510EFEEF9CFDE43E8EEE2F776DA94FEC0EAACC463261B1DECEF7C70548343DCDBC0BAE8CB2DB015BA8FBC2DA4E3F083077D1FD951D3183BA706C3F914BA974734EAC38A1B4EAE43CB358F455C0B4567EF871A6F1FC589C11C2F234CA480BD73E5E6D7C5F813DC705547318196B3881942844C80E04975096FB0DF997BA1C008C0D7258DA6D2BA8CA8A6211834358C4CAA6891880F7E19AD4EC68CD6840BF337FB67CFA774FCCD68B4A7591B18ACAFB1B69F4A640952DA46E156908899F93A4176D1A91A68DE9125C87A7F4D7384513EF5A1EDB155210800BCCAF96488E8960352A5591152F6AF315E6D2207C9C3561E5219053263AD85B04FED976447D5A8666370F05FFDA46EE1F80BF7F1C71147D695CA374987C969CBD4970D4A605095056AAD51F845040ADFF0A07214DD9E8B40060D2DA84CAA72FB4211E86CB123AAA3D6685B10964DEE0BBFB644C541D0486DA2B0462DE5AFC271E6C6BC7B5D991A13CC085D133E88A26737D1D84EC0C88F6BCCF718ACE8439E0B4F5947451BA6BA0D7FC161776B681C83470650D0BF86C6D0D823EFA37AACF76D9C787AB91C3FAA7A46668A35AF94D9DB242ED12C6287D755C3015E8D7921C5C0D3692B7572F9CE7829A9F019B72D22C68B1D07C376E249C5BA4EFFEB3DB03658F1FF0FB3D1B16E3F2F02BC8120BB5093E9CCD3368CA000C8DD1DE31E9E9FB4DBAAFC84F1D80B31DF142FA0D0A91CC306ED0C830B50282C76B4FBDAA784CEDF73C25EFD7136F3A810828BDFB79F73F472BA8E2E0A4068FF962E11DA1B185CE91DD9372055C352BDA0DED7C95FA81B2A20F3E42219D74F685355778DA6033467DD39819146A3CA07F24284B6CFE93453B93544EA935F06D8DE1F79088B79038924D5C3A628531C0A11A2D013F1D1F090F082C0F6339E8401C75F5364D90D51EFF756825A4F9473A0C145D1D81E2FD538C4807EA3F48F67B1DD589A6CD0C29877C851C6069E6256220447F54DF793B5AC54A306DF7E130686A7C7AFE50B45D9F99F47FBD6DE5D6C02ED2E43814892C72ECF804F809802423A15E6450C4AF2F62EA4A782E8E53A2266B20E64D25087FBFD852CCF5751587DDB5A093A38E50297085EA177901FB144FF7A25B10641848B9F33F811E4A6969F9E838EDA6404DBFFDDC07406686E7D1F43DD54B5275EB1BDA828ABB1AB8CD4C8D188E572B594C250003F8FDFF24E5E2A810309C16E4C3235268612DF2CCB329B11D8BA9216B5911228FD58D6AADDEA65A54B4F6607C5838487C119514D8E1CB226E1113A30A4C2E3A77F087FF3B86242D8CBD4133DDF81007BFE 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 4, padding = 1 -run_rsa 0103000501000100F5882A51F4CE0AA7588153A0D918192DE1CCE44A886A8131DB0B88B731852B2BA2A283BEA144AAC3CF07CCB6E04C53017479214451836E9BEE1E0C87CC98E31DC4DEC90D7E87D408B5312816F445DE0ACAB932FC753F2E09F9B28A9AD343F4B08029B972B9D7344C1F615CCAFC3F0A43FDC6E4EF4C273CAC2C1F6D2BFAA22B4C1AB759E6629C21FF0E319DAB316A2B97F34597ECAD289B3E4C531F23268903A034889E3C0591D57B44482F06EF129F713623E7254B3A853F02DC460F0422D32FCEF66508B1D7ECDEA77F42ECB58A8D518330E826601E8A5D1CE5E439292AEDC6578018CB2FB27798C6338922A9EE0447F43B6B48312CB9268D9C0DFE5DB094D215208A64DE8421E5EEDAFF587381F5EBEFBF251FF156A58E087DE429B44CA8C874ECB0456ABB3B3845787887829EE08804FA9707F5BC3E844B46151EB56D428A17C2DB1024B507F242F4060D3D1204CB5250C371723A739C240137902A0D30BFDDF9D7F5B14655D7FBE63A23F808B86BD73495952C5781654FD446753618C6C138414C8EDDA58854B7F9DF531E18341756B93569F774AA314598E7508C0CEE46655A8D5C1E279BC7D3E77A692246024AD99B80B9CF5881136DA11B083496CE8C2EC2314FADBCFED6454D3BCD3026D0758918D54067D3C8606F9FC20CB420D544D90FDE254C55C61BF3D9F1F69DC095A3C234D4E0817E2C0368D3D5F3342B7FE21B11F1192F8339729B047D6D1E934E571FBD0D7A5EBA691312EB8363D2E9ABB219469799B53F5C52FA9CFB57236F23A1D41520B9839ABFE757F495404C9DC0C3532EF2A74B7208A67116D9A278683D364FC2A26911273891D02297A277C306BE691826FAF9A60D38D2B048DFA0150CC23176737703B70387AB412E376B6516F20901A5B085E8EB5C192FD61B63CE11F41537A9559AE8822702FE3E20598B951E80C52C900369AD861874126D025352A8116B5A0C3A754A59A9893F1642B8B87D16831446DADF91BBD6774B767E73F51979A6933B352C056D832A869744E5781D75FE354FD39437AEE3C8CF903F8A16F9565415994CD2A5829A68BB960AB2CB5733F9D273BED9926FABFE66BBF7AF24C0DFEFC62E040E1B83B21C581DFA3ADD8755D1E4B6C42B42703270388EBC63136398F1AF937E0DEC3BCA17F412B80920F9F8DA99FCA766FDE484A8AF4831A2A9C402E2643063283FE3E5FABB49B7A0ACA8A892B98C031371998F79C0277C26609115BAB52703A7F30E242D7B541699054BBE07E93FD9DC5158797C42A421DE241F94DA230B7E232FD7854F7C675BAB474C88830F6F57FCF9D5694CBDDA31C3B15B3B342E09114DB12C97C5C3F2D6A10484408FA407A05D500E152836B9F1FE13055ED40FB79439E968CC8D45FB3104FE8587004C5F780F0765A2082E2020AA6B3B457AD40D2D3085BCBC1151273CA39A04 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 5, padding = 0 -run_rsa 0103010501000100356B15B770925B22523C514DAC1C2F1376CF35021D87C1BD18A64713E67D928B772BB3F0BC31FC6D888CBC69FF7F05280D36540D83EF17A2489F1DC59AA995D74EC8890EC25F63DA0EF43803DBF0264B58D31E79DFADE516776C163AC31BF18E30E508D0F2313C92CE2B1A134C8369D33A92DFD84CAD6BC823A1D6C9BBFBF98C9E85CEB354653B3F6446B9774D76B9B42E48E903EA7EF306B45552B7B521093CF651AA69457320FEF6087439120B3ECB081861E0E70520D2E2EF365C0FC28E0B35BFBB8698877A30D01E808681B565A359F1E27522BEB3D17A60ADD5F8FEC5849E9EC9CE1E83CDF531F1493AF67235E4B4CA697EFD381A92D1A0DDEE241FB61885B9F1899B59DD9D8D7C88D1E5E3891E32383DF644BD7E4E563C89B40614A35F63335696FE4B63305F324B7E5819C74D28F46B51ACF56B411DA163CFA5E9450E34EB5A9D37E379C9F79AE4FAE7D539A2B78947BF79F1FAC01E19423956F5D980172C2C6F5795F81CCC84380C9633E7E3AAD50744F4DA856E8952A5F6867680C6BB97ABE2AB86BF53EDF021232AEF42DA21C7133C8AC423D0EA548BEA50D0EC257A0C26AEB22C78450374C914CE6DEA6509154CA36C29C7FB922E8777C53FFCEC39822C967B3005FF8B17BB9D41C83BE4425A3870F8B2A9D38298A8E49068D1B4881F5F764F7AADE1906938610EF56DC046F358208E2201FAB55AD1227318A3E92790D5B801C6C3EE1B9B7BE0C31994130A5324BADED00E6E6ABA5B8DDC2E5853651BF2E6FB8226F2F0B064FF41F3B2084B017445A13DA17932132FC75068D743FD21812DF4E3EEDF45B4A8AFC0E0BAF0F51888FC2DAEE525709E8F7E4DB417376D9940C1D3D613846E54E59210333AADEE1C909025D035F3DA028DD77CB6D277B5DE91C2B80A58060F9206C0AF8B1617BB5C93E29D499B8AA26769B8C28F3306DF7A498ABA7964AB07B2FC8BCBB136CAB4D97BD8B15F78A9C77E3DAC18B2DAF2422063E869A687ACA7D4A3260D1C97837EA0BC838A9E930902A4C4FB815B60E0E0771AB13D59F880C929DE66BAABC0DCE3E21811803E6981E57C0CDEE229C2F016AF23626D54EBF405BE9A77FF69425C59CB9CCD65CE56FC19343BB4D5F9666F10C3E89DB933755BCAD4E8F0E5F43046F9C0718C8B97E499F99BB698990B910281460C637DBBB290704CFFB3A99158A17858E1B1F415650E61D2CBB847325110938DF519F52B3454E805F40429A4A69BCD7569087476161DEC8403EDFB7CBE995183333B0753617CC69D1D422C7E8315B1E65C4D262EFAD8AB10446E76950969F4690110F30361840E82BA9A0B5EFE1CF7F02330F53E8ED0C0F8A3829A64E48A25AA7DDD08F8EE039D3145407195E56E03C87B068CD088B845A455AF62F0D9E9B586561935726CB9C46EEB98E764C4DF7EA9D481B135FE27C71C9CA8F6BE0EB4 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 5, padding = 1 -run_rsa 0103000601000100E37527A8DE511D5394412EE1DE0D3DBA258CC2A952E134F71453F945F98539A942BF1CFF996346737D7FDD3EAE0F3F0E6CD73838C9860FB151F39D8B7C5914F6A260F44E7BC04833202C96F155C5EB7B00043C77FE590D18B92EC86DB99495D5D38199EC76EC435D42965376AF307A56972A2AF5B5ABB3E527772F421AB2FB159C2752FADDA3188E6AB0E882FADC35991888C24CBD7217A8BDF5BFB744140338FE22957A8543D214AC0D312EFCE4BD4CDE7ADF8BA825BD642761819D9B30557D0902DC279A58D6E52639E039E8758BAC158DB9C01CFFA88BEDCED687491D85A9C492B1AD0C8B03529CF93BC0BCC7C7C64D769C59FD30A76A78B3C3E531499BFA4E72774B8FF5E9252F6087CAAFE938DC55C6254F796F86A9D870793C3FD309A0EF422AD12B108D421C3A52A939109E03EC128DDA0126EBCC883CABD6715597B6D621E2CC961585734F3A729ACDDEB3B9E46130B843A1D5BA0CCB055D5F2BA8E11C5250E20AA650782111A12049B7AF1850321C7F5CE197493261B53B688297EF9BE1F6AEAD42A669A9CD2D2AACEEA6BF1AEEF825E4919EA3A4378D5ED8FA45A385A12B6253325972B94F54B0E9829962E22A677602B3CF65B589E25397B2628F043D2DF46F5B9FD16299B83F69A6C974298909980ADDAD6C487E338A1EAE7E62CEB1BF2DAAEDCABE83F6FD08E78EBFBBBDA2E0671F908D7721465E338FE94CAD71124F5C5C7FF8020D6A4E65D4F9C10858908C75ED0F388C4D109C982BC169C5B4551FB476BA09B0C193F4E400F434AF7E57ADF2688CD43B77D4F8A0122BEB230ABC819C56604E1163CBA5C4DC11BA2F16DB52AB0B5C312CD7C9E6E3E4C8073B64A28A37F368D855050362C08253D2761AA4ED5B880195F783BA1165766EBD134BB3E6917ECAB99FC61730133345E5138E8C2F4A55CB9801024FE39695B59C358EB1F1E0104BC546D9B811330C45AB31BBCE82F8547E27FB9FCEA905CBC7529F8DEB694D3D1C51313646C891F5824DC3480D6211AB3C9D8696C3303C2BD772BC24A1BF6698CEEFAA5B2C99F43330372E10D473703B06149EC9859D16B7CA832A7D8C0FC4B0C60E9B5A32B2B662B1EC65F89E51E2B009B095429E494D3BF3457CF15A84F46CBF91405FDBAECA5940DBD376FE26136A6C3A2DFE66A6D45A92CD12AF159E4189D880B90AFC03FF08F1F42A0186423C6B8C2B0D055EC7050A165895C32B6D196C15C06F4F6DB2A2019D96D4F8FB56E037561C0C3E4236C8BC0DD60AE6C18025A0297C5CF84BBCC2C2848B438C3F292D5C6A45D3E58363A25B3A08C578F5878BB189B4DA26B0908D4BC6ACF7BE7FA0396CB6AE20665ECF829C760C477D08458952D979714E7263DD1BAB6B9BEADCBE5744675AB7FDDDF59863307E6ED332BB02F1D330B08A3A63E3AA5F42EE91AC4D0D8C5CDD23F081FC2518BF6C47 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 6, padding = 0 -run_rsa 0103010601000100352429641141EE474922CC8DED027A29B73CFF366F4D1AFF59AD9B8F3B529AF4507D061486B691F410AB478A3F2EFD33D76AFC7A9A30359C6EA58CC155E066848A0C7C0B072B63BE3CA5CFA672719E63D99A533EB325699C086DB8CCE7A71A0619F6EB561536C08770CD732B9F316E6B2A6483C07209494358A702F9F3F740F8D3DD8B8808F540C799188FE5A48D70826B027CF372808411B2702B4C2D3408D5C1D79DDFB365DB78F3636B0FE6DBCE0D9F80045A4BF57AE623CD2D1FDA2A83A273D382E6E057F6EF85057460F13DBFF6405A0CB538956E01B031D108C502C55BE853B1D300330A45DA570719051D2E89AD9A473C37C019CA938F047ACE34CC63F0C5C277C2B94B7212E41EA3C5814EE3ECB2A0F4A2A531CD13351E9A53012FCAD6831E9B89D9C898624CD06D5F52C57DFC42DA6336E31DAB8E91915C80B1655A1127F3E7CA830559B9E2D6C71554C39BE3E38E4F263114940CBC24FBE5D9EEE8A2B0E3C370FBAD9173A82873913AE71B8BEDB23EB74EDEEB7957627A54D1E699A363855CB9AB9BA6D1785C2DF8040B710822F5F94979E06C6A69197608E2EB1929DA472C30270CEB014264F3B08A0D96B2D0DE021300FED131BC4A4C61ED4F7E2AB7B1C8CCB4F6EFCCB9939060C062CE1E45F0D28DB80B0FE3783FC421CB784BD72AB9AF9161CC91E0524BB13CA4BBC3C4B3A6251CFDC1E85BCD017054FE8DA045D25A9CF33C14A705BD4DED39FEA8A61F1A281A90872AC3F74A4FDE3AE5582D7CE714AA4F7724D10E3CDD6ACE92A5B45C6E263235661C72820D093A7FABDD03D2E107B62D7570E900BFD9DB6150E6D994F5691D34612082659131438E2646ACCD2E7F8D09DD44F0CCA3A60E08F07B26A65BE0F7341A59214F025E655A05045B93D9718AC9169C5F37D9976308E17899B2758A4D2104FDA962DA4716D194B43505A96644096279B6DFF0E0A518DDE105EF672E793ECC9670CFE503397C3EE8F9758653A61D19FF77655C020D9E30178E297FCF83B08F5FE15A807418897A1A5B3ACB22616BF6A69492F1CE0E69C92F874F2285FC98293DAAD5823D47B9798AC1999BA122C0DEF7A8387A06E7B62DB4FD59FA11CD83C8013860F8A0D5E7EDE690A185681CB455C28AC070C4FE60E9DBA8BA35E98B83BCF9216616E0F92BEA50CEBA605DC95968E8F4780312B47645B37A85CE80B84992FACA9C97B874924242275E959AFA03184917D5F938375FB86260795B9E4A4928C4EDA05E2B47845789F80D32B9335425552A957A6DABE2B5B1C67F802C2C386E4401FE8A500718C89638C5F0E4D0E9E81DAD4D6CB52A83ABF620F291C18B7EBC523E558937C9FD94EB72187A540ED0738EC8A27EFC70C0A2982C357512497396F9F8CB593AEE1E3E3681FA1A5BA13AE79D962BA5391E72D9C9631061DE54EC49CEDD4E7CD07633DBCA93 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 6, padding = 1 -run_rsa 01030007010001005DA0D695F602FFD859220B39A08EFC1E4A2EAF50BD9C345E668F0971F350B30209CCAADEFA9DEE66CA35397533BBAABF1B74E283E329A2FBF7F676407062F501906EA7363218272C2D5F79D95600DF0A92A69AAA185391C5C1528E609F9F5D6717DC121699B9E0050096FE535CC98039654C2D5C977D77E7379772B44806902897BDB00F76281BA80FEFD8FBD66535EAF0045DC97938F75FA9945643B8A7B1C4FB1B571F537947BDEF1AE61EFF477FA6D3F3FB3C417B729E7200090AAA2B4EBC46737E42F485333678EF537169CDD4A30BB8C98DFCE0B437BFD2327F39113529AE03D1E249752CDD9087529A043DCF29B57014A464B0982D7AC9B2E6A1964E9D2F8B9DF56CE8D57DBCBCD7DC098895E0E32C392184021800193AC602A88B522195ABE13A7BC6EF839579F793B92B0A44FADF25EDD92D06ACA8FE732F2919B91A3DB04A7E43700A673CB03DBA40CEE2B0DC749D006E0B82F2B2D41B3A0483B47ABB2F1D2F650DD49CCFEB9553F6A2D8CA06DBF25EA0F1779182CF142BE2444C2F1C5CD20C6520B0CC2444315217CA23C21275877E033B8E05FB71DD38720885104354A4C530E75FE495C2954E358DECAB599AB3B3158FB465D463CE44429035839BDF137E61DFC3E361376C8816204F46CCC02F4706EDD18B709C7374F2C47AFFB9B36AA93DA5507F152DE0466E478DA4FF7F686CBF86AF2D0E3FE57BBDC67BD6AC99B2236A6789F8BA130575B467F2C3FDB24BF5B76E9CA19445EA1818658FEB487D9DC2B65BD1012965F29975558871735BD5D6A08717AD47437E2A38224188F10C99DCF09261C1BB4532F12280DCCDBFE4F57D639B69987A8DF6E1255F0C273D15F79663DAEFBACEC4B4F4DDE2D2C16A90A0559D821114A797C7557F58F38B7D83CD8136909CB1A13378C8C38F791CF2F630B53261F2D5EF1EEE8E1D5EB23712A20584F5944E5683B9546B8F94BBA44060E66FB5A97DEE04E7119F0539DE70DECD624F2B71D50BFC9FC8704F823D6588A6040E1FDF1556E9FEC558EA9310594C887C471D689DBC0663F81F5AB5254815F3F71897101B5B9B3809F969F05AAD24401C8410A9A4ABACB391588400A7FAB71B70018C94237F50134095AAB43DDE66CD22E2C2D4B04C9D0A7A62D22289B77B511D5F2E437C21A16B1BDFC4F5EC2A7A90D2AC15A4662CA672C35CB58B1EB064F1CCAA0DBCD095BE77B33CA915F6F725242696E7EB4A1F14BFD1A5B4C651AC49D051F1F2EE2FC71D1177904538CF4358640091933527836A6F887C2512F43905344E789A8EFAB3061FBC0C81EB7F2490162D1778BEAA06A30A9F77FE1C6AF26C8826EE4E35D783F9D0200648606984DAE89ABD59E272B9E500F87192751D85BE20D20227A308923AE64973FF1EF28E798D75259D7E0649572057B89126BC524F4A7A3172CF9049F176F7045610E82F 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 4096, md_type = 7, padding = 0 -run_rsa 0103010701000100597A7F75C709816398E1C100B71F4516EF1F941139D67BD100E0A7DC643B375BB2623280B3036BCF71130C1E7DEE878FDC5CE71D46F830EC81B2F5A3936D9E8AC92ECBFA287FDC6F2B2DE8FF4A8D81F2AD08EFCCB18141C5E83CA143816B34B4F8AE239A8C46F559487E58E98255CF49E8BB924B6A1611D357ABC6065D15183859EC03FFFC7C3AFB0260F69929B694FEA1E9D24C3ADFD19B13E510891395900D47E58AEE34D28DBB0AC283138350BE42796F3C6C830324F3BB277D965ADF32FB5A37A8572994C0EFDE4EDB7E3CD2D5BE29FD87BE6BD75DCD8138CD7A465BFE6A9574F645CD6FF9A9E5D9586A81B4ED5E8E7DC4C14BF98B67CD7B06479AF6A0022A24F4A33B1569300A47CF9177A6B03E7E0E8C917156CD605AA7E812E03B3CE8941D4D84BD82D3BA791D3C5847ADBF28089BE60C15757274D1DBC8A91749DA4AB438C8C736E5C165335986E62F54620CF78AEC539FF0BC1E7D2A1F22191DE87CCB9CF23D4406C3432A4093AD205947D4DAFC87CFE5D70D585763E85805CF91F296AA91171C8817B7582D6E77B03A9D7680CD0C38EA5F0D8A091F9B140ED5B77437CEB3F75D17AEC75857889EA0A448E7215BABA9346CDCBB3AED241E3D07AC0E7311F31FE8993A7D884E3BF8ACE17CDCEB60157DEEC1090C7D82A9C61A53B58C4C6D712593BFD2086E2A1FB00819921677F7FF54F736C76EC85D6B61C4A04EA56A9DDBEAF7403DAE96108DCFC1FA57E941B4B19F820BD413D93BE91AFA9880E2612D5FBCAF2519F86E36533FA8FA68CFDACA41622F9B17D23607D179F4F800B4D27A6FAFD2E755DA5E61A14552C7304606D77E90206066C7F67FC55C539406BD1118FD8D272C7B9F49DC99749D87F352C8333B1F8C45C42D294712797A3E09C6F318FAD444B2E685D79174FC277D000551259A1C6F2A996E6FE6E9E1E4DE654537952F205AD69833E68D015A412D66D27F934B2F29B3325715E80FEFCB63B9D2D318B4F9CD2B6E35206199992CB385F122A3C4DF99DFACFE3491A1492943703D1B652FCE44B04145E5A20570306EAE0D172C08DEF1891AD1816612F97AFB71D7F41D55A8B2F3197CABFD183A8B86157BE54C1CE0EDAD8CDA429D07452751F1C0867441E317C2DEC7ADBB939CDE11623AEBDCCF23BDE889C120715F95AA03815B2789D38CD193266E17F20F44285585656BE0E6F6A54C09629EFA824D9B78796C56D8AC776EAB1288009BF5434379FADF3698E9A4124FC9438EF322C8BE0730043397F3EE5ADF3EC3A23A4C8252A7D36842477E02FBF049717EB1D5720DC2752FA366DE3B2299AA42942348FB9F637893F2B5485EE823F60AEC4C09076F99579F3B5A3C2351F5F2FA89AC8D38B30D94349D5C344153AEF2F3035DF5BA2DCA558727FD4315507B8DB1FE53855C392DA91B55397C49407725B78EF8F1384F855E61 0102030400000000000000000000000000000000000000000000000000000000 -#test_validate_signature() passed: key size = 4096, md_type = 7, padding = 1 -run_rsa 01030008010001006F669B8FA917E65AD2BEA1E2DB10AC204BDF1DF43CE40D24CEDAD0A366B895F271FE5B0E06DD81D5AB1F874CBE2D0CFA44515B0B07366D4D791AC4D45FBE60495D07AF7BF5B99B07B1249A78B79E46B4F293A00D4464CAE122D4EECF2EC489CFF0EFFC6B84D0FBF457AC5E482A9B85901F9EAF04A1FA035CC76B2127D46CF857864EEE3128A6D5FD6890C7AC57CC1A7BC6AEC31F70C8655212BEC27DDF53A85627FED584317CADB80251A5B08822015B257386B3A4153BB5E2BC62C5DC1A16BC0A2CCB285C07E0252A5EBC452EAFBB001CCC582C015699E445FC0D988D1E8D3A112F22BB8ED1F3154CD7C5CFDDAFDF611B4717966EA25FBC95C656F2EACEE3D5E123DF3FFFD849AE4195E96CE2028E8ECB6B719B172A88BA032756156FE2E8D6CD58ED957D5D5E90EC837CE28FE4027A52BD17B106EE99587813967D6DCD0D0060FBC332C3EB1D5E8C9CD8C886A46776EE082AF6DA4812AAF582D350531F3CB158A97383620AFD859ADFFA51F8A422092A831BBEFB4DA99172853250ECA3CC5A7EE679DB5BE8A1EA085A183EEC3F0E8D3182F0D6F41BBCE27EED69DE0FA53A6B718E2C59F9798F6F30908653381F96A42234F42D2405782D3A26A6577FAC07714F3CB551DD77A662DCEF7D27000C547AFC7F9141BCCDBED6331F4073D335027F5DF42D47114E0268F281103B4EE37BC04E45B66E9EC9F7B2B8C3F9C46A0AEAC926F307ED1F5B4C68D62EBFF5C19B6BFD19F0E85CA8EFAF9486930D7F7E7FDA3838C1006E65DDD206DEDA42E5F3AD5D4E77621563A418386E76EEE7038C5BA2ABC005BBDE9D303B4A40533D80D3745E34ACC4D10F4854830F3A28CE0E330C0ADDFBA2B178EA84EF864345B3D357EFD9D676170C4CC840751D7EDC1A8B428A2E35164839A2BB71E42536CC6F1551B16ED29EEA245D46A9AEB93AEBFD6109B8E1E620F871028E38715D9AEF77C21FFD836182674EC9DE64CE88AFB13B1E8ABF721756182B06487772FDCAA9A06CC59AFA47741175E772BD660F7CC3DDF1E3A76CB90EF205F139B7D89B2A845E8B4BECDEFDA87B6ED5343D96CD44D506C958552D63BE23F22CAFD3565DA5EA98F73DF118D3CA32A2D72FF82A9C91BE7AEEE7E6365A75FC5489AC5277B10E6B16CFD72431455116EF2607736E6C05C44F2F13AA07FD0ADD2A252F0C6FB33E273F2E3A48923521636C91651B3555BD53E3B42AAF24495D441603B3EEB633A49E449501095AA08A975B25F3AE444E665B10FF1E69320B3BCE9A214CB89B5599A6C4CB27789D209CFF1C14EF2221CD03F4A9BBFC4134A1B1B9EEE0AFA75D1FD9547DE4C72A277028312675E9DB6DED4BBD743286ED9463D723779F90B77F7D4B90470F24B1D48264D029CA85B4AEE7AB60B399A5A7A69A67AA21140A1077E73CB2837040C924A8DC1B43A8E4A87A298E43964C45887A64 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 8, padding = 0 -run_rsa 0103010801000100BDC474AF10CFB7833B52DA4CA2526DC1DD672019D78096569547D9F7B7833A7DC650C68F279BBAB5E38834118E03C58D6E33C9F6E71CC2BD61B7B0F8B3FFEAE13C366DE6023C8897D46BAD742B8A012A80D6ECA027581231CB7C4889DEF09FE170933B43DFF0A0BB6D88DC771FCD981336CA98074E37D7542802CDDB13AE9408829161E985A2FA6E8C51B7817301B1A7629E0315FAD275C021A1A5B5DD537C825CC5E4AC77E59A3F09CC14F94FEEDFFEE55580A63D1467B86D1A81679A6CA96300FDC759FC582CA60BAD508D2E55C449E274F99045DBC25F506CF7CA5B663FEAC1151D6E80C7E60DCAF515D7B0CAE32CDD44000B36855801A957ECECA23DD0763E35811871F81A58641284E6CC6AE33151734A3C53332AFC910B9706C5539D30FFB3166845331172E7382DA0295D25D3C30FF63805940FD19AFECF719ABDE8F82B2FF6BF261264E19A3986B1FE39DDBC859C8574E495ABEFD891732EBEFD7BBBE2DE4A09FA68C986AAD5B7863F1662CE6285F4DC29C91EE858F26C437D2E1BC90FBBCA5C392B92E40E5FE94F07596606BC7EC9B6D39EC3C06D99F35A1D9991446E6250D3DFF6D7EA224E3D62EA7ADE98CD72B68974E5BC1EC1BAC40EB2F3B3BE17BA293599B0FACC1B16183B57751A60A794B5D3D917C49A947D7C5059C974C863300FFA1FC5A7EB3FBCF301CFDB92ADE504F740311ACB464140140C37944EE3081484C76854C849098F797295A94CF4E6E680AD808846E9000EE3FBF41CB47441DC1384F49E3BD6417C1172730CCFD3B94F6857D71A562586751625CF566ABCF37511E5ED0C8E2091BF97BB61C46A666F426EE3684BB0EEF0E87C0F6BB3ECA3179F0457F301A90F74ECB32C482FBBD5F6D9BF2B0B3F016990423F5DE0AC15B13E3AE5385E5D3378083B2F54EA803EF97AA578C3C6BF0080D8A6DC0BB69BD14B14382ADC5A83FBABB169FDCCAB6D02CA72B46D036C569570841A18016E28B6209BA95296C835D2F9798838B9F0EF6402914F96C323C0AC6EC4F3B2C68F660F0E52B7BB391BEC7BEE77B40C8E3923C6D78F97F9737108DF799BE034F4A8704CC9069A07648A297432142567A0A47446CEB2C707A34DE316D04CAAB1C14EFE30B5D6F141C5B33320BB06487C0224F3CB293B2841251CF1D8979EB106EF128BF586619B7313661B51F12328D15741EB0644D0F9788115EE36C16E59D3A28B78AD32663104F658E8AB4FF5C5CAC6C710B4E0B8ABDCD08DC8D6C11512B1AE2D69D61AB1F5837D51F9F7DDD151823A93665446BB0B0DAB1BB7533A6F98661E6E953EB1FBD8C7416B9003BDB8F02607A065CED2E6DF955F739574B977273A662012AAD8C059B591F8671D58322C2FE18462A1B1DA19B4F7904E96DF4F95707CF0D5A9BD4C1C553231593F56C028EC01A245D746C1087C9023BE45CC853C248CE9F2789A 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 8, padding = 1 -run_rsa 0103000901000100816E6B9861293308267D01C6C36221AFB1EDB87CFAF82E45BE31B98ED8423F788D5BA54476221B7A79F6DE176E6CEE8D8336DEE0FE50385D9219364AA31F8125A164345C56DBC1932682F4642735AC796C10E2CFF516C8B80EF7B7004F3B280987A2269285C18C7DDEB68CE7293574A92A74624FF85910161AE5EFE9AC98D7F385B8A88DDE1148CFD77A75E53AD7371D3CF0237B1E2F30DB995C258C8A01C059CD8D19E2F0CF40D57037534DEB052EC9CC9E97C7E2F91E5AB36A2B2135AC0C14BB05E98941DA761674D5285C0C671D6FDFA701D53DA47FA9B764CD5F434D86EE3EB4C3F982846513DD16A2D6B7B29D480588CC803595A31ECA115D581492DEE7B4D1A7F0D3CF6F65D4C1FBC0075A40E146E5C3D703048AE26C800930F936D3734A6770F0962998995C7B4F9672984113698D528C362645FE917BDFC93A598AF4FF6D1081EDD5C018FE3155119DFEDA4B4BDA6E8DE9D3840F332EAFC94DC69CB407BEEB82235C0AC2301D8D38BBA661C7E5C7741CF360AE7942D94C5D22DFE469D417B311AA973CF2AA305B1EDE75AC60658BCC85534C68D6B1035EDBE029113D1D6E396820667127BFD64E3C5BBF62A705A535040528307FA616FB317A20057006C42384E083A0F3883EA7C7AEA79511E07E83C0DF6E12308B168DCCBDE9AE41C493E561FD5085F88D748FD20C3459531458558B72924A1A61B941ED95526ACB909347526458EA4AD0126E638BC0E83A8111B88CCE6EF1370B3E72615388C5DE4B4B57A7C46FFEF9DEA7BB19F1CE9119F16CEFF7D053B87BC94BAAB0F6FBEFB14D8D586405543FE4D6391AD0E16C2FBF318CC6A055A857975CCE0BA34AE5E872DAB42D948885DA651663FFFF2C81A91E5BE6753889BEBBD508002C89974DE6A2AF5CFD6FE3685D2A4A80F7B11CBD917DEF83A7FD9B906A283CB2A6CAC38064EFBC677181BAEE3A46B3B5856257D97BF14EA897E460B043C3363D8E40226C1AD0D026312DC3F6816FE04C4E0CF92A7EB5621C4A8F98530BA386FBA550A660ED7716113B4B7B8F7D0AA3CC282E69788B20E49FBFE9519728AC47438B1D44B78A9468EC14A744EDA3C18487085D9B1C6F9E91F655A4AE45B5D7558268DE6FE2C489C6566BF63697003D5C617BAEE6D015F97DEBCC8A2CA6EDCF0A4786BF098C863F055EFD2726A3CE09F2F6544529B1BE4EF4AA07938510BDC94C5BF89E144BED922898C68218B7D894F24F0E5CBD88FC476EDCCBE3FCF44F8D0C4769E83BC07CD97350CDEA935D77F04DB57198E730CA849DF76FE651D34974FC24C9716C04CD48178D4DE69186BAE3D163E691910E9B21D1AA6E14FE5A176F556F200EBFEAFA4FF10D137FBEC84DFA346EA61691CA07BD4FF96C067689DB64475CFB95523A00BECDB70F5DB9C4E1E462150B91CA2FBF763330C8139302AC5341EAE41D7A6A3A7F 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 9, padding = 0 -run_rsa 0103010901000100791D91A7222F3BC8719710C7483C1778FB8F910BDCB74724F95F5C41CBCC23A3B100F87FCDA442C96D33E27413FBC789ECB79812FB5A39408B848DDE9F51C8F9D5DB23C29AFBF08DD47CEFD61E711345B876A08620324B2C651AA12AB6472A6A14F46CC77EC93EC00BF841DD4EF710269C23803ACB056610D64AC2E5DB84AEB970CC60719653B2BC0D5E7A6FB3DEF5B6913B28570881192193C7CBD56704BA2FFED93EA11F0C8942655CC8DD7B31B040ABA4E26D2714E81C4E6835BD0676C0B36265049B87A238C919F35A612F13F1F0B5510F2BBD376A73E12591CEBEBFCA46CA2C1CA54824FD65894E629C934EF1682ECF4C348541247A55831D76D3924760B16FC80BD06BC964B722A3D3C8A25369F9480CCAE538A159D6FCCF89912C3761E326AE7F89E88F6C8989E3C5EDE816A5C4B3D296A664E8271273D196829E04B151185B51232458EE6A1C34871D8A8EB422A768F250553F8F6DE05D3582313576B27250A6D723AE507E8B282DA95DC764F02D7B934F1398665E82EC62A7130AC5B971E0CBB2F707FF2DE60E4CE2F04F62CC3AAB1D917EFDB76D64C51078A9B1A7563563E3EF91E66BE2EB8CAA41E622FB068257D7B13EAAEBFDCC55A2FA03E585A58A165DF07FFA22DE16E960967F6876EC3ACA117BBDDC38F26E8501F78AC1980B0E501717DB5DD1A84F288F0FC7B04CEE731FF08B7104F6F605C12CCF564FC4B9A0A4C984AD9FD4EE29F09C5E48C677C2A8FD5409EB61BD62074E5ACF0034B22CC23AB6DE07CB9EBACA3775119758E65F17146EA6178C25E26F374E6D7E181AADC9D68DC0461D36B36298AD21766136638024577ADCA23DA6368DE8E3AEF6AEBD3D2A93F6B1210141091A60E58BD4DCA4C1322168A3DC93450FB12D45F3F61CC5D61B06028FED69E41E88335084B8DE13F14E220F665F16884BE7E11DD68DF0402DB46EEF9B9D5BB30DC21CA8CDDFF1514D952A6DB62E359DF27E7962BA4745600CAC4E39C70CA9CA70043549DF5823ED2A78CA6515C593072D32CC2F91E5160BEC1979CEB080DCAE53886ED69000236E6ACCBB083CD9E9FEB9370163B136EC5C5CD320EF0045D547CF9E9DFD6F320C1506DC07E6BB55C3EFE9DDFB333A0BD3B744650BC7AC55755FA9C95A60389890D10FAB4F166B3386C8AFE03ADAE11578B7B8BF640F544932A8DAF026178B5FCF7EE74C11AE8966AD35A305754375AF8962B6AB0E4CCAC54119980D4A5D821A9A7F19F8B781FC68C532C08BE63F2168EC7AEE6023ABB991F0FC1E6C0D9DE58B0A928401EF912F0B1AA0E263B2261FF9767E105A2600B072C6E57471BC9130BED7C1B6DEC1050ABB4236B83B6D858B0DD01DB912D894E1070C68161DB6FB555B92FDABFDF9F5D4894952ACDA9B6E80F093B117CDE1EDC64DC737970FC0DEF57A6F031342F2C99ED1954BBCEAE4AF867680 0102030400000000000000000000000000000000000000000000000000000000 -# test_validate_signature() passed: key size = 4096, md_type = 9, padding = 1 diff --git a/tests/validate_signature_rsa/run.sh b/tests/validate_signature_rsa/run.sh deleted file mode 100644 index f38bcb4..0000000 --- a/tests/validate_signature_rsa/run.sh +++ /dev/null @@ -1,7 +0,0 @@ -set -e -cd "$(dirname "${BASH_SOURCE[0]}")" -mkdir -p build.simulator -cd build.simulator -cmake -DCMAKE_C_COMPILER=clang ../../.. -make all -../build.simulator/validate_signature_rsa diff --git a/tests/validate_signature_rsa/testing_results.md b/tests/validate_signature_rsa/testing_results.md deleted file mode 100644 index 80b3814..0000000 --- a/tests/validate_signature_rsa/testing_results.md +++ /dev/null @@ -1,123 +0,0 @@ -# Testing Results for validate_signature_rsa - -Following [ckb-contract-guidelines](https://github.com/nervosnetwork/ckb-contract-guidelines) - - -### Rule 1: 100% test coverage -Uncomment the following in CMakeLists.txt to enable: -```text -# uncomment it for coverage test -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") -#add_definitions(-DCKB_COVERAGE) -``` -Then use ```tests/validate_signature_rsa/run.sh``` to run the whole test case and get coverage results. - -Every branch is covered as much as possible, see "iso97962_error_cases_test", -"validate_signature_error_cases_test" in "tests/validate_signature_rsa/validate_signature_rsa_sim.c". -They're created to cover corner cases. - -The final results is 92%. The code is not fully covered by test case due to some reasons: -1. Already checked condition makes some code unreachable, for example, the following ASSERT(false) -is unreachable due to being checked before use. -```C - if (key_size_enum == CKB_KEYSIZE_1024) { - return 1024; - } else if (key_size_enum == CKB_KEYSIZE_2048) { - return 2048; - } else if (key_size_enum == CKB_KEYSIZE_4096) { - return 4096; - } else { - ASSERT(false); - return 0; - } -} -``` - -Comments are added on some place for this reason. - -2. We can't cover full ISO 9796-2 cases due to not enough data. -It happens in ```get_trailer_by_md```: we now only use SHA1. - -### Rule 2: Multiple execution environment for tests - -#### Normal CKB-VM as used in CKB -```bash -run tests/validate_signature_rsa/run-in-vm.sh -``` - -#### At least 20 runs of CKB-VM running in chaos mode -Rebuild ckb-vm with -```text -cargo build --release --features "enable-chaos-mode-by-default" -``` -And then run: -```bash -run tests/validate_signature_rsa/run-in-vm.sh -``` - - -#### Native x64 environment for gathering test coverage -See rule 1. - -#### LLVM Undefined Behavior Sanitizer -See below. - -#### LLVM Address Sanitizer -Uncomment the following in CMakeLists.txt to enable: -``` -# uncomment it for sanitize -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined") -``` - -There 2 issues detected: - -1. An overflow issue is detected and it's intended: - -```C -uint8_t *get_rsa_signature(RsaInfo *info) { - int length = get_key_size(info->key_size) / 8; - // note: sanitizer reports error: - // Index 256 out of bounds for type 'uint8_t [128]' - // It's intended. RsaInfo is actually an variable length buffer. - return (uint8_t *)&info->N[length]; -} -``` - -2. The warning from mbedtls: -```text -Load of misaligned address 0x7ffee94dd25c for type 'size_t' (aka 'unsigned long'), which requires 8 byte alignment -``` -It happens in memory allocation in mbedtls source code. It's difficult to change. - -### Fuzzing test on ckb_dlopen2 -This work is contributed by Trail of Bits. It only works for "ckb_dlfcn.h", mainly for the function "ckb_dlopen2". - -```bash -make -./dlopen_fuzzer -workers=40 -jobs=40 corpus -``` -adjust "40" to CPU cores of your machine. It's great to put some dynamic library files in "corpus" folder first: -```bash -cp ../../build/always_success corpus/ -cp ../../build/validate_signature_rsa corpus/ -``` - -Get code coverage by: -```bash -make report -make show -``` - -#### heap-buffer-overflow at "context->dynstr + sym->st_name" -This issue is resolved by post-checking. -```C - // here the fuzzer reports "heap-buffer-overflow" issue - // we will check "str" in range next - const char *str = context->dynstr + sym->st_name; - // issue: - // 9. Possible out-of-bounds read in ckb_dlsym - if (!check_in_range(str, context)) { - return 0; - } -``` - diff --git a/tests/validate_signature_rsa/validate_signature_rsa_sim.c b/tests/validate_signature_rsa/validate_signature_rsa_sim.c deleted file mode 100644 index 2e1e621..0000000 --- a/tests/validate_signature_rsa/validate_signature_rsa_sim.c +++ /dev/null @@ -1,818 +0,0 @@ - -// uncomment to enable printf in CKB-VM -//#define CKB_C_STDLIB_PRINTF -//#include - -#if defined(CKB_COVERAGE) || defined(CKB_RUN_IN_VM) -#define ASSERT(s) (void)0 -#else -#include -#define ASSERT assert -#endif - -#include - -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/entropy.h" -#include "mbedtls/md.h" -#include "validate_signature_rsa.c" - -#define EXPONENT 65537 - -#define count_of(arr) (sizeof(arr) / sizeof(arr[0])) - -#if defined(CKB_RUN_IN_VM) -int rand(void) { return __LINE__; } -#endif - -int mbedtls_hardware_poll(void* data, unsigned char* output, size_t len, - size_t* olen) { - return 0; -} - -int iso97962_sign(ISO97962Encoding* enc, uint8_t* msg, int msg_len, - uint8_t* block, int block_len) { - int err = 0; - const mbedtls_md_info_t* digest = mbedtls_md_info_from_type(enc->md); - int dig_size = digest->size; - int t = 0; - int delta = 0; - - if (enc->trailer == TRAILER_IMPLICIT) { - t = 8; - delta = block_len - dig_size - 1; - mbedtls_md(digest, msg, msg_len, block + delta); - block[block_len - 1] = (uint8_t)TRAILER_IMPLICIT; - } else { - t = 16; - delta = block_len - dig_size - 2; - mbedtls_md(digest, msg, msg_len, block + delta); - block[block_len - 2] = (uint8_t)(enc->trailer >> 8); - block[block_len - 1] = (uint8_t)enc->trailer; - } - - uint8_t header = 0; - int x = (dig_size + msg_len) * 8 + t + 4 - enc->key_size; - - if (x > 0) { - int msg_rem = msg_len - ((x + 7) / 8); - header = 0x60; - delta -= msg_rem; - memcpy(block + delta, msg, msg_rem); - } else { - header = 0x40; - delta -= msg_len; - memcpy(block + delta, msg, msg_len); - } - - if ((delta - 1) > 0) { - for (int i = delta - 1; i != 0; i--) { - block[i] = (uint8_t)0xbb; - } - block[delta - 1] ^= (uint8_t)0x01; - block[0] = (uint8_t)0x0b; - block[0] |= header; - } else { - block[0] = (uint8_t)0x0a; - block[0] |= header; - } - err = 0; - return err; -} - -void dump_as_carray(uint8_t* ptr, size_t size) { - for (size_t i = 0; i < size; i++) { - if (i == (size - 1)) { - mbedtls_printf("0x%02X\n", ptr[i]); - } else { - mbedtls_printf("0x%02X,", ptr[i]); - } - } -} - -void print_string(uint8_t* ptr, size_t size) { - for (size_t i = 0; i < size; i++) { - if (i == (size - 1)) { - mbedtls_printf("%02X\n", ptr[i]); - } else { - mbedtls_printf("%02X", ptr[i]); - } - } -} - -static unsigned char get_hex(unsigned char c) { - if (c >= '0' && c <= '9') - return c - '0'; - else if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - else if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - else - return 0; -} - -static int scan_hex(const char* s, unsigned char* value) { - if (s[0] == '\0' || s[1] == '\0') return 0; - - unsigned char high_part = get_hex(s[0]); - unsigned char low_part = get_hex(s[1]); - - *value = (high_part << 4) + low_part; - return 1; -} - -static uint32_t read_string(const char* str, uint8_t* buf, uint32_t buf_size) { - size_t sig_len = strlen(str); - const char* ptr = str; - const char* end = str + sig_len; - - uint32_t i = 0; - while (1) { - unsigned char c = 0; - int consumed = scan_hex(ptr, &c); - if (consumed == 0) break; - if (i >= buf_size) break; - buf[i++] = (uint8_t)c; - ptr += consumed * 2; - if (ptr >= end) break; - } - return i; -} - -void mbedtls_mpi_dump(const char* prefix, const mbedtls_mpi* X) { - size_t n; - char s[1024]; - memset(s, 0, sizeof(s)); - - mbedtls_mpi_write_string(X, 16, s, sizeof(s) - 2, &n); - mbedtls_printf("%s%s\n", prefix, s); -} - -void dup_buffer(const unsigned char* src, int src_len, unsigned char* dest, - int dup_count) { - for (int i = 0; i < dup_count; i++) { - for (int j = 0; j < src_len; j++) { - dest[i * src_len + j] = src[j]; - } - } -} - -typedef struct mbedtls_test_rnd_pseudo_info { - uint32_t key[16]; - uint32_t v0, v1; -} mbedtls_test_rnd_pseudo_info; - -int mbedtls_test_rnd_pseudo_rand(void* rng_state, unsigned char* output, - size_t len) { - for (size_t i = 0; i < len; i++) { - output[i] = (unsigned char)rand(); - } - return 0; -} - -void srand(unsigned seed); -long time(long*); - -int fake_random_entropy_poll(void* data, unsigned char* output, size_t len, - size_t* olen) { - *output = (unsigned char)rand(); - *olen = len; - return 0; -} - -int gen_rsa_key(uint32_t key_size, mbedtls_rsa_context* rsa, RsaInfo* info) { - int err = 0; - mbedtls_entropy_context entropy; - mbedtls_ctr_drbg_context ctr_drbg; - const char* pers = "rsa_genkey"; - - mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_entropy_init(&entropy); - int padding = convert_padding(info->padding); - // The hash_id in the RSA context is the one used for the verification. - // md_alg in the function call is the type of hash that is verified. - // According to RFC-3447: Public-Key Cryptography Standards (PKCS) #1 v2.1: - // RSA Cryptography Specifications it is advised to keep both hashes the same. - mbedtls_rsa_init(rsa, padding, info->md_type); - - err = mbedtls_entropy_add_source(&entropy, fake_random_entropy_poll, NULL, 32, - MBEDTLS_ENTROPY_SOURCE_STRONG); - CHECK(err); - - err = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, - (const unsigned char*)pers, strlen(pers)); - CHECK(err); - - err = mbedtls_rsa_gen_key(rsa, mbedtls_ctr_drbg_random, &ctr_drbg, key_size, - EXPONENT); - CHECK(err); - - err = 0; - -exit: - mbedtls_ctr_drbg_free(&ctr_drbg); - mbedtls_entropy_free(&entropy); - return err; -} - -int rsa_sign(mbedtls_rsa_context* rsa, const uint8_t* msg_buf, - uint32_t msg_size, uint8_t* sig, RsaInfo* info) { - int err = 0; - mbedtls_md_type_t md_type = convert_md_type(info->md_type); - const mbedtls_md_info_t* md_info = mbedtls_md_info_from_type(md_type); - - uint32_t hash_size = md_info->size; - uint8_t hash_buf[hash_size]; - - mbedtls_test_rnd_pseudo_info rnd_info; - - memset(&rnd_info, 0, sizeof(mbedtls_test_rnd_pseudo_info)); - ASSERT(mbedtls_rsa_check_privkey(rsa) == 0); - err = md_string(md_info, msg_buf, msg_size, hash_buf); - CHECK(err); - - err = mbedtls_rsa_pkcs1_sign(rsa, &mbedtls_test_rnd_pseudo_rand, &rnd_info, - MBEDTLS_RSA_PRIVATE, md_type, hash_size, - hash_buf, sig); - CHECK(err); - err = CKB_SUCCESS; -exit: - return err; -} - -int rsa_verify(mbedtls_rsa_context* rsa, const uint8_t* msg_buf, - uint32_t msg_size, const uint8_t* sig) { - int err = 0; - uint8_t hash_buf[32] = {0}; - uint32_t hash_size = 32; - - ASSERT(mbedtls_rsa_check_pubkey(rsa) == 0); - err = md_string(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), msg_buf, - msg_size, hash_buf); - CHECK(err); - err = mbedtls_rsa_pkcs1_verify(rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, - MBEDTLS_MD_SHA256, hash_size, hash_buf, sig); - CHECK(err); - - err = 0; -exit: - return err; -} - -int rsa_random(void) { - int err = 0; - - int alloc_buff_size = 1024 * 1024; - unsigned char alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - uint32_t key_size = 1024; - uint32_t byte_size = key_size / 8; - - uint8_t msg[32] = {1, 2, 3, 4}; - uint8_t sig[byte_size]; - mbedtls_rsa_context rsa; - RsaInfo info = {0}; - info.algorithm_id = CKB_VERIFY_RSA; - info.key_size = CKB_KEYSIZE_1024; - info.padding = CKB_PKCS_15; - info.md_type = CKB_MD_SHA256; - - err = gen_rsa_key(key_size, &rsa, &info); - CHECK(err); - - err = rsa_sign(&rsa, msg, sizeof(msg), sig, &info); - CHECK(err); - - err = rsa_verify(&rsa, msg, sizeof(msg), sig); - CHECK(err); - - err = 0; -exit: - if (err == CKB_SUCCESS) { - mbedtls_printf("rsa_random() passed.\n"); - } else { - mbedtls_printf("rsa_random() failed.\n"); - } - return err; -} - -void export_public_key(const mbedtls_rsa_context* rsa, RsaInfo* info) { - uint32_t key_size = get_key_size(info->key_size); - mbedtls_mpi N, E; - mbedtls_mpi_init(&N); - mbedtls_mpi_init(&E); - int ret = mbedtls_rsa_export(rsa, &N, NULL, NULL, NULL, &E); - ASSERT(ret == 0); - mbedtls_mpi_write_binary_le(&N, info->N, key_size / 8); - mbedtls_mpi_write_binary_le(&E, (unsigned char*)&info->E, sizeof(info->E)); -} - -int test_validate_signature(uint8_t key_size_enum, uint8_t md_type, - uint8_t padding) { - int err = 0; - - int alloc_buff_size = 1024 * 1024; - unsigned char alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - uint32_t key_size = get_key_size(key_size_enum); - uint8_t msg[32] = {1, 2, 3, 4}; - uint32_t sig_buff_size = calculate_rsa_info_length(key_size); - uint8_t sig_buff[sig_buff_size]; - RsaInfo* info = (RsaInfo*)sig_buff; - - mbedtls_rsa_context rsa; - - info->algorithm_id = CKB_VERIFY_RSA; - info->key_size = key_size_enum; - info->padding = padding; - info->md_type = md_type; - - err = gen_rsa_key(key_size, &rsa, info); - CHECK(err); - - uint8_t* ptr = get_rsa_signature(info); - err = rsa_sign(&rsa, msg, sizeof(msg), ptr, info); - CHECK(err); - - export_public_key(&rsa, info); - - uint8_t output[20]; - size_t output_len = 20; - -#if 0 - printf("sig = "); - print_string(sig_buff, sig_buff_size); - printf("msg = "); - print_string(msg, sizeof(msg)); -#endif - err = validate_signature(NULL, sig_buff, sig_buff_size, msg, sizeof(msg), - output, &output_len); - CHECK(err); - - uint8_t pubkey_hash[20]; - get_pubkey_hash(info, pubkey_hash); - CHECK2(memcmp(pubkey_hash, output, 20) == 0, ERROR_WRONG_PUBKEY); - CHECK2(output_len == 20, ERROR_WRONG_PUBKEY); - - err = 0; -exit: - if (err == 0) { - mbedtls_printf( - "test_validate_signature() passed: key size = %d, md_type = %d, " - "padding = " - "%d\n", - key_size, md_type, padding); - } else { - mbedtls_printf( - "test_validate_signature() failed: key size = %d, md_type = %d, " - "padding = " - "%d\n", - key_size, md_type, padding); - } - return err; -} - -void reset_rsa_info(RsaInfo* info) { - info->algorithm_id = CKB_VERIFY_RSA; - info->key_size = CKB_KEYSIZE_1024; - info->padding = CKB_PKCS_15; - info->md_type = CKB_MD_SHA256; -} - -int validate_signature_error_cases_test(void) { - int err = 0; - - uint8_t padding = CKB_PKCS_15; - uint8_t key_size_enum = CKB_KEYSIZE_1024; - uint8_t md_type = CKB_MD_SHA256; - uint32_t key_size = get_key_size(key_size_enum); - uint8_t msg[32] = {1, 2, 3, 4}; - uint32_t sig_buff_size = calculate_rsa_info_length(key_size); - uint8_t sig_buff[sig_buff_size]; - RsaInfo* info = (RsaInfo*)sig_buff; - info->algorithm_id = CKB_VERIFY_RSA; - info->key_size = key_size_enum; - info->padding = padding; - info->md_type = md_type; - - size_t len = 0; - load_prefilled_data(NULL, &len); - mbedtls_hardware_poll(0, 0, 0, 0); - - reset_rsa_info(info); - err = validate_signature(NULL, sig_buff, sig_buff_size, msg, sizeof(msg), - NULL, NULL); - CHECK2(err == ERROR_RSA_VERIFY_FAILED, -1); - - reset_rsa_info(info); - info->algorithm_id = 100; - err = validate_signature(NULL, sig_buff, sig_buff_size, msg, sizeof(msg), - NULL, NULL); - CHECK2(err == ERROR_RSA_INVALID_ID, -1); - - reset_rsa_info(info); - err = validate_signature(NULL, NULL, sig_buff_size, msg, sizeof(msg), NULL, - NULL); - CHECK2(err == ERROR_RSA_INVALID_PARAM1, -1); - - reset_rsa_info(info); - info->md_type = 100; - err = validate_signature(NULL, sig_buff, sig_buff_size, msg, sizeof(msg), - NULL, NULL); - CHECK2(err == ERROR_INVALID_MD_TYPE, -1); - - reset_rsa_info(info); - info->padding = 100; - err = validate_signature(NULL, sig_buff, sig_buff_size, msg, sizeof(msg), - NULL, NULL); - CHECK2(err == ERROR_INVALID_PADDING, -1); - - reset_rsa_info(info); - info->key_size = 100; - err = validate_signature(NULL, sig_buff, sig_buff_size, msg, sizeof(msg), - NULL, NULL); - CHECK2(err == ERROR_RSA_INVALID_KEY_SIZE, -1); - - reset_rsa_info(info); - err = validate_signature(NULL, NULL, sig_buff_size, msg, sizeof(msg), NULL, - NULL); - CHECK2(err == ERROR_RSA_INVALID_PARAM1, -1); - - reset_rsa_info(info); - err = validate_signature(NULL, sig_buff, sig_buff_size, NULL, sizeof(msg), - NULL, NULL); - CHECK2(err == ERROR_RSA_INVALID_PARAM1, -1); - - reset_rsa_info(info); - err = validate_signature(NULL, sig_buff, 0, msg, sizeof(msg), NULL, NULL); - CHECK2(err == ERROR_RSA_INVALID_PARAM2, -1); - - err = 0; -exit: - if (err == 0) { - mbedtls_printf("validate_signature_error_cases_test() passed.\n"); - } else { - mbedtls_printf("validate_signature_error_cases_test() failed.\n"); - } - return err; -} - -// cover all test cases -int validate_signature_all_test(void) { - int err = 0; - uint8_t md_type_set[] = {CKB_MD_SHA224, CKB_MD_SHA256, CKB_MD_SHA384, - CKB_MD_SHA512}; - uint8_t key_size_set[] = {CKB_KEYSIZE_1024, CKB_KEYSIZE_2048, - CKB_KEYSIZE_4096}; - // uint8_t key_size_set[] = {CKB_KEYSIZE_1024}; - uint8_t padding_set[] = {CKB_PKCS_15, CKB_PKCS_21}; - for (int i = 0; i < count_of(key_size_set); i++) { - for (int j = 0; j < count_of(md_type_set); j++) { - for (int k = 0; k < count_of(padding_set); k++) { - err = test_validate_signature(key_size_set[i], md_type_set[j], - padding_set[k]); - CHECK(err); - } - } - } - err = 0; -exit: - if (err == 0) { - mbedtls_printf("validate_signature_all_test() passed.\n"); - } else { - mbedtls_printf("validate_signature_all_test() failed.\n"); - } - return err; -} - -int iso97962_test2(void) { - int err = 0; - const char* N_str = - "9cf68418644a5418529373350bafd57ddbf5626527b95e8ea3217d8dac8fbcb7db107eda" - "5e47979b7e4343ed6441950f7fbd921075579104ba081f1a9af950b4c0ee67c2eef2068d" - "9fe2d9d0cfdcbb9be7066e19cc945600e9fd41fc50e771f437ce4bdde63e7acf2a828a4b" - "f38b9f907a252b3dfef550919da1819033f9c619"; - const char* E_str = "10001"; - const char* msg_str = "B30D0D9FA0C8BBDF"; - const char* sig_str = - "46E52F52599A97B7DBBB8BCDD3A3BE6857F4CEF41B0723BE9FBD404DCF471DFC00D2DBF2" - "F5DA6A9B8C1A41893A569873CAD2E90EECEC84DEE85DCDE76041390D1E1328751F2832C8" - "3699986744AF68087EFFB21CD9526317424C136911144AE31B00F1764F1C5CCD974D52F6" - "278B029197C5746E62F67C544FA5C9B66E2A8AFB"; - const char* plaintext_str = - "6A51762ED9802385DD5AE676C603778A037FFDCCD2BA92E32DD3AECE0C31AF76CFF88F75" - "B257930255EA361218BEDCC4B1A96BBC9BCCF77BF6BA4B4A7F847F475F81C1FDD30C74B6" - "AC97732C32D4B23C4BF8200270F5F15FED198E80AA5089807B9861E374D3871509C9965A" - "AD886D9FB5A345873A4EB58EEFA5C35A4C3B55BC"; - - mbedtls_rsa_context rsa; - mbedtls_mpi N; - mbedtls_mpi E; - - uint8_t msg[8]; - uint8_t sig[128]; - uint8_t block[128]; - uint32_t sig_len = 0; - uint32_t msg_len = 0; - uint8_t m1[128]; - uint32_t m1_len = 128; - uint8_t full_msg[1024]; - uint8_t new_msg[1024]; - uint32_t new_msg_len = 1024; - - int alloc_buff_size = 1024 * 1024; - unsigned char alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - mbedtls_mpi_init(&N); - mbedtls_mpi_init(&E); - - mbedtls_mpi_read_string(&N, 16, N_str); - mbedtls_mpi_read_string(&E, 16, E_str); - mbedtls_rsa_init(&rsa, MBEDTLS_RSA_PKCS_V15, 0); - mbedtls_rsa_import(&rsa, &N, NULL, NULL, NULL, &E); - - sig_len = read_string(sig_str, sig, sizeof(sig)); - ASSERT(sig_len == 128); - msg_len = read_string(msg_str, msg, sizeof(msg)); - ASSERT(msg_len == 8); - - err = mbedtls_rsa_public(&rsa, sig, block); - CHECK(err); - - ISO97962Encoding enc = {0}; - iso97962_init(&enc, 128, MBEDTLS_MD_SHA1, false); - err = iso97962_verify(&enc, block, sizeof(block), msg, msg_len, m1, &m1_len); - CHECK2(err == 0 || err == ERROR_ISO97962_MISMATCH_HASH, - ERROR_ISO97962_INVALID_ARG9); - - memcpy(full_msg, m1, m1_len); - memcpy(full_msg + m1_len, msg, sizeof(msg)); - - err = iso97962_verify(&enc, block, sizeof(block), full_msg, - m1_len + sizeof(msg), new_msg, &new_msg_len); - CHECK(err); - - err = 0; -exit: - if (err == 0) { - mbedtls_printf("iso97962_test2() passed.\n"); - } else { - mbedtls_printf("iso97962_test2() failed.\n"); - } - return err; -} - -int iso97962_test(void) { - int err = 0; - ISO97962Encoding enc = {0}; - iso97962_init(&enc, 128, MBEDTLS_MD_SHA1, false); - uint8_t msg[] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint32_t msg_len = sizeof(msg); - - uint8_t block[128] = {0}; - err = iso97962_sign(&enc, msg, sizeof(msg), block, sizeof(block)); - CHECK(err); - uint8_t new_msg[128]; - uint32_t new_msg_len = 128; - err = iso97962_verify(&enc, block, sizeof(block), NULL, 0, new_msg, - &new_msg_len); - CHECK(err); - ASSERT(new_msg_len == msg_len); - ASSERT(memcmp(msg, new_msg, msg_len) == 0); - - err = 0; -exit: - if (err == 0) { - mbedtls_printf("iso97962_test() passed.\n"); - } else { - mbedtls_printf("iso97962_test() failed.\n"); - } - return err; -} - -int iso97962_error_cases_test() { - int err = 0; - ISO97962Encoding enc = {0}; - ISO97962Encoding wrong_enc = {0}; - iso97962_init(&enc, 128, MBEDTLS_MD_SHA1, false); - - uint8_t msg[] = {1, 2, 3, 4, 5, 6, 7, 8}; - uint32_t msg_len = sizeof(msg); - - uint8_t block[128] = {0}; - uint8_t wrong_block[128] = {0}; - err = iso97962_sign(&enc, msg, sizeof(msg), block, sizeof(block)); - CHECK(err); - uint8_t new_msg[128]; - uint32_t new_msg_len = 128; - - memcpy(wrong_block, block, sizeof(block)); - wrong_block[107] -= 1; - err = iso97962_verify(&enc, wrong_block, sizeof(wrong_block), NULL, 0, - new_msg, &new_msg_len); - CHECK2(err == ERROR_ISO97962_MISMATCH_HASH, -1); - - memcpy(wrong_block, block, sizeof(block)); - new_msg_len = 128; - wrong_block[sizeof(wrong_block) - 2] -= 1; - err = iso97962_verify(&enc, wrong_block, sizeof(wrong_block), NULL, 0, - new_msg, &new_msg_len); - CHECK2(err == ERROR_ISO97962_INVALID_ARG4, -1); - - memcpy(wrong_block, block, sizeof(block)); - new_msg_len = 128; - for (int i = 97; i < 108; i++) { - wrong_block[i] = (wrong_block[i] & 0xF0) | 0x0B; - } - err = iso97962_verify(&enc, wrong_block, sizeof(wrong_block), NULL, 0, - new_msg, &new_msg_len); - CHECK2(err == ERROR_ISO97962_INVALID_ARG5, -1); - - memcpy(wrong_block, block, sizeof(block)); - new_msg_len = 128; - wrong_block[0] = 0xC0; - err = iso97962_verify(&enc, wrong_block, sizeof(wrong_block), NULL, 0, - new_msg, &new_msg_len); - CHECK2(err == ERROR_ISO97962_INVALID_ARG2, -1); - - memcpy(wrong_block, block, sizeof(block)); - wrong_block[sizeof(wrong_block) - 1] = 0xFF; - err = iso97962_verify(&enc, wrong_block, sizeof(wrong_block), NULL, 0, - new_msg, &new_msg_len); - CHECK2(err == ERROR_ISO97962_INVALID_ARG3, -1); - - memcpy(&wrong_enc, &enc, sizeof(enc)); - wrong_enc.md = 100; - err = iso97962_verify(&wrong_enc, block, sizeof(block), NULL, 0, new_msg, - &new_msg_len); - - CHECK2(err == ERROR_ISO97962_INVALID_ARG6, -1); - - err = 0; -exit: - if (err == 0) { - mbedtls_printf("iso97962_error_cases_test() passed.\n"); - } else { - mbedtls_printf("iso97962_error_cases_test() failed.\n"); - } - return err; -} - -int iso97962_sample_test(uint8_t key_size_enum, const char* N_str, - const char* E_str, const char* msg_str, - const char* sig_str) { - int err = 0; - - mbedtls_mpi N; - mbedtls_mpi E; - - uint32_t key_size_byte = 0; - uint8_t msg[4096]; - uint32_t msg_len = 0; - - uint8_t sig[4096]; - uint32_t sig_len = 0; - - uint8_t new_msg[1024]; - size_t new_msg_len = 1024; - - int alloc_buff_size = 1024 * 1024; - unsigned char alloc_buff[alloc_buff_size]; - mbedtls_memory_buffer_alloc_init(alloc_buff, alloc_buff_size); - - mbedtls_mpi_init(&N); - mbedtls_mpi_init(&E); - mbedtls_mpi_read_string(&N, 16, N_str); - mbedtls_mpi_read_string(&E, 16, E_str); - - key_size_byte = get_key_size(key_size_enum) / 8; - ASSERT(key_size_byte > 0); - sig_len = read_string(sig_str, sig, sizeof(sig)); - ASSERT(sig_len == key_size_byte); - msg_len = read_string(msg_str, msg, sizeof(msg)); - ASSERT(msg_len > 0 && msg_len < key_size_byte); - - RsaInfo info; - info.key_size = key_size_enum; - info.algorithm_id = CKB_VERIFY_ISO9796_2; - info.md_type = CKB_MD_SHA1; - mbedtls_mpi_write_binary_le(&N, (uint8_t*)info.N, key_size_byte); - mbedtls_mpi_write_binary_le(&E, (uint8_t*)&info.E, sizeof(info.E)); - - ASSERT(sig_len == key_size_byte); - memcpy(info.sig, sig, sig_len); - - err = validate_signature(NULL, (uint8_t*)&info, sizeof(info), msg, msg_len, - new_msg, &new_msg_len); - CHECK(err); - - err = 0; -exit: - return err; -} - -int iso97962_test3(void) { - int err = 0; - - // RSA public key, N - const char* N_str = - "9cf68418644a5418529373350bafd57ddbf5626527b95e8ea3217d8dac8fbcb7db107eda" - "5e47979b7e4343ed6441950f7fbd921075579104ba081f1a9af950b4c0ee67c2eef2068d" - "9fe2d9d0cfdcbb9be7066e19cc945600e9fd41fc50e771f437ce4bdde63e7acf2a828a4b" - "f38b9f907a252b3dfef550919da1819033f9c619"; - // RSA public key, E, 65537 - const char* E_str = "10001"; - // input small message - const char* msg_str = "B30D0D9FA0C8BBDF"; - // input signature - const char* sig_str = - "46E52F52599A97B7DBBB8BCDD3A3BE6857F4CEF41B0723BE9FBD404DCF471DFC00D2DBF2" - "F5DA6A9B8C1A41893A569873CAD2E90EECEC84DEE85DCDE76041390D1E1328751F2832C8" - "3699986744AF68087EFFB21CD9526317424C136911144AE31B00F1764F1C5CCD974D52F6" - "278B029197C5746E62F67C544FA5C9B66E2A8AFB"; - err = iso97962_sample_test(CKB_KEYSIZE_1024, N_str, E_str, msg_str, sig_str); - CHECK(err); - -exit: - return err; -} - -// validate_signature_rsa ckbvm -// validate_signature_rsa ckbvm -iso97962_test2 -// validate_signature_rsa ckbvm -iso97962_test3 -// validate_signature_rsa ckbvm -rsa sig_buf_in_hex msg_buf_in_hex -// validate_signature_rsa ckbvm -rsa sig_buf_in_hex msg_buf_in_hex -// ... -int ckbvm_main(int argc, const char* argv[]) { - int err = 0; - if (argc <= 2) { - return -1; - } - - if (strcmp(argv[2], "-iso97962_test2") == 0) { - err = iso97962_test2(); - CHECK(err); - } - if (strcmp(argv[2], "-iso97962_test3") == 0) { - err = iso97962_test2(); - CHECK(err); - } - if (strcmp(argv[2], "-rsa") == 0) { - if (argc != 5) return -1; - uint32_t sig_len = 0; - uint8_t sig_buf[1024 * 2]; - uint32_t msg_len = 0; - uint8_t msg_buf[1024 * 2]; - sig_len = read_string(argv[3], sig_buf, sizeof(sig_buf)); - msg_len = read_string(argv[4], msg_buf, sizeof(msg_buf)); - err = validate_signature(NULL, sig_buf, sig_len, msg_buf, msg_len, NULL, - NULL); - CHECK(err); - } - - err = 0; -exit: - return err; -} - -int main(int argc, const char* argv[]) { - if (argc >= 2) { - if (strcmp(argv[1], "ckbvm") == 0) { - return ckbvm_main(argc, argv); - } - } - - int err = 0; - - err = rsa_random(); - CHECK(err); - - err = validate_signature_all_test(); - CHECK(err); - -#ifdef CKB_COVERAGE - err = validate_signature_error_cases_test(); - CHECK(err); -#endif - - err = iso97962_test(); - CHECK(err); - -#ifdef CKB_COVERAGE - err = iso97962_error_cases_test(); - CHECK(err); -#endif - - err = iso97962_test2(); - CHECK(err); - - err = iso97962_test3(); - CHECK(err); - - err = 0; -exit: - return err; -} diff --git a/tests/xudt_rce/CMakeLists.txt b/tests/xudt_rce/CMakeLists.txt deleted file mode 100644 index a75abd3..0000000 --- a/tests/xudt_rce/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -cmake_minimum_required(VERSION 3.12) -project(xudt_rce_simulator C) - -set(CMAKE_C_STANDARD 11) -# uncomment it for sanitize -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined") - -# uncomment it for coverage test -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") -#add_definitions(-DCKB_COVERAGE) -#add_definitions(-Wno-incompatible-pointer-types) - -#add_definitions(-DCKB_SIMULATOR) -add_definitions(-D__SHARED_LIBRARY__) -add_definitions(-DCKB_DECLARATION_ONLY) -add_definitions(-DCKB_USE_SIM) - -include_directories(../../tests/xudt_rce) -include_directories(../../deps/ckb-c-stdlib-20210713) -# include_directories(deps/ckb-c-stdlib/libc) -# on simulator, we don't use own "libc" -include_directories(../../deps) -include_directories(../../deps/ckb-c-stdlib-20210713/molecule) -include_directories(../../c) -include_directories(../../build) -include_directories(../../deps/sparse-merkle-tree/c) - - -add_executable(xudt_rce_simulator ../../tests/xudt_rce/xudt_rce_sim.c) -target_compile_definitions(xudt_rce_simulator PUBLIC -D_FILE_OFFSET_BITS=64 -DCKB_DECLARATION_ONLY) -target_include_directories(xudt_rce_simulator PUBLIC deps/ckb-c-stdlib-20210713/libc) -target_link_libraries(xudt_rce_simulator dl) - -add_executable(xudt_rce_validator_simulator ../../tests/xudt_rce/xudt_rce_validator_sim.c) -target_compile_definitions(xudt_rce_validator_simulator PUBLIC -D_FILE_OFFSET_BITS=64 -DCKB_DECLARATION_ONLY -DCKB_TYPE_ID_DECLARATION_ONLY) -target_include_directories(xudt_rce_validator_simulator PUBLIC deps/ckb-c-stdlib-20210713/libc) -target_link_libraries(xudt_rce_validator_simulator dl) - -add_library(extension_script_0 SHARED ../../tests/xudt_rce/extension_script_0.c) -add_library(extension_script_1 SHARED ../../tests/xudt_rce/extension_script_1.c) - - -add_executable(smt_coverage smt_fuzzer/smt_coverage.c smt_fuzzer/smt_fuzzer.c) diff --git a/tests/xudt_rce/ckb_syscall_rce_validator_sim.h b/tests/xudt_rce/ckb_syscall_rce_validator_sim.h deleted file mode 100644 index bf0b560..0000000 --- a/tests/xudt_rce/ckb_syscall_rce_validator_sim.h +++ /dev/null @@ -1,343 +0,0 @@ -// note, this macro must be same as in ckb_syscall.h -#ifndef CKB_C_STDLIB_CKB_SYSCALLS_H_ -#define CKB_C_STDLIB_CKB_SYSCALLS_H_ -#include -#include -#undef ASSERT -#include -#define ASSERT assert - -#include "xudt_rce_mol.h" - -mol_seg_t build_bytes(const uint8_t *data, uint32_t len) { - mol_builder_t b; - mol_seg_res_t res; - MolBuilder_Bytes_init(&b); - for (uint32_t i = 0; i < len; i++) { - MolBuilder_Bytes_push(&b, data[i]); - } - res = MolBuilder_Bytes_build(b); - return res.seg; -} - -mol_seg_t build_script(const uint8_t *code_hash, uint8_t hash_type, - const uint8_t *args, uint32_t args_len) { - mol_builder_t b; - mol_seg_res_t res; - MolBuilder_Script_init(&b); - - MolBuilder_Script_set_code_hash(&b, code_hash, 32); - MolBuilder_Script_set_hash_type(&b, hash_type); - mol_seg_t bytes = build_bytes(args, args_len); - MolBuilder_Script_set_args(&b, bytes.ptr, bytes.size); - - res = MolBuilder_Script_build(b); - assert(res.errno == 0); - assert(MolReader_Script_verify(&res.seg, false) == 0); - free(bytes.ptr); - return res.seg; -} - -#define MAX_RCDATA_COUNT (8192 * 2) - -typedef uint16_t RCHashType; - -typedef struct SIMRCRule { - uint8_t id; // id = 0 - uint8_t flags; - uint8_t smt_root[32]; -} SIMRCRule; -#define MAX_RCRULE_IN_CELL 16 -typedef struct SIMRCCellVec { - uint8_t id; // id = 1 - uint8_t hash_count; - RCHashType hash[MAX_RCRULE_IN_CELL]; -} SIMRCCellVec; - -typedef union SIMRCData { - SIMRCRule rcrule; - SIMRCCellVec rccell_vec; -} SIMRCData; - -mol_seg_t build_rcdata(SIMRCData *rcdata) { - mol_builder_t b2; - mol_union_builder_initialize(&b2, 64, 0, MolDefault_RCRule, 33); - if (rcdata->rcrule.id == 0) { - // RCRule - mol_builder_t b; - MolBuilder_RCRule_init(&b); - MolBuilder_RCRule_set_flags(&b, rcdata->rcrule.flags); - MolBuilder_RCRule_set_smt_root(&b, rcdata->rcrule.smt_root); - mol_seg_res_t res = MolBuilder_RCRule_build(b); - ASSERT(res.errno == 0); - - MolBuilder_RCData_set_RCRule(&b2, res.seg.ptr, res.seg.size); - free(res.seg.ptr); - } else if (rcdata->rcrule.id == 1) { - // RCCellVec - mol_builder_t b; - MolBuilder_RCCellVec_init(&b); - for (uint8_t i = 0; i < rcdata->rccell_vec.hash_count; i++) { - uint8_t hash[32] = {0}; - // very small 2-byte hash - *((RCHashType *)hash) = rcdata->rccell_vec.hash[i]; - MolBuilder_RCCellVec_push(&b, hash); - } - mol_seg_res_t res = MolBuilder_RCCellVec_build(b); - ASSERT(res.errno == 0); - - MolBuilder_RCData_set_RCCellVec(&b2, res.seg.ptr, res.seg.size); - free(res.seg.ptr); - } else { - ASSERT(false); - } - mol_seg_res_t res2 = MolBuilder_RCData_build(b2); - ASSERT(res2.errno == 0); - return res2.seg; -} - -void load_offset(uint8_t *source_buff, uint64_t source_size, void *addr, - uint64_t *len, size_t offset) { - assert(source_size > offset); - assert(*len > 0); - - uint64_t size = MIN(source_size - offset, *len); - memcpy(addr, source_buff + offset, size); - *len = size; -} - -uint8_t g_script_code_hash[32] = {0}; -uint8_t g_script_type_id[32] = {0}; -uint8_t g_script_flags = 0; -uint8_t g_script_hash_type = 0; -int g_cell_group_exists[2][2] = {{1, 0}, {1, 0}}; -SIMRCData g_sim_rcdata[MAX_RCDATA_COUNT][2]; -uint16_t g_sim_rcdata_count[2] = {0, 0}; -uint8_t g_witness[1024 * 100] = {1}; -int g_witness_size = 1024 * 100; - -uint8_t k1[32] = {111}; -uint8_t k2[32] = {222}; -uint8_t smt_ooo_root[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -uint8_t smt_one_root[32] = {103,33,160,5,252,89,102,62,163,76,168,21,69,166,16,118,170,224,70,19,204,136,173,3,227,209,92,20,166,238,37,168}; -uint8_t smt_two_root[32] = { 172,99,85,52,77,196,187,176,70,180,110,205,18,232,52,110,234,91,184,102,203,207,141,141,34,134,0,222,207,54,183,52}; -uint8_t smt_ooo_not_k1_proof[3] = {76, 79, 0}; -uint8_t smt_one_has_k1_proof[3] = {76, 79, 0}; -uint8_t smt_one_not_k2_proof[] = {76,79,7,81,7,230,87,4,102,231,44,33,43,86,223,122,31,55,149,180,232,119,169,0,69,197,39,143,196,158,36,48,102,77,139,36,87,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,79,248}; -// run -- --exclude "222" 111 -uint8_t smt_tow_has_k2_proof[] = {76,79,7,81,7,230,87,4,102,231,44,33,43,86,223,122,31,55,149,180,232,119,169,0,69,197,39,143,196,158,36,48,102,77,139,36,87,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,79,248}; - -#define countof(s) (sizeof(s) / sizeof(s[0])) - -int ckb_exit(int8_t code) { - exit(code); - return 0; -} - -int ckb_load_tx_hash(void *addr, uint64_t *len, size_t offset) { return 0; } - -int ckb_load_transaction(void *addr, uint64_t *len, size_t offset) { return 0; } - -int ckb_load_script_hash(void *addr, uint64_t *len, size_t offset) { return 0; } - -int ckb_load_script(void *addr, uint64_t *len, size_t offset) { - uint8_t buf[33] = {}; - memcpy(buf, g_script_type_id, 32); - buf[32] = g_script_flags; - mol_seg_t seg = - build_script(g_script_code_hash, g_script_hash_type, buf, sizeof(buf)); - if (addr == NULL) { - *len = seg.size; - } else { - load_offset(seg.ptr, seg.size, addr, len, offset); - }; - free(seg.ptr); - return 0; -} - -int ckb_debug(const char *s) { return 0; } - -int ckb_load_cell(void *addr, uint64_t *len, size_t offset, size_t index, - size_t source) { - if (source == CKB_SOURCE_GROUP_INPUT) { - ASSERT(offset == 0); - return g_cell_group_exists[0][index] == 0; - } else if (source == CKB_SOURCE_GROUP_OUTPUT) { - ASSERT(offset == 0); - return g_cell_group_exists[1][index] == 0; - } else if (source == CKB_SOURCE_CELL_DEP) { - ASSERT(offset == 0); - ASSERT(false); - } else { - ASSERT(false); - } -} - -int ckb_load_input(void *addr, uint64_t *len, size_t offset, size_t index, - size_t source) { - return 0; -} - -int ckb_load_header(void *addr, uint64_t *len, size_t offset, size_t index, - size_t source) { - return 0; -} - -int ckb_load_witness(void *addr, uint64_t *len, size_t offset, size_t index, - size_t source) { - ASSERT(index == 0); - if (*len != 0) { - load_offset(g_witness, g_witness_size, addr, len, offset); - } - *len = g_witness_size - offset; - return 0; -} - -int ckb_load_cell_by_field(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source, size_t field) { - return 0; -} - -int ckb_load_header_by_field(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source, size_t field) { - return 0; -} - -int ckb_load_input_by_field(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source, size_t field) { - return 0; -} - -int ckb_load_cell_data(void *addr, uint64_t *len, size_t offset, size_t index, - size_t source) { - if (source == CKB_SOURCE_GROUP_INPUT) { - ASSERT(index < g_sim_rcdata_count[0]); - SIMRCData *curr = g_sim_rcdata[0] + index; - mol_seg_t seg = build_rcdata(curr); - if (*len != 0) { - load_offset(seg.ptr, seg.size, addr, len, offset); - } - *len = seg.size - offset; - free(seg.ptr); - } else if (source == CKB_SOURCE_GROUP_OUTPUT) { - ASSERT(index < g_sim_rcdata_count[1]); - SIMRCData *curr = g_sim_rcdata[1] + index; - mol_seg_t seg = build_rcdata(curr); - if (*len != 0) { - load_offset(seg.ptr, seg.size, addr, len, offset); - } - *len = seg.size - offset; - free(seg.ptr); - } else if (source == CKB_SOURCE_CELL_DEP) { - ASSERT(false); - } else { - ASSERT(false); - } - return 0; -} - -int ckb_dlopen2(const uint8_t *dep_cell_hash, uint8_t hash_type, - uint8_t *aligned_addr, size_t aligned_size, void **handle, - size_t *consumed_size) { - return 0; -} - -void *ckb_dlsym(void *handle, const char *symbol) { return 0; } - -int ckb_checked_load_input(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source) { - uint64_t old_len = *len; - int ret = ckb_load_input(addr, len, offset, index, source); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -int ckb_checked_load_script(void *addr, uint64_t *len, size_t offset) { - uint64_t old_len = *len; - int ret = ckb_load_script(addr, len, offset); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -int ckb_checked_load_cell_data(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source) { - uint64_t old_len = *len; - int ret = ckb_load_cell_data(addr, len, offset, index, source); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} -int ckb_look_for_dep_with_hash2(const uint8_t *code_hash, uint8_t hash_type, - size_t *index) { - size_t current = 0; - size_t field = - (hash_type == 1) ? CKB_CELL_FIELD_TYPE_HASH : CKB_CELL_FIELD_DATA_HASH; - while (current < SIZE_MAX) { - uint64_t len = 32; - uint8_t hash[32]; - - int ret = ckb_load_cell_by_field(hash, &len, 0, current, - CKB_SOURCE_CELL_DEP, field); - switch (ret) { - case CKB_ITEM_MISSING: - break; - case CKB_SUCCESS: - if (memcmp(code_hash, hash, 32) == 0) { - /* Found a match */ - *index = current; - return CKB_SUCCESS; - } - break; - default: - return CKB_INDEX_OUT_OF_BOUND; - } - current++; - } - return CKB_INDEX_OUT_OF_BOUND; -} - -int ckb_checked_load_cell_by_field(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source, size_t field) { - uint64_t old_len = *len; - int ret = ckb_load_cell_by_field(addr, len, offset, index, source, field); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -int ckb_checked_load_witness(void *addr, uint64_t *len, size_t offset, - size_t index, size_t source) { - uint64_t old_len = *len; - int ret = ckb_load_witness(addr, len, offset, index, source); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -#endif - -#ifdef CKB_TYPE_ID_DEBUG -#define DEBUG(s) ckb_debug(s) -#else -#define DEBUG(s) -#endif /* CKB_TYPE_ID_DEBUG */ - -#ifdef CKB_TYPE_ID_DECLARATION_ONLY -int ckb_validate_type_id(const uint8_t type_id[32]) { return 0; } - -int _ckb_has_type_id_cell(size_t index, int is_input) { - uint64_t len = 0; - size_t source = - is_input == 1 ? CKB_SOURCE_GROUP_INPUT : CKB_SOURCE_GROUP_OUTPUT; - int ret = ckb_load_cell(NULL, &len, 0, index, source); - return ret == CKB_SUCCESS ? 1 : 0; -} -#endif /* CKB_TYPE_ID_DECLARATION_ONLY */ diff --git a/tests/xudt_rce/ckb_syscall_xudt_sim.h b/tests/xudt_rce/ckb_syscall_xudt_sim.h deleted file mode 100644 index f5a2a3e..0000000 --- a/tests/xudt_rce/ckb_syscall_xudt_sim.h +++ /dev/null @@ -1,685 +0,0 @@ -// note, this macro must be same as in ckb_syscall.h -#ifndef CKB_C_STDLIB_CKB_SYSCALLS_H_ -#define CKB_C_STDLIB_CKB_SYSCALLS_H_ -#include -#include -#undef ASSERT -#include -#define ASSERT assert - -#include "xudt_rce_mol.h" - -#define countof(s) (sizeof(s) / sizeof(s[0])) - -// forward declarations -void ckbsim_map_lib(const uint8_t* dep_cell_hash, const char* path); -mol_seg_t build_bytes(const uint8_t* data, uint32_t len); -mol_seg_t build_script(const uint8_t* code_hash, uint8_t hash_type, - const uint8_t* args, uint32_t args_len); -extern int g_lib_size; -// simulator for RCData -typedef uint16_t RCHashType; - -typedef struct SIMRCRule { - uint8_t id; // id = 0 - uint8_t flags; - uint8_t smt_root[32]; -} SIMRCRule; -#define MAX_RCRULE_IN_CELL 16 -typedef struct SIMRCCellVec { - uint8_t id; // id = 1 - uint8_t hash_count; - RCHashType hash[MAX_RCRULE_IN_CELL]; -} SIMRCCellVec; - -typedef union SIMRCData { - SIMRCRule rcrule; - SIMRCCellVec rccell_vec; -} SIMRCData; - -#define MAX_RCDATA_COUNT (8192 * 2) - -SIMRCData g_sim_rcdata[MAX_RCDATA_COUNT]; -uint16_t g_sim_rcdata_count = 0; - -uint32_t g_flags = 0; -void xudt_set_flags(uint32_t flags) { g_flags = flags; } - -mol_builder_t g_extension_script_hash_builder = {0}; -mol_seg_t g_extension_script_hash = {0}; - -mol_builder_t g_proof_builder = {0}; - -mol_builder_t g_structure_builder = {0}; -mol_seg_t g_structure = {0}; - -uint8_t g_hash_in_args[32] = {0}; - -uint8_t g_input_lock_script_hash[32][16]; -uint32_t g_input_lock_script_hash_count = 0; - -uint8_t g_output_lock_script_hash[32][16]; -uint32_t g_output_lock_script_hash_count = 0; - -__int128 g_input_amount[32] = {0}; -uint32_t g_input_count = 0; -__int128 g_output_amount[32] = {0}; -uint32_t g_output_count = 0; - -void xudt_add_extension_script(const uint8_t* hash, uint8_t hash_type, - uint8_t* args, uint32_t args_len, - const char* path) { - mol_seg_t script = build_script(hash, hash_type, args, args_len); - - MolBuilder_ScriptVec_push(&g_extension_script_hash_builder, script.ptr, - script.size); - ckbsim_map_lib(hash, path); - - free(script.ptr); -} - -void xudt_calc_extension_script_hash(const uint8_t* hash, uint8_t hash_type, - uint8_t* args, uint32_t args_len, - uint8_t* out_hash) { - mol_seg_t script = build_script(hash, hash_type, args, args_len); - int err = blake2b(out_hash, 32, script.ptr, script.size, NULL, 0); - ASSERT(err == 0); - - free(script.ptr); -} - -void xudt_add_structure_item(const uint8_t* item, uint32_t len) { - mol_seg_t seg = build_bytes(item, len); - MolBuilder_BytesVec_push(&g_structure_builder, seg.ptr, seg.size); - free(seg.ptr); -} - -void rce_begin_proof() { MolBuilder_SmtProofEntryVec_init(&g_proof_builder); } - -void rce_add_proof(const uint8_t* proof, uint32_t proof_len, uint8_t mask) { - ASSERT(mask >= 0 && mask <= 3); - - mol_builder_t b; - mol_seg_t proof_seg = build_bytes(proof, proof_len); - - MolBuilder_SmtProofEntry_init(&b); - MolBuilder_SmtProofEntry_set_mask(&b, mask); - MolBuilder_SmtProofEntry_set_proof(&b, proof_seg.ptr, proof_seg.size); - - mol_seg_res_t res = MolBuilder_SmtProofEntry_build(b); - ASSERT(res.errno == 0); - - MolBuilder_SmtProofEntryVec_push(&g_proof_builder, res.seg.ptr, res.seg.size); - free(proof_seg.ptr); - free(res.seg.ptr); -} - -void rce_end_proof() { - mol_seg_res_t res = MolBuilder_SmtProofEntryVec_build(g_proof_builder); - ASSERT(res.errno == 0); - - xudt_add_structure_item(res.seg.ptr, res.seg.size); - free(res.seg.ptr); -} - -void xudt_add_data(const uint8_t* data, uint32_t len) { - // not used -} - -void xudt_add_input_lock_script_hash(uint8_t* hash) { - if (g_input_lock_script_hash_count >= 16) { - ASSERT(false); - return; - } - memcpy(g_input_lock_script_hash[g_input_lock_script_hash_count], hash, 32); - g_input_lock_script_hash_count++; -} - -// set them to same to enable owner mode -void xudt_set_owner_mode(uint8_t* hash_in_args, uint8_t* lock_script_hash) { - memcpy(g_hash_in_args, hash_in_args, 32); - xudt_add_input_lock_script_hash(lock_script_hash); -} - -void xudt_add_output_lock_script_hash(uint8_t* hash) { - if (g_output_lock_script_hash_count > 16) { - return; - } - memcpy(g_output_lock_script_hash[g_output_lock_script_hash_count], hash, 32); - g_output_lock_script_hash_count++; -} - -void xudt_add_input_amount(__int128 val) { - g_input_amount[g_input_count] = val; - g_input_count++; -} - -void xudt_add_output_amount(__int128 val) { - g_output_amount[g_output_count] = val; - g_output_count++; -} - -void xudt_begin_data(void) { - g_flags = 0; - MolBuilder_ScriptVec_init(&g_extension_script_hash_builder); - if (g_extension_script_hash.ptr) free(g_extension_script_hash.ptr); - - MolBuilder_BytesVec_init(&g_structure_builder); - if (g_structure.ptr) free(g_structure.ptr); - - g_extension_script_hash.ptr = 0; - g_extension_script_hash.size = 0; - g_input_count = 0; - g_output_count = 0; - memset(g_input_lock_script_hash, 0, sizeof(g_input_lock_script_hash)); - memset(g_output_lock_script_hash, 0, sizeof(g_output_lock_script_hash)); - memset(g_hash_in_args, 0, sizeof(g_hash_in_args)); - - g_lib_size = 0; - g_input_lock_script_hash_count = 0; - g_output_lock_script_hash_count = 0; - - g_sim_rcdata_count = 0; -} - -void xudt_end_data(void) { - mol_seg_res_t res = - MolBuilder_ScriptVec_build(g_extension_script_hash_builder); - ASSERT(res.errno == 0); - g_extension_script_hash = res.seg; - - mol_seg_res_t res2 = MolBuilder_BytesVec_build(g_structure_builder); - g_structure = res2.seg; -} - -int ckb_exit(int8_t code) { - exit(code); - return 0; -} - -int ckb_load_tx_hash(void* addr, uint64_t* len, size_t offset) { return 0; } - -int ckb_checked_load_script(void* addr, uint64_t* len, size_t offset); - -int ckb_load_cell(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source); - -int ckb_load_input(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source); - -int ckb_load_header(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source); - -int ckb_load_script_hash(void* addr, uint64_t* len, size_t offset) { return 0; } - -int ckb_checked_load_script_hash(void* addr, uint64_t* len, size_t offset) { - uint64_t old_len = *len; - int ret = ckb_load_script_hash(addr, len, offset); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -int ckb_load_witness(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source) { - if (index > 1) { - return 1; // CKB_INDEX_OUT_OF_BOUND; - } - mol_builder_t w; - MolBuilder_WitnessArgs_init(&w); - - mol_builder_t xwi_builder; - MolBuilder_XudtWitnessInput_init(&xwi_builder); - if (g_flags == 2) { - MolBuilder_XudtWitnessInput_set_raw_extension_data( - &xwi_builder, g_extension_script_hash.ptr, - g_extension_script_hash.size); - } - MolBuilder_XudtWitnessInput_set_extension_data(&xwi_builder, g_structure.ptr, - g_structure.size); - - mol_seg_res_t xwi_res = MolBuilder_XudtWitnessInput_build(xwi_builder); - ASSERT(xwi_res.errno == MOL_OK); - - // here we fill a "big" lock to generate a big "witness" - // to test functions like read_from_witness - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&w, lock.ptr, lock.size); - - mol_seg_t seg = build_bytes(xwi_res.seg.ptr, xwi_res.seg.size); - MolBuilder_WitnessArgs_set_input_type(&w, seg.ptr, seg.size); - free(seg.ptr); - - mol_seg_res_t res = MolBuilder_WitnessArgs_build(w); - assert(res.errno == 0); - - if (res.seg.size <= offset) { - *len = 0; - return 0; - } - if (addr == NULL) { - *len = res.seg.size; - return 0; - } - - uint32_t remaining = res.seg.size - offset; - if (remaining > *len) { - memcpy(addr, res.seg.ptr + offset, *len); - } else { - memcpy(addr, res.seg.ptr + offset, remaining); - } - *len = remaining; - - free(res.seg.ptr); - free(xwi_res.seg.ptr); - - return 0; -} - -int ckb_checked_load_witness(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source) { - uint64_t old_len = *len; - int ret = ckb_load_witness(addr, len, offset, index, source); - if (ret == CKB_SUCCESS && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -mol_seg_t build_bytes(const uint8_t* data, uint32_t len) { - mol_builder_t b; - mol_seg_res_t res; - MolBuilder_Bytes_init(&b); - for (uint32_t i = 0; i < len; i++) { - MolBuilder_Bytes_push(&b, data[i]); - } - res = MolBuilder_Bytes_build(b); - return res.seg; -} - -mol_seg_t build_script(const uint8_t* code_hash, uint8_t hash_type, - const uint8_t* args, uint32_t args_len) { - mol_builder_t b; - mol_seg_res_t res; - MolBuilder_Script_init(&b); - - MolBuilder_Script_set_code_hash(&b, code_hash, 32); - MolBuilder_Script_set_hash_type(&b, hash_type); - mol_seg_t bytes = build_bytes(args, args_len); - MolBuilder_Script_set_args(&b, bytes.ptr, bytes.size); - - res = MolBuilder_Script_build(b); - assert(res.errno == 0); - assert(MolReader_Script_verify(&res.seg, false) == 0); - free(bytes.ptr); - return res.seg; -} - -mol_seg_t build_rcdata(SIMRCData* rcdata) { - mol_builder_t b2; - mol_union_builder_initialize(&b2, 64, 0, MolDefault_RCRule, 33); - if (rcdata->rcrule.id == 0) { - // RCRule - mol_builder_t b; - MolBuilder_RCRule_init(&b); - MolBuilder_RCRule_set_flags(&b, rcdata->rcrule.flags); - MolBuilder_RCRule_set_smt_root(&b, rcdata->rcrule.smt_root); - mol_seg_res_t res = MolBuilder_RCRule_build(b); - ASSERT(res.errno == 0); - - MolBuilder_RCData_set_RCRule(&b2, res.seg.ptr, res.seg.size); - free(res.seg.ptr); - } else if (rcdata->rcrule.id == 1) { - // RCCellVec - mol_builder_t b; - MolBuilder_RCCellVec_init(&b); - for (uint8_t i = 0; i < rcdata->rccell_vec.hash_count; i++) { - uint8_t hash[32] = {0}; - // very small 2-byte hash - *((RCHashType*)hash) = rcdata->rccell_vec.hash[i]; - MolBuilder_RCCellVec_push(&b, hash); - } - mol_seg_res_t res = MolBuilder_RCCellVec_build(b); - ASSERT(res.errno == 0); - - MolBuilder_RCData_set_RCCellVec(&b2, res.seg.ptr, res.seg.size); - free(res.seg.ptr); - } else { - ASSERT(false); - } - mol_seg_res_t res2 = MolBuilder_RCData_build(b2); - ASSERT(res2.errno == 0); - return res2.seg; -} - -int ckb_checked_load_script(void* addr, uint64_t* len, size_t offset) { - mol_builder_t b = {0}; - mol_seg_res_t res = {0}; - assert(offset == 0); - - MolBuilder_Script_init(&b); - uint8_t hash_type = 0; - MolBuilder_Script_set_code_hash(&b, g_hash_in_args, 32); - MolBuilder_Script_set_hash_type(&b, hash_type); - { - uint32_t args_len = 32 + 4 + g_extension_script_hash.size; - uint8_t args[args_len]; - - memcpy(args, g_hash_in_args, 32); - memcpy(args + 32, &g_flags, 4); - - mol_seg_t seg = {0}; - if (g_flags == 1) { - memcpy(args + 32 + 4, g_extension_script_hash.ptr, - g_extension_script_hash.size); - seg = build_bytes(args, args_len); - } else if (g_flags == 2) { - uint8_t hash[32] = {0}; - int err = blake2b(hash, 32, g_extension_script_hash.ptr, - g_extension_script_hash.size, NULL, 0); - ASSERT(err == 0); - memcpy(args + 32 + 4, hash, 20); - // blake160 hash - seg = build_bytes(args, 32 + 4 + 20); - } else if (g_flags == 0) { - seg = build_bytes(args, 32); - } else if (g_flags == 0xFF) { - // test flags, make flags available, but value is zero - uint32_t flags = 0; - memcpy(args + 32, &flags, 4); - seg = build_bytes(args, 32 + 4); - } else { - ASSERT(false); - } - MolBuilder_Script_set_args(&b, seg.ptr, seg.size); - free(seg.ptr); - } - res = MolBuilder_Script_build(b); - assert(res.errno == 0); - - if (*len < res.seg.size) { - return -1; - } - memcpy(addr, res.seg.ptr, res.seg.size); - *len = res.seg.size; - - free(res.seg.ptr); - return 0; -} - -int ckb_load_cell_by_field(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source, size_t field); - -int ckb_load_header_by_field(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source, size_t field); - -int ckb_load_input_by_field(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source, size_t field); - -int ckb_load_cell_code(void* addr, size_t memory_size, size_t content_offset, - size_t content_size, size_t index, size_t source); - -int ckb_load_cell_data(void* addr, uint64_t* len, size_t offset, size_t index, - size_t source) { - if (source == CKB_SOURCE_GROUP_INPUT) { - ASSERT(offset == 0); - if (index >= g_input_count) { - return CKB_INDEX_OUT_OF_BOUND; - } else { - if (addr) { - memcpy(addr, &g_input_amount[index], sizeof(__int128)); - } - *len = sizeof(__int128); - } - } else if (source == CKB_SOURCE_GROUP_OUTPUT) { - ASSERT(offset == 0); - if (index >= g_output_count) { - return CKB_INDEX_OUT_OF_BOUND; - } else { - if (addr) { - memcpy(addr, &g_output_amount[index], sizeof(__int128)); - } - *len = sizeof(__int128); - } - } else if (source == CKB_SOURCE_CELL_DEP) { - ASSERT(index < g_sim_rcdata_count); - SIMRCData* curr = g_sim_rcdata + index; - mol_seg_t seg = build_rcdata(curr); - - if (addr == NULL) { - ASSERT(*len == 0); - *len = seg.size; - return 0; - } - if (seg.size <= offset) { - *len = 0; - return 0; - } - uint32_t remaining = seg.size - offset; - if (remaining > *len) { - memcpy(addr, seg.ptr + offset, *len); - } else { - memcpy(addr, seg.ptr + offset, remaining); - } - *len = remaining; - - free(seg.ptr); - } else { - ASSERT(false); - } - return 0; -} - -int ckb_checked_load_cell_data(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source) { - return ckb_load_cell_data(addr, len, offset, index, source); -} - -int ckb_debug(const char* s); - -/* load the actual witness for the current type verify group. - use this instead of ckb_load_witness if type contract needs args to verify - input/output. - */ -int load_actual_type_witness(uint8_t* buf, uint64_t* len, size_t index, - size_t* type_source); - -int ckb_look_for_dep_with_hash(const uint8_t* data_hash, size_t* index); - -int ckb_calculate_inputs_len() { return 0; } - -int ckb_load_cell_by_field(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source, size_t field) { - if (field == CKB_CELL_FIELD_LOCK_HASH) { - if (source == CKB_SOURCE_GROUP_OUTPUT || source == CKB_SOURCE_OUTPUT) { - ASSERT(offset == 0); - ASSERT(*len >= 32); - if (index >= g_output_lock_script_hash_count) { - return CKB_INDEX_OUT_OF_BOUND; - } - memcpy(addr, g_output_lock_script_hash[index], 32); - *len = 32; - } else if (source == CKB_SOURCE_GROUP_INPUT || source == CKB_SOURCE_INPUT) { - ASSERT(offset == 0); - ASSERT(*len >= 32); - if (index >= g_input_lock_script_hash_count) { - return CKB_INDEX_OUT_OF_BOUND; - } - memcpy(addr, g_input_lock_script_hash[index], 32); - *len = 32; - } else { - ASSERT(false); - } - } else if (field == CKB_CELL_FIELD_TYPE_HASH) { - return CKB_INDEX_OUT_OF_BOUND; - } - return 0; -} - -int ckb_checked_load_cell_by_field(void* addr, uint64_t* len, size_t offset, - size_t index, size_t source, size_t field) { - uint64_t old_len = *len; - int ret = ckb_load_cell_by_field(addr, len, offset, index, source, field); - if (ret == 0 && (*len) > old_len) { - ret = CKB_LENGTH_NOT_ENOUGH; - } - return ret; -} - -// return index as hash -uint16_t rce_add_rcrule(uint8_t* rcrule, uint8_t flags) { - ASSERT(g_sim_rcdata_count < countof(g_sim_rcdata)); - - SIMRCData* curr = g_sim_rcdata + g_sim_rcdata_count; - curr->rcrule.id = 0; - curr->rcrule.flags = flags; - memcpy(curr->rcrule.smt_root, rcrule, 32); - g_sim_rcdata_count++; - return g_sim_rcdata_count - 1; -} - -// return index as hash -RCHashType rce_modify_rcrule(uint32_t index, uint8_t* rcrule, uint8_t flags) { - ASSERT(index < g_sim_rcdata_count); - - SIMRCData* curr = g_sim_rcdata + index; - curr->rcrule.flags = flags; - memcpy(curr->rcrule.smt_root, rcrule, 32); - return index; -} - -RCHashType rce_add_rccellvec(RCHashType* hash, uint32_t length) { - ASSERT(g_sim_rcdata_count < countof(g_sim_rcdata)); - SIMRCData* curr = g_sim_rcdata + g_sim_rcdata_count; - curr->rccell_vec.id = 1; - curr->rccell_vec.hash_count = length; - memcpy(curr->rccell_vec.hash, hash, length * sizeof(RCHashType)); - g_sim_rcdata_count++; - return g_sim_rcdata_count - 1; -} - -int ckb_look_for_dep_with_hash2(const uint8_t* code_hash, uint8_t hash_type, - size_t* index) { - *index = *(uint16_t*)code_hash; - return 0; -} - -// dlopen simulator -#include -#include -#include - -#define ERROR_MEMORY_NOT_ENOUGH -23 -#define ERROR_DYNAMIC_LOADING -24 -#define RISCV_PGSIZE 4096 -#define ROUNDUP(a, b) ((((a)-1) / (b) + 1) * (b)) -#define MAX_PATH_SIZE 1024 - -typedef struct LibMappingEntry { - uint8_t dep_cell_hash[32]; - char path[MAX_PATH_SIZE]; -} LibMappingEntry; - -#define MAX_LIB_MAPPING_COUNT 1024 -LibMappingEntry g_lib_mapping[MAX_LIB_MAPPING_COUNT]; -int g_lib_size = 0; - -void ckbsim_map_lib(const uint8_t* dep_cell_hash, const char* path) { - if (g_lib_size >= MAX_LIB_MAPPING_COUNT) { - ASSERT(false); - return; - } - ASSERT(strlen(path) < MAX_PATH_SIZE); - - memcpy(g_lib_mapping[g_lib_size].dep_cell_hash, dep_cell_hash, 32); - strcpy(g_lib_mapping[g_lib_size].path, path); - - g_lib_size++; -} - -bool file_exists(const char* path) { - FILE* fp = fopen(path, "r"); - if (fp != NULL) { - fclose(fp); - }; - return fp != NULL; -} - -void file_with_so(const char* input, char* output, uint32_t output_len) { - strcpy(output, input); - char* pos = strchr(output, '.'); - if (pos != NULL) { - *pos = 0; - strcat(output, ".so"); - } -} - -int ckbsim_get_lib(const uint8_t* dep_cell_hash, char* path) { - for (int i = 0; i < g_lib_size; i++) { - if (memcmp(g_lib_mapping[i].dep_cell_hash, dep_cell_hash, 32) == 0) { - const char* target = g_lib_mapping[i].path; - if (file_exists(target)) { - strcpy(path, target); - } else { - char output[1024] = {0}; - file_with_so(target, output, sizeof(output)); - if (file_exists(output)) { - strcpy(path, output); - } else { - ASSERT(false); - return -1; - } - } - return 0; - } - } - return 1; -} - -size_t get_file_size(const char* path) { - FILE* fp = fopen(path, "r"); - ASSERT(fp != NULL); - fseek(fp, 0L, SEEK_END); - long size = ftell(fp); - fclose(fp); - - return size; -} - -int ckb_dlopen2(const uint8_t* dep_cell_hash, uint8_t hash_type, - uint8_t* aligned_addr, size_t aligned_size, void** handle, - size_t* consumed_size) { - int err = 0; - (void)hash_type; - (void)aligned_size; - - char path[MAX_PATH_SIZE] = {0}; - ASSERT((aligned_size % RISCV_PGSIZE) == 0); - ASSERT(((size_t)aligned_addr) % RISCV_PGSIZE == 0); - - err = ckbsim_get_lib(dep_cell_hash, path); - ASSERT(err == 0); - - *handle = dlopen(path, RTLD_NOW); - *consumed_size = 0; - - if (*handle == NULL) { - printf("Error occurs in dlopen: %s\n", dlerror()); - ASSERT(false); - return -1; - } - return 0; -} - -void* ckb_dlsym(void* handle, const char* symbol) { - void* ret = dlsym(handle, symbol); - ASSERT(ret != NULL); - return ret; -} - -#undef ASSERT -#define ASSERT(s) (void)0 - -#endif diff --git a/tests/xudt_rce/dump.h b/tests/xudt_rce/dump.h deleted file mode 100644 index f2ec275..0000000 --- a/tests/xudt_rce/dump.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef DUMP_H_ -#define DUMP_H_ - -#define CKB_C_STDLIB_PRINTF - -#include -#include - -// Usage: -// hex_dump(desc, addr, len, perLine); -// desc: if non-NULL, printed as a description before hex dump. -// addr: the address to start dumping from. -// len: the number of bytes to dump. -// perLine: number of bytes on each output line. - -void hex_dump(const char *desc, const void *addr, const int len, int perLine) { - // Silently ignore silly per-line values. - - if (perLine < 4 || perLine > 64) perLine = 16; - - int i; - unsigned char buff[perLine + 1]; - const unsigned char *pc = (const unsigned char *)addr; - - // Output description if given. - - if (desc != NULL) printf("%s:\n", desc); - - // Length checks. - - if (len == 0) { - printf(" ZERO LENGTH\n"); - return; - } - if (len < 0) { - printf(" NEGATIVE LENGTH: %d\n", len); - return; - } - - // Process every byte in the data. - - for (i = 0; i < len; i++) { - // Multiple of perLine means new or first line (with line offset). - - if ((i % perLine) == 0) { - // Only print previous-line ASCII buffer for lines beyond first. - - if (i != 0) printf(" %s\n", buff); - - // Output the offset of current line. - - printf(" %04x ", i); - } - - // Now the hex code for the specific character. - - printf(" %02x", pc[i]); - - // And buffer a printable ASCII character for later. - - if ((pc[i] < 0x20) || (pc[i] > 0x7e)) // isprint() may be better. - buff[i % perLine] = '.'; - else - buff[i % perLine] = pc[i]; - buff[(i % perLine) + 1] = '\0'; - } - - // Pad out last line if not exactly perLine characters. - - while ((i % perLine) != 0) { - printf(" "); - i++; - } - - // And print the final ASCII buffer. - - printf(" %s\n", buff); -} - -#endif diff --git a/tests/xudt_rce/extension_script_0.c b/tests/xudt_rce/extension_script_0.c deleted file mode 100644 index 385ee4a..0000000 --- a/tests/xudt_rce/extension_script_0.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -__attribute__((visibility("default"))) int validate(int is_owner_mode, - size_t extension_index, - const uint8_t* args, - size_t args_len) { - return 0; -} diff --git a/tests/xudt_rce/extension_script_1.c b/tests/xudt_rce/extension_script_1.c deleted file mode 100644 index 73bde95..0000000 --- a/tests/xudt_rce/extension_script_1.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -__attribute__((visibility("default"))) int validate(int is_owner_mode, - size_t extension_index, - const uint8_t* args, - size_t args_len) { - return 1; -} diff --git a/tests/xudt_rce/extension_scripts.Makefile b/tests/xudt_rce/extension_scripts.Makefile deleted file mode 100644 index bb7f8c8..0000000 --- a/tests/xudt_rce/extension_scripts.Makefile +++ /dev/null @@ -1,50 +0,0 @@ - -# invoke it from root folder: -# make -f tests/xudt_rce/extension_scripts.Makefile all-via-docker - -TARGET := riscv64-unknown-linux-gnu -CC := $(TARGET)-gcc -LD := $(TARGET)-gcc -OBJCOPY := $(TARGET)-objcopy - -CFLAGS := -fPIC -Os -fno-builtin-printf -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I deps/ckb-c-std-lib -I deps/ckb-c-std-lib/molecule -I deps/ckb-c-std-lib/libc -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -OWNER_SCRIPT_CFLAGS := $(subst ckb-c-std-lib,ckb-c-stdlib-20210801,$(CFLAGS)) -I c -I deps/secp256k1-20210801 -I deps/secp256k1-20210801/src -I build -I deps/sparse-merkle-tree/c -LDFLAGS := -Wl,-static -Wl,--gc-sections -MOLC := moleculec -MOLC_VERSION := 0.7.0 - - -# docker pull nervos/ckb-riscv-gnu-toolchain:gnu-bionic-20191012 -BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:aae8a3f79705f67d505d1f1d5ddc694a4fd537ed1c7e9622420a470d59ba2ec3 - -all: build/extension_script_0 build/extension_script_1 build/owner_script - -all-via-docker: ${PROTOCOL_HEADER} - docker run --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make -f tests/xudt_rce/extension_scripts.Makefile" - -build/extension_script_0: tests/xudt_rce/extension_script_0.c - $(CC) $(CFLAGS) $(LDFLAGS) -D__SHARED_LIBRARY__ -fPIC -fPIE -pie -Wl,--dynamic-list tests/xudt_rce/validate.syms -o $@ $^ - -build/extension_script_1: tests/xudt_rce/extension_script_1.c - $(CC) $(CFLAGS) $(LDFLAGS) -D__SHARED_LIBRARY__ -fPIC -fPIE -pie -Wl,--dynamic-list tests/xudt_rce/validate.syms -o $@ $^ - -build/owner_script: tests/xudt_rce/owner_script.c - $(CC) $(OWNER_SCRIPT_CFLAGS) $(LDFLAGS) -D__SHARED_LIBRARY__ -fPIC -fPIE -pie -Wl,--dynamic-list tests/xudt_rce/validate.syms -o $@ $^ - -mol: src/tests/xudt_rce_mol.rs src/tests/blockchain.rs - -src/tests/xudt_rce_mol.rs: c/xudt_rce.mol - ${MOLC} --language rust --schema-file $< | rustfmt > $@ - -src/tests/blockchain.rs: c/blockchain.mol - ${MOLC} --language rust --schema-file $< | rustfmt > $@ - - -clean: - rm -rf build/extension_script_0 - rm -rf build/extension_script_1 - rm -rf build/owner_script - -dist: clean all - -.PHONY: all all-via-docker dist clean diff --git a/tests/xudt_rce/owner_script.c b/tests/xudt_rce/owner_script.c deleted file mode 100644 index f863857..0000000 --- a/tests/xudt_rce/owner_script.c +++ /dev/null @@ -1,171 +0,0 @@ -#include "dump.h" - -#ifndef MOL2_EXIT -#define MOL2_EXIT ckb_exit -#endif -int ckb_exit(signed char); - -#include -#include - -// in secp256k1_ctz64_var: we don't have __builtin_ctzl in gcc for RISC-V -#define __builtin_ctzl secp256k1_ctz64_var_debruijn - -// clang-format off -#include "blockchain.h" -#include "blake2b.h" -#include "ckb_consts.h" -#include "ckb_swappable_signatures.h" -#include "ckb_syscalls.h" -#include "secp256k1_helper_20210801.h" -#include "ckb_identity.h" -#include "validate_signature_rsa.h" -// The MOLECULEC_VERSION defined in blockchain.h is incompatible with -// that defined in xudt_rce_mol.h -#undef MOLECULEC_VERSION - -#include "xudt_rce_mol.h" - -#define MAX_WITNESS_SIZE 32768 - -#define ERROR_UNREACHABLE -100; -#define ERROR_ILLEGAL_ARGUMENTS -101; -#define ERROR_SIGNATURE_VERIFICATION -102; -#define ERROR_ENCODING -103; -#define ERROR_SYSCALL -104; - -int get_owner_signature(uint8_t signature[SIGNATURE_SIZE]) { - int ret = 0; - unsigned char witness_bytes[MAX_WITNESS_SIZE]; - uint64_t witness_len = MAX_WITNESS_SIZE; - int use_input_type = 1; - ret = ckb_load_witness(witness_bytes, &witness_len, 0, 0, - CKB_SOURCE_GROUP_INPUT); - if (ret == CKB_INDEX_OUT_OF_BOUND) { - use_input_type = 0; - ret = ckb_load_witness(witness_bytes, &witness_len, 0, 0, - CKB_SOURCE_GROUP_OUTPUT); - } - if (ret != CKB_SUCCESS) { - printf("Error while loading witness: %d\n", ret); - return ERROR_SYSCALL; - } - - if (witness_len > MAX_WITNESS_SIZE) { - printf("Error witness too large\n"); - return ERROR_ENCODING; - } - - mol_seg_t witness_seg; - witness_seg.ptr = witness_bytes; - witness_seg.size = witness_len; - - if (MolReader_WitnessArgs_verify(&witness_seg, false) != MOL_OK) { - printf("Error while verifying WitnessArgs\n"); - return ERROR_ENCODING; - } - - mol_seg_t witness_input_type_seg = use_input_type ? - MolReader_WitnessArgs_get_input_type(&witness_seg) : MolReader_WitnessArgs_get_output_type(&witness_seg); - - if (MolReader_BytesOpt_is_none(&witness_input_type_seg)) { - printf("Error input_type in witness is empty\n"); - return ERROR_ENCODING; - } - - mol_seg_t witness_input_seg = - MolReader_Bytes_raw_bytes(&witness_input_type_seg); - - if (MolReader_XudtWitnessInput_verify(&witness_input_seg, false) != MOL_OK) { - printf("Error while verifying XudtWitnessInput\n"); - return ERROR_ENCODING; - } - - mol_seg_t signature_bytes_seg = - MolReader_XudtWitnessInput_get_owner_signature(&witness_input_seg); - - if (MolReader_BytesOpt_is_none(&signature_bytes_seg)) { - printf("Error owner_signature in witness is empty\n"); - return ERROR_ENCODING; - } - - mol_seg_t signature_seg = MolReader_Bytes_raw_bytes(&signature_bytes_seg); - - if (signature_seg.size != SIGNATURE_SIZE) { - printf("Error wrong signature size: got %d, expecting %d\n", - signature_seg.size, SIGNATURE_SIZE); - hex_dump("signature", signature_seg.ptr, signature_seg.size, 0); - return ERROR_ENCODING; - } - - memcpy(signature, signature_seg.ptr, signature_seg.size); - return CKB_SUCCESS; -} - -int verify_signature(uint8_t *pk_hash, uint64_t pk_hash_len, uint8_t *sig, - uint64_t sig_len) { - if (pk_hash_len != BLAKE160_SIZE) { - printf("Error wrong pk hash length: got %d, expecting %d\n", - pk_hash_len, BLAKE160_SIZE); - return ERROR_ILLEGAL_ARGUMENTS; - } - - uint64_t tx_hash_len = BLAKE2B_BLOCK_SIZE; - unsigned char tx_hash[BLAKE2B_BLOCK_SIZE]; - int ret = ckb_load_tx_hash(tx_hash, &tx_hash_len, 0); - if (ret != CKB_SUCCESS) { - return ret; - } - if (tx_hash_len != BLAKE2B_BLOCK_SIZE) { - return ERROR_UNREACHABLE; - } - - uint8_t output_pk_hash[BLAKE160_SIZE]; - uint64_t output_pk_hash_len = BLAKE160_SIZE; - hex_dump("sig", sig, sig_len, 0); - hex_dump("tx_hash", tx_hash, sizeof(tx_hash), 0); - ret = - validate_signature_secp256k1(NULL, sig, sig_len, tx_hash, sizeof(tx_hash), - output_pk_hash, &output_pk_hash_len); - - if (ret != 0) { - printf("Error validating secp256k1 %d\n", ret); - return ret; - } - if (output_pk_hash_len != BLAKE160_SIZE) { - return ERROR_UNREACHABLE; - } - - if (memcmp(pk_hash, output_pk_hash, BLAKE160_SIZE) != 0) { - hex_dump("pk hash in arguments", (const void *)pk_hash, pk_hash_len, 0); - hex_dump("pk hash from output", (const void *)output_pk_hash, output_pk_hash_len, 0); - return ERROR_SIGNATURE_VERIFICATION; - } - - return 0; -} - -__attribute__((visibility("default"))) int validate(int _is_owner_mode, - size_t _extension_index, - const uint8_t *args, - size_t args_len) { - int ret = 0; - uint8_t signature[SIGNATURE_SIZE]; - - hex_dump("args", (const void *)args, args_len, 0); - - // Read signature from witness. - ret = get_owner_signature(signature); - if (ret != 0) { - printf("Error while fetching owner signature\n", ret); - return ret; - } - - hex_dump("sig", (const void *)signature, SIGNATURE_SIZE, 0); - - // Validate signature. - ret = verify_signature((uint8_t *)args, args_len, signature, SIGNATURE_SIZE); - printf("verify sighash all result %d\n", ret); - return ret; -} - diff --git a/tests/xudt_rce/run.sh b/tests/xudt_rce/run.sh deleted file mode 100644 index 7e35bd1..0000000 --- a/tests/xudt_rce/run.sh +++ /dev/null @@ -1,13 +0,0 @@ - -set -e -FOLDER=simulator-build-debug -cd "$(dirname "${BASH_SOURCE[0]}")" -mkdir -p ${FOLDER} -cd ${FOLDER} -cmake -DCMAKE_C_COMPILER=clang .. -make all -cd ../../.. -echo "Running tests" -tests/xudt_rce/${FOLDER}/xudt_rce_simulator -tests/xudt_rce/${FOLDER}/xudt_rce_validator_simulator -echo "Done" diff --git a/tests/xudt_rce/smt_fuzzer/Makefile b/tests/xudt_rce/smt_fuzzer/Makefile deleted file mode 100644 index 1ee395e..0000000 --- a/tests/xudt_rce/smt_fuzzer/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -OS = Unknown -ifneq ($(shell uname -a | grep -i Darwin),) - OS = MacOS -endif -ifneq ($(shell uname -a | grep -i Linux),) - OS = Linux -endif -ifeq ($(OS),Unknown) - echo "error: unsupported OS"; exit 1 -endif - -NPROC?=4 -CC=clang -LLVM_PROFDATA=llvm-profdata -LLVM_COV=llvm-cov - -CORPUS_DIR=corpus - -FUZZER_FLAGS=-g -O1 -fsanitize=fuzzer,address,undefined -I ../../../c -I ../../../deps/ckb-c-stdlib-20210713 -I ../../../deps/sparse-merkle-tree/c - -COVERAGE_DIR=coverage -COVERAGE_FLAGS=-fprofile-instr-generate -fcoverage-mapping -I ../../../c -I ../../../deps/ckb-c-stdlib-20210713 -I ../../../deps/sparse-merkle-tree/c - -ifeq ($(OS),MacOS) - COVERAGE_FLAGS+=-Wl,-U,_LLVMFuzzerCustomMutator -Wl,-U,_LLVMFuzzerInitialize -endif - -EXTERNAL_HEADERS=../../../deps/sparse-merkle-tree/c/ckb_smt.h - -all: fuzzer coverage - -show: $(COVERAGE_DIR)/fuzzer.profdata - $(LLVM_COV) show --instr-profile=$(COVERAGE_DIR)/fuzzer.profdata smt_coverage - -report: $(COVERAGE_DIR)/fuzzer.profdata coverage $(EXTERNAL_HEADERS) - $(LLVM_COV) report --show-functions --instr-profile=$(COVERAGE_DIR)/fuzzer.profdata smt_coverage $(EXTERNAL_HEADERS) - -fuzzer: $(EXTERNAL_HEADERS) - clang $(FUZZER_FLAGS) smt_fuzzer.c -o smt_fuzzer - -coverage: $(EXTERNAL_HEADERS) - clang $(COVERAGE_FLAGS) smt_coverage.c smt_fuzzer.c -o smt_coverage - -start-fuzzer: fuzzer - ./smt_fuzzer -max_len=800000 -workers=$(NPROC) -jobs=$(NPROC) corpus - -start-fuzzer2: fuzzer - ./smt_fuzzer -max_len=800000 corpus - -clean: - rm -rf smt_fuzzer smt_coverage smt_fuzzer.dSYM - -#%.h: -# ln -s $(CURDIR)/../$@ $(CURDIR)/$@ - -%.profraw: coverage - LLVM_PROFILE_FILE=$@ ./smt_coverage $(CORPUS_DIR)/* - -%.profdata: %.profraw - $(LLVM_PROFDATA) merge --sparse $< -o $@ - -.PHONY: all fuzzer coverage report - -.PRECIOUS: $(COVERAGE_DIR)/fuzzer.profraw $(COVERAGE_DIR)/fuzzer.profdata diff --git a/tests/xudt_rce/smt_fuzzer/smt_coverage.c b/tests/xudt_rce/smt_fuzzer/smt_coverage.c deleted file mode 100644 index 87e372e..0000000 --- a/tests/xudt_rce/smt_fuzzer/smt_coverage.c +++ /dev/null @@ -1,41 +0,0 @@ -/*===- StandaloneFuzzTargetMain.c - standalone main() for fuzz targets. ---===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// This main() function can be linked to a fuzz target (i.e. a library -// that exports LLVMFuzzerTestOneInput() and possibly LLVMFuzzerInitialize()) -// instead of libFuzzer. This main() function will not perform any fuzzing -// but will simply feed all input files one by one to the fuzz target. -// -// Use this file to provide reproducers for bugs when linking against libFuzzer -// or other fuzzing engine is undesirable. -//===----------------------------------------------------------------------===*/ -#include -#include -#include - -extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); -__attribute__((weak)) extern int LLVMFuzzerInitialize(int *argc, char ***argv); - -int main(int argc, char **argv) { - fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1); - // if (LLVMFuzzerInitialize) LLVMFuzzerInitialize(&argc, &argv); - for (int i = 1; i < argc; i++) { - fprintf(stderr, "Running: %s\n", argv[i]); - FILE *f = fopen(argv[i], "r"); - assert(f); - fseek(f, 0, SEEK_END); - size_t len = ftell(f); - fseek(f, 0, SEEK_SET); - unsigned char *buf = (unsigned char *)malloc(len); - size_t n_read = fread(buf, 1, len, f); - fclose(f); - assert(n_read == len); - LLVMFuzzerTestOneInput(buf, len); - free(buf); - fprintf(stderr, "Done: %s: (%zd bytes)\n", argv[i], n_read); - } -} diff --git a/tests/xudt_rce/smt_fuzzer/smt_func.h b/tests/xudt_rce/smt_fuzzer/smt_func.h deleted file mode 100644 index 093d8b5..0000000 --- a/tests/xudt_rce/smt_fuzzer/smt_func.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef XUDT_RCE_SIMULATOR_TESTS_XUDT_RCE_SMT_FUZZER_SMT_FUNC_H_ -#define XUDT_RCE_SIMULATOR_TESTS_XUDT_RCE_SMT_FUZZER_SMT_FUNC_H_ -#include -#include -#include -#include "blake2b.h" - -#include "ckb_smt.h" - -#define MAX_ENTRIES_COUNT 8196 -int smt_func(const uint8_t* data, size_t size) { - smt_pair_t entries[MAX_ENTRIES_COUNT]; - smt_state_t states; - smt_state_init(&states, entries, MAX_ENTRIES_COUNT); - const uint8_t* root_hash = NULL; - int32_t size2 = (int32_t)size; - - if (size2 > 32) { - root_hash = data; - } else { - return 1; - } - int32_t index = 32; - int32_t count = 0; - while (index < (size2-128)) { - smt_state_insert(&states, data + index, data + index + 32); - index += 64; - count ++; - if (count > MAX_ENTRIES_COUNT) - break; - } - smt_state_normalize(&states); - if ((size2 - index) > 12) { - if (smt_verify(root_hash, &states, data + index, size2 - index) == 0) { - return 0; - } else { - return 2; - } - } else { - return 3; - } -} -#endif //XUDT_RCE_SIMULATOR_TESTS_XUDT_RCE_SMT_FUZZER_SMT_FUNC_H_ diff --git a/tests/xudt_rce/smt_fuzzer/smt_fuzzer.c b/tests/xudt_rce/smt_fuzzer/smt_fuzzer.c deleted file mode 100644 index 59b8df1..0000000 --- a/tests/xudt_rce/smt_fuzzer/smt_fuzzer.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "smt_func.h" - - -int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { - smt_func(data, size); - return 0; -} diff --git a/tests/xudt_rce/testing_report.md b/tests/xudt_rce/testing_report.md deleted file mode 100644 index 9168077..0000000 --- a/tests/xudt_rce/testing_report.md +++ /dev/null @@ -1,111 +0,0 @@ -# Testing Results for XUDT/RCE - -Following [ckb-contract-guidelines](https://github.com/nervosnetwork/ckb-contract-guidelines) - - -### Rule 1: 100% test coverage -Uncomment the following in CMakeLists.txt to enable: -```cmake -# uncomment it for coverage test -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") -#add_definitions(-DCKB_COVERAGE) -``` -Then use ```tests/xudt_rce/run.sh``` to run the whole test case and get coverage results. - -we have rce.h with 98% coverage and xudt_rce.c with 96% coverage. Some of code is hard to covered. -for example, in rce.h, -```C -} else { -CHECK2(false, ERROR_INVALID_MOL_FORMAT); -} -``` -It failed immediately when the data format is malformed. - -In xudt_rce.c: -```C - err = ckb_checked_load_witness(ptr, &output_len, offset, arg[0], arg[1]); - if (err != 0) { - return 0; - } -``` -They are also about the malformed data. They only have 1 or 2 lines of code, -which can be easily inspected. - -### Rule 2: Multiple execution environment for tests - -#### Normal CKB-VM as used in CKB - -require Rust test cases - -#### At least 20 runs of CKB-VM running in chaos mode - -require Rust test cases - - -#### Native x64 environment for gathering test coverage -See rule 1. - -#### LLVM Undefined Behavior Sanitizer -See below. - -#### LLVM Address Sanitizer -Uncomment the following in CMakeLists.txt to enable: -``` -# uncomment it for sanitize -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined") -``` - -There 2 issues detected: - -1. An overflow issue is detected and it's intended: - -``` -typedef struct mol2_data_source_t { - // function "read" might have more arguments - uintptr_t args[4]; - mol2_source_t read; - // start point of the cache - // if [offset, size) is in [start_point, start_point+cache_size), it returns - // memory in cache directly otherwise, it will try to load first (like cache - // miss) - uint32_t start_point; - uint32_t cache_size; - // it's normally same as MAX_CACHE_SIZE. - // modify it for testing purpose - uint32_t max_cache_size; - // sanitizer will report: Index ??? out of bounds for type 'uint8_t [64]' - // it's safe: because we use variable length structure/array. - uint8_t cache[MAX_CACHE_SIZE]; -} mol2_data_source_t; - -``` - -The sanitizer will report: Index ??? out of bounds for type `````'uint8_t [64]`````, it's intended. - -2. The warning of misaligned address - -``` -report error: -Load of misaligned address ??? for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment - -uint32_t* flag_ptr = (uint32_t*)(args_bytes_seg.ptr + BLAKE2B_BLOCK_SIZE); -``` -don't have good solution to avoid. - -### Fuzzing test on smt -It only works for "ckb_smt.h". - -```bash -cd smt_fuzzer -make start-fuzzer -``` - -Get code coverage by: -```bash -make report -make show -``` - -Currently there is no issue (overflow, out of bounds) found. -It is also served as an excellent coverage test. - diff --git a/tests/xudt_rce/utest.h b/tests/xudt_rce/utest.h deleted file mode 100644 index 1d3d832..0000000 --- a/tests/xudt_rce/utest.h +++ /dev/null @@ -1,932 +0,0 @@ -/* - The latest version of this library is available on GitHub; - https://github.com/sheredom/utest.h -*/ - -/* - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or - distribute this software, either in source code form or as a compiled - binary, for any purpose, commercial or non-commercial, and by any - means. - - In jurisdictions that recognize copyright laws, the author or authors - of this software dedicate any and all copyright interest in the - software to the public domain. We make this dedication for the benefit - of the public at large and to the detriment of our heirs and - successors. We intend this dedication to be an overt act of - relinquishment in perpetuity of all present and future rights to this - software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - For more information, please refer to -*/ - -#ifndef SHEREDOM_UTEST_H_INCLUDED -#define SHEREDOM_UTEST_H_INCLUDED - -#ifdef _MSC_VER -/* - Disable warning about not inlining 'inline' functions. - TODO: We'll fix this later by not using fprintf within our macros, and - instead use snprintf to a realloc'ed buffer. -*/ -#pragma warning(disable : 4710) - -/* - Disable warning about inlining functions that are not marked 'inline'. - TODO: add a UTEST_NOINLINE onto the macro generated functions to fix this. -*/ -#pragma warning(disable : 4711) -#pragma warning(push, 1) -#endif - -#if defined(_MSC_VER) -typedef __int64 utest_int64_t; -typedef unsigned __int64 utest_uint64_t; -#else -#include -typedef int64_t utest_int64_t; -typedef uint64_t utest_uint64_t; -#endif - -#include -#include -#include -#include - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#if defined(_MSC_VER) -#if defined(_M_IX86) -#define _X86_ -#endif - -#if defined(_M_AMD64) -#define _AMD64_ -#endif - -#pragma warning(push, 1) -#include -#include -#pragma warning(pop) - -#elif defined(__linux__) - -/* - slightly obscure include here - we need to include glibc's features.h, but - we don't want to just include a header that might not be defined for other - c libraries like musl. Instead we include limits.h, which we know on all - glibc distributions includes features.h -*/ -#include - -#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) -#include - -#if ((2 < __GLIBC__) || ((2 == __GLIBC__) && (17 <= __GLIBC_MINOR__))) -/* glibc is version 2.17 or above, so we can just use clock_gettime */ -#define UTEST_USE_CLOCKGETTIME -#else -#include -#include -#endif -#endif - -#elif defined(__APPLE__) -#include -#endif - -#if defined(_MSC_VER) -#define UTEST_PRId64 "I64d" -#define UTEST_PRIu64 "I64u" -#define UTEST_INLINE __forceinline - -#pragma section(".CRT$XCU", read) -#define UTEST_INITIALIZER(f) \ - static void __cdecl f(void); \ - __declspec(allocate(".CRT$XCU")) void(__cdecl * f##_)(void) = f; \ - static void __cdecl f(void) -#else -#if defined(__linux__) -#if defined(__clang__) -#if __has_warning("-Wreserved-id-macro") -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif -#endif - -#define __STDC_FORMAT_MACROS 1 - -#if defined(__clang__) -#if __has_warning("-Wreserved-id-macro") -#pragma clang diagnostic pop -#endif -#endif -#endif - -#include - -#define UTEST_PRId64 PRId64 -#define UTEST_PRIu64 PRIu64 -#define UTEST_INLINE inline - -#define UTEST_INITIALIZER(f) \ - static void f(void) __attribute__((constructor)); \ - static void f(void) -#endif - -#if defined(__cplusplus) -#define UTEST_CAST(type, x) static_cast(x) -#define UTEST_PTR_CAST(type, x) reinterpret_cast(x) -#define UTEST_EXTERN extern "C" -#define UTEST_NULL NULL -#else -#define UTEST_CAST(type, x) ((type)x) -#define UTEST_PTR_CAST(type, x) ((type)x) -#define UTEST_EXTERN extern -#define UTEST_NULL 0 -#endif - -#ifdef _MSC_VER -/* - io.h contains definitions for some structures with natural padding. This is - uninteresting, but for some reason MSVC's behaviour is to warn about - including this system header. That *is* interesting -*/ -#pragma warning(disable : 4820) -#pragma warning(push, 1) -#include -#pragma warning(pop) -#define UTEST_COLOUR_OUTPUT() (_isatty(_fileno(stdout))) -#else -#include -#define UTEST_COLOUR_OUTPUT() (isatty(STDOUT_FILENO)) -#endif - -static UTEST_INLINE utest_int64_t utest_ns(void) { -#ifdef _MSC_VER - LARGE_INTEGER counter; - LARGE_INTEGER frequency; - QueryPerformanceCounter(&counter); - QueryPerformanceFrequency(&frequency); - return UTEST_CAST(utest_int64_t, - (counter.QuadPart * 1000000000) / frequency.QuadPart); -#elif defined(__linux) - struct timespec ts; - const clockid_t cid = CLOCK_REALTIME; -#if defined(UTEST_USE_CLOCKGETTIME) - clock_gettime(cid, &ts); -#else - syscall(SYS_clock_gettime, cid, &ts); -#endif - return UTEST_CAST(utest_int64_t, ts.tv_sec) * 1000 * 1000 * 1000 + ts.tv_nsec; -#elif __APPLE__ - return UTEST_CAST(utest_int64_t, mach_absolute_time()); -#endif -} - -typedef void (*utest_testcase_t)(int *, size_t); - -struct utest_test_state_s { - utest_testcase_t func; - size_t index; - char *name; -}; - -struct utest_state_s { - struct utest_test_state_s *tests; - size_t tests_length; - FILE *output; -}; - -/* extern to the global state utest needs to execute */ -UTEST_EXTERN struct utest_state_s utest_state; - -#if defined(_MSC_VER) -#define UTEST_WEAK __forceinline -#else -#define UTEST_WEAK __attribute__((weak)) -#endif - -#if defined(_MSC_VER) -#define UTEST_UNUSED -#else -#define UTEST_UNUSED __attribute__((unused)) -#endif - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wvariadic-macros" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#define UTEST_PRINTF(...) \ - if (utest_state.output) { \ - fprintf(utest_state.output, __VA_ARGS__); \ - } \ - printf(__VA_ARGS__) -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#ifdef _MSC_VER -#define UTEST_SNPRINTF(BUFFER, N, ...) _snprintf_s(BUFFER, N, N, __VA_ARGS__) -#else -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wvariadic-macros" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#define UTEST_SNPRINTF(...) snprintf(__VA_ARGS__) -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif - -#if defined(__cplusplus) -/* if we are using c++ we can use overloaded methods (its in the language) */ -#define UTEST_OVERLOADABLE -#elif defined(__clang__) -/* otherwise, if we are using clang with c - use the overloadable attribute */ -#define UTEST_OVERLOADABLE __attribute__((overloadable)) -#endif - -#if defined(UTEST_OVERLOADABLE) -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(float f); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(float f) { - UTEST_PRINTF("%f", UTEST_CAST(double, f)); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(double d); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(double d) { - UTEST_PRINTF("%f", d); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long double d); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long double d) { - UTEST_PRINTF("%Lf", d); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(int i); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(int i) { - UTEST_PRINTF("%d", i); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(unsigned int i); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(unsigned int i) { - UTEST_PRINTF("%u", i); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long int i); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long int i) { - UTEST_PRINTF("%ld", i); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long unsigned int i); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long unsigned int i) { - UTEST_PRINTF("%lu", i); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(const void *p); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(const void *p) { - UTEST_PRINTF("%p", p); -} - -/* - long long is a c++11 extension -*/ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) || \ - defined(__cplusplus) && (__cplusplus >= 201103L) - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long long int i); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long long int i) { - UTEST_PRINTF("%lld", i); -} - -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long long unsigned int i); -UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer( - long long unsigned int i) { - UTEST_PRINTF("%llu", i); -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) -#define utest_type_printer(val) \ - UTEST_PRINTF(_Generic((val), int \ - : "%d", long \ - : "%ld", long long \ - : "%lld", unsigned \ - : "%u", unsigned long \ - : "%lu", unsigned long long \ - : "%llu", float \ - : "%f", double \ - : "%f", long double \ - : "%Lf", default \ - : _Generic((val - val), ptrdiff_t \ - : "%p", default \ - : "undef")), \ - (val)) -#else -/* - we don't have the ability to print the values we got, so we create a macro - to tell our users we can't do anything fancy -*/ -#define utest_type_printer(...) UTEST_PRINTF("undef") -#endif - -#if defined(__cplusplus) && (__cplusplus >= 201103L) -#define UTEST_AUTO(x) auto -#elif !defined(__cplusplus) - -#if defined(__clang__) -/* clang-format off */ -/* had to disable clang-format here because it malforms the pragmas */ -#define UTEST_AUTO(x) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wgnu-auto-type\"") __auto_type \ - _Pragma("clang diagnostic pop") -/* clang-format on */ -#else -#define UTEST_AUTO(x) __auto_type -#endif - -#else -#define UTEST_AUTO(x) typeof(x + 0) -#endif - -#if defined(__clang__) -#define UTEST_EXPECT(x, y, cond) \ - { \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wlanguage-extension-token\"") \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \ - _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") \ - UTEST_AUTO(x) xEval = (x); \ - UTEST_AUTO(y) yEval = (y); \ - if (!((xEval)cond(yEval))) { \ - _Pragma("clang diagnostic pop") \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : "); \ - utest_type_printer(xEval); \ - UTEST_PRINTF("\n"); \ - UTEST_PRINTF(" Actual : "); \ - utest_type_printer(yEval); \ - UTEST_PRINTF("\n"); \ - *utest_result = 1; \ - } \ - } -#elif defined(__GNUC__) -#define UTEST_EXPECT(x, y, cond) \ - { \ - UTEST_AUTO(x) xEval = (x); \ - UTEST_AUTO(y) yEval = (y); \ - if (!((xEval)cond(yEval))) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : "); \ - utest_type_printer(xEval); \ - UTEST_PRINTF("\n"); \ - UTEST_PRINTF(" Actual : "); \ - utest_type_printer(yEval); \ - UTEST_PRINTF("\n"); \ - *utest_result = 1; \ - } \ - } -#else -#define UTEST_EXPECT(x, y, cond) \ - { \ - if (!((x)cond(y))) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - *utest_result = 1; \ - } \ - } -#endif - -#define EXPECT_TRUE(x) \ - if (!(x)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : true\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - } - -#define EXPECT_FALSE(x) \ - if (x) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : false\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - } - -#define EXPECT_EQ(x, y) UTEST_EXPECT(x, y, ==) -#define EXPECT_NE(x, y) UTEST_EXPECT(x, y, !=) -#define EXPECT_LT(x, y) UTEST_EXPECT(x, y, <) -#define EXPECT_LE(x, y) UTEST_EXPECT(x, y, <=) -#define EXPECT_GT(x, y) UTEST_EXPECT(x, y, >) -#define EXPECT_GE(x, y) UTEST_EXPECT(x, y, >=) - -#define EXPECT_STREQ(x, y) \ - if (0 != strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - } - -#define EXPECT_STRNE(x, y) \ - if (0 == strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - } - -#if defined(__clang__) -#define UTEST_ASSERT(x, y, cond) \ - { \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wlanguage-extension-token\"") \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \ - _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") \ - UTEST_AUTO(x) xEval = (x); \ - UTEST_AUTO(y) yEval = (y); \ - if (!((xEval)cond(yEval))) { \ - _Pragma("clang diagnostic pop") \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : "); \ - utest_type_printer(xEval); \ - UTEST_PRINTF("\n"); \ - UTEST_PRINTF(" Actual : "); \ - utest_type_printer(yEval); \ - UTEST_PRINTF("\n"); \ - *utest_result = 1; \ - return; \ - } \ - } -#elif defined(__GNUC__) -#define UTEST_ASSERT(x, y, cond) \ - { \ - UTEST_AUTO(x) xEval = (x); \ - UTEST_AUTO(y) yEval = (y); \ - if (!((xEval)cond(yEval))) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : "); \ - utest_type_printer(xEval); \ - UTEST_PRINTF("\n"); \ - UTEST_PRINTF(" Actual : "); \ - utest_type_printer(yEval); \ - UTEST_PRINTF("\n"); \ - *utest_result = 1; \ - return; \ - } \ - } -#else -#define UTEST_ASSERT(x, y, cond) \ - { \ - if (!((x)cond(y))) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - *utest_result = 1; \ - return; \ - } \ - } -#endif - -#define ASSERT_TRUE(x) \ - if (!(x)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : true\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - return; \ - } - -#define ASSERT_FALSE(x) \ - if (x) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : false\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - return; \ - } - -#define ASSERT_EQ(x, y) UTEST_ASSERT(x, y, ==) -#define ASSERT_NE(x, y) UTEST_ASSERT(x, y, !=) -#define ASSERT_LT(x, y) UTEST_ASSERT(x, y, <) -#define ASSERT_LE(x, y) UTEST_ASSERT(x, y, <=) -#define ASSERT_GT(x, y) UTEST_ASSERT(x, y, >) -#define ASSERT_GE(x, y) UTEST_ASSERT(x, y, >=) - -#define ASSERT_STREQ(x, y) \ - EXPECT_STREQ(x, y); \ - if (0 != strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - return; \ - } - -#define ASSERT_STRNE(x, y) \ - EXPECT_STRNE(x, y); \ - if (0 == strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - return; \ - } - -#define UTEST(SET, NAME) \ - UTEST_EXTERN struct utest_state_s utest_state; \ - static void utest_run_##SET##_##NAME(int *utest_result); \ - static void utest_##SET##_##NAME(int *utest_result, size_t utest_index) { \ - (void)utest_index; \ - utest_run_##SET##_##NAME(utest_result); \ - } \ - UTEST_INITIALIZER(utest_register_##SET##_##NAME) { \ - const size_t index = utest_state.tests_length++; \ - const char *name_part = #SET "." #NAME; \ - const size_t name_size = strlen(name_part) + 1; \ - char *name = UTEST_PTR_CAST(char *, malloc(name_size)); \ - utest_state.tests = \ - UTEST_PTR_CAST(struct utest_test_state_s *, \ - realloc(UTEST_PTR_CAST(void *, utest_state.tests), \ - sizeof(struct utest_test_state_s) * \ - utest_state.tests_length)); \ - utest_state.tests[index].func = &utest_##SET##_##NAME; \ - utest_state.tests[index].name = name; \ - UTEST_SNPRINTF(name, name_size, "%s", name_part); \ - } \ - void utest_run_##SET##_##NAME(int *utest_result) - -#define UTEST_F_SETUP(FIXTURE) \ - static void utest_f_setup_##FIXTURE(int *utest_result, \ - struct FIXTURE *utest_fixture) - -#define UTEST_F_TEARDOWN(FIXTURE) \ - static void utest_f_teardown_##FIXTURE(int *utest_result, \ - struct FIXTURE *utest_fixture) - -#define UTEST_F(FIXTURE, NAME) \ - UTEST_EXTERN struct utest_state_s utest_state; \ - static void utest_f_setup_##FIXTURE(int *, struct FIXTURE *); \ - static void utest_f_teardown_##FIXTURE(int *, struct FIXTURE *); \ - static void utest_run_##FIXTURE##_##NAME(int *, struct FIXTURE *); \ - static void utest_f_##FIXTURE##_##NAME(int *utest_result, \ - size_t utest_index) { \ - struct FIXTURE fixture; \ - (void)utest_index; \ - memset(&fixture, 0, sizeof(fixture)); \ - utest_f_setup_##FIXTURE(utest_result, &fixture); \ - if (0 != *utest_result) { \ - return; \ - } \ - utest_run_##FIXTURE##_##NAME(utest_result, &fixture); \ - utest_f_teardown_##FIXTURE(utest_result, &fixture); \ - } \ - UTEST_INITIALIZER(utest_register_##FIXTURE##_##NAME) { \ - const size_t index = utest_state.tests_length++; \ - const char *name_part = #FIXTURE "." #NAME; \ - const size_t name_size = strlen(name_part) + 1; \ - char *name = UTEST_PTR_CAST(char *, malloc(name_size)); \ - utest_state.tests = \ - UTEST_PTR_CAST(struct utest_test_state_s *, \ - realloc(UTEST_PTR_CAST(void *, utest_state.tests), \ - sizeof(struct utest_test_state_s) * \ - utest_state.tests_length)); \ - utest_state.tests[index].func = &utest_f_##FIXTURE##_##NAME; \ - utest_state.tests[index].name = name; \ - UTEST_SNPRINTF(name, name_size, "%s", name_part); \ - } \ - void utest_run_##FIXTURE##_##NAME(int *utest_result, \ - struct FIXTURE *utest_fixture) - -#define UTEST_I_SETUP(FIXTURE) \ - static void utest_i_setup_##FIXTURE( \ - int *utest_result, struct FIXTURE *utest_fixture, size_t utest_index) - -#define UTEST_I_TEARDOWN(FIXTURE) \ - static void utest_i_teardown_##FIXTURE( \ - int *utest_result, struct FIXTURE *utest_fixture, size_t utest_index) - -#define UTEST_I(FIXTURE, NAME, INDEX) \ - UTEST_EXTERN struct utest_state_s utest_state; \ - static void utest_run_##FIXTURE##_##NAME##_##INDEX(int *, struct FIXTURE *); \ - static void utest_i_##FIXTURE##_##NAME##_##INDEX(int *utest_result, \ - size_t index) { \ - struct FIXTURE fixture; \ - memset(&fixture, 0, sizeof(fixture)); \ - utest_i_setup_##FIXTURE(utest_result, &fixture, index); \ - if (0 != *utest_result) { \ - return; \ - } \ - utest_run_##FIXTURE##_##NAME##_##INDEX(utest_result, &fixture); \ - utest_i_teardown_##FIXTURE(utest_result, &fixture, index); \ - } \ - UTEST_INITIALIZER(utest_register_##FIXTURE##_##NAME##_##INDEX) { \ - size_t i; \ - utest_uint64_t iUp; \ - for (i = 0; i < (INDEX); i++) { \ - const size_t index = utest_state.tests_length++; \ - const char *name_part = #FIXTURE "." #NAME; \ - const size_t name_size = strlen(name_part) + 32; \ - char *name = UTEST_PTR_CAST(char *, malloc(name_size)); \ - utest_state.tests = \ - UTEST_PTR_CAST(struct utest_test_state_s *, \ - realloc(UTEST_PTR_CAST(void *, utest_state.tests), \ - sizeof(struct utest_test_state_s) * \ - utest_state.tests_length)); \ - utest_state.tests[index].func = &utest_i_##FIXTURE##_##NAME##_##INDEX; \ - utest_state.tests[index].index = i; \ - utest_state.tests[index].name = name; \ - iUp = UTEST_CAST(utest_uint64_t, i); \ - UTEST_SNPRINTF(name, name_size, "%s/%" UTEST_PRIu64, name_part, iUp); \ - } \ - } \ - void utest_run_##FIXTURE##_##NAME##_##INDEX(int *utest_result, \ - struct FIXTURE *utest_fixture) - -UTEST_WEAK -int utest_should_filter_test(const char *filter, const char *testcase); -UTEST_WEAK int utest_should_filter_test(const char *filter, - const char *testcase) { - if (filter) { - const char *filter_cur = filter; - const char *testcase_cur = testcase; - const char *filter_wildcard = UTEST_NULL; - - while (('\0' != *filter_cur) && ('\0' != *testcase_cur)) { - if ('*' == *filter_cur) { - /* store the position of the wildcard */ - filter_wildcard = filter_cur; - - /* skip the wildcard character */ - filter_cur++; - - while (('\0' != *filter_cur) && ('\0' != *testcase_cur)) { - if ('*' == *filter_cur) { - /* - we found another wildcard (filter is something like *foo*) so we - exit the current loop, and return to the parent loop to handle - the wildcard case - */ - break; - } else if (*filter_cur != *testcase_cur) { - /* otherwise our filter didn't match, so reset it */ - filter_cur = filter_wildcard; - } - - /* move testcase along */ - testcase_cur++; - - /* move filter along */ - filter_cur++; - } - - if (('\0' == *filter_cur) && ('\0' == *testcase_cur)) { - return 0; - } - - /* if the testcase has been exhausted, we don't have a match! */ - if ('\0' == *testcase_cur) { - return 1; - } - } else { - if (*testcase_cur != *filter_cur) { - /* test case doesn't match filter */ - return 1; - } else { - /* move our filter and testcase forward */ - testcase_cur++; - filter_cur++; - } - } - } - - if (('\0' != *filter_cur) || - (('\0' != *testcase_cur) && - ((filter == filter_cur) || ('*' != filter_cur[-1])))) { - /* we have a mismatch! */ - return 1; - } - } - - return 0; -} - -static UTEST_INLINE int utest_strncmp(const char *a, const char *b, size_t n) { - /* strncmp breaks on Wall / Werror on gcc/clang, so we avoid using it */ - unsigned i; - - for (i = 0; i < n; i++) { - if (a[i] < b[i]) { - return -1; - } else if (a[i] > b[i]) { - return 1; - } - } - - return 0; -} - -static UTEST_INLINE FILE *utest_fopen(const char *filename, const char *mode) { -#ifdef _MSC_VER - FILE *file; - if (0 == fopen_s(&file, filename, mode)) { - return file; - } else { - return 0; - } -#else - return fopen(filename, mode); -#endif -} - -UTEST_WEAK int utest_main(int argc, const char *const argv[]); -UTEST_WEAK int utest_main(int argc, const char *const argv[]) { - utest_uint64_t failed = 0; - size_t index = 0; - size_t *failed_testcases = UTEST_NULL; - size_t failed_testcases_length = 0; - const char *filter = UTEST_NULL; - utest_uint64_t ran_tests = 0; - - enum colours { RESET, GREEN, RED }; - - const int use_colours = UTEST_COLOUR_OUTPUT(); - const char *colours[] = {"\033[0m", "\033[32m", "\033[31m"}; - if (!use_colours) { - for (index = 0; index < sizeof colours / sizeof colours[0]; index++) { - colours[index] = ""; - } - } - /* loop through all arguments looking for our options */ - for (index = 1; index < UTEST_CAST(size_t, argc); index++) { - /* Informational switches */ - const char help_str[] = "--help"; - const char list_str[] = "--list-tests"; - /* Test config switches */ - const char filter_str[] = "--filter="; - const char output_str[] = "--output="; - - if (0 == utest_strncmp(argv[index], help_str, strlen(help_str))) { - printf( - "utest.h - the single file unit testing solution for C/C++!\n" - "Command line Options:\n" - " --help Show this message and exit.\n" - " --filter= Filter the test cases to run (EG. MyTest*.a " - "would run MyTestCase.a but not MyTestCase.b).\n" - " --list-tests List testnames, one per line. Output names " - "can be passed to --filter.\n" - " --output= Output an xunit XML file to the file " - "specified in .\n"); - goto cleanup; - } else if (0 == - utest_strncmp(argv[index], filter_str, strlen(filter_str))) { - /* user wants to filter what test cases run! */ - filter = argv[index] + strlen(filter_str); - } else if (0 == - utest_strncmp(argv[index], output_str, strlen(output_str))) { - utest_state.output = utest_fopen(argv[index] + strlen(output_str), "w+"); - } else if (0 == utest_strncmp(argv[index], list_str, strlen(list_str))) { - for (index = 0; index < utest_state.tests_length; index++) { - UTEST_PRINTF("%s\n", utest_state.tests[index].name); - } - /* when printing the test list, don't actually run the tests */ - return 0; - } - } - - for (index = 0; index < utest_state.tests_length; index++) { - if (utest_should_filter_test(filter, utest_state.tests[index].name)) { - continue; - } - - ran_tests++; - } - - printf("%s[==========]%s Running %" UTEST_PRIu64 " test cases.\n", - colours[GREEN], colours[RESET], UTEST_CAST(utest_uint64_t, ran_tests)); - - if (utest_state.output) { - fprintf(utest_state.output, "\n"); - fprintf(utest_state.output, - "\n", - UTEST_CAST(utest_uint64_t, ran_tests)); - fprintf(utest_state.output, - "\n", - UTEST_CAST(utest_uint64_t, ran_tests)); - } - - for (index = 0; index < utest_state.tests_length; index++) { - int result = 0; - utest_int64_t ns = 0; - - if (utest_should_filter_test(filter, utest_state.tests[index].name)) { - continue; - } - - printf("%s[ RUN ]%s %s\n", colours[GREEN], colours[RESET], - utest_state.tests[index].name); - - if (utest_state.output) { - fprintf(utest_state.output, "", - utest_state.tests[index].name); - } - - ns = utest_ns(); - utest_state.tests[index].func(&result, utest_state.tests[index].index); - ns = utest_ns() - ns; - - if (utest_state.output) { - fprintf(utest_state.output, "\n"); - } - - if (0 != result) { - const size_t failed_testcase_index = failed_testcases_length++; - failed_testcases = UTEST_PTR_CAST( - size_t *, realloc(UTEST_PTR_CAST(void *, failed_testcases), - sizeof(size_t) * failed_testcases_length)); - failed_testcases[failed_testcase_index] = index; - failed++; - printf("%s[ FAILED ]%s %s (%" UTEST_PRId64 "ns)\n", colours[RED], - colours[RESET], utest_state.tests[index].name, ns); - } else { - printf("%s[ OK ]%s %s (%" UTEST_PRId64 "ns)\n", colours[GREEN], - colours[RESET], utest_state.tests[index].name, ns); - } - } - - printf("%s[==========]%s %" UTEST_PRIu64 " test cases ran.\n", colours[GREEN], - colours[RESET], ran_tests); - printf("%s[ PASSED ]%s %" UTEST_PRIu64 " tests.\n", colours[GREEN], - colours[RESET], ran_tests - failed); - - if (0 != failed) { - printf("%s[ FAILED ]%s %" UTEST_PRIu64 " tests, listed below:\n", - colours[RED], colours[RESET], failed); - for (index = 0; index < failed_testcases_length; index++) { - printf("%s[ FAILED ]%s %s\n", colours[RED], colours[RESET], - utest_state.tests[failed_testcases[index]].name); - } - } - - if (utest_state.output) { - fprintf(utest_state.output, "\n\n"); - } - -cleanup: - for (index = 0; index < utest_state.tests_length; index++) { - free(UTEST_PTR_CAST(void *, utest_state.tests[index].name)); - } - - free(UTEST_PTR_CAST(void *, failed_testcases)); - free(UTEST_PTR_CAST(void *, utest_state.tests)); - - if (utest_state.output) { - fclose(utest_state.output); - } - - return UTEST_CAST(int, failed); -} - -/* - we need, in exactly one source file, define the global struct that will hold - the data we need to run utest. This macro allows the user to declare the - data without having to use the UTEST_MAIN macro, thus allowing them to write - their own main() function. -*/ -#define UTEST_STATE() struct utest_state_s utest_state = {0, 0, 0} - -/* - define a main() function to call into utest.h and start executing tests! A - user can optionally not use this macro, and instead define their own main() - function and manually call utest_main. The user must, in exactly one source - file, use the UTEST_STATE macro to declare a global struct variable that - utest requires. -*/ -#define UTEST_MAIN() \ - UTEST_STATE(); \ - int main(int argc, const char *const argv[]) { \ - return utest_main(argc, argv); \ - } - -#endif /* SHEREDOM_UTEST_H_INCLUDED */ diff --git a/tests/xudt_rce/validate.syms b/tests/xudt_rce/validate.syms deleted file mode 100644 index 3a9e9a8..0000000 --- a/tests/xudt_rce/validate.syms +++ /dev/null @@ -1,3 +0,0 @@ -{ - validate; -}; diff --git a/tests/xudt_rce/xudt_rce_sim.c b/tests/xudt_rce/xudt_rce_sim.c deleted file mode 100644 index 7af8513..0000000 --- a/tests/xudt_rce/xudt_rce_sim.c +++ /dev/null @@ -1,929 +0,0 @@ -#if defined(CKB_COVERAGE) -#define ASSERT(s) (void)0 -#else -#define ASSERT(s) (void)0 -#endif - -int ckb_exit(signed char code); - -#include "utest.h" -#include "xudt_rce.c" -void debug_print_hex(const char* prefix, const uint8_t* buf, size_t length) { - printf("%s: ", prefix); - for (size_t i = 0; i < length; i++) { - printf("%02x ", buf[i]); - } - printf("\n"); -} - -/* hex2bin modified from - * https://chromium.googlesource.com/chromium/deps/xz/+/77022065014d48cf51d83322264ab4836fd175ec/debug/hex2bin.c - */ -int getbin(int x) { - if (x >= '0' && x <= '9') return x - '0'; - if (x >= 'A' && x <= 'F') return x - 'A' + 10; - return x - 'a' + 10; -} - -int hex2bin(uint8_t* buf, const char* src) { - size_t length = strlen(src) / 2; - if (src[0] == '0' && (src[1] == 'x' || src[1] == 'X')) { - src += 2; - length--; - } - for (size_t i = 0; i < length; i++) { - buf[i] = (getbin(src[i * 2]) << 4) | getbin(src[i * 2 + 1]); - } - return length; -} - -void set_basic_data() { - xudt_set_flags(1); - xudt_add_input_amount(999); - xudt_add_output_amount(999); - - // lock script hash - uint8_t input_lock_script_hash[32] = {11}; - uint8_t output_lock_script_hash[32] = {22}; - xudt_add_input_lock_script_hash(input_lock_script_hash); - xudt_add_output_lock_script_hash(output_lock_script_hash); -} - -// the following hash_root, proof pairs are verified successfully -// with the following lock script hash: -// uint8_t input_lock_script_hash[32] = {11}; -// uint8_t output_lock_script_hash[32] = {22}; - -uint8_t BLACK_LIST_HASH_ROOT[32] = { - 126, 135, 248, 129, 55, 74, 37, 2, 200, 13, 112, 6, 225, 50, 60, 119, - 17, 26, 212, 53, 176, 39, 79, 18, 40, 147, 224, 67, 94, 50, 10, 130}; -uint8_t BLACK_LIST_PROOF[] = { - 76, 79, 3, 81, 2, 107, 31, 136, 57, 101, 46, 172, 224, 208, 71, - 81, 138, 235, 101, 93, 254, 147, 224, 69, 164, 216, 73, 120, 175, 255, - 83, 63, 60, 252, 171, 50, 90, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 79, 4, 72, 79, 251}; - -uint8_t WHITE_LIST_HASH_ROOT[32] = {121, 187, 51, 140, 11, 10, 158, 101, - 156, 132, 190, 246, 8, 83, 151, 51, - 128, 51, 8, 199, 110, 150, 151, 174, - 54, 156, 56, 94, 100, 186, 73, 119}; -uint8_t WHITE_LIST_PROOF[] = {76, 79, 4, 76, 79, 4, 72, 79, 251}; - -void set_rce_not_on_black_list_data() { - int err = 0; - set_basic_data(); - uint16_t root_rcrule = - rce_add_rcrule(BLACK_LIST_HASH_ROOT, 0x0); // black list - rce_begin_proof(); - rce_add_proof(BLACK_LIST_PROOF, countof(BLACK_LIST_PROOF), 0x3); - rce_end_proof(); - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); -} - -void set_rce_on_black_list_data() { - int err = 0; - set_basic_data(); - uint8_t hash[32] = { - 0}; // invalid hash, so the verify result is false: it's on black list. - uint16_t root_rcrule = rce_add_rcrule(hash, 0x0); // on black list - rce_begin_proof(); - rce_add_proof(BLACK_LIST_PROOF, countof(BLACK_LIST_PROOF), 0x3); - rce_end_proof(); - - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); -} - -UTEST(xudt, main) { - int err = 0; - - // prepare basic data - xudt_begin_data(); - set_basic_data(); - - uint8_t hash0[BLAKE2B_BLOCK_SIZE] = {0}; - uint8_t hash1[BLAKE2B_BLOCK_SIZE] = {1}; - uint8_t extension_hash[BLAKE2B_BLOCK_SIZE] = {0x66}; - uint8_t args[32] = {0}; - xudt_set_owner_mode(hash0, hash1); - xudt_add_extension_script( - extension_hash, 1, args, sizeof(args), - "tests/xudt_rce/simulator-build-debug/libextension_script_0.dylib"); - - xudt_end_data(); - - // flags = 1 - xudt_set_flags(1); - err = simulator_main(); - ASSERT_EQ(err, 0); - CHECK(err); - // flags = 2 - xudt_set_flags(2); - err = simulator_main(); - ASSERT_EQ(err, 0); - CHECK(err); - // flags is not available - xudt_set_flags(0); - err = simulator_main(); - ASSERT_EQ(err, 0); - CHECK(err); - // flags is available, but it's value is 0, - // Note: testing purpose, there is no such 0xFF flags. - xudt_set_flags(0xFF); - err = simulator_main(); - ASSERT_EQ(err, 0); - CHECK(err); - - // owner mode is true - xudt_set_owner_mode(hash0, hash0); - err = simulator_main(); - ASSERT_EQ(err, 0); - CHECK(err); - - err = 0; -exit: - ASSERT_EQ(err, 0); -} - -UTEST(xudt_many_scripts, main) { - int err = 0; - - // prepare basic data - xudt_begin_data(); - set_basic_data(); - - uint8_t hash0[BLAKE2B_BLOCK_SIZE] = {0}; - uint8_t hash1[BLAKE2B_BLOCK_SIZE] = {1}; - uint8_t extension_hash[BLAKE2B_BLOCK_SIZE] = {0x66}; - uint8_t args[32] = {0}; - xudt_set_owner_mode(hash0, hash1); - - for (int i = 0; i < 512; i++) { - xudt_add_extension_script( - extension_hash, 1, args, sizeof(args), - "tests/xudt_rce/simulator-build-debug/libextension_script_0.dylib"); - } - - xudt_end_data(); - - // when flags = 1, The extension script data is on args: - // it's too small to hold all these data - xudt_set_flags(1); - err = simulator_main(); - ASSERT_EQ(err, -1); - - // flags = 2 - xudt_set_flags(2); - err = simulator_main(); - ASSERT_EQ(err, 0); - CHECK(err); - - err = 0; -exit: - ASSERT_EQ(err, 0); -} - -UTEST(rce, white_list) { - int err = 0; - xudt_begin_data(); - set_basic_data(); - uint16_t root_rcrule = - rce_add_rcrule(WHITE_LIST_HASH_ROOT, 0x2); // white list - rce_begin_proof(); - rce_add_proof(WHITE_LIST_PROOF, countof(WHITE_LIST_PROOF), 0x3); - rce_end_proof(); - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - - err = simulator_main(); - ASSERT_EQ(err, 0); -exit: - return; -} - -UTEST(rce, both_input_and_output_on_white_list) { - int err = 0; - xudt_begin_data(); - set_basic_data(); - - // --include "0" 11 22 - uint8_t hash_root1[] = {121, 187, 51, 140, 11, 10, 158, 101, 156, 132, 190, - 246, 8, 83, 151, 51, 128, 51, 8, 199, 110, 150, - 151, 174, 54, 156, 56, 94, 100, 186, 73, 119}; - uint8_t proof1[] = {76, 79, 4, 81, 4, 183, 161, 135, 240, 168, 177, 241, - 159, 252, 171, 12, 137, 59, 35, 168, 236, 254, 11, 18, - 23, 44, 30, 23, 44, 151, 165, 109, 24, 54, 198, 17, - 34, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 251}; - - // --include "1" 11 22 - uint8_t hash_root2[] = {121, 187, 51, 140, 11, 10, 158, 101, 156, 132, 190, - 246, 8, 83, 151, 51, 128, 51, 8, 199, 110, 150, - 151, 174, 54, 156, 56, 94, 100, 186, 73, 119}; - uint8_t proof2[] = { - 76, 79, 4, 81, 4, 79, 165, 120, 195, 32, 225, 87, 101, 216, 104, - 215, 165, 4, 63, 251, 58, 229, 109, 123, 59, 26, 8, 183, 190, 133, - 142, 28, 222, 5, 23, 175, 72, 11, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 251}; - - uint16_t rcrulevec[MAX_RCRULE_IN_CELL] = {0}; - rcrulevec[0] = rce_add_rcrule(hash_root1, 0x2); - rcrulevec[1] = rce_add_rcrule(hash_root2, 0x2); - RCHashType root_rcrule = rce_add_rccellvec(rcrulevec, 2); - - rce_begin_proof(); - rce_add_proof(proof1, countof(proof1), 0x1); // input - rce_add_proof(proof2, countof(proof2), 0x2); // output - rce_end_proof(); - - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - - err = simulator_main(); - ASSERT_EQ(err, 0); -exit: - return; -} - -UTEST(rce, only_input_on_white_list) { - int err = 0; - xudt_begin_data(); - set_basic_data(); - - uint8_t hash_root1[] = {151, 81, 37, 242, 189, 99, 62, 175, 115, 9, 251, - 94, 105, 190, 173, 153, 42, 249, 87, 115, 253, 152, - 110, 88, 1, 58, 224, 21, 51, 99, 72, 182}; - uint8_t proof1[] = {76, 80, 4, 157, 181, 3, 109, 35, 79, 233, 114, 91, - 219, 188, 99, 77, 45, 214, 230, 222, 170, 154, 162, 63, - 51, 85, 254, 115, 15, 23, 166, 5, 21, 254, 51}; - - uint8_t hash_root2[] = {151, 81, 37, 242, 189, 99, 62, 175, 115, 9, 251, - 94, 105, 190, 173, 153, 42, 249, 87, 115, 253, 152, - 110, 88, 1, 58, 224, 21, 51, 99, 72, 182}; - hash_root2[0] = 0; // make output not on white list - uint8_t proof2[] = {76, 80, 4, 96, 186, 33, 226, 13, 35, 104, 150, 165, - 4, 223, 103, 18, 193, 40, 37, 99, 107, 99, 12, 175, - 14, 142, 165, 116, 90, 255, 239, 90, 63, 128, 35}; - - uint16_t rcrulevec[MAX_RCRULE_IN_CELL] = {0}; - rcrulevec[0] = rce_add_rcrule(hash_root1, 0x2); - rcrulevec[1] = rce_add_rcrule(hash_root2, 0x2); - RCHashType root_rcrule = rce_add_rccellvec(rcrulevec, 2); - - rce_begin_proof(); - rce_add_proof(proof1, countof(proof1), 0x1); // input - rce_add_proof(proof2, countof(proof2), 0x2); // output - rce_end_proof(); - - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - - err = simulator_main(); - ASSERT_EQ(ERROR_NOT_ON_WHITE_LIST, err); -exit: - return; -} - -UTEST(rce, not_on_white_list) { - int err = 0; - xudt_begin_data(); - set_basic_data(); - - uint8_t rcrule[32] = {0}; // invalid root_hash - uint16_t root_rcrule = rce_add_rcrule(rcrule, 0x2); // white list - uint8_t proof[] = {76, 76, 72, 4}; - rce_begin_proof(); - rce_add_proof(proof, countof(proof), 0x3); - rce_end_proof(); - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - - err = simulator_main(); - ASSERT_EQ(err, ERROR_NOT_ON_WHITE_LIST); -exit: - return; -} - -UTEST(smt, verify_not_on_bl) { - uint8_t key1[32] = {11}; - uint8_t value1[32] = {0}; - uint8_t key2[32] = {22}; - uint8_t value2[32] = {0}; - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key1, value1); - smt_state_insert(&changes, key2, value2); - smt_state_normalize(&changes); - - int err = smt_verify(BLACK_LIST_HASH_ROOT, &changes, BLACK_LIST_PROOF, - sizeof(BLACK_LIST_PROOF)); - ASSERT_EQ(0, err); -} - -UTEST(rce, black_list) { - int err = 0; - xudt_begin_data(); - set_basic_data(); - uint16_t root_rcrule = - rce_add_rcrule(BLACK_LIST_HASH_ROOT, 0x0); // black list - rce_begin_proof(); - rce_add_proof(BLACK_LIST_PROOF, countof(BLACK_LIST_PROOF), 0x3); - rce_end_proof(); - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - err = simulator_main(); - ASSERT_EQ(0, err); -exit: - return; -} - -UTEST(xudt, simple_udt) { - int err = 0; - xudt_begin_data(); - set_rce_not_on_black_list_data(); - xudt_add_input_amount(999); - xudt_add_output_amount(1000); - xudt_end_data(); - err = simulator_main(); - ASSERT_EQ(err, ERROR_AMOUNT); - -exit: - return; -} - -UTEST(xudt, emergency_halt_mode) { - int err = 0; - xudt_begin_data(); - xudt_set_flags(2); - - uint16_t root_rcrule = rce_add_rcrule( - BLACK_LIST_HASH_ROOT, 0x1); // emergency halt mode, black list - rce_begin_proof(); - rce_add_proof(BLACK_LIST_PROOF, countof(BLACK_LIST_PROOF), 0x3); - rce_end_proof(); - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - err = simulator_main(); - ASSERT_EQ(err, ERROR_RCE_EMERGENCY_HALT); -exit: - return; -} - -UTEST(xudt, extension_script_is_validated) { - int err = 0; - - xudt_begin_data(); - - xudt_set_flags(1); - xudt_add_input_amount(999); - xudt_add_output_amount(999); - uint8_t extension_hash[BLAKE2B_BLOCK_SIZE] = {0x66}; - uint8_t args[32] = {0}; - - xudt_add_extension_script( - extension_hash, 1, args, sizeof(args), - "tests/xudt_rce/simulator-build-debug/libextension_script_0.dylib"); - uint8_t hash[32]; - xudt_calc_extension_script_hash(extension_hash, 1, args, sizeof(args), hash); - uint8_t output_lock_script_hash[32] = {22}; - // extension script hash is identical to lock script hash - xudt_add_input_lock_script_hash(hash); - xudt_add_output_lock_script_hash(output_lock_script_hash); - - // finish data - xudt_end_data(); - - err = simulator_main(); - ASSERT_EQ(err, 0); -exit: - return; -} - -UTEST(xudt, extension_script_returns_non_zero) { - int err = 0; - xudt_begin_data(); - set_rce_on_black_list_data(); - uint8_t extension_hash[BLAKE2B_BLOCK_SIZE] = {0x66}; - uint8_t args[32] = {0}; - xudt_add_extension_script( - extension_hash, 1, args, sizeof(args), - "tests/xudt_rce/simulator-build-debug/libextension_script_1.dylib"); - xudt_end_data(); - err = simulator_main(); - ASSERT_EQ(ERROR_ON_BLACK_LIST, err); - -exit: - return; -} - -UTEST(rce, use_rc_cell_vec) { - int err = 0; - // prepare basic data - xudt_begin_data(); - set_basic_data(); - uint16_t rcrulevec[MAX_RCRULE_IN_CELL] = {0}; - for (int i = 0; i < MAX_RCRULE_IN_CELL; i++) { - rcrulevec[i] = - rce_add_rcrule(BLACK_LIST_HASH_ROOT, 0x0); // not on black list - } - RCHashType root_rcrule = rce_add_rccellvec(rcrulevec, MAX_RCRULE_IN_CELL); - rce_begin_proof(); - for (int i = 0; i < MAX_RCRULE_IN_CELL; i++) { - rce_add_proof(BLACK_LIST_PROOF, countof(BLACK_LIST_PROOF), 0x3); - } - rce_end_proof(); - uint8_t args[32] = {0}; - memcpy(args, &root_rcrule, 2); - xudt_add_extension_script(RCE_HASH, 1, args, sizeof(args), - "internal extension script, no path"); - xudt_end_data(); - - err = simulator_main(); - ASSERT_EQ(0, err); -exit: - return; -} - -UTEST(smt, verify_not_existing) { - uint8_t key1[32] = {11}; - uint8_t value1[32] = {0}; - uint8_t key2[32] = {22}; - uint8_t value2[32] = {0}; - // --exclude "11|22" 0 1 - uint8_t root_hash[32] = {126, 135, 248, 129, 55, 74, 37, 2, 200, 13, 112, - 6, 225, 50, 60, 119, 17, 26, 212, 53, 176, 39, - 79, 18, 40, 147, 224, 67, 94, 50, 10, 130}; - uint8_t proof[] = { - 76, 79, 3, 81, 2, 107, 31, 136, 57, 101, 46, 172, 224, 208, 71, - 81, 138, 235, 101, 93, 254, 147, 224, 69, 164, 216, 73, 120, 175, 255, - 83, 63, 60, 252, 171, 50, 90, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 79, 4, 72, 79, 251}; - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key1, value1); - smt_state_insert(&changes, key2, value2); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, sizeof(proof))); -} - -UTEST(smt, verify_last_byte_is_0x48) { - // --include "0|1" 11 - // 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - uint8_t key1[32] = {11}; - uint8_t value1[32] = {1}; - uint8_t key2[32] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - uint8_t value2[32] = {1}; - uint8_t root_hash[32] = {186, 238, 33, 242, 95, 185, 159, 239, - 2, 142, 238, 46, 209, 248, 223, 148, - 228, 225, 128, 18, 35, 190, 17, 41, - 236, 47, 207, 230, 217, 247, 145, 191}; - uint8_t proof[] = {76, 79, 255, 76, 79, 255, 72}; // 72 is 0x48 - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key1, value1); - smt_state_insert(&changes, key2, value2); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, sizeof(proof))); -} - -// this is the case from -// https://github.com/nervosnetwork/ckb-simple-account-layer/blob/1970c0382271837ff46fdc276c5b63bccb4324db/c/tests/main.c#L136 -// the names are changed accordingly. -// --hex --kvpair --exclude -// 0x0101010101010101010101010101010101010101010101010101010101010101 1 1 -UTEST(smt, verify_empty) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(key, - "0x0101010101010101010101010101010101010101010101010101010101010101"); - hex2bin(value, - "0x0000000000000000000000000000000000000000000000000000000000000000"); - hex2bin(root_hash, - "0x2e53c97352a7a7d126e96ace29acbdd1ccadb7ce01fae60e45eb1140002ca5e4"); - int proof_length = hex2bin(proof, - "0x4c4ff851f833522063667f32b6cc23ef966e0dfd6407425" - "c7cd7ea87156303e7be9cc37a4f0100000000000000000000" - "0000000000000000000000000000000000000000004f07"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -// --hex --kvpair --exclude -// 0x0101010101010101010101010101010101010101010101010101010101010101 1 1 -UTEST(smt, verify_empty2) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(key, - "0x0101010101010101010101010101010101010101010101010101010101010101"); - hex2bin(value, - "0x0000000000000000000000000000000000000000000000000000000000000000"); - hex2bin(root_hash, - "0x0f39878077162cf8a5e9455c28956dd2f460b5b8bba5389336b8fdb5032263c7"); - int proof_length = hex2bin(proof, - "0x4c4ff851f8ece253fdd24dc8e1b991b6f6fd0a537caa0de" - "a20f4093844a79de77d33972e480100000000000000000000" - "0000000000000000000000000000000000000000004f07"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -// --hex --kvpair --include "0" -// 0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b -// 0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b 11 11 -UTEST(smt, verify1) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(key, - "0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b"); - hex2bin(value, - "0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b"); - hex2bin(root_hash, - "0xebe0fab376cd802d364eeb44af20c67a74d6183a33928fead163120ef12e6e06"); - int proof_length = hex2bin( - proof, - "0x4c4fff51ff322de8a89fe589987f97220cfcb6820bd798b31a0b56ffea221093d35f90" - "9e580b00000000000000000000000000000000000000000000000000000000000000"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -// run -- --hex --kvpair --include "0" -// 0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a -// 0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82 11 11 22 -// 22 -UTEST(smt, verify2) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(key, - "0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a"); - hex2bin(value, - "0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82"); - hex2bin(root_hash, - "0x6e5c722644cd55cef8c4ed886cd8b44027ae9ed129e70a4b67d87be1c6857842"); - int proof_length = hex2bin( - proof, - "0x4c4fff51fa8aaa2aece17b92ec3f202a40a09f7286522bae1e5581a2a49195ab6781b1" - "b8090000000000000000000000000000000000000000000000000000000000000000"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -// run -- --hex --kvpair --include "0" -// 0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5 -// 0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb 11 11 -// 22 22 -UTEST(smt, verify3) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb"); - hex2bin(root_hash, - "0xc8f513901e34383bcec57c368628ce66da7496df0a180ee1e021df3d97cb8f7b"); - int proof_length = hex2bin( - proof, - "0x4c4fff51fa8aaa2aece17b92ec3f202a40a09f7286522bae1e5581a2a49195ab6781b1" - "b8090000000000000000000000000000000000000000000000000000000000000000"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -UTEST(smt, verify_invalid_hash) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb"); - hex2bin(root_hash, - "0xa4cbf1b69a848396ac759f362679e2b185ac87a17cba747d2db1ef6fd929042f"); - int proof_length = hex2bin( - proof, - "0x4c50fe32845309d34f132cd6f7ac6a7881962401adc35c19a18d4fffeb511b97ea" - "bf86"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_NE(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -UTEST(smt, verify_all_leaves_used) {} - -// --hex --kvpair --include '0|1' -// 0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5 -// 0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb -// 0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e6 -// 0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19ec -UTEST(smt, verify_multi_2) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(root_hash, - "0xae39dd03298b9fe839358b3dd68bc45794c0598aa7ebfc147b9b5c228e7e67cc"); - int proof_length = hex2bin(proof, "0x4c4ff94c4ff9484f06"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb"); - smt_state_insert(&changes, key, value); - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e6"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19ec"); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -// --hex --kvpair --include '0|1|2' -// 0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5 -// 0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb -// 0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b -// 0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b -// 0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a -// 0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82 -UTEST(smt, verify_multi_3) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(root_hash, - "0x35fb14c8d5994f8871d7a107cbf3be05db578c6dbd0a731c3cee241eccc77d82"); - int proof_length = hex2bin(proof, "0x4c4ff84c4ff8484f054c4ffe484f01"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb"); - smt_state_insert(&changes, key, value); - hex2bin(key, - "0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b"); - hex2bin(value, - "0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b"); - smt_state_insert(&changes, key, value); - hex2bin(key, - "0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a"); - hex2bin(value, - "0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82"); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_EQ(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -UTEST(smt, verify_invalid_height) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t proof[96]; - - hex2bin(root_hash, - "0xa4cbf1b69a848396ac759f362679e2b185ac87a17cba747d2db1ef6fd929042f"); - int proof_length = hex2bin(proof, "0x4c4c48204c4840"); - - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, 32); - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb"); - smt_state_insert(&changes, key, value); - hex2bin(key, - "0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b"); - hex2bin(value, - "0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b"); - smt_state_insert(&changes, key, value); - hex2bin(key, - "0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a"); - hex2bin(value, - "0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82"); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - - ASSERT_NE(0, smt_verify(root_hash, &changes, proof, proof_length)); -} - -UTEST(smt, update) { - uint8_t key[32]; - uint8_t value[32]; - uint8_t root_hash[32]; - uint8_t expected_hash[32]; - uint8_t proof[96]; - smt_pair_t entries[8]; - smt_state_t changes; - - memset(root_hash, 0, 32); - hex2bin(key, - "0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a"); - hex2bin(value, - "0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82"); - int proof_length = hex2bin(proof, "0x4c4f00"); - memset(&proof[32], 0, 64); - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - ASSERT_EQ(0, smt_calculate_root(root_hash, &changes, proof, proof_length)); - // --hex --kvpair --include "0" - // 0xa9bb945be71f0bd2757d33d2465b6387383da42f321072e47472f0c9c7428a8a - // 0xa939a47335f777eac4c40fbc0970e25f832a24e1d55adc45a7b76d63fe364e82 - hex2bin(expected_hash, - "0xd75c4d6624ce668856d9a382c45276a2c06ba7065192d8bb805d48e106a4136d"); - ASSERT_EQ(0, memcmp(root_hash, expected_hash, 32)); - - // run -- --hex --kvpair --include "0" - // 0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b - // 0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b - // 11 - // 11 - hex2bin(key, - "0x381dc5391dab099da5e28acd1ad859a051cf18ace804d037f12819c6fbc0e18b"); - hex2bin(value, - "0x9158ce9b0e11dd150ba2ae5d55c1db04b1c5986ec626f2e38a93fe8ad0b2923b"); - proof_length = hex2bin( - proof, - "0x4c4fff51ff322de8a89fe589987f97220cfcb6820bd798b31a0b56ffea221093d35f90" - "9e580b00000000000000000000000000000000000000000000000000000000000000"); - memset(&proof[64], 0, 32); - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - ASSERT_EQ(0, smt_calculate_root(root_hash, &changes, proof, proof_length)); - hex2bin(expected_hash, - "0xebe0fab376cd802d364eeb44af20c67a74d6183a33928fead163120ef12e6e06"); - ASSERT_EQ(0, memcmp(root_hash, expected_hash, 32)); - - hex2bin(key, - "0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5"); - hex2bin(value, - "0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb"); - proof_length = hex2bin(proof, "0x4c4f00"); - smt_state_init(&changes, entries, 32); - smt_state_insert(&changes, key, value); - smt_state_normalize(&changes); - ASSERT_EQ(0, smt_calculate_root(root_hash, &changes, proof, proof_length)); - // --hex --kvpair --include "0" - // 0xe8c0265680a02b680b6cbc880348f062b825b28e237da7169aded4bcac0a04e5 - // 0x2ca41595841e46ce8e74ad749e5c3f1d17202150f99c3d8631233ebdd19b19eb - hex2bin(expected_hash, - "0xc4cb09d4ffc0cad781fa2b64bd67a587e4107fe67eed7dee833e8f349d9596f5"); - ASSERT_EQ(0, memcmp(root_hash, expected_hash, 32)); -} - -// naive implementation, get element at "index" , not counting "zero" element. -uint8_t get_from_table(uint8_t* table, int len, int index) { - int true_index = -1; - for (int i = 0; i < len; i++) { - if (table[i] != 0) { - true_index++; - } - if (true_index == index) { - return table[i]; - } - } - ASSERT(false); - return 0xFF; -} - -bool test_state_normalize_random() { - uint8_t table[8] = {0}; - smt_pair_t entries[8]; - smt_state_t changes; - smt_state_init(&changes, entries, countof(entries)); - char msg_to_print[32768] = {0}; - int msg_start = 0; - for (int i = 0; i < countof(entries); i++) { - int key = rand() % 8; - table[key] += 1; - - uint8_t key32[32] = {key}; - uint8_t value32[32] = {table[key]}; - int used = sprintf(msg_to_print + msg_start, - "pushed key = %d, value = %d\n", key, table[key]); - msg_start += used; - smt_state_insert(&changes, key32, value32); - } - smt_state_normalize(&changes); - for (int i = 0; i < changes.len; i++) { - uint8_t expected = get_from_table(table, countof(entries), i); - if (changes.pairs[i].value[0] != expected) { - printf("%s\n", msg_to_print); - printf("changes.pairs[%d].key[0] = %d, changes.pairs[%d].value[0] = %d\n", - i, changes.pairs[i].key[0], i, changes.pairs[i].value[0]); - printf("expected = %d\n", expected); - return false; - } - } - return true; -} - -UTEST(smt, test_state_normalize) { - for (int i = 0; i < 10000; i++) { - bool result = test_state_normalize_random(); - ASSERT_TRUE(result); - } -} - -UTEST_MAIN(); diff --git a/tests/xudt_rce/xudt_rce_validator_sim.c b/tests/xudt_rce/xudt_rce_validator_sim.c deleted file mode 100644 index 1d06b33..0000000 --- a/tests/xudt_rce/xudt_rce_validator_sim.c +++ /dev/null @@ -1,671 +0,0 @@ -#define ASSERT(s) (void)0 - -int ckb_exit(signed char code); - -#include "rce_validator.c" -#include "utest.h" - -// make compiler happy -int make_cursor_from_witness(WitnessArgsType *witness, bool *use_input_type) { - ASSERT(false); - return -1; -} - -// reset all status -void rce_validator_init() { - g_sim_rcdata_count[0] = 0; - g_sim_rcdata_count[1] = 0; - g_script_flags = 0; - g_cell_group_exists[0][0] = 1; - g_cell_group_exists[1][0] = 1; -} - -UTEST(rce_validator, bl_append_key) { - rce_validator_init(); - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rcrule.id = 0; - curr_0->rcrule.flags = 0; - memcpy(curr_0->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_two_root, countof(smt_two_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (0 << 4) | 1; - uint8_t update_proof_bytes[countof(smt_one_not_k2_proof)]; - memcpy(update_key, k2, 32); - memcpy(update_proof_bytes, smt_one_not_k2_proof, - countof(smt_one_not_k2_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_one_not_k2_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, 0); -} - -UTEST(rce_validator, bl_append_key_with_freeze_type) { - rce_validator_init(); - g_script_flags = 0x2; - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rcrule.id = 0; - curr_0->rcrule.flags = 0; - memcpy(curr_0->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_two_root, countof(smt_two_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (0 << 4) | 1; - uint8_t update_proof_bytes[countof(smt_one_not_k2_proof)]; - memcpy(update_key, k2, 32); - memcpy(update_proof_bytes, smt_one_not_k2_proof, - countof(smt_one_not_k2_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_one_not_k2_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, 0); -} - -UTEST(rce_validator, bl_remove_key) { - rce_validator_init(); - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rcrule.id = 0; - curr_0->rcrule.flags = 0; - memcpy(curr_0->rcrule.smt_root, smt_two_root, countof(smt_two_root)); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (1 << 4) | 0; - uint8_t update_proof_bytes[countof(smt_tow_has_k2_proof)]; - memcpy(update_key, k2, 32); - memcpy(update_proof_bytes, smt_tow_has_k2_proof, - countof(smt_tow_has_k2_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_tow_has_k2_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, 0); -} - -UTEST(rce_validator, bl_remove_key_but_append_only) { - rce_validator_init(); - g_script_flags = 1; - - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rcrule.id = 0; - curr_0->rcrule.flags = 0; - memcpy(curr_0->rcrule.smt_root, smt_two_root, countof(smt_two_root)); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (1 << 4) | 0; - uint8_t update_proof_bytes[countof(smt_tow_has_k2_proof)]; - memcpy(update_key, k2, 32); - memcpy(update_proof_bytes, smt_tow_has_k2_proof, - countof(smt_tow_has_k2_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_tow_has_k2_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, ERROR_APPEND_ONLY); -} - -UTEST(rce_validator, no_input) { - rce_validator_init(); - g_cell_group_exists[0][0] = 0; - int err = 0; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (0 << 4) | 1; - uint8_t update_proof_bytes[countof(smt_ooo_not_k1_proof)]; - memcpy(update_key, k1, 32); - memcpy(update_proof_bytes, smt_ooo_not_k1_proof, - countof(smt_ooo_not_k1_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_ooo_not_k1_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, 0); -} - -UTEST(rce_validator, rccellvec_to_rccell) { - rce_validator_init(); - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rccell_vec.id = 1; - curr_0->rccell_vec.hash_count = 0; - memset(curr_0->rccell_vec.hash, 0, 32); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (0 << 4) | 1; - uint8_t update_proof_bytes[countof(smt_ooo_not_k1_proof)]; - memcpy(update_key, k1, 32); - memcpy(update_proof_bytes, smt_ooo_not_k1_proof, - countof(smt_ooo_not_k1_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_ooo_not_k1_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, 0); -} - -UTEST(rce_validator, rccellvec_to_rcrule_with_freeze_type) { - rce_validator_init(); - g_script_flags = 0x2; - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rccell_vec.id = 1; - curr_0->rccell_vec.hash_count = 0; - memset(curr_0->rccell_vec.hash, 0, 32); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 0; - memcpy(curr_1->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (0 << 4) | 1; - uint8_t update_proof_bytes[countof(smt_one_not_k2_proof)]; - memcpy(update_key, k2, 32); - memcpy(update_proof_bytes, smt_one_not_k2_proof, - countof(smt_one_not_k2_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_one_not_k2_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, ERROR_TYPE_FREEZED); -} - -UTEST(rce_validator, rcrule_to_rccellvec_with_freeze_type) { - rce_validator_init(); - g_script_flags = 0x2; - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_0->rcrule.id = 0; - curr_0->rcrule.flags = 0; - memcpy(curr_0->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_1->rccell_vec.id = 1; - curr_1->rccell_vec.hash_count = 0; - memset(curr_1->rccell_vec.hash, 0, 32); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (1 << 4) | 0; - uint8_t update_proof_bytes[countof(smt_one_has_k1_proof)]; - memcpy(update_key, k1, 32); - memcpy(update_proof_bytes, smt_one_has_k1_proof, - countof(smt_one_has_k1_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_one_has_k1_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, ERROR_TYPE_FREEZED); -} - -UTEST(rce_validator, bl_update_to_wl) { - rce_validator_init(); - int err = 0; - - SIMRCData *curr_0 = g_sim_rcdata[0] + g_sim_rcdata_count[0]; - curr_0->rcrule.id = 0; - curr_0->rcrule.flags = 0; - memcpy(curr_0->rcrule.smt_root, smt_one_root, countof(smt_one_root)); - g_sim_rcdata_count[0] += 1; - - SIMRCData *curr_1 = g_sim_rcdata[1] + g_sim_rcdata_count[1]; - curr_1->rcrule.id = 0; - curr_1->rcrule.flags = 1; - memcpy(curr_1->rcrule.smt_root, smt_two_root, countof(smt_two_root)); - g_sim_rcdata_count[1] += 1; - - uint8_t update_key[32]; - uint8_t update_packed_value = (0 << 4) | 1; - uint8_t update_proof_bytes[countof(smt_one_not_k2_proof)]; - memcpy(update_key, k2, 32); - memcpy(update_proof_bytes, smt_one_not_k2_proof, - countof(smt_one_not_k2_proof)); - mol_seg_t update_proof = - build_bytes(update_proof_bytes, countof(smt_one_not_k2_proof)); - - mol_builder_t update_item_builer; - MolBuilder_SmtUpdateItem_init(&update_item_builer); - MolBuilder_SmtUpdateItem_set_key(&update_item_builer, update_key); - MolBuilder_SmtUpdateItem_set_packed_values(&update_item_builer, - update_packed_value); - mol_seg_res_t update_item_res = - MolBuilder_SmtUpdateItem_build(update_item_builer); - mol_seg_t update_item = update_item_res.seg; - - mol_builder_t update_item_vec_builder; - MolBuilder_SmtUpdateItemVec_init(&update_item_vec_builder); - MolBuilder_SmtUpdateItemVec_push(&update_item_vec_builder, update_item.ptr); - mol_seg_res_t update_item_vec_res = - MolBuilder_SmtUpdateItemVec_build(update_item_vec_builder); - mol_seg_t update_item_vec = update_item_vec_res.seg; - - mol_builder_t update_action_builder; - MolBuilder_SmtUpdateAction_init(&update_action_builder); - MolBuilder_SmtUpdateAction_set_updates( - &update_action_builder, update_item_vec.ptr, update_item_vec.size); - MolBuilder_SmtUpdateAction_set_proof(&update_action_builder, update_proof.ptr, - update_proof.size); - mol_seg_res_t update_action_res = - MolBuilder_SmtUpdateAction_build(update_action_builder); - mol_seg_t update_action = - build_bytes(update_action_res.seg.ptr, update_action_res.seg.size); - - mol_builder_t witness_args_builder; - MolBuilder_WitnessArgs_init(&witness_args_builder); - MolBuilder_WitnessArgs_set_input_type(&witness_args_builder, - update_action.ptr, update_action.size); - uint8_t dummy_lock[4096] = {0}; - mol_seg_t lock = build_bytes(dummy_lock, sizeof(dummy_lock)); - MolBuilder_WitnessArgs_set_lock(&witness_args_builder, lock.ptr, lock.size); - mol_seg_res_t witness_args_res = - MolBuilder_WitnessArgs_build(witness_args_builder); - mol_seg_t witness_args = witness_args_res.seg; - - g_witness_size = witness_args.size; - memcpy(g_witness, witness_args.ptr, g_witness_size); - - err = simulator_main(); - -exit: - ASSERT_EQ(err, 0); -} - -UTEST_MAIN(); diff --git a/tests/xudt_rce_rust/Cargo.lock b/tests/xudt_rce_rust/Cargo.lock deleted file mode 100644 index eab59b1..0000000 --- a/tests/xudt_rce_rust/Cargo.lock +++ /dev/null @@ -1,1294 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "blake2b-ref" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95916998c798756098a4eb1b3f2cd510659705a9817bf203d61abd30fbec3e7b" - -[[package]] -name = "blake2b-rs" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e35e362830ef90ecea16f09b21b75d22d33a8562a679c74ab4f4fa49b4fcb87" -dependencies = [ - "cc", -] - -[[package]] -name = "blake2b-rs" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89a8565807f21b913288968e391819e7f9b2f0f46c7b89549c051cccf3a2771" -dependencies = [ - "cc", - "cty", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -dependencies = [ - "serde", -] - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "ckb-chain-spec" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0f0606bce9ccbde520465890486807a0ac2fcba3e60d37df54a2d0be071725" -dependencies = [ - "ckb-constant", - "ckb-crypto", - "ckb-dao-utils", - "ckb-error", - "ckb-hash", - "ckb-jsonrpc-types", - "ckb-pow", - "ckb-rational", - "ckb-resource", - "ckb-traits", - "ckb-types", - "ckb-util", - "serde", - "toml", -] - -[[package]] -name = "ckb-channel" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0da1f4e474de48b05e30ad603da4da3b410344b619c7cf35d444e406c0bb6e" -dependencies = [ - "crossbeam-channel", -] - -[[package]] -name = "ckb-constant" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a6df9fd997d58f1e5f12a683a00d98158a82c07a422e6f81ff390607f19c493" - -[[package]] -name = "ckb-crypto" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1650275e0f5a59e8ebbd747d835e10b9179d8ab4941b96100d5b7e48fada695e" -dependencies = [ - "ckb-fixed-hash", - "faster-hex", - "lazy_static", - "rand 0.7.3", - "secp256k1", - "thiserror", -] - -[[package]] -name = "ckb-dao-utils" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294c46e06c315900c9eb4e5719311902d68fcad6c802f43ebc658902715b5ea" -dependencies = [ - "byteorder", - "ckb-error", - "ckb-types", -] - -[[package]] -name = "ckb-error" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51748ac5e08dce6c685cf4b43e27dcbcfc98e21442c4001c9f06509a04a400ed" -dependencies = [ - "anyhow", - "ckb-occupied-capacity", - "derive_more", - "thiserror", -] - -[[package]] -name = "ckb-fixed-hash" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d665013dbb8ff2df8e67c4add67db703ae3b642679f1a2962f76399703eee1" -dependencies = [ - "ckb-fixed-hash-core", - "ckb-fixed-hash-macros", -] - -[[package]] -name = "ckb-fixed-hash-core" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd92b9d691bbfd11a900ee17ad1010a553ae0b5d3a120e0c8094afcd30f9b15e" -dependencies = [ - "faster-hex", - "serde", - "thiserror", -] - -[[package]] -name = "ckb-fixed-hash-macros" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24e42b82da4d891ac8b5b19de2807cae360c5377138a7cde377b60edc6ec953" -dependencies = [ - "ckb-fixed-hash-core", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ckb-hash" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b64eff869839aff45741515540e81a0447926d79262a439b5e9d0a5c98ac95" -dependencies = [ - "blake2b-ref", - "blake2b-rs 0.2.0", -] - -[[package]] -name = "ckb-jsonrpc-types" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82268ddea09f95324496d6def1b37d6bdc3a4841fecc185388e7a2bb6451687f" -dependencies = [ - "ckb-types", - "faster-hex", - "serde", - "serde_json", -] - -[[package]] -name = "ckb-logger" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a312280df7ba55dc99cf8584ac4d3c9e3b85297a896202c76a21dfd43ffb0ea" -dependencies = [ - "log", -] - -[[package]] -name = "ckb-merkle-mountain-range" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "ckb-occupied-capacity" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a11e010c034a98b734074a79655c738c40501e9113426173132856a35c6e71c6" -dependencies = [ - "ckb-occupied-capacity-core", - "ckb-occupied-capacity-macros", -] - -[[package]] -name = "ckb-occupied-capacity-core" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e48f0306a3fe072711e0342b71335898ac6d0a82b897ca3ae13e43770ce0e0" -dependencies = [ - "serde", -] - -[[package]] -name = "ckb-occupied-capacity-macros" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656db5615c791b8d7b31a38e024f98fb497be5e2cb120b38be48eb4d9d1d0f6d" -dependencies = [ - "ckb-occupied-capacity-core", - "quote", - "syn", -] - -[[package]] -name = "ckb-pow" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9708f81c8c9058bf3dab834be2be68d14dcd9fa41bd793727428a2cf6b1ddf59" -dependencies = [ - "byteorder", - "ckb-hash", - "ckb-types", - "eaglesong", - "log", - "serde", -] - -[[package]] -name = "ckb-rational" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444926bc5a9ad789b2b98e75f90330bcfe741bab517ca45d8f084449fe35efd8" -dependencies = [ - "numext-fixed-uint", - "serde", -] - -[[package]] -name = "ckb-resource" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95464c0e69e20553f34c132789f6275a1e06468362226cf5a986719f6da96161" -dependencies = [ - "ckb-system-scripts", - "ckb-types", - "includedir", - "includedir_codegen", - "phf", - "serde", - "walkdir", -] - -[[package]] -name = "ckb-script" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f06c44207d8e90b86f2b29f2341188a6d1a3520f6b657eb2ba662b3a772abfc" -dependencies = [ - "byteorder", - "ckb-chain-spec", - "ckb-error", - "ckb-hash", - "ckb-logger", - "ckb-traits", - "ckb-types", - "ckb-vm", - "faster-hex", - "serde", -] - -[[package]] -name = "ckb-system-scripts" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5c59063142de7a68cfad4449c6b3863563856219a2925dfb8c5f019ec2aa47" -dependencies = [ - "blake2b-rs 0.2.0", - "faster-hex", - "includedir", - "includedir_codegen", - "phf", -] - -[[package]] -name = "ckb-traits" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d54a03a03af9857264cc252060f4274e11858956a4985793b04047117828329" -dependencies = [ - "ckb-types", -] - -[[package]] -name = "ckb-types" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f06812497491fa58cea1c93dda2de074e0c5d51cf7d70d93dd50c862c661494c" -dependencies = [ - "bit-vec", - "bytes", - "ckb-channel", - "ckb-error", - "ckb-fixed-hash", - "ckb-hash", - "ckb-merkle-mountain-range", - "ckb-occupied-capacity", - "ckb-rational", - "derive_more", - "merkle-cbt", - "molecule", - "numext-fixed-uint", - "once_cell", -] - -[[package]] -name = "ckb-util" -version = "0.105.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0f4f5647372cc1c2fdc7122e062984754e062edbcc654436a1af7f5b1382a0" -dependencies = [ - "linked-hash-map", - "once_cell", - "parking_lot", - "regex", -] - -[[package]] -name = "ckb-vm" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1126bf0240d100234bc06efa7020f0d50ca35fe90e5ac7cac1b7721e1bacb7" -dependencies = [ - "byteorder", - "bytes", - "cc", - "ckb-vm-definitions", - "derive_more", - "goblin 0.2.3", - "goblin 0.4.0", - "rand 0.7.3", - "scroll", - "serde", -] - -[[package]] -name = "ckb-vm-definitions" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14739bf59648c169de9257ec7dd6aba1aeb6a41725d636005f1c91853df58fcc" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", -] - -[[package]] -name = "eaglesong" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d978bd5d343e8ab9b5c0fc8d93ff9c602fdc96616ffff9c05ac7a155419b824" - -[[package]] -name = "faster-hex" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" - -[[package]] -name = "flate2" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi", -] - -[[package]] -name = "goblin" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884" -dependencies = [ - "log", - "plain", - "scroll", -] - -[[package]] -name = "goblin" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532a09cd3df2c6bbfc795fb0434bff8f22255d1d07328180e918a2e6ce122d4d" -dependencies = [ - "log", - "plain", - "scroll", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi", -] - -[[package]] -name = "includedir" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afd126bd778c00c43a9dc76d1609a0894bf4222088088b2217ccc0ce9e816db7" -dependencies = [ - "flate2", - "phf", -] - -[[package]] -name = "includedir_codegen" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ac1500c9780957c9808c4ec3b94002f35aab01483833f5a8bce7dfb243e3148" -dependencies = [ - "flate2", - "phf_codegen", - "walkdir", -] - -[[package]] -name = "itoa" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -dependencies = [ - "serde", -] - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg 1.1.0", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "merkle-cbt" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171d2f700835121c3b04ccf0880882987a050fd5c7ae88148abf537d33dd3a56" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "molecule" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc8276c02a006bddad7d1c28c1a88f30421e1b5f0ba0ca96ceb8077c7d20c01" -dependencies = [ - "bytes", - "cfg-if 1.0.0", - "faster-hex", -] - -[[package]] -name = "numext-constructor" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "621fe0f044729f810c6815cdd77e8f5e0cd803ce4f6a38380ebfc1322af98661" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "numext-fixed-uint" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c68c76f96d589d1009a666c5072f37f3114d682696505f2cf445f27766c7d70" -dependencies = [ - "numext-fixed-uint-core", - "numext-fixed-uint-hack", -] - -[[package]] -name = "numext-fixed-uint-core" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aab1d6457b97b49482f22a92f0f58a2f39bdd7f3b2f977eae67e8bc206aa980" -dependencies = [ - "heapsize", - "numext-constructor", - "rand 0.7.3", - "serde", - "thiserror", -] - -[[package]] -name = "numext-fixed-uint-hack" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200f8d55c36ec1b6a8cf810115be85d4814f045e0097dfd50033ba25adb4c9e" -dependencies = [ - "numext-fixed-uint-core", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - -[[package]] -name = "phf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" -dependencies = [ - "phf_shared", - "rand 0.7.3", -] - -[[package]] -name = "phf_shared" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" -dependencies = [ - "siphasher", -] - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro2" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg 0.1.2", - "rand_xorshift", - "winapi", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", - "rand_pcg 0.2.1", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "scroll" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "secp256k1" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "sparse-merkle-tree" -version = "0.5.2-rc1" -source = "git+https://github.com/nervosnetwork/sparse-merkle-tree.git?rev=2ba5a95#2ba5a95c42cfe811962a30bfc94e1113e9d6ef36" -dependencies = [ - "blake2b-rs 0.1.5", - "cfg-if 0.1.10", -] - -[[package]] -name = "syn" -version = "1.0.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56e159d99e6c2b93995d171050271edb50ecc5288fbc7cc17de8fdce4e58c14" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "xudt-test" -version = "0.1.0" -dependencies = [ - "blake2b-rs 0.1.5", - "ckb-crypto", - "ckb-error", - "ckb-hash", - "ckb-script", - "ckb-traits", - "ckb-types", - "lazy_static", - "rand 0.6.5", - "sparse-merkle-tree", -] diff --git a/tests/xudt_rce_rust/Cargo.toml b/tests/xudt_rce_rust/Cargo.toml deleted file mode 100644 index 88bd01d..0000000 --- a/tests/xudt_rce_rust/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "xudt-test" -version = "0.1.0" -authors = ["mohanson "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -blake2b-rs = "0.1" -ckb-crypto = "0.105.1" -ckb-error = "0.105.1" -ckb-hash = "0.105.1" -ckb-script = "0.105.1" -ckb-traits = "0.105.1" -ckb-types = "0.105.1" -lazy_static = "1.3.0" -rand = "0.6.5" -sparse-merkle-tree = { git = "https://github.com/nervosnetwork/sparse-merkle-tree.git", rev = "2ba5a95"} - diff --git a/tests/xudt_rce_rust/src/lib.rs b/tests/xudt_rce_rust/src/lib.rs deleted file mode 100644 index a83d5aa..0000000 --- a/tests/xudt_rce_rust/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod xudt_rce_mol; diff --git a/tests/xudt_rce_rust/src/xudt_rce_mol.rs b/tests/xudt_rce_rust/src/xudt_rce_mol.rs deleted file mode 100644 index 4c4b412..0000000 --- a/tests/xudt_rce_rust/src/xudt_rce_mol.rs +++ /dev/null @@ -1,3348 +0,0 @@ -// Generated by Molecule 0.7.0 -#![allow(unused_imports)] - -use ckb_types::molecule; -use ckb_types::packed::*; -use ckb_types::prelude::*; -// these lines above are manually added -// replace "::molecule" to "molecule" in below code - -#[derive(Clone)] -pub struct ScriptVec(molecule::bytes::Bytes); -impl ::core::fmt::LowerHex for ScriptVec { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - use molecule::hex_string; - if f.alternate() { - write!(f, "0x")?; - } - write!(f, "{}", hex_string(self.as_slice())) - } -} -impl ::core::fmt::Debug for ScriptVec { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - write!(f, "{}({:#x})", Self::NAME, self) - } -} -impl ::core::fmt::Display for ScriptVec { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - write!(f, "{} [", Self::NAME)?; - for i in 0..self.len() { - if i == 0 { - write!(f, "{}", self.get_unchecked(i))?; - } else { - write!(f, ", {}", self.get_unchecked(i))?; - } - } - write!(f, "]") - } -} -impl ::core::default::Default for ScriptVec { - fn default() -> Self { - let v: Vec = vec![4, 0, 0, 0]; - ScriptVec::new_unchecked(v.into()) - } -} -impl ScriptVec { - pub fn total_size(&self) -> usize { - molecule::unpack_number(self.as_slice()) as usize - } - pub fn item_count(&self) -> usize { - if self.total_size() == molecule::NUMBER_SIZE { - 0 - } else { - (molecule::unpack_number(&self.as_slice()[molecule::NUMBER_SIZE..]) as usize / 4) - 1 - } - } - pub fn len(&self) -> usize { - self.item_count() - } - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - pub fn get(&self, idx: usize) -> Option