react-native-nitro-bsx 0.0.0-stage → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +7 -2
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +35 -0
- package/android/src/main/cpp/cpp-adapter.cpp +12 -0
- package/android/src/main/java/com/nitrobsx/BSXAlarmReceiver.kt +29 -0
- package/android/src/main/java/com/nitrobsx/BSXAlarmScheduler.kt +112 -0
- package/android/src/main/java/com/nitrobsx/BSXForegroundService.kt +78 -0
- package/android/src/main/java/com/nitrobsx/BSXNotifications.kt +47 -0
- package/android/src/main/java/com/nitrobsx/BSXServiceController.kt +90 -0
- package/android/src/main/java/com/nitrobsx/BSXWakeWorker.kt +136 -0
- package/android/src/main/java/com/nitrobsx/HeadlessJsTaskSupportShim.kt +41 -0
- package/android/src/main/java/com/nitrobsx/NitroBSXPackage.kt +28 -0
- package/android/src/main/res/drawable/bsx_ic_stat_swap.xml +9 -0
- package/cpp/BSXContext.cpp +263 -0
- package/cpp/BSXContext.h +49 -0
- package/cpp/BSXModule.cpp +21191 -0
- package/cpp/BSXModule.h +1523 -0
- package/cpp/CMakeLists.txt +463 -0
- package/cpp/HybridNitroBSX.cpp +1483 -0
- package/cpp/HybridNitroBSX.hpp +173 -0
- package/cpp/arith_uint256.cpp +232 -0
- package/cpp/arith_uint256.h +277 -0
- package/cpp/bsx/event.cpp +48 -0
- package/cpp/bsx/event.h +29 -0
- package/cpp/bsx/swap.h +293 -0
- package/cpp/bsx/types.cpp +486 -0
- package/cpp/bsx/types.h +308 -0
- package/cpp/bsx_db.cpp +4951 -0
- package/cpp/bsx_db.h +465 -0
- package/cpp/chain_client.h +143 -0
- package/cpp/cmake/GenVersion.cmake +52 -0
- package/cpp/coin_config.h.in +12 -0
- package/cpp/coins/block_index.cpp +33 -0
- package/cpp/coins/block_index.h +35 -0
- package/cpp/coins/btc/chainparams.cpp +70 -0
- package/cpp/coins/btc/chainparams.h +23 -0
- package/cpp/coins/btc/interface.h +30 -0
- package/cpp/coins/btc_base/interface.cpp +2200 -0
- package/cpp/coins/btc_base/interface.h +225 -0
- package/cpp/coins/btc_base/primitives.cpp +560 -0
- package/cpp/coins/btc_base/primitives.h +157 -0
- package/cpp/coins/btc_base/psbt.cpp +150 -0
- package/cpp/coins/btc_base/psbt.h +52 -0
- package/cpp/coins/btc_base/script.cpp +304 -0
- package/cpp/coins/btc_base/script.h +181 -0
- package/cpp/coins/chainparams.cpp +47 -0
- package/cpp/coins/chainparams.h +58 -0
- package/cpp/coins/firo/chainparams.cpp +52 -0
- package/cpp/coins/firo/chainparams.h +24 -0
- package/cpp/coins/firo/firo.cpp +118 -0
- package/cpp/coins/firo/firo.h +79 -0
- package/cpp/coins/firo/primitives.cpp +109 -0
- package/cpp/coins/firo/primitives.h +47 -0
- package/cpp/coins/interface.cpp +1815 -0
- package/cpp/coins/interface.h +554 -0
- package/cpp/coins/ltc/chainparams.cpp +70 -0
- package/cpp/coins/ltc/chainparams.h +22 -0
- package/cpp/coins/ltc/ltc.cpp +69 -0
- package/cpp/coins/ltc/ltc.h +82 -0
- package/cpp/coins/ltc/primitives.cpp +20 -0
- package/cpp/coins/ltc/primitives.h +18 -0
- package/cpp/coins/part/chainparams.cpp +89 -0
- package/cpp/coins/part/chainparams.h +47 -0
- package/cpp/coins/part/part.cpp +905 -0
- package/cpp/coins/part/part.h +164 -0
- package/cpp/coins/part/primitives.cpp +548 -0
- package/cpp/coins/part/primitives.h +187 -0
- package/cpp/coins/part/stake.cpp +330 -0
- package/cpp/coins/part/stake.h +92 -0
- package/cpp/coins/primitives.h +125 -0
- package/cpp/coins/registry.cpp +99 -0
- package/cpp/coins/registry.h +32 -0
- package/cpp/coins/script.h +18 -0
- package/cpp/coins/types.cpp +60 -0
- package/cpp/coins/types.h +41 -0
- package/cpp/coins/xmr/chainparams.cpp +28 -0
- package/cpp/coins/xmr/chainparams.h +24 -0
- package/cpp/coins/xmr/tx.cpp +670 -0
- package/cpp/coins/xmr/tx.h +77 -0
- package/cpp/coins/xmr/xmr.cpp +639 -0
- package/cpp/coins/xmr/xmr.h +223 -0
- package/cpp/compat/byteswap.h +74 -0
- package/cpp/compat/endian.h +98 -0
- package/cpp/compat/mbedtls/threading_alt.h +20 -0
- package/cpp/compat/sockets.h +160 -0
- package/cpp/contrib/mbedtls/CMakeLists.txt +566 -0
- package/cpp/contrib/mbedtls/LICENSE +553 -0
- package/cpp/contrib/mbedtls/cmake/MbedTLSConfig.cmake.in +3 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_encdec.h +52 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_hashing.h +30 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_mainpage.h +52 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_rng.h +27 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_ssltls.h +37 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_tcpip.h +32 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_x509.h +31 -0
- package/cpp/contrib/mbedtls/doxygen/mbedtls.doxyfile +56 -0
- package/cpp/contrib/mbedtls/framework/CMakeLists.txt +1 -0
- package/cpp/contrib/mbedtls/framework/LICENSE +553 -0
- package/cpp/contrib/mbedtls/include/CMakeLists.txt +21 -0
- package/cpp/contrib/mbedtls/include/mbedtls/build_info.h +93 -0
- package/cpp/contrib/mbedtls/include/mbedtls/debug.h +120 -0
- package/cpp/contrib/mbedtls/include/mbedtls/error.h +39 -0
- package/cpp/contrib/mbedtls/include/mbedtls/mbedtls_config.h +1189 -0
- package/cpp/contrib/mbedtls/include/mbedtls/net_sockets.h +299 -0
- package/cpp/contrib/mbedtls/include/mbedtls/oid.h +304 -0
- package/cpp/contrib/mbedtls/include/mbedtls/pkcs7.h +250 -0
- package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_ssl.h +84 -0
- package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_x509.h +35 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl.h +5622 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_cache.h +187 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_ciphersuites.h +303 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_cookie.h +90 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_ticket.h +186 -0
- package/cpp/contrib/mbedtls/include/mbedtls/timing.h +105 -0
- package/cpp/contrib/mbedtls/include/mbedtls/version.h +69 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509.h +503 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_crl.h +180 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_crt.h +1174 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_csr.h +368 -0
- package/cpp/contrib/mbedtls/library/CMakeLists.txt +375 -0
- package/cpp/contrib/mbedtls/library/Makefile +334 -0
- package/cpp/contrib/mbedtls/library/debug.c +285 -0
- package/cpp/contrib/mbedtls/library/debug_internal.h +108 -0
- package/cpp/contrib/mbedtls/library/error.c +505 -0
- package/cpp/contrib/mbedtls/library/mbedtls_check_config.h +376 -0
- package/cpp/contrib/mbedtls/library/mbedtls_common.h +51 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config.c +40 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_before.h +1769 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_final.h +12 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_user.h +2436 -0
- package/cpp/contrib/mbedtls/library/mbedtls_platform_requirements.h +55 -0
- package/cpp/contrib/mbedtls/library/mbedtls_utils.h +23 -0
- package/cpp/contrib/mbedtls/library/mps_common.h +181 -0
- package/cpp/contrib/mbedtls/library/mps_error.h +89 -0
- package/cpp/contrib/mbedtls/library/mps_reader.c +538 -0
- package/cpp/contrib/mbedtls/library/mps_reader.h +366 -0
- package/cpp/contrib/mbedtls/library/mps_trace.c +112 -0
- package/cpp/contrib/mbedtls/library/mps_trace.h +154 -0
- package/cpp/contrib/mbedtls/library/net_sockets.c +684 -0
- package/cpp/contrib/mbedtls/library/pkcs7.c +784 -0
- package/cpp/contrib/mbedtls/library/ssl_cache.c +409 -0
- package/cpp/contrib/mbedtls/library/ssl_ciphersuites.c +996 -0
- package/cpp/contrib/mbedtls/library/ssl_ciphersuites_internal.h +108 -0
- package/cpp/contrib/mbedtls/library/ssl_client.c +1019 -0
- package/cpp/contrib/mbedtls/library/ssl_client.h +18 -0
- package/cpp/contrib/mbedtls/library/ssl_cookie.c +251 -0
- package/cpp/contrib/mbedtls/library/ssl_debug_helpers.h +83 -0
- package/cpp/contrib/mbedtls/library/ssl_debug_helpers_generated.c +243 -0
- package/cpp/contrib/mbedtls/library/ssl_misc.h +2851 -0
- package/cpp/contrib/mbedtls/library/ssl_msg.c +6275 -0
- package/cpp/contrib/mbedtls/library/ssl_ticket.c +453 -0
- package/cpp/contrib/mbedtls/library/ssl_tls.c +9048 -0
- package/cpp/contrib/mbedtls/library/ssl_tls12_client.c +3054 -0
- package/cpp/contrib/mbedtls/library/ssl_tls12_server.c +3546 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_client.c +3202 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_generic.c +1773 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_invasive.h +23 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_keys.c +1860 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_keys.h +668 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_server.c +3602 -0
- package/cpp/contrib/mbedtls/library/timing.c +76 -0
- package/cpp/contrib/mbedtls/library/version.c +30 -0
- package/cpp/contrib/mbedtls/library/version_features.c +244 -0
- package/cpp/contrib/mbedtls/library/x509.c +1848 -0
- package/cpp/contrib/mbedtls/library/x509_create.c +747 -0
- package/cpp/contrib/mbedtls/library/x509_crl.c +701 -0
- package/cpp/contrib/mbedtls/library/x509_crt.c +3278 -0
- package/cpp/contrib/mbedtls/library/x509_csr.c +642 -0
- package/cpp/contrib/mbedtls/library/x509_internal.h +97 -0
- package/cpp/contrib/mbedtls/library/x509_oid.c +603 -0
- package/cpp/contrib/mbedtls/library/x509_oid.h +150 -0
- package/cpp/contrib/mbedtls/library/x509write.c +171 -0
- package/cpp/contrib/mbedtls/library/x509write_crt.c +637 -0
- package/cpp/contrib/mbedtls/library/x509write_csr.c +317 -0
- package/cpp/contrib/mbedtls/pkgconfig/CMakeLists.txt +25 -0
- package/cpp/contrib/mbedtls/pkgconfig/JoinPaths.cmake +27 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedcrypto.pc.in +10 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedtls.pc.in +11 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedx509.pc.in +11 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/CMakeLists.txt +584 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/LICENSE +552 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/cmake/TF-PSA-CryptoConfig.cmake.in +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/CMakeLists.txt +193 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/alignment.h +700 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/check_crypto_config.h +111 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/crypto-library.make +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto.c +9820 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_client.c +22 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core.h +972 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core_common.h +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers.h +3395 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers_no_static.c +247 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_invasive.h +85 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_its.h +131 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.c +168 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.h +72 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random_impl.h +215 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.c +998 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.h +330 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.c +400 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.h +201 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_its_file.c +254 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_util.c +295 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_check_config.h +598 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_common.h +628 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config.c +72 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_before.h +12 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_final.h +12 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_user.h +1220 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_platform_requirements.h +62 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_version.c +28 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/dispatch/psa_crypto_driver_wrappers_no_static.h +31 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/input/doc_mainpage.h.in +51 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/tfpsacrypto.doxyfile.in +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/CMakeLists.txt +142 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aes.h +607 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aria.h +342 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/bignum.h +1137 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/block_cipher.h +76 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/camellia.h +302 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ccm.h +523 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chacha20.h +230 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chachapoly.h +339 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cipher.h +1173 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cmac.h +209 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/config_adjust_test_accelerators.h +111 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_enable_builtins.h +820 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_tweak_builtins.h +203 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_composites.h +278 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_key_derivation.h +120 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_primitives.h +136 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ctr_drbg.h +554 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecdsa.h +667 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecjpake.h +296 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecp.h +1452 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/entropy.h +253 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/error_common.h +79 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/gcm.h +382 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/hmac_drbg.h +426 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/md5.h +169 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/pkcs5.h +123 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/poly1305.h +165 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ripemd160.h +120 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/rsa.h +821 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha1.h +196 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha256.h +180 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha3.h +189 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha512.h +188 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private_access.h +53 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aes.c +2236 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.c +624 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.c +846 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.h +162 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aria.c +966 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum.c +2635 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c +1242 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.h +885 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core_invasive.h +38 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_internal.h +164 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.c +394 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.h +452 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.c +276 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.h +416 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw_invasive.h +34 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher.c +207 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher_internal.h +99 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bn_mul.h +1094 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/camellia.c +1055 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ccm.c +773 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20.c +576 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.c +294 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.h +62 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chachapoly.c +479 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher.c +1126 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_invasive.h +28 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.c +1937 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.h +173 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cmac.c +911 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr.h +35 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr_drbg.c +1017 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecdsa.c +826 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecjpake.c +1206 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp.c +3478 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_curves.c +4798 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_invasive.h +220 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy.c +677 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.c +89 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.h +44 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/gcm.c +1314 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/hmac_drbg.c +639 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md5.c +419 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md_psa.h +26 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/poly1305.c +488 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.c +648 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.h +499 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.c +752 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.h +314 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c +921 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.h +516 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.c +781 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.h +131 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.h +211 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.c +495 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.h +264 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.c +568 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.h +159 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.c +698 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.h +321 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.c +149 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.h +155 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.c +282 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.h +132 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ripemd160.c +482 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa.c +2720 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.c +294 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.h +185 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_internal.h +172 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_invasive.h +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha1.c +473 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha256.c +956 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha3.c +951 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha512.c +1089 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/driver.cmake +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/CMakeLists.txt +45 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/Makefile.inc +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/README.md +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/Hacl_Curve25519.h +25 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt128.h +124 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h +280 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib.h +29 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/c_endianness.h +206 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/builtin.h +16 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/callconv.h +48 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/compat.h +34 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/debug.h +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/target.h +102 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/types.h +61 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/wasmsupport.h +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/vs2013/Hacl_Curve25519.h +21 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/x25519.h +48 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519.c +760 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519_joined.c +50 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt128_extracted.c +413 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c +100 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/legacy/Hacl_Curve25519.c +805 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/x25519.c +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/CMakeLists.txt +36 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/Makefile.inc +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/README.md +4 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/README.md +544 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.c +1514 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.c +312 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.h +219 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/CMakeLists.txt +14 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/Makefile.inc +6 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/include/tf-psa-crypto/private/crypto_struct_pqcp.h +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/fips202_psa.h +117 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/pqcp-config.h +68 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.c +528 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.h +301 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.c +66 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.h +37 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.c +768 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.h +272 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lms.c +772 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md.c +1182 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md_wrap.h +46 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/nist_kw.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk.c +1464 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_ecc.c +175 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_internal.h +188 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_rsa.c +106 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.c +667 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.h +101 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkparse.c +1351 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.c +574 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.h +101 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/framework/CMakeLists.txt +1 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/framework/LICENSE +553 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/CMakeLists.txt +41 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1.h +623 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1write.h +397 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/base64.h +81 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/compat-3-crypto.h +43 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/constant_time.h +36 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/lms.h +431 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/md.h +538 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/memory_buffer_alloc.h +142 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/nist_kw.h +106 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pem.h +157 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pk.h +888 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform.h +513 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_time.h +79 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_util.h +197 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/private/pk_private.h +150 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/psa_util.h +199 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/threading.h +412 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto.h +6082 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_compat.h +74 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_config.h +2073 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_common.h +42 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h +182 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_key_derivation.h +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_random.h +49 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_extra.h +2115 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_platform.h +94 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_sizes.h +1301 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_struct.h +682 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_types.h +466 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_values.h +2827 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/build_info.h +193 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_auto_enabled.h +23 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_dependencies.h +58 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_derived.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_key_pair_types.h +93 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_support.h +211 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_synonyms.h +41 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/version.h +44 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/objlib.cmake +71 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/CMakeLists.txt +15 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/JoinPaths.cmake +27 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/tfpsacrypto.pc.in +10 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/memory_buffer_alloc.c +751 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform.c +362 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform_util.c +428 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading.c +311 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading_internal.h +75 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1parse.c +483 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1write.c +465 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64.c +322 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64_internal.h +45 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time.c +247 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_impl.h +514 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_internal.h +540 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/crypto_oid.h +354 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/oid.c +469 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pem.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pkcs5.c +475 -0
- package/cpp/contrib/monero/LICENSE +41 -0
- package/cpp/contrib/monero/bsx/common/perf_timer.h +15 -0
- package/cpp/contrib/monero/bsx/common/threadpool.h +43 -0
- package/cpp/contrib/monero/bsx/hex.h +25 -0
- package/cpp/contrib/monero/bsx/misc_log_ex.h +61 -0
- package/cpp/contrib/monero/bsx/random.cpp +20 -0
- package/cpp/contrib/monero/contrib/epee/include/int-util.h +320 -0
- package/cpp/contrib/monero/contrib/epee/include/memwipe.h +81 -0
- package/cpp/contrib/monero/contrib/epee/include/misc_language.h +109 -0
- package/cpp/contrib/monero/contrib/epee/include/mlocker.h +89 -0
- package/cpp/contrib/monero/contrib/epee/include/span.h +189 -0
- package/cpp/contrib/monero/contrib/epee/include/warnings.h +31 -0
- package/cpp/contrib/monero/contrib/epee/src/memwipe.c +115 -0
- package/cpp/contrib/monero/contrib/epee/src/mlocker.cpp +197 -0
- package/cpp/contrib/monero/src/common/aligned.c +139 -0
- package/cpp/contrib/monero/src/common/aligned.h +42 -0
- package/cpp/contrib/monero/src/common/base58.cpp +259 -0
- package/cpp/contrib/monero/src/common/base58.h +46 -0
- package/cpp/contrib/monero/src/common/pod-class.h +43 -0
- package/cpp/contrib/monero/src/common/varint.h +138 -0
- package/cpp/contrib/monero/src/crypto/chacha.h +96 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops-data.c +881 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops.c +3891 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops.h +167 -0
- package/cpp/contrib/monero/src/crypto/crypto.cpp +792 -0
- package/cpp/contrib/monero/src/crypto/crypto.h +359 -0
- package/cpp/contrib/monero/src/crypto/generic-ops.h +103 -0
- package/cpp/contrib/monero/src/crypto/hash-ops.h +105 -0
- package/cpp/contrib/monero/src/crypto/hash.c +57 -0
- package/cpp/contrib/monero/src/crypto/hash.h +110 -0
- package/cpp/contrib/monero/src/crypto/keccak.c +239 -0
- package/cpp/contrib/monero/src/crypto/keccak.h +40 -0
- package/cpp/contrib/monero/src/crypto/random.h +46 -0
- package/cpp/contrib/monero/src/crypto/tree-hash.c +257 -0
- package/cpp/contrib/monero/src/crypto/wallet/crypto.h +57 -0
- package/cpp/contrib/monero/src/crypto/wallet/ops.h +32 -0
- package/cpp/contrib/monero/src/cryptonote_config.h +365 -0
- package/cpp/contrib/monero/src/device/device.cpp +105 -0
- package/cpp/contrib/monero/src/device/device.hpp +274 -0
- package/cpp/contrib/monero/src/device/device_default.cpp +343 -0
- package/cpp/contrib/monero/src/device/device_default.hpp +156 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs.cc +1097 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs.h +51 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs_plus.cc +1120 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs_plus.h +49 -0
- package/cpp/contrib/monero/src/ringct/multiexp.cc +708 -0
- package/cpp/contrib/monero/src/ringct/multiexp.h +72 -0
- package/cpp/contrib/monero/src/ringct/rctCryptoOps.c +221 -0
- package/cpp/contrib/monero/src/ringct/rctCryptoOps.h +37 -0
- package/cpp/contrib/monero/src/ringct/rctOps.cpp +727 -0
- package/cpp/contrib/monero/src/ringct/rctOps.h +191 -0
- package/cpp/contrib/monero/src/ringct/rctSigs.cpp +1652 -0
- package/cpp/contrib/monero/src/ringct/rctSigs.h +143 -0
- package/cpp/contrib/monero/src/ringct/rctTypes.cpp +338 -0
- package/cpp/contrib/monero/src/ringct/rctTypes.h +842 -0
- package/cpp/contrib/monero/src/serialization/binary_archive.h +243 -0
- package/cpp/contrib/monero/src/serialization/container.h +146 -0
- package/cpp/contrib/monero/src/serialization/containers.h +127 -0
- package/cpp/contrib/monero/src/serialization/crypto.h +97 -0
- package/cpp/contrib/monero/src/serialization/debug_archive.h +53 -0
- package/cpp/contrib/monero/src/serialization/json_archive.h +193 -0
- package/cpp/contrib/monero/src/serialization/serialization.h +328 -0
- package/cpp/contrib/monero/src/serialization/variant.h +50 -0
- package/cpp/contrib/nlohmann/LICENSE.MIT +21 -0
- package/cpp/contrib/nlohmann/json.hpp +25526 -0
- package/cpp/contrib/nlohmann/json_fwd.hpp +187 -0
- package/cpp/contrib/notes.txt +96 -0
- package/cpp/contrib/secp256k1/CHANGELOG.md +214 -0
- package/cpp/contrib/secp256k1/CMakeLists.txt +392 -0
- package/cpp/contrib/secp256k1/CMakePresets.json +18 -0
- package/cpp/contrib/secp256k1/CONTRIBUTING.md +111 -0
- package/cpp/contrib/secp256k1/COPYING +19 -0
- package/cpp/contrib/secp256k1/Makefile.am +332 -0
- package/cpp/contrib/secp256k1/README.md +176 -0
- package/cpp/contrib/secp256k1/SECURITY.md +15 -0
- package/cpp/contrib/secp256k1/autogen.sh +3 -0
- package/cpp/contrib/secp256k1/ci/ci.sh +147 -0
- package/cpp/contrib/secp256k1/ci/linux-debian.Dockerfile +84 -0
- package/cpp/contrib/secp256k1/ci/travis.sh +68 -0
- package/cpp/contrib/secp256k1/cmake/CheckArm32Assembly.cmake +6 -0
- package/cpp/contrib/secp256k1/cmake/CheckMemorySanitizer.cmake +18 -0
- package/cpp/contrib/secp256k1/cmake/CheckStringOptionValue.cmake +10 -0
- package/cpp/contrib/secp256k1/cmake/CheckX86_64Assembly.cmake +15 -0
- package/cpp/contrib/secp256k1/cmake/DiscoverTests.cmake +71 -0
- package/cpp/contrib/secp256k1/cmake/FindValgrind.cmake +41 -0
- package/cpp/contrib/secp256k1/cmake/GeneratePkgConfigFile.cmake +8 -0
- package/cpp/contrib/secp256k1/cmake/TryAppendCFlags.cmake +24 -0
- package/cpp/contrib/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake +3 -0
- package/cpp/contrib/secp256k1/cmake/config.cmake.in +5 -0
- package/cpp/contrib/secp256k1/cmake/source_arm32.s +9 -0
- package/cpp/contrib/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake +3 -0
- package/cpp/contrib/secp256k1/configure.ac +590 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_parsing.c +148 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_parsing.h +97 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.c +112 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.h +95 -0
- package/cpp/contrib/secp256k1/doc/ellswift.md +483 -0
- package/cpp/contrib/secp256k1/doc/musig.md +54 -0
- package/cpp/contrib/secp256k1/doc/release-process.md +94 -0
- package/cpp/contrib/secp256k1/doc/safegcd_implementation.md +819 -0
- package/cpp/contrib/secp256k1/examples/CMakeLists.txt +33 -0
- package/cpp/contrib/secp256k1/examples/EXAMPLES_COPYING +121 -0
- package/cpp/contrib/secp256k1/examples/ecdh.c +121 -0
- package/cpp/contrib/secp256k1/examples/ecdsa.c +138 -0
- package/cpp/contrib/secp256k1/examples/ellswift.c +122 -0
- package/cpp/contrib/secp256k1/examples/examples_util.h +108 -0
- package/cpp/contrib/secp256k1/examples/musig.c +261 -0
- package/cpp/contrib/secp256k1/examples/schnorr.c +154 -0
- package/cpp/contrib/secp256k1/include/secp256k1.h +877 -0
- package/cpp/contrib/secp256k1/include/secp256k1_dleag.h +150 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ecdh.h +63 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ecdsaotves.h +55 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ed25519.h +239 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ellswift.h +200 -0
- package/cpp/contrib/secp256k1/include/secp256k1_extrakeys.h +250 -0
- package/cpp/contrib/secp256k1/include/secp256k1_generator.h +106 -0
- package/cpp/contrib/secp256k1/include/secp256k1_hash.h +45 -0
- package/cpp/contrib/secp256k1/include/secp256k1_musig.h +588 -0
- package/cpp/contrib/secp256k1/include/secp256k1_preallocated.h +134 -0
- package/cpp/contrib/secp256k1/include/secp256k1_recovery.h +123 -0
- package/cpp/contrib/secp256k1/include/secp256k1_schnorrsig.h +190 -0
- package/cpp/contrib/secp256k1/include/visibility.h +58 -0
- package/cpp/contrib/secp256k1/libsecp256k1.pc.in +12 -0
- package/cpp/contrib/secp256k1/sage/gen_exhaustive_groups.sage +156 -0
- package/cpp/contrib/secp256k1/sage/gen_split_lambda_constants.sage +123 -0
- package/cpp/contrib/secp256k1/sage/group_prover.sage +353 -0
- package/cpp/contrib/secp256k1/sage/prove_group_implementations.sage +285 -0
- package/cpp/contrib/secp256k1/sage/secp256k1_params.sage +39 -0
- package/cpp/contrib/secp256k1/sage/weierstrass_prover.sage +275 -0
- package/cpp/contrib/secp256k1/src/CMakeLists.txt +253 -0
- package/cpp/contrib/secp256k1/src/asm/field_10x26_arm.s +916 -0
- package/cpp/contrib/secp256k1/src/assumptions.h +87 -0
- package/cpp/contrib/secp256k1/src/checkmem.h +117 -0
- package/cpp/contrib/secp256k1/src/ecdsa.h +21 -0
- package/cpp/contrib/secp256k1/src/ecdsa_impl.h +312 -0
- package/cpp/contrib/secp256k1/src/eckey.h +28 -0
- package/cpp/contrib/secp256k1/src/eckey_impl.h +94 -0
- package/cpp/contrib/secp256k1/src/ecmult.h +64 -0
- package/cpp/contrib/secp256k1/src/ecmult_compute_table.h +16 -0
- package/cpp/contrib/secp256k1/src/ecmult_compute_table_impl.h +49 -0
- package/cpp/contrib/secp256k1/src/ecmult_const.h +38 -0
- package/cpp/contrib/secp256k1/src/ecmult_const_impl.h +402 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen.h +144 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table.h +14 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table_impl.h +108 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_impl.h +341 -0
- package/cpp/contrib/secp256k1/src/ecmult_impl.h +869 -0
- package/cpp/contrib/secp256k1/src/field.h +354 -0
- package/cpp/contrib/secp256k1/src/field_10x26.h +57 -0
- package/cpp/contrib/secp256k1/src/field_10x26_impl.h +1234 -0
- package/cpp/contrib/secp256k1/src/field_5x52.h +62 -0
- package/cpp/contrib/secp256k1/src/field_5x52_impl.h +524 -0
- package/cpp/contrib/secp256k1/src/field_5x52_int128_impl.h +274 -0
- package/cpp/contrib/secp256k1/src/field_impl.h +462 -0
- package/cpp/contrib/secp256k1/src/group.h +224 -0
- package/cpp/contrib/secp256k1/src/group_impl.h +1024 -0
- package/cpp/contrib/secp256k1/src/hash.h +54 -0
- package/cpp/contrib/secp256k1/src/hash_impl.h +360 -0
- package/cpp/contrib/secp256k1/src/hsort.h +33 -0
- package/cpp/contrib/secp256k1/src/hsort_impl.h +125 -0
- package/cpp/contrib/secp256k1/src/int128.h +90 -0
- package/cpp/contrib/secp256k1/src/int128_impl.h +18 -0
- package/cpp/contrib/secp256k1/src/int128_native.h +19 -0
- package/cpp/contrib/secp256k1/src/int128_native_impl.h +94 -0
- package/cpp/contrib/secp256k1/src/int128_struct.h +14 -0
- package/cpp/contrib/secp256k1/src/int128_struct_impl.h +205 -0
- package/cpp/contrib/secp256k1/src/modinv32.h +43 -0
- package/cpp/contrib/secp256k1/src/modinv32_impl.h +725 -0
- package/cpp/contrib/secp256k1/src/modinv64.h +47 -0
- package/cpp/contrib/secp256k1/src/modinv64_impl.h +780 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/Makefile.am.include +3 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/main_impl.h +1073 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/tests_impl.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/bench_impl.h +54 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/main_impl.h +79 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/tests_impl.h +218 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/Makefile.am.include +3 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/main_impl.h +365 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/tests_impl.h +49 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/Makefile.am.include +16 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/common.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/core_ed25519.h +229 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/main_impl.h +98 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/common.h +21 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10.h +2698 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_25_5.h +1056 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_51.h +518 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base.h +1344 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base2.h +40 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/constants.h +40 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/fe.h +220 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/scalarmult_ed25519_ref10.h +417 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512.h +14 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512_cp.h +287 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/tests_impl.h +109 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/utils.h +97 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/bench_impl.h +106 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/main_impl.h +581 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/tests_exhaustive_impl.h +39 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/tests_impl.h +544 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/Makefile.am.include +4 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/main_impl.h +285 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_impl.h +484 -0
- package/cpp/contrib/secp256k1/src/modules/generator/Makefile.am.include +9 -0
- package/cpp/contrib/secp256k1/src/modules/generator/main_impl.h +271 -0
- package/cpp/contrib/secp256k1/src/modules/generator/tests_impl.h +227 -0
- package/cpp/contrib/secp256k1/src/modules/musig/Makefile.am.include +8 -0
- package/cpp/contrib/secp256k1/src/modules/musig/keyagg.h +32 -0
- package/cpp/contrib/secp256k1/src/modules/musig/keyagg_impl.h +275 -0
- package/cpp/contrib/secp256k1/src/modules/musig/main_impl.h +12 -0
- package/cpp/contrib/secp256k1/src/modules/musig/session.h +24 -0
- package/cpp/contrib/secp256k1/src/modules/musig/session_impl.h +795 -0
- package/cpp/contrib/secp256k1/src/modules/musig/tests_impl.h +1161 -0
- package/cpp/contrib/secp256k1/src/modules/musig/vectors.h +346 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/bench_impl.h +62 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/main_impl.h +159 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/tests_exhaustive_impl.h +148 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/tests_impl.h +339 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/bench_impl.h +104 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/main_impl.h +263 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h +214 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_impl.h +1010 -0
- package/cpp/contrib/secp256k1/src/precompute_ecmult.c +91 -0
- package/cpp/contrib/secp256k1/src/precompute_ecmult_gen.c +101 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult.c +16456 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult.h +40 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.c +1779 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.h +28 -0
- package/cpp/contrib/secp256k1/src/scalar.h +108 -0
- package/cpp/contrib/secp256k1/src/scalar_4x64.h +19 -0
- package/cpp/contrib/secp256k1/src/scalar_4x64_impl.h +1010 -0
- package/cpp/contrib/secp256k1/src/scalar_8x32.h +19 -0
- package/cpp/contrib/secp256k1/src/scalar_8x32_impl.h +830 -0
- package/cpp/contrib/secp256k1/src/scalar_impl.h +321 -0
- package/cpp/contrib/secp256k1/src/scalar_low.h +24 -0
- package/cpp/contrib/secp256k1/src/scalar_low_impl.h +215 -0
- package/cpp/contrib/secp256k1/src/scratch.h +44 -0
- package/cpp/contrib/secp256k1/src/scratch_impl.h +99 -0
- package/cpp/contrib/secp256k1/src/secp256k1.c +896 -0
- package/cpp/contrib/secp256k1/src/selftest.h +35 -0
- package/cpp/contrib/secp256k1/src/testrand.h +45 -0
- package/cpp/contrib/secp256k1/src/testrand_impl.h +162 -0
- package/cpp/contrib/secp256k1/src/testutil.h +161 -0
- package/cpp/contrib/secp256k1/src/unit_test.c +479 -0
- package/cpp/contrib/secp256k1/src/unit_test.h +147 -0
- package/cpp/contrib/secp256k1/src/util.h +469 -0
- package/cpp/contrib/secp256k1/src/util_local_visibility.h +12 -0
- package/cpp/contrib/secp256k1/tools/check-abi.sh +67 -0
- package/cpp/contrib/secp256k1/tools/symbol-check.py +72 -0
- package/cpp/contrib/secp256k1/tools/test_vectors_musig2_generate.py +656 -0
- package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdh.py +166 -0
- package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdsa.py +111 -0
- package/cpp/contrib/secp256k1/tools/wycheproof_utils.py +12 -0
- package/cpp/contrib/secp256k1/wasm/test_module.html +320 -0
- package/cpp/contrib/secp256k1/wasm/wrap.cpp +331 -0
- package/cpp/contrib/sqlite3.h +14349 -0
- package/cpp/contrib/sqlite3mc_amalgamation.c +369890 -0
- package/cpp/contrib/sqlite3mc_amalgamation.h +15548 -0
- package/cpp/contrib/unilib/uninorms.cpp +393 -0
- package/cpp/contrib/unilib/uninorms.h +56 -0
- package/cpp/contrib/unilib/utf8.cpp +78 -0
- package/cpp/contrib/unilib/utf8.h +260 -0
- package/cpp/contrib/update_mbedtls.sh +85 -0
- package/cpp/crypto/aes.cpp +141 -0
- package/cpp/crypto/aes.h +67 -0
- package/cpp/crypto/chacha20.cpp +342 -0
- package/cpp/crypto/chacha20.h +82 -0
- package/cpp/crypto/chacha20poly1305.cpp +91 -0
- package/cpp/crypto/chacha20poly1305.h +46 -0
- package/cpp/crypto/common.h +85 -0
- package/cpp/crypto/ctaes/COPYING +21 -0
- package/cpp/crypto/ctaes/README.md +41 -0
- package/cpp/crypto/ctaes/bench.c +170 -0
- package/cpp/crypto/ctaes/ctaes.c +556 -0
- package/cpp/crypto/ctaes/ctaes.h +41 -0
- package/cpp/crypto/ctaes/test.c +110 -0
- package/cpp/crypto/extkey.cpp +257 -0
- package/cpp/crypto/extkey.h +66 -0
- package/cpp/crypto/hmac_sha512.cpp +37 -0
- package/cpp/crypto/hmac_sha512.h +32 -0
- package/cpp/crypto/merkle.cpp +47 -0
- package/cpp/crypto/merkle.h +20 -0
- package/cpp/crypto/poly1305.cpp +223 -0
- package/cpp/crypto/poly1305.h +59 -0
- package/cpp/crypto/ripemd160.cpp +292 -0
- package/cpp/crypto/ripemd160.h +28 -0
- package/cpp/crypto/scrypt-sse2.cpp +141 -0
- package/cpp/crypto/scrypt.cpp +336 -0
- package/cpp/crypto/scrypt.h +49 -0
- package/cpp/crypto/sealed_key.cpp +62 -0
- package/cpp/crypto/sealed_key.h +34 -0
- package/cpp/crypto/secure_bytes.h +16 -0
- package/cpp/crypto/sha512.cpp +206 -0
- package/cpp/crypto/sha512.h +29 -0
- package/cpp/crypto/util.cpp +77 -0
- package/cpp/crypto/util.h +32 -0
- package/cpp/debug_rpc.cpp +703 -0
- package/cpp/debug_rpc.h +63 -0
- package/cpp/electrum.cpp +931 -0
- package/cpp/electrum.h +169 -0
- package/cpp/engine/xmr_engine.cpp +463 -0
- package/cpp/engine/xmr_engine.h +84 -0
- package/cpp/engine/xmr_engine_c.cpp +141 -0
- package/cpp/engine/xmr_engine_c.h +35 -0
- package/cpp/fees.cpp +270 -0
- package/cpp/fees.h +60 -0
- package/cpp/height_search.cpp +64 -0
- package/cpp/height_search.h +27 -0
- package/cpp/main.cpp +146 -0
- package/cpp/messages_npb.cpp +701 -0
- package/cpp/messages_npb.h +667 -0
- package/cpp/mnemonic/mnemonic.cpp +715 -0
- package/cpp/mnemonic/mnemonic.h +52 -0
- package/cpp/mnemonic/wordlists/english.h +1103 -0
- package/cpp/mnemonic/wordlists/japanese.h +2212 -0
- package/cpp/network/bridge.cpp +232 -0
- package/cpp/network/bridge.h +115 -0
- package/cpp/network/ca_roots.cpp +114 -0
- package/cpp/network/ca_roots.h +12 -0
- package/cpp/network/http_client.cpp +261 -0
- package/cpp/network/http_client.h +33 -0
- package/cpp/network/pem.cpp +84 -0
- package/cpp/network/pem.h +22 -0
- package/cpp/network/psa_user_config.h +15 -0
- package/cpp/network/socks5.cpp +180 -0
- package/cpp/network/socks5.h +26 -0
- package/cpp/network/tls_transport.cpp +502 -0
- package/cpp/network/tls_transport.h +62 -0
- package/cpp/network/transport.cpp +169 -0
- package/cpp/network/transport.h +115 -0
- package/cpp/network/url.cpp +88 -0
- package/cpp/network/url.h +25 -0
- package/cpp/network/websocket.cpp +253 -0
- package/cpp/network/websocket.h +68 -0
- package/cpp/network/ws_transport.cpp +361 -0
- package/cpp/network/ws_transport.h +72 -0
- package/cpp/node_client.cpp +1196 -0
- package/cpp/node_client.h +209 -0
- package/cpp/node_scan.h +35 -0
- package/cpp/schema.cpp +1249 -0
- package/cpp/schema.h +132 -0
- package/cpp/smsg.cpp +453 -0
- package/cpp/smsg.h +43 -0
- package/cpp/support/allocators/secure.h +85 -0
- package/cpp/support/cleanse.cpp +35 -0
- package/cpp/support/cleanse.h +15 -0
- package/cpp/support/coop.cpp +319 -0
- package/cpp/support/coop.h +157 -0
- package/cpp/support/lockedpool.cpp +406 -0
- package/cpp/support/lockedpool.h +240 -0
- package/cpp/uint256.cpp +62 -0
- package/cpp/uint256.h +121 -0
- package/cpp/util/base58.cpp +181 -0
- package/cpp/util/base58.h +45 -0
- package/cpp/util/bech32.cpp +578 -0
- package/cpp/util/bech32.h +96 -0
- package/cpp/util/debug.cpp +23 -0
- package/cpp/util/debug.h +12 -0
- package/cpp/util/int.cpp +118 -0
- package/cpp/util/int.h +18 -0
- package/cpp/util/json.h +26 -0
- package/cpp/util/log.cpp +137 -0
- package/cpp/util/log.h +37 -0
- package/cpp/util/mutex.h +89 -0
- package/cpp/util/platform.cpp +90 -0
- package/cpp/util/platform.h +17 -0
- package/cpp/util/random.cpp +136 -0
- package/cpp/util/random.h +28 -0
- package/cpp/util/rpc.cpp +192 -0
- package/cpp/util/rpc.h +454 -0
- package/cpp/util/str.cpp +254 -0
- package/cpp/util/str.h +54 -0
- package/cpp/util/thread.cpp +17 -0
- package/cpp/util/thread.h +12 -0
- package/cpp/util/time.cpp +30 -0
- package/cpp/util/time.h +30 -0
- package/cpp/util/tinyformat.h +1163 -0
- package/cpp/util/vector.h +83 -0
- package/cpp/version.h.in +12 -0
- package/cpp/view_key_chain.h +283 -0
- package/cpp/wallet/account_wallet.cpp +668 -0
- package/cpp/wallet/account_wallet.h +136 -0
- package/cpp/wallet/base_wallet.cpp +302 -0
- package/cpp/wallet/base_wallet.h +129 -0
- package/cpp/wallet/debug_wallet.cpp +40 -0
- package/cpp/wallet/debug_wallet.h +36 -0
- package/cpp/wallet/encrypted_seed.cpp +96 -0
- package/cpp/wallet/encrypted_seed.h +41 -0
- package/cpp/wallet/host_wallet.cpp +85 -0
- package/cpp/wallet/host_wallet.h +51 -0
- package/cpp/wallet/native_wallet.cpp +34 -0
- package/cpp/wallet/native_wallet.h +28 -0
- package/cpp/wallet/xmr/account_wallet.cpp +803 -0
- package/cpp/wallet/xmr/account_wallet.h +139 -0
- package/cpp/wallet/xmr/builder.cpp +568 -0
- package/cpp/wallet/xmr/builder.h +65 -0
- package/cpp/wallet/xmr/chain.cpp +1437 -0
- package/cpp/wallet/xmr/chain.h +213 -0
- package/cpp/wallet/xmr/daemon.cpp +583 -0
- package/cpp/wallet/xmr/daemon.h +153 -0
- package/cpp/wallet/xmr/decoys.cpp +197 -0
- package/cpp/wallet/xmr/decoys.h +64 -0
- package/cpp/wallet/xmr/epee.cpp +448 -0
- package/cpp/wallet/xmr/epee.h +25 -0
- package/cpp/wallet/xmr/fee.cpp +169 -0
- package/cpp/wallet/xmr/fee.h +61 -0
- package/cpp/wallet/xmr/reserve_proof.cpp +169 -0
- package/cpp/wallet/xmr/reserve_proof.h +24 -0
- package/cpp/wallet/xmr/scanner.cpp +860 -0
- package/cpp/wallet/xmr/scanner.h +239 -0
- package/lib/commonjs/NativeNitroBSX.js +128 -0
- package/lib/commonjs/NativeNitroBSX.js.map +1 -0
- package/lib/commonjs/format.js +21 -0
- package/lib/commonjs/format.js.map +1 -0
- package/lib/commonjs/index.js +50 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/service.js +75 -0
- package/lib/commonjs/service.js.map +1 -0
- package/lib/commonjs/specs/NitroBSX.nitro.js +6 -0
- package/lib/commonjs/specs/NitroBSX.nitro.js.map +1 -0
- package/lib/module/NativeNitroBSX.js +124 -0
- package/lib/module/NativeNitroBSX.js.map +1 -0
- package/lib/module/format.js +15 -0
- package/lib/module/format.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/service.js +66 -0
- package/lib/module/service.js.map +1 -0
- package/lib/module/specs/NitroBSX.nitro.js +4 -0
- package/lib/module/specs/NitroBSX.nitro.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts +94 -0
- package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/format.d.ts +3 -0
- package/lib/typescript/commonjs/src/format.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/service.d.ts +28 -0
- package/lib/typescript/commonjs/src/service.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts +251 -0
- package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeNitroBSX.d.ts +94 -0
- package/lib/typescript/module/src/NativeNitroBSX.d.ts.map +1 -0
- package/lib/typescript/module/src/format.d.ts +3 -0
- package/lib/typescript/module/src/format.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +5 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/service.d.ts +28 -0
- package/lib/typescript/module/src/service.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts +251 -0
- package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts.map +1 -0
- package/nitro.json +19 -0
- package/nitrogen/generated/android/NitroBSX+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroBSX+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroBSXOnLoad.cpp +49 -0
- package/nitrogen/generated/android/NitroBSXOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobsx/NitroBSXOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroBSX+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/NitroBSXAutolinking.mm +35 -0
- package/nitrogen/generated/ios/NitroBSXAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.cpp +91 -0
- package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.hpp +142 -0
- package/nitrogen/generated/shared/c++/NotificationPair.hpp +87 -0
- package/nitrogen/generated/shared/c++/SignOutcome.hpp +80 -0
- package/nitrogen/generated/shared/c++/SignTxResult.hpp +89 -0
- package/package.json +172 -4
- package/react-native-nitro-bsx.podspec +33 -0
- package/react-native.config.js +26 -0
- package/scripts/build-ios.sh +49 -0
- package/src/NativeNitroBSX.ts +203 -0
- package/src/format.ts +14 -0
- package/src/index.ts +4 -0
- package/src/service.ts +77 -0
- package/src/specs/NitroBSX.nitro.ts +300 -0
|
@@ -0,0 +1,905 @@
|
|
|
1
|
+
/*Copyright (c) 2025-2026 The Basicswap developers
|
|
2
|
+
Distributed under the MIT software license, see the accompanying
|
|
3
|
+
file LICENSE or http://www.opensource.org/licenses/mit-license.php.*/
|
|
4
|
+
|
|
5
|
+
#include "part.h"
|
|
6
|
+
#include "chainparams.h"
|
|
7
|
+
|
|
8
|
+
#include <coins/btc_base/script.h>
|
|
9
|
+
#include <compat/endian.h>
|
|
10
|
+
#include <crypto/merkle.h>
|
|
11
|
+
#include <crypto/util.h>
|
|
12
|
+
#include <electrum.h>
|
|
13
|
+
#include <util/int.h>
|
|
14
|
+
#include <util/log.h>
|
|
15
|
+
#include <util/str.h>
|
|
16
|
+
#include <util/tinyformat.h>
|
|
17
|
+
|
|
18
|
+
#include <secp256k1_hash.h>
|
|
19
|
+
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <cinttypes>
|
|
22
|
+
#include <climits>
|
|
23
|
+
|
|
24
|
+
namespace bsx {
|
|
25
|
+
namespace part {
|
|
26
|
+
|
|
27
|
+
// Particl writes no segwit marker or flag
|
|
28
|
+
size_t Interface::getWitnessStackSerialisedLength(
|
|
29
|
+
std::vector<std::vector<unsigned char>> &witness_stack) const
|
|
30
|
+
{
|
|
31
|
+
size_t rv = bytes_compactsize(witness_stack.size());
|
|
32
|
+
for (const auto &e : witness_stack) {
|
|
33
|
+
rv += bytes_compactsize(e.size()) + e.size();
|
|
34
|
+
}
|
|
35
|
+
return rv;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
size_t Interface::getWitnessStackSerialisedLength(
|
|
39
|
+
std::vector<std::vector<std::vector<unsigned char>>> &witness_stacks) const
|
|
40
|
+
{
|
|
41
|
+
size_t rv{0};
|
|
42
|
+
for (auto &witness_stack : witness_stacks) {
|
|
43
|
+
rv += getWitnessStackSerialisedLength(witness_stack);
|
|
44
|
+
}
|
|
45
|
+
return rv;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
int Interface::getScriptForPubkeyHash(std::vector<unsigned char> &script_dest,
|
|
49
|
+
const std::vector<unsigned char> &pkh) const
|
|
50
|
+
{
|
|
51
|
+
if (0 != btc_base::make_script_P2PKH(script_dest, pkh)) {
|
|
52
|
+
LOGE("getScriptForPubkeyHash invalid pubkey hash size");
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
int Interface::getPubkeyHashFromScript(std::vector<unsigned char> &pkh,
|
|
59
|
+
const std::vector<unsigned char> &script) const
|
|
60
|
+
{
|
|
61
|
+
return btc_base::get_P2PKH_pubkey_hash(pkh, script);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
int Interface::getSignatureHash(unsigned char *out,
|
|
65
|
+
const std::vector<unsigned char> &prevout_script,
|
|
66
|
+
const bsx::Transaction *ptx, unsigned int input_n, int hash_type,
|
|
67
|
+
int64_t prevout_value, SignatureHashes &hashes) const
|
|
68
|
+
{
|
|
69
|
+
const Transaction *tx = dynamic_cast<const Transaction *>(ptx);
|
|
70
|
+
if (!tx) {
|
|
71
|
+
LOGE("getSignatureHash: Invalid tx class type");
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
const static unsigned char null_hash[32] = {0};
|
|
75
|
+
unsigned char buf[32];
|
|
76
|
+
std::vector<unsigned char> tmp;
|
|
77
|
+
secp256k1_sha256 sha;
|
|
78
|
+
|
|
79
|
+
if (input_n < 0 || input_n >= tx->m_vin.size()) {
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
secp256k1_sha256_initialize(&sha);
|
|
84
|
+
|
|
85
|
+
uint32_t t32 = htole32_internal(tx->m_version);
|
|
86
|
+
secp256k1_sha256_write_(&sha, (unsigned char *)&t32, 4);
|
|
87
|
+
|
|
88
|
+
if (!(hash_type & btc_base::SIGHASH_ANYONECANPAY)) {
|
|
89
|
+
if (!hashes.m_hashed_prevouts) {
|
|
90
|
+
secp256k1_sha256 sha_inner;
|
|
91
|
+
secp256k1_sha256_initialize(&sha_inner);
|
|
92
|
+
for (const auto &txin : tx->m_vin) {
|
|
93
|
+
const auto ptxin = dynamic_cast<Input *>(txin.get());
|
|
94
|
+
ptxin->m_prevout.to_bytes(tmp);
|
|
95
|
+
secp256k1_sha256_write_(&sha_inner, tmp.data(), tmp.size());
|
|
96
|
+
}
|
|
97
|
+
secp256k1_sha256_finalize_(&sha_inner, hashes.m_hash_prevouts);
|
|
98
|
+
sha256(hashes.m_hash_prevouts, hashes.m_hash_prevouts, 32);
|
|
99
|
+
hashes.m_hashed_prevouts = true;
|
|
100
|
+
}
|
|
101
|
+
secp256k1_sha256_write_(&sha, hashes.m_hash_prevouts, 32);
|
|
102
|
+
} else {
|
|
103
|
+
secp256k1_sha256_write_(&sha, null_hash, 32);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!(hash_type & btc_base::SIGHASH_ANYONECANPAY) &&
|
|
107
|
+
(hash_type & 0x1f) != btc_base::SIGHASH_SINGLE &&
|
|
108
|
+
(hash_type & 0x1f) != btc_base::SIGHASH_NONE) {
|
|
109
|
+
if (!hashes.m_hashed_sequence) {
|
|
110
|
+
secp256k1_sha256 sha_inner;
|
|
111
|
+
secp256k1_sha256_initialize(&sha_inner);
|
|
112
|
+
for (const auto &txin : tx->m_vin) {
|
|
113
|
+
const auto ptxin = dynamic_cast<Input *>(txin.get());
|
|
114
|
+
t32 = htole32_internal(ptxin->m_sequence);
|
|
115
|
+
secp256k1_sha256_write_(&sha_inner, (unsigned char *)&t32, 4);
|
|
116
|
+
}
|
|
117
|
+
secp256k1_sha256_finalize_(&sha_inner, hashes.m_hash_sequence);
|
|
118
|
+
sha256(hashes.m_hash_sequence, hashes.m_hash_sequence, 32);
|
|
119
|
+
hashes.m_hashed_sequence = true;
|
|
120
|
+
}
|
|
121
|
+
secp256k1_sha256_write_(&sha, hashes.m_hash_sequence, 32);
|
|
122
|
+
} else {
|
|
123
|
+
secp256k1_sha256_write_(&sha, hashes.m_hash_sequence, 32);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const auto txin_input_n = dynamic_cast<Input *>(tx->m_vin[input_n].get());
|
|
127
|
+
txin_input_n->m_prevout.to_bytes(tmp);
|
|
128
|
+
secp256k1_sha256_write_(&sha, tmp.data(), tmp.size());
|
|
129
|
+
|
|
130
|
+
int cl = encode_compactsize(buf, prevout_script.size());
|
|
131
|
+
secp256k1_sha256_write_(&sha, buf, cl);
|
|
132
|
+
secp256k1_sha256_write_(&sha, prevout_script.data(), prevout_script.size());
|
|
133
|
+
|
|
134
|
+
int64_t t64 = htole64_internal(prevout_value);
|
|
135
|
+
secp256k1_sha256_write_(&sha, (unsigned char *)&t64, 8);
|
|
136
|
+
|
|
137
|
+
t32 = htole32_internal(txin_input_n->m_sequence);
|
|
138
|
+
secp256k1_sha256_write_(&sha, (unsigned char *)&t32, 4);
|
|
139
|
+
|
|
140
|
+
if ((hash_type & 0x1f) != btc_base::SIGHASH_SINGLE &&
|
|
141
|
+
(hash_type & 0x1f) != btc_base::SIGHASH_NONE) {
|
|
142
|
+
if (!hashes.m_hashed_outputs) {
|
|
143
|
+
secp256k1_sha256 sha_inner;
|
|
144
|
+
secp256k1_sha256_initialize(&sha_inner);
|
|
145
|
+
for (const auto &txout : tx->m_vout) {
|
|
146
|
+
txout->to_bytes(tmp);
|
|
147
|
+
secp256k1_sha256_write_(&sha_inner, tmp.data(), tmp.size());
|
|
148
|
+
}
|
|
149
|
+
secp256k1_sha256_finalize_(&sha_inner, hashes.m_hash_outputs);
|
|
150
|
+
sha256(hashes.m_hash_outputs, hashes.m_hash_outputs, 32);
|
|
151
|
+
hashes.m_hashed_outputs = true;
|
|
152
|
+
}
|
|
153
|
+
secp256k1_sha256_write_(&sha, hashes.m_hash_outputs, 32);
|
|
154
|
+
} else if ((hash_type & 0x1f) == btc_base::SIGHASH_SINGLE && input_n < tx->m_vout.size()) {
|
|
155
|
+
tx->m_vout[input_n]->to_bytes(tmp);
|
|
156
|
+
double_sha256(buf, tmp.data(), tmp.size());
|
|
157
|
+
secp256k1_sha256_write_(&sha, buf, 32);
|
|
158
|
+
} else {
|
|
159
|
+
secp256k1_sha256_write_(&sha, null_hash, 32);
|
|
160
|
+
}
|
|
161
|
+
t32 = htole32_internal(tx->m_locktime);
|
|
162
|
+
secp256k1_sha256_write_(&sha, (unsigned char *)&t32, 4);
|
|
163
|
+
t32 = htole32_internal(hash_type);
|
|
164
|
+
secp256k1_sha256_write_(&sha, (unsigned char *)&t32, 4);
|
|
165
|
+
secp256k1_sha256_finalize_(&sha, out);
|
|
166
|
+
sha256(out, out, 32);
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
bool Interface::checkBlockHeader(int height, std::shared_ptr<bsx::BlockHeader> header) const
|
|
171
|
+
{
|
|
172
|
+
// Validating PoS work requires tx data
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
int Interface::verifiedHeight()
|
|
177
|
+
{
|
|
178
|
+
if (!m_verify_stake) {
|
|
179
|
+
return getChainHeight();
|
|
180
|
+
}
|
|
181
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
182
|
+
return verifiedHeightLocked();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
int Interface::verifiedHeightLocked()
|
|
186
|
+
{
|
|
187
|
+
loadStakeState();
|
|
188
|
+
if (rewindToBestChain()) {
|
|
189
|
+
saveStakeState();
|
|
190
|
+
}
|
|
191
|
+
if (m_verified_height >= 0 && !onBestChain(m_verified_height, m_verified_hash)) {
|
|
192
|
+
return -1;
|
|
193
|
+
}
|
|
194
|
+
return m_verified_height;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
void Interface::failedBlocksCleared()
|
|
198
|
+
{
|
|
199
|
+
m_stake_rejection = StakeRejection();
|
|
200
|
+
m_stake_request_id = 0;
|
|
201
|
+
requestStakeProofs();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
bool Interface::stakeRejectionCurrent()
|
|
205
|
+
{
|
|
206
|
+
if (m_stake_rejection.height < 0 || m_stake_rejection.height != m_verified_height + 1) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
BlockIndex *rejected = blockIndexAtHeight(m_stake_rejection.height);
|
|
210
|
+
return rejected && *rejected->m_pblock_hash == m_stake_rejection.block_hash;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
void Interface::getStakeStatus(nlohmann::json &j)
|
|
214
|
+
{
|
|
215
|
+
if (!m_verify_stake) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
219
|
+
j["verified_height"] = verifiedHeightLocked();
|
|
220
|
+
if (!stakeRejectionCurrent()) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
nlohmann::json j_rejection;
|
|
224
|
+
j_rejection["height"] = m_stake_rejection.height;
|
|
225
|
+
j_rejection["block_hash"] = m_stake_rejection.block_hash.ToString();
|
|
226
|
+
if (!m_stake_rejection.source_txid.empty()) {
|
|
227
|
+
j_rejection["source_txid"] = m_stake_rejection.source_txid;
|
|
228
|
+
}
|
|
229
|
+
j_rejection["reason"] = m_stake_rejection.reason;
|
|
230
|
+
j_rejection["server"] = m_stake_rejection.server_host;
|
|
231
|
+
j_rejection["time"] = m_stake_rejection.time;
|
|
232
|
+
j_rejection["retry_time"] = m_stake_rejection.time + STAKE_REJECTION_RETRY_SECONDS;
|
|
233
|
+
j["stake_rejection"] = j_rejection;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
void Interface::recordVerifiedBlock(const uint256 &block_hash)
|
|
237
|
+
{
|
|
238
|
+
m_verified_hash = block_hash;
|
|
239
|
+
StakeState state;
|
|
240
|
+
state.height = m_verified_height;
|
|
241
|
+
state.block_hash = block_hash;
|
|
242
|
+
state.modifier = m_verified_modifier;
|
|
243
|
+
state.frontier = m_frontier;
|
|
244
|
+
m_stake_history.push(state);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void Interface::resetStakeState()
|
|
248
|
+
{
|
|
249
|
+
m_verified_height = -1;
|
|
250
|
+
m_verified_modifier = uint256();
|
|
251
|
+
m_verified_hash = uint256();
|
|
252
|
+
m_frontier = MerkleFrontier();
|
|
253
|
+
m_stake_history.clear();
|
|
254
|
+
m_stake_request_id = 0;
|
|
255
|
+
m_commit_height = -1;
|
|
256
|
+
m_commit_parent_time = 0;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
bool Interface::onBestChain(int height, const uint256 &hash)
|
|
260
|
+
{
|
|
261
|
+
BlockIndex *block_index = blockIndexAtHeight(height);
|
|
262
|
+
return block_index && block_index->m_pblock_hash && *block_index->m_pblock_hash == hash;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
bool Interface::rewindToBestChain()
|
|
266
|
+
{
|
|
267
|
+
if (m_verified_height < 0) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
auto on_best_chain = [this](int height, const uint256 &hash)
|
|
271
|
+
REQUIRES(m_mtx_chain) { return onBestChain(height, hash); };
|
|
272
|
+
if (!blockIndexAtHeight(m_verified_height) &&
|
|
273
|
+
m_block_index.find(m_verified_hash) == m_block_index.end()) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
if (on_best_chain(m_verified_height, m_verified_hash)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
const int from_height = m_verified_height;
|
|
280
|
+
StakeState state;
|
|
281
|
+
if (m_stake_history.rewind(state, on_best_chain)) {
|
|
282
|
+
m_verified_height = state.height;
|
|
283
|
+
m_verified_hash = state.block_hash;
|
|
284
|
+
m_verified_modifier = state.modifier;
|
|
285
|
+
m_frontier = state.frontier;
|
|
286
|
+
m_stake_request_id = 0;
|
|
287
|
+
LOGW("%s stake verification rewound from %d to %d after a reorg", coinTicker(), from_height,
|
|
288
|
+
m_verified_height);
|
|
289
|
+
} else {
|
|
290
|
+
resetStakeState();
|
|
291
|
+
LOGW("%s stake verification reorged below its history at %d, needs a new commitment",
|
|
292
|
+
coinTicker(), from_height);
|
|
293
|
+
}
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
void Interface::loadStakeState()
|
|
298
|
+
{
|
|
299
|
+
if (m_stake_state_loaded || !m_db) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
m_stake_state_loaded = true;
|
|
303
|
+
const bool open_here = !m_db->isDBOpen();
|
|
304
|
+
if (open_here && 0 != m_db->openDB()) {
|
|
305
|
+
LOGE("loadStakeState: DB open failed");
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
int64_t verified_height{-1};
|
|
309
|
+
std::string modifier_hex, frontier_hex, hash_hex;
|
|
310
|
+
if (0 == m_db->getKVInt("part_stake_verified_height", verified_height) &&
|
|
311
|
+
0 == m_db->getKVString("part_stake_modifier", modifier_hex) &&
|
|
312
|
+
0 == m_db->getKVString("part_stake_frontier", frontier_hex) &&
|
|
313
|
+
0 == m_db->getKVString("part_stake_hash", hash_hex)) {
|
|
314
|
+
std::vector<unsigned char> modifier, frontier_nodes, block_hash;
|
|
315
|
+
MerkleFrontier frontier;
|
|
316
|
+
if (0 == decode_hex(modifier, modifier_hex) && modifier.size() == 32 &&
|
|
317
|
+
0 == decode_hex(block_hash, hash_hex) && block_hash.size() == 32 &&
|
|
318
|
+
0 == decode_hex(frontier_nodes, frontier_hex) &&
|
|
319
|
+
0 == frontier.fromNodes((uint64_t)verified_height + 1, frontier_nodes)) {
|
|
320
|
+
m_verified_height = (int)verified_height;
|
|
321
|
+
m_verified_modifier = uint256(modifier.data(), 32);
|
|
322
|
+
m_frontier = frontier;
|
|
323
|
+
recordVerifiedBlock(uint256(block_hash.data(), 32));
|
|
324
|
+
int64_t commit_height{-1}, commit_parent_time{0};
|
|
325
|
+
if (0 == m_db->getKVInt("part_stake_commit_height", commit_height) &&
|
|
326
|
+
0 == m_db->getKVInt("part_stake_commit_parent_time", commit_parent_time)) {
|
|
327
|
+
m_commit_height = (int)commit_height;
|
|
328
|
+
m_commit_parent_time = commit_parent_time;
|
|
329
|
+
}
|
|
330
|
+
std::string history_hex;
|
|
331
|
+
std::vector<unsigned char> history_data;
|
|
332
|
+
StakeHistory history;
|
|
333
|
+
if (0 == m_db->getKVString("part_stake_history", history_hex) &&
|
|
334
|
+
0 == decode_hex(history_data, history_hex) &&
|
|
335
|
+
0 == history.fromBytes(history_data) && history.size() > 0 &&
|
|
336
|
+
history.newest().height == m_verified_height &&
|
|
337
|
+
history.newest().block_hash == m_verified_hash) {
|
|
338
|
+
m_stake_history = history;
|
|
339
|
+
}
|
|
340
|
+
LOGI("%s stake state loaded, verified to %d", coinTicker(), m_verified_height);
|
|
341
|
+
LOGD("%s stake history loaded, %zu entries", coinTicker(), m_stake_history.size());
|
|
342
|
+
} else {
|
|
343
|
+
LOGE("%s stake state unreadable, starting over", coinTicker());
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (open_here) {
|
|
347
|
+
m_db->closeDB();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
int Interface::saveStakeState()
|
|
352
|
+
{
|
|
353
|
+
if (!m_db) {
|
|
354
|
+
LOGE("saveStakeState: DB is not set");
|
|
355
|
+
return 1;
|
|
356
|
+
}
|
|
357
|
+
const bool open_here = !m_db->isDBOpen();
|
|
358
|
+
if (open_here && 0 != m_db->openDB()) {
|
|
359
|
+
LOGE("saveStakeState: DB open failed");
|
|
360
|
+
return 1;
|
|
361
|
+
}
|
|
362
|
+
int rv = m_db->savepoint("stake_state");
|
|
363
|
+
if (rv == 0) {
|
|
364
|
+
rv |= m_db->setKVInt("part_stake_verified_height", m_verified_height);
|
|
365
|
+
rv |= m_db->setKVString("part_stake_modifier", hex_str(m_verified_modifier.begin(), 32));
|
|
366
|
+
rv |= m_db->setKVString("part_stake_frontier", hex_str(m_frontier.nodes()));
|
|
367
|
+
rv |= m_db->setKVString("part_stake_hash", hex_str(m_verified_hash.begin(), 32));
|
|
368
|
+
rv |= m_db->setKVInt("part_stake_commit_height", m_commit_height);
|
|
369
|
+
rv |= m_db->setKVInt("part_stake_commit_parent_time", m_commit_parent_time);
|
|
370
|
+
rv |= m_db->setKVString("part_stake_history", hex_str(m_stake_history.toBytes()));
|
|
371
|
+
if (rv != 0 || 0 != m_db->releaseSavepoint("stake_state")) {
|
|
372
|
+
m_db->rollbackToSavepoint("stake_state");
|
|
373
|
+
rv = 1;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (open_here) {
|
|
377
|
+
m_db->closeDB();
|
|
378
|
+
}
|
|
379
|
+
return rv;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
bool Interface::needsChainCommitment(int anchor_height)
|
|
383
|
+
{
|
|
384
|
+
if (!m_verify_stake || anchor_height < 0) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
388
|
+
loadStakeState();
|
|
389
|
+
return m_verified_height < anchor_height;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
StakeRejection Interface::stakeRejection()
|
|
393
|
+
{
|
|
394
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
395
|
+
return m_stake_rejection;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
int Interface::stakeTargetRequired(int height, uint32_t &bits)
|
|
399
|
+
{
|
|
400
|
+
BlockIndex *prev = blockIndexAtHeight(height - 1);
|
|
401
|
+
if (!prev) {
|
|
402
|
+
return 1;
|
|
403
|
+
}
|
|
404
|
+
return targetRequiredAfter(*prev, bits);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
int64_t Interface::targetSpacing() const
|
|
408
|
+
{
|
|
409
|
+
auto *part_params = dynamic_cast<const part::ChainParams *>(m_chain_params.get());
|
|
410
|
+
return part_params ? part_params->m_target_spacing : CoinInterface::targetSpacing();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
int Interface::targetRequiredAfter(const BlockIndex &prev, uint32_t &bits) const
|
|
414
|
+
{
|
|
415
|
+
auto *part_params = dynamic_cast<const part::ChainParams *>(m_chain_params.get());
|
|
416
|
+
if (!part_params || !prev.m_header) {
|
|
417
|
+
return 1;
|
|
418
|
+
}
|
|
419
|
+
int64_t prev_prev_time{0};
|
|
420
|
+
if (prev.m_prev) {
|
|
421
|
+
prev_prev_time = prev.m_prev->getBlockTime();
|
|
422
|
+
} else if (prev.m_height == m_commit_height && m_commit_parent_time > 0) {
|
|
423
|
+
prev_prev_time = m_commit_parent_time;
|
|
424
|
+
} else {
|
|
425
|
+
return 1;
|
|
426
|
+
}
|
|
427
|
+
bits = nextTargetRequired(prev.m_height + 1, prev.m_header->getBits(), prev.getBlockTime(),
|
|
428
|
+
prev_prev_time, *part_params);
|
|
429
|
+
return bits == 0 ? 1 : 0;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
bool Interface::checkBlockHeaderContext(const BlockIndex &prev,
|
|
433
|
+
std::shared_ptr<bsx::BlockHeader> header) const
|
|
434
|
+
{
|
|
435
|
+
// Reloads come from the module's own db, which may hold an anchor without its parent
|
|
436
|
+
if (!m_verify_stake || m_loading_block_index) {
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
uint32_t bits{0};
|
|
440
|
+
auto *part_params = dynamic_cast<const part::ChainParams *>(m_chain_params.get());
|
|
441
|
+
if (!part_params || 0 != targetRequiredAfter(prev, bits) || bits != header->getBits()) {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
std::vector<int64_t> previous_times;
|
|
445
|
+
for (const BlockIndex *p = &prev; p && previous_times.size() < 11; p = p->m_prev) {
|
|
446
|
+
previous_times.push_back(p->getBlockTime());
|
|
447
|
+
}
|
|
448
|
+
// The future limit waits for the stake proof, so a slow phone clock doesn't refuse new headers
|
|
449
|
+
return stakeHeaderTimeValid(header->getBlockTime(), medianTime(previous_times),
|
|
450
|
+
prev.getBlockTime(), part_params->m_stake_timestamp_mask);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
bool Interface::commitmentFitsAnchor(int height)
|
|
454
|
+
{
|
|
455
|
+
int anchor_height = m_anchor_block ? m_anchor_block->m_height : -1;
|
|
456
|
+
if (height != anchor_height || m_verified_height >= anchor_height) {
|
|
457
|
+
LOGW("%s commitment at %d ignored, anchor %d, verified %d", coinTicker(), height,
|
|
458
|
+
anchor_height, m_verified_height);
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
int Interface::stageChainCommitment(int height, const std::vector<unsigned char> &modifier,
|
|
465
|
+
const std::vector<unsigned char> &frontier_nodes,
|
|
466
|
+
int64_t parent_time)
|
|
467
|
+
{
|
|
468
|
+
if (!m_verify_stake || height < 0 || modifier.size() != 32) {
|
|
469
|
+
return 1;
|
|
470
|
+
}
|
|
471
|
+
MerkleFrontier frontier;
|
|
472
|
+
if (0 != frontier.fromNodes((uint64_t)height + 1, frontier_nodes)) {
|
|
473
|
+
return 2;
|
|
474
|
+
}
|
|
475
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
476
|
+
loadStakeState();
|
|
477
|
+
m_pending_commitment = PendingCommitment();
|
|
478
|
+
if (commitmentFitsAnchor(height)) {
|
|
479
|
+
m_pending_commitment = {height, frontier, uint256(modifier.data(), 32), parent_time};
|
|
480
|
+
}
|
|
481
|
+
return 0;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
int Interface::setChainCommitment(int height, const std::vector<unsigned char> &modifier,
|
|
485
|
+
const std::vector<unsigned char> &frontier_nodes,
|
|
486
|
+
int64_t parent_time)
|
|
487
|
+
{
|
|
488
|
+
const int rv = stageChainCommitment(height, modifier, frontier_nodes, parent_time);
|
|
489
|
+
if (rv != 0 || pendingChainCommitment() < 0) {
|
|
490
|
+
return rv;
|
|
491
|
+
}
|
|
492
|
+
return applyChainCommitment();
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
int Interface::holdChainCommitment(int height, const std::vector<unsigned char> &modifier,
|
|
496
|
+
const std::vector<unsigned char> &frontier_nodes,
|
|
497
|
+
int64_t parent_time)
|
|
498
|
+
{
|
|
499
|
+
const int rv = stageChainCommitment(height, modifier, frontier_nodes, parent_time);
|
|
500
|
+
if (rv != 0) {
|
|
501
|
+
return rv;
|
|
502
|
+
}
|
|
503
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
504
|
+
const BlockIndex *parent = m_anchor_block ? m_anchor_block->m_prev : nullptr;
|
|
505
|
+
if (m_pending_commitment.m_height < 0) {
|
|
506
|
+
return 0;
|
|
507
|
+
}
|
|
508
|
+
if (!parent || !parent->m_header) {
|
|
509
|
+
LOGE("%s commitment at %d refused: the anchor's parent header is missing", coinTicker(),
|
|
510
|
+
height);
|
|
511
|
+
m_pending_commitment = PendingCommitment();
|
|
512
|
+
return 3;
|
|
513
|
+
}
|
|
514
|
+
if (parent->getBlockTime() != parent_time) {
|
|
515
|
+
LOGE("%s commitment at %d refused: parent time %" PRId64
|
|
516
|
+
" differs from the anchor's parent header, %" PRId64,
|
|
517
|
+
coinTicker(), height, parent_time, parent->getBlockTime());
|
|
518
|
+
m_pending_commitment = PendingCommitment();
|
|
519
|
+
return 3;
|
|
520
|
+
}
|
|
521
|
+
return 0;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
int Interface::pendingChainCommitment()
|
|
525
|
+
{
|
|
526
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
527
|
+
return m_pending_commitment.m_height;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
int Interface::askChainCommitment(ElectrumClient &client)
|
|
531
|
+
{
|
|
532
|
+
const int height = pendingChainCommitment();
|
|
533
|
+
if (height < 0) {
|
|
534
|
+
return 1;
|
|
535
|
+
}
|
|
536
|
+
return client.getStakeProofs(0, height + 1, 1, height, ElectrumMessageTypes::CHECK_COMMITMENT);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
CommitmentReply Interface::checkChainCommitmentReply(const ElectrumResponse &response,
|
|
540
|
+
std::string &detail)
|
|
541
|
+
{
|
|
542
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
543
|
+
const int height = m_pending_commitment.m_height;
|
|
544
|
+
if (height < 0 || response.m_request.m_height != height + 1) {
|
|
545
|
+
detail = "not for the pending commitment";
|
|
546
|
+
return CommitmentReply::UNKNOWN;
|
|
547
|
+
}
|
|
548
|
+
std::vector<unsigned char> modifier, root;
|
|
549
|
+
try {
|
|
550
|
+
const auto &proof = response.m_jdata.at("result").at("proofs").at(0);
|
|
551
|
+
if (proof.at("height").get<int>() != height + 1 || !proof.contains("stake_modifier") ||
|
|
552
|
+
!proof.contains("kernel") || !proof["kernel"].contains("root") ||
|
|
553
|
+
0 != decode_hex(modifier, proof["stake_modifier"].get<std::string>()) ||
|
|
554
|
+
0 != decode_hex(root, proof["kernel"]["root"].get<std::string>()) ||
|
|
555
|
+
modifier.size() != 32 || root.size() != 32) {
|
|
556
|
+
detail = "no stake modifier or header root";
|
|
557
|
+
return CommitmentReply::UNKNOWN;
|
|
558
|
+
}
|
|
559
|
+
} catch (const std::exception &e) {
|
|
560
|
+
detail = e.what();
|
|
561
|
+
return CommitmentReply::UNKNOWN;
|
|
562
|
+
}
|
|
563
|
+
std::reverse(modifier.begin(), modifier.end());
|
|
564
|
+
std::reverse(root.begin(), root.end());
|
|
565
|
+
unsigned char frontier_root[32];
|
|
566
|
+
if (0 != m_pending_commitment.m_frontier.root(frontier_root)) {
|
|
567
|
+
detail = "no frontier root";
|
|
568
|
+
return CommitmentReply::UNKNOWN;
|
|
569
|
+
}
|
|
570
|
+
const uint256 server_modifier(modifier.data(), 32), server_root(root.data(), 32);
|
|
571
|
+
const uint256 glue_root(frontier_root, 32);
|
|
572
|
+
if (server_modifier != m_pending_commitment.m_modifier || server_root != glue_root) {
|
|
573
|
+
detail = strprintf("modifier %s, glue %s; header root %s, glue %s",
|
|
574
|
+
server_modifier.ToString(), m_pending_commitment.m_modifier.ToString(),
|
|
575
|
+
server_root.ToString(), glue_root.ToString());
|
|
576
|
+
return CommitmentReply::CONTRADICTS;
|
|
577
|
+
}
|
|
578
|
+
return CommitmentReply::CONFIRMS;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
void Interface::dropChainCommitment()
|
|
582
|
+
{
|
|
583
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
584
|
+
m_pending_commitment = PendingCommitment();
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
int Interface::applyChainCommitment()
|
|
588
|
+
{
|
|
589
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
590
|
+
const PendingCommitment pending = std::exchange(m_pending_commitment, PendingCommitment());
|
|
591
|
+
if (pending.m_height < 0) {
|
|
592
|
+
return 1;
|
|
593
|
+
}
|
|
594
|
+
loadStakeState();
|
|
595
|
+
if (!commitmentFitsAnchor(pending.m_height)) {
|
|
596
|
+
return 0;
|
|
597
|
+
}
|
|
598
|
+
const int height = pending.m_height;
|
|
599
|
+
m_frontier = pending.m_frontier;
|
|
600
|
+
m_verified_height = height;
|
|
601
|
+
m_commit_height = height;
|
|
602
|
+
m_commit_parent_time = pending.m_parent_time;
|
|
603
|
+
m_verified_modifier = pending.m_modifier;
|
|
604
|
+
m_anchor_block->m_stake_modifier = m_verified_modifier;
|
|
605
|
+
m_stake_request_id = 0;
|
|
606
|
+
m_stake_history.clear();
|
|
607
|
+
recordVerifiedBlock(*m_anchor_block->m_pblock_hash);
|
|
608
|
+
saveStakeState();
|
|
609
|
+
requestStakeProofs();
|
|
610
|
+
return 0;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
void Interface::requestStakeProofs()
|
|
614
|
+
{
|
|
615
|
+
if (!m_verify_stake) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (m_stake_request_id != 0) {
|
|
619
|
+
auto ec = electrumClient();
|
|
620
|
+
if (ec &&
|
|
621
|
+
ec->waitingForResponse(m_stake_request_id, ElectrumMessageTypes::GET_STAKE_PROOFS)) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
LOGW("%s stake proof request %" PRId64 " was dropped, requesting again", coinTicker(),
|
|
625
|
+
m_stake_request_id);
|
|
626
|
+
m_stake_request_id = 0;
|
|
627
|
+
}
|
|
628
|
+
loadStakeState();
|
|
629
|
+
if (rewindToBestChain()) {
|
|
630
|
+
saveStakeState();
|
|
631
|
+
}
|
|
632
|
+
if (m_verified_height < 0 || !m_best_block || m_verified_height >= m_best_block->m_height) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (!blockIndexAtHeight(m_verified_height + 1)) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
auto ec = electrumClient();
|
|
639
|
+
if (!ec) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
unsigned char root[32];
|
|
643
|
+
if (0 != m_frontier.root(root)) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
int count = std::min(STAKE_PROOFS_PER_REQUEST, m_best_block->m_height - m_verified_height);
|
|
647
|
+
if (stakeRejectionCurrent() && m_stake_rejection.server == ec) {
|
|
648
|
+
if (ec->getTime() - m_stake_rejection.time < STAKE_REJECTION_RETRY_SECONDS) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
count = 1;
|
|
652
|
+
}
|
|
653
|
+
int64_t request_id = ++m_stake_request_counter;
|
|
654
|
+
if (0 != ec->getStakeProofs(request_id, m_verified_height + 1, count, m_verified_height)) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
m_stake_request_id = request_id;
|
|
658
|
+
m_request_cp_height = m_verified_height;
|
|
659
|
+
m_request_root = uint256(root, 32);
|
|
660
|
+
m_request_block_hash = *blockIndexAtHeight(m_verified_height + 1)->m_pblock_hash;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
static int decodeHashList(std::vector<uint256> &out, const nlohmann::json &jlist)
|
|
664
|
+
{
|
|
665
|
+
out.clear();
|
|
666
|
+
for (const auto &jhash : jlist) {
|
|
667
|
+
std::vector<unsigned char> hash;
|
|
668
|
+
if (0 != decode_hex(hash, jhash.get<std::string>()) || hash.size() != 32) {
|
|
669
|
+
return 1;
|
|
670
|
+
}
|
|
671
|
+
std::reverse(hash.begin(), hash.end());
|
|
672
|
+
out.emplace_back(hash.data(), hash.size());
|
|
673
|
+
}
|
|
674
|
+
return 0;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
static bool rejectProof(StakeRejection &rejection, const std::string &reason,
|
|
678
|
+
bool invalid_block = false)
|
|
679
|
+
{
|
|
680
|
+
rejection.reason = reason;
|
|
681
|
+
rejection.invalid_block = invalid_block;
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
bool Interface::verifyStakeProof(const nlohmann::json &proof, BlockIndex *block_index,
|
|
686
|
+
StakeRejection &rejection)
|
|
687
|
+
{
|
|
688
|
+
const int height = block_index->m_height;
|
|
689
|
+
const uint256 &block_hash = *block_index->m_pblock_hash;
|
|
690
|
+
|
|
691
|
+
auto *part_params = dynamic_cast<const part::ChainParams *>(m_chain_params.get());
|
|
692
|
+
if (!part_params) {
|
|
693
|
+
return rejectProof(rejection, "no chain params");
|
|
694
|
+
}
|
|
695
|
+
std::vector<int64_t> previous_times;
|
|
696
|
+
for (BlockIndex *prev = block_index->m_prev; prev && previous_times.size() < 11;
|
|
697
|
+
prev = prev->m_prev) {
|
|
698
|
+
previous_times.push_back(prev->getBlockTime());
|
|
699
|
+
}
|
|
700
|
+
auto ec = electrumClient();
|
|
701
|
+
const int64_t block_time = block_index->getBlockTime();
|
|
702
|
+
if (!ec || previous_times.empty()) {
|
|
703
|
+
return rejectProof(rejection, "no server or no parent time");
|
|
704
|
+
}
|
|
705
|
+
if (!stakeHeaderTimeValid(block_time, medianTime(previous_times), previous_times.front(),
|
|
706
|
+
part_params->m_stake_timestamp_mask)) {
|
|
707
|
+
return rejectProof(
|
|
708
|
+
rejection,
|
|
709
|
+
strprintf("block time %d outside the median, parent or mask limits", block_time), true);
|
|
710
|
+
}
|
|
711
|
+
if (block_time > ec->getTime() + STAKE_MAX_FUTURE_SECONDS) {
|
|
712
|
+
return rejectProof(rejection, strprintf("block time %d ahead of the clock", block_time));
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
std::vector<unsigned char> coinstake_bytes, blocksig;
|
|
716
|
+
std::vector<uint256> branch;
|
|
717
|
+
if (0 != decode_hex(coinstake_bytes, proof.at("coinstake").get<std::string>()) ||
|
|
718
|
+
0 != decode_hex(blocksig, proof.at("blocksig").get<std::string>()) ||
|
|
719
|
+
0 != decodeHashList(branch, proof.at("merkle"))) {
|
|
720
|
+
return rejectProof(rejection, "malformed");
|
|
721
|
+
}
|
|
722
|
+
Transaction coinstake;
|
|
723
|
+
if (coinstake.from_bytes(coinstake_bytes.data(), coinstake_bytes.size()) !=
|
|
724
|
+
(int)coinstake_bytes.size() ||
|
|
725
|
+
coinstake.m_vin.empty()) {
|
|
726
|
+
return rejectProof(rejection, "bad coinstake");
|
|
727
|
+
}
|
|
728
|
+
const auto is_tx = [this](const unsigned char *data, size_t data_len) {
|
|
729
|
+
return isValidTx(data, data_len);
|
|
730
|
+
};
|
|
731
|
+
unsigned char txid[32];
|
|
732
|
+
uint256 root;
|
|
733
|
+
coinstake.getTxid(txid, true);
|
|
734
|
+
if (0 != hash_merkle_root(root, branch, uint256(txid, 32), 0, is_tx) ||
|
|
735
|
+
0 != memcmp(root.begin(), block_index->getMerkleRoot(), 32)) {
|
|
736
|
+
return rejectProof(rejection, "coinstake not in block");
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
const auto &kernel_input = coinstake.m_vin[0];
|
|
740
|
+
rejection.source_txid = uint256(kernel_input->txid(), 32).ToString();
|
|
741
|
+
if (!proof.contains("kernel")) {
|
|
742
|
+
return rejectProof(rejection, "no kernel");
|
|
743
|
+
}
|
|
744
|
+
const auto &kernel = proof["kernel"];
|
|
745
|
+
std::vector<unsigned char> source_bytes, source_header_bytes;
|
|
746
|
+
std::vector<uint256> source_branch;
|
|
747
|
+
if (0 != decode_hex(source_bytes, kernel.at("tx").get<std::string>()) ||
|
|
748
|
+
0 != decode_hex(source_header_bytes, kernel.at("header").get<std::string>()) ||
|
|
749
|
+
0 != decodeHashList(source_branch, kernel.at("merkle"))) {
|
|
750
|
+
return rejectProof(rejection, "malformed kernel");
|
|
751
|
+
}
|
|
752
|
+
const int source_height = kernel.at("height").get<int>();
|
|
753
|
+
const size_t source_pos = kernel.at("pos").get<size_t>();
|
|
754
|
+
Transaction source;
|
|
755
|
+
if (source.from_bytes(source_bytes.data(), source_bytes.size()) != (int)source_bytes.size()) {
|
|
756
|
+
return rejectProof(rejection, "bad source tx");
|
|
757
|
+
}
|
|
758
|
+
unsigned char source_txid[32];
|
|
759
|
+
source.getTxid(source_txid, true);
|
|
760
|
+
if (0 != memcmp(source_txid, kernel_input->txid(), 32) || kernel_input->vout() < 0 ||
|
|
761
|
+
(size_t)kernel_input->vout() >= source.m_vout.size()) {
|
|
762
|
+
return rejectProof(rejection, "source is not the kernel prevout");
|
|
763
|
+
}
|
|
764
|
+
if (source.m_vout[kernel_input->vout()]->type() != OutputTypes::STANDARD) {
|
|
765
|
+
return rejectProof(rejection, "kernel output is not standard", true);
|
|
766
|
+
}
|
|
767
|
+
BlockHeader source_header;
|
|
768
|
+
if (source_header.from_bytes(source_header_bytes.data(), source_header_bytes.size()) != 112) {
|
|
769
|
+
return rejectProof(rejection, "bad source header");
|
|
770
|
+
}
|
|
771
|
+
if (source_pos > INT_MAX ||
|
|
772
|
+
0 != hash_merkle_root(root, source_branch, uint256(source_txid, 32), (int)source_pos,
|
|
773
|
+
is_tx) ||
|
|
774
|
+
0 != memcmp(root.begin(), source_header.getMerkleRoot(), 32)) {
|
|
775
|
+
return rejectProof(rejection, "source tx not in its block");
|
|
776
|
+
}
|
|
777
|
+
uint256 source_block_hash;
|
|
778
|
+
source_header.getBlockHash(source_block_hash);
|
|
779
|
+
if (source_height <= m_request_cp_height) {
|
|
780
|
+
std::vector<uint256> header_branch;
|
|
781
|
+
if (0 != decodeHashList(header_branch, kernel.at("header_branch")) ||
|
|
782
|
+
0 != hash_merkle_root(root, header_branch, source_block_hash, source_height, is_tx) ||
|
|
783
|
+
0 != memcmp(root.begin(), m_request_root.begin(), 32)) {
|
|
784
|
+
return rejectProof(
|
|
785
|
+
rejection, strprintf("source block %d not in the committed chain", source_height));
|
|
786
|
+
}
|
|
787
|
+
} else if (!m_stake_history.contains(source_height, source_block_hash)) {
|
|
788
|
+
return rejectProof(rejection, strprintf("source block %d not verified", source_height));
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (!stakeSourceDeepEnough(height, source_height, part_params->m_stake_min_confirmations)) {
|
|
792
|
+
return rejectProof(rejection, strprintf("source block %d too shallow", source_height),
|
|
793
|
+
true);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
uint32_t required_bits{0};
|
|
797
|
+
if (0 != stakeTargetRequired(height, required_bits) ||
|
|
798
|
+
required_bits != block_index->m_header->getBits()) {
|
|
799
|
+
return rejectProof(
|
|
800
|
+
rejection,
|
|
801
|
+
strprintf("bits %08x, required %08x", block_index->m_header->getBits(), required_bits),
|
|
802
|
+
true);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
int64_t amount = source.m_vout[kernel_input->vout()]->value();
|
|
806
|
+
if (!checkStakeKernel(block_index->m_header->getBits(), amount, m_verified_modifier.begin(),
|
|
807
|
+
(uint32_t)source_header.getBlockTime(), kernel_input->txid(),
|
|
808
|
+
kernel_input->vout(), (uint32_t)block_index->m_header->getBlockTime())) {
|
|
809
|
+
return rejectProof(rejection, "kernel below target", true);
|
|
810
|
+
}
|
|
811
|
+
std::vector<std::vector<unsigned char>> witness;
|
|
812
|
+
const std::vector<unsigned char> *kernel_script = source.m_vout[kernel_input->vout()]->script();
|
|
813
|
+
if (0 != kernel_input->getWitnessData(witness) || witness.size() != 2 || !kernel_script ||
|
|
814
|
+
!stakeKeyMatchesScript(*kernel_script, witness[1])) {
|
|
815
|
+
return rejectProof(rejection, "block key does not own the kernel output");
|
|
816
|
+
}
|
|
817
|
+
if (!checkBlockSignature(m_context, block_hash, witness[1], blocksig)) {
|
|
818
|
+
return rejectProof(rejection, "bad block signature");
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
unsigned char modifier[32];
|
|
822
|
+
stakeModifier(modifier, kernel_input->txid(), m_verified_modifier.begin());
|
|
823
|
+
m_verified_modifier = uint256(modifier, 32);
|
|
824
|
+
block_index->m_stake_modifier = m_verified_modifier;
|
|
825
|
+
m_frontier.append(block_hash.begin());
|
|
826
|
+
m_verified_height = height;
|
|
827
|
+
recordVerifiedBlock(block_hash);
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
int Interface::processStakeProofs(std::shared_ptr<ElectrumResponse> response)
|
|
832
|
+
{
|
|
833
|
+
BSX_SCOPED_LOCK lock(m_mtx_chain);
|
|
834
|
+
if (rewindToBestChain()) {
|
|
835
|
+
saveStakeState();
|
|
836
|
+
}
|
|
837
|
+
if (response->m_request.m_watched_id != m_stake_request_id) {
|
|
838
|
+
LOGD("%s stake proofs %d: stale response", coinTicker(), response->m_request_id);
|
|
839
|
+
return 0;
|
|
840
|
+
}
|
|
841
|
+
m_stake_request_id = 0;
|
|
842
|
+
BlockIndex *requested = blockIndexAtHeight(m_verified_height + 1);
|
|
843
|
+
if (!requested || *requested->m_pblock_hash != m_request_block_hash) {
|
|
844
|
+
// Proofs for a block a reorg replaced say nothing about the server
|
|
845
|
+
LOGD("%s stake proofs %d: block %d changed since the request, asking again", coinTicker(),
|
|
846
|
+
response->m_request_id, m_verified_height + 1);
|
|
847
|
+
requestStakeProofs();
|
|
848
|
+
return 0;
|
|
849
|
+
}
|
|
850
|
+
if (response->m_jdata.contains("error")) {
|
|
851
|
+
LOGE("processStakeProofs %s: server error %s", coinTicker(),
|
|
852
|
+
response->m_jdata["error"].dump().c_str());
|
|
853
|
+
return 1;
|
|
854
|
+
}
|
|
855
|
+
int verified_from = m_verified_height;
|
|
856
|
+
try {
|
|
857
|
+
for (const auto &proof : response->m_jdata.at("result").at("proofs")) {
|
|
858
|
+
int height = proof.at("height").get<int>();
|
|
859
|
+
if (height != m_verified_height + 1) {
|
|
860
|
+
throw std::runtime_error(strprintf("proof %d out of order", height));
|
|
861
|
+
}
|
|
862
|
+
BlockIndex *block_index = blockIndexAtHeight(height);
|
|
863
|
+
if (!block_index) {
|
|
864
|
+
throw std::runtime_error(strprintf("header %d not held", height));
|
|
865
|
+
}
|
|
866
|
+
StakeRejection rejection;
|
|
867
|
+
if (!verifyStakeProof(proof, block_index, rejection)) {
|
|
868
|
+
auto ec = electrumClient();
|
|
869
|
+
rejection.height = height;
|
|
870
|
+
rejection.block_hash = *block_index->m_pblock_hash;
|
|
871
|
+
rejection.time = ec ? ec->getTime() : 0;
|
|
872
|
+
rejection.server = ec;
|
|
873
|
+
rejection.server_host = ec ? ec->m_host : "";
|
|
874
|
+
m_stake_rejection = rejection;
|
|
875
|
+
throw std::runtime_error(
|
|
876
|
+
strprintf("proof %d rejected, block %s, source %s: %s", height,
|
|
877
|
+
rejection.block_hash.ToString(),
|
|
878
|
+
rejection.source_txid.empty() ? "unknown" : rejection.source_txid,
|
|
879
|
+
rejection.reason));
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
} catch (const std::exception &e) {
|
|
883
|
+
LOGE("processStakeProofs %s: %s", coinTicker(), e.what());
|
|
884
|
+
if (m_verified_height != verified_from) {
|
|
885
|
+
saveStakeState();
|
|
886
|
+
}
|
|
887
|
+
if (m_stake_rejection.invalid_block && m_stake_rejection.height == m_verified_height + 1 &&
|
|
888
|
+
0 == markBlockFailed(m_stake_rejection.block_hash)) {
|
|
889
|
+
requestStakeProofs();
|
|
890
|
+
}
|
|
891
|
+
return 1;
|
|
892
|
+
}
|
|
893
|
+
if (m_verified_height != verified_from) {
|
|
894
|
+
LOGD("%s stake verified %d to %d", coinTicker(), verified_from + 1, m_verified_height);
|
|
895
|
+
if (m_stake_rejection.height <= m_verified_height) {
|
|
896
|
+
m_stake_rejection = StakeRejection();
|
|
897
|
+
}
|
|
898
|
+
saveStakeState();
|
|
899
|
+
requestStakeProofs();
|
|
900
|
+
}
|
|
901
|
+
return 0;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
} // namespace part
|
|
905
|
+
} // namespace bsx
|