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,1097 @@
|
|
|
1
|
+
// Copyright (c) 2017-2022, The Monero Project
|
|
2
|
+
//
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// Redistribution and use in source and binary forms, with or without modification, are
|
|
6
|
+
// permitted provided that the following conditions are met:
|
|
7
|
+
//
|
|
8
|
+
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
9
|
+
// conditions and the following disclaimer.
|
|
10
|
+
//
|
|
11
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
12
|
+
// of conditions and the following disclaimer in the documentation and/or other
|
|
13
|
+
// materials provided with the distribution.
|
|
14
|
+
//
|
|
15
|
+
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
16
|
+
// used to endorse or promote products derived from this software without specific
|
|
17
|
+
// prior written permission.
|
|
18
|
+
//
|
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
20
|
+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
21
|
+
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
22
|
+
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
23
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
24
|
+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
25
|
+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
26
|
+
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
27
|
+
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
//
|
|
29
|
+
// Adapted from Java code by Sarang Noether
|
|
30
|
+
// Paper references are to https://eprint.iacr.org/2017/1066 (revision 1 July 2018)
|
|
31
|
+
|
|
32
|
+
#include <stdlib.h>
|
|
33
|
+
#include <mutex>
|
|
34
|
+
#include "misc_log_ex.h"
|
|
35
|
+
#include "span.h"
|
|
36
|
+
#include "common/perf_timer.h"
|
|
37
|
+
#include "cryptonote_config.h"
|
|
38
|
+
extern "C"
|
|
39
|
+
{
|
|
40
|
+
#include "crypto/crypto-ops.h"
|
|
41
|
+
}
|
|
42
|
+
#include "rctOps.h"
|
|
43
|
+
#include "multiexp.h"
|
|
44
|
+
#include "bulletproofs.h"
|
|
45
|
+
|
|
46
|
+
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
47
|
+
#define MONERO_DEFAULT_LOG_CATEGORY "bulletproofs"
|
|
48
|
+
|
|
49
|
+
//#define DEBUG_BP
|
|
50
|
+
|
|
51
|
+
#if 0
|
|
52
|
+
#define PERF_TIMER_START_BP(x) PERF_TIMER_START_UNIT(x, 1000000)
|
|
53
|
+
#define PERF_TIMER_STOP_BP(x) PERF_TIMER_STOP(x)
|
|
54
|
+
#else
|
|
55
|
+
#define PERF_TIMER_START_BP(x) ((void)0)
|
|
56
|
+
#define PERF_TIMER_STOP_BP(x) ((void)0)
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
#define STRAUS_SIZE_LIMIT 232
|
|
60
|
+
#define PIPPENGER_SIZE_LIMIT 0
|
|
61
|
+
|
|
62
|
+
namespace rct
|
|
63
|
+
{
|
|
64
|
+
|
|
65
|
+
static rct::key vector_exponent(const rct::keyV &a, const rct::keyV &b);
|
|
66
|
+
static rct::keyV vector_powers(const rct::key &x, size_t n);
|
|
67
|
+
static rct::keyV vector_dup(const rct::key &x, size_t n);
|
|
68
|
+
static rct::key inner_product(const rct::keyV &a, const rct::keyV &b);
|
|
69
|
+
|
|
70
|
+
static constexpr size_t maxN = 64;
|
|
71
|
+
static constexpr size_t maxM = BULLETPROOF_MAX_OUTPUTS;
|
|
72
|
+
static ge_p3 Hi_p3[maxN*maxM], Gi_p3[maxN*maxM];
|
|
73
|
+
static std::shared_ptr<straus_cached_data> straus_HiGi_cache;
|
|
74
|
+
static std::shared_ptr<pippenger_cached_data> pippenger_HiGi_cache;
|
|
75
|
+
static const constexpr rct::key TWO = { {0x02, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 } };
|
|
76
|
+
static const constexpr rct::key MINUS_ONE = { { 0xec, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 } };
|
|
77
|
+
static const constexpr rct::key MINUS_INV_EIGHT = { { 0x74, 0xa4, 0x19, 0x7a, 0xf0, 0x7d, 0x0b, 0xf7, 0x05, 0xc2, 0xda, 0x25, 0x2b, 0x5c, 0x0b, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a } };
|
|
78
|
+
static const rct::keyV oneN = vector_dup(rct::identity(), maxN);
|
|
79
|
+
static const rct::keyV twoN = vector_powers(TWO, maxN);
|
|
80
|
+
static const rct::key ip12 = inner_product(oneN, twoN);
|
|
81
|
+
static std::mutex init_mutex;
|
|
82
|
+
|
|
83
|
+
static inline rct::key multiexp(const std::vector<MultiexpData> &data, size_t HiGi_size)
|
|
84
|
+
{
|
|
85
|
+
if (HiGi_size > 0)
|
|
86
|
+
{
|
|
87
|
+
static_assert(232 <= STRAUS_SIZE_LIMIT, "Straus in precalc mode can only be calculated till STRAUS_SIZE_LIMIT");
|
|
88
|
+
return HiGi_size <= 232 && data.size() == HiGi_size ? straus(data, straus_HiGi_cache, 0) : pippenger(data, pippenger_HiGi_cache, HiGi_size, get_pippenger_c(data.size()));
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
return data.size() <= 95 ? straus(data, NULL, 0) : pippenger(data, NULL, 0, get_pippenger_c(data.size()));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static inline bool is_reduced(const rct::key &scalar)
|
|
95
|
+
{
|
|
96
|
+
return sc_check(scalar.bytes) == 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static rct::key get_exponent(const rct::key &base, size_t idx)
|
|
100
|
+
{
|
|
101
|
+
std::string hashed = std::string((const char*)base.bytes, sizeof(base)) + config::HASH_KEY_BULLETPROOF_EXPONENT + tools::get_varint_data(idx);
|
|
102
|
+
rct::key e;
|
|
103
|
+
ge_p3 e_p3;
|
|
104
|
+
rct::hash_to_p3(e_p3, rct::hash2rct(crypto::cn_fast_hash(hashed.data(), hashed.size())));
|
|
105
|
+
ge_p3_tobytes(e.bytes, &e_p3);
|
|
106
|
+
CHECK_AND_ASSERT_THROW_MES(!(e == rct::identity()), "Exponent is point at infinity");
|
|
107
|
+
return e;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static void init_exponents()
|
|
111
|
+
{
|
|
112
|
+
std::lock_guard<std::mutex> lock(init_mutex);
|
|
113
|
+
|
|
114
|
+
static bool init_done = false;
|
|
115
|
+
if (init_done)
|
|
116
|
+
return;
|
|
117
|
+
std::vector<MultiexpData> data;
|
|
118
|
+
data.reserve(maxN*maxM*2);
|
|
119
|
+
for (size_t i = 0; i < maxN*maxM; ++i)
|
|
120
|
+
{
|
|
121
|
+
const rct::key Hi = get_exponent(rct::H, i * 2);
|
|
122
|
+
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&Hi_p3[i], Hi.bytes) == 0, "ge_frombytes_vartime failed");
|
|
123
|
+
const rct::key Gi = get_exponent(rct::H, i * 2 + 1);
|
|
124
|
+
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&Gi_p3[i], Gi.bytes) == 0, "ge_frombytes_vartime failed");
|
|
125
|
+
|
|
126
|
+
data.push_back({rct::zero(), Gi_p3[i]});
|
|
127
|
+
data.push_back({rct::zero(), Hi_p3[i]});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
straus_HiGi_cache = straus_init_cache(data, STRAUS_SIZE_LIMIT);
|
|
131
|
+
pippenger_HiGi_cache = pippenger_init_cache(data, 0, PIPPENGER_SIZE_LIMIT);
|
|
132
|
+
|
|
133
|
+
MINFO("Hi_p3/Gi_p3 cache size: " << (sizeof(Hi_p3)+sizeof(Gi_p3))/1024 << " kB");
|
|
134
|
+
MINFO("Straus cache size: " << straus_get_cache_size(straus_HiGi_cache)/1024 << " kB");
|
|
135
|
+
MINFO("Pippenger cache size: " << pippenger_get_cache_size(pippenger_HiGi_cache)/1024 << " kB");
|
|
136
|
+
size_t cache_size = straus_get_cache_size(straus_HiGi_cache) + pippenger_get_cache_size(pippenger_HiGi_cache);
|
|
137
|
+
MINFO("Total cache size: " << cache_size/1024 << "kB");
|
|
138
|
+
init_done = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* Given two scalar arrays, construct a vector commitment */
|
|
142
|
+
static rct::key vector_exponent(const rct::keyV &a, const rct::keyV &b)
|
|
143
|
+
{
|
|
144
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
145
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() <= maxN*maxM, "Incompatible sizes of a and maxN");
|
|
146
|
+
|
|
147
|
+
std::vector<MultiexpData> multiexp_data;
|
|
148
|
+
multiexp_data.reserve(a.size()*2);
|
|
149
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
150
|
+
{
|
|
151
|
+
multiexp_data.emplace_back(a[i], Gi_p3[i]);
|
|
152
|
+
multiexp_data.emplace_back(b[i], Hi_p3[i]);
|
|
153
|
+
}
|
|
154
|
+
return multiexp(multiexp_data, 2 * a.size());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Compute a custom vector-scalar commitment */
|
|
158
|
+
static rct::key cross_vector_exponent8(size_t size, const std::vector<ge_p3> &A, size_t Ao, const std::vector<ge_p3> &B, size_t Bo, const rct::keyV &a, size_t ao, const rct::keyV &b, size_t bo, const rct::keyV *scale, const ge_p3 *extra_point, const rct::key *extra_scalar)
|
|
159
|
+
{
|
|
160
|
+
CHECK_AND_ASSERT_THROW_MES(size + Ao <= A.size(), "Incompatible size for A");
|
|
161
|
+
CHECK_AND_ASSERT_THROW_MES(size + Bo <= B.size(), "Incompatible size for B");
|
|
162
|
+
CHECK_AND_ASSERT_THROW_MES(size + ao <= a.size(), "Incompatible size for a");
|
|
163
|
+
CHECK_AND_ASSERT_THROW_MES(size + bo <= b.size(), "Incompatible size for b");
|
|
164
|
+
CHECK_AND_ASSERT_THROW_MES(size <= maxN*maxM, "size is too large");
|
|
165
|
+
CHECK_AND_ASSERT_THROW_MES(!scale || size == scale->size() / 2, "Incompatible size for scale");
|
|
166
|
+
CHECK_AND_ASSERT_THROW_MES(!!extra_point == !!extra_scalar, "only one of extra point/scalar present");
|
|
167
|
+
|
|
168
|
+
std::vector<MultiexpData> multiexp_data;
|
|
169
|
+
multiexp_data.resize(size*2 + (!!extra_point));
|
|
170
|
+
for (size_t i = 0; i < size; ++i)
|
|
171
|
+
{
|
|
172
|
+
sc_mul(multiexp_data[i*2].scalar.bytes, a[ao+i].bytes, INV_EIGHT.bytes);
|
|
173
|
+
multiexp_data[i*2].point = A[Ao+i];
|
|
174
|
+
sc_mul(multiexp_data[i*2+1].scalar.bytes, b[bo+i].bytes, INV_EIGHT.bytes);
|
|
175
|
+
if (scale)
|
|
176
|
+
sc_mul(multiexp_data[i*2+1].scalar.bytes, multiexp_data[i*2+1].scalar.bytes, (*scale)[Bo+i].bytes);
|
|
177
|
+
multiexp_data[i*2+1].point = B[Bo+i];
|
|
178
|
+
}
|
|
179
|
+
if (extra_point)
|
|
180
|
+
{
|
|
181
|
+
sc_mul(multiexp_data.back().scalar.bytes, extra_scalar->bytes, INV_EIGHT.bytes);
|
|
182
|
+
multiexp_data.back().point = *extra_point;
|
|
183
|
+
}
|
|
184
|
+
return multiexp(multiexp_data, 0);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* Given a scalar, construct a vector of powers */
|
|
188
|
+
static rct::keyV vector_powers(const rct::key &x, size_t n)
|
|
189
|
+
{
|
|
190
|
+
rct::keyV res(n);
|
|
191
|
+
if (n == 0)
|
|
192
|
+
return res;
|
|
193
|
+
res[0] = rct::identity();
|
|
194
|
+
if (n == 1)
|
|
195
|
+
return res;
|
|
196
|
+
res[1] = x;
|
|
197
|
+
for (size_t i = 2; i < n; ++i)
|
|
198
|
+
{
|
|
199
|
+
sc_mul(res[i].bytes, res[i-1].bytes, x.bytes);
|
|
200
|
+
}
|
|
201
|
+
return res;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* Given a scalar, return the sum of its powers from 0 to n-1 */
|
|
205
|
+
static rct::key vector_power_sum(rct::key x, size_t n)
|
|
206
|
+
{
|
|
207
|
+
if (n == 0)
|
|
208
|
+
return rct::zero();
|
|
209
|
+
rct::key res = rct::identity();
|
|
210
|
+
if (n == 1)
|
|
211
|
+
return res;
|
|
212
|
+
|
|
213
|
+
const bool is_power_of_2 = (n & (n - 1)) == 0;
|
|
214
|
+
if (is_power_of_2)
|
|
215
|
+
{
|
|
216
|
+
sc_add(res.bytes, res.bytes, x.bytes);
|
|
217
|
+
while (n > 2)
|
|
218
|
+
{
|
|
219
|
+
sc_mul(x.bytes, x.bytes, x.bytes);
|
|
220
|
+
sc_muladd(res.bytes, x.bytes, res.bytes, res.bytes);
|
|
221
|
+
n /= 2;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
{
|
|
226
|
+
rct::key prev = x;
|
|
227
|
+
for (size_t i = 1; i < n; ++i)
|
|
228
|
+
{
|
|
229
|
+
if (i > 1)
|
|
230
|
+
sc_mul(prev.bytes, prev.bytes, x.bytes);
|
|
231
|
+
sc_add(res.bytes, res.bytes, prev.bytes);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return res;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Given two scalar arrays, construct the inner product */
|
|
239
|
+
static rct::key inner_product(const epee::span<const rct::key> &a, const epee::span<const rct::key> &b)
|
|
240
|
+
{
|
|
241
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
242
|
+
rct::key res = rct::zero();
|
|
243
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
244
|
+
{
|
|
245
|
+
sc_muladd(res.bytes, a[i].bytes, b[i].bytes, res.bytes);
|
|
246
|
+
}
|
|
247
|
+
return res;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
static rct::key inner_product(const rct::keyV &a, const rct::keyV &b)
|
|
251
|
+
{
|
|
252
|
+
return inner_product(epee::span<const rct::key>(a.data(), a.size()), epee::span<const rct::key>(b.data(), b.size()));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Given two scalar arrays, construct the Hadamard product */
|
|
256
|
+
static rct::keyV hadamard(const rct::keyV &a, const rct::keyV &b)
|
|
257
|
+
{
|
|
258
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
259
|
+
rct::keyV res(a.size());
|
|
260
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
261
|
+
{
|
|
262
|
+
sc_mul(res[i].bytes, a[i].bytes, b[i].bytes);
|
|
263
|
+
}
|
|
264
|
+
return res;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* folds a curvepoint array using a two way scaled Hadamard product */
|
|
268
|
+
static void hadamard_fold(std::vector<ge_p3> &v, const rct::keyV *scale, const rct::key &a, const rct::key &b)
|
|
269
|
+
{
|
|
270
|
+
CHECK_AND_ASSERT_THROW_MES((v.size() & 1) == 0, "Vector size should be even");
|
|
271
|
+
const size_t sz = v.size() / 2;
|
|
272
|
+
for (size_t n = 0; n < sz; ++n)
|
|
273
|
+
{
|
|
274
|
+
ge_dsmp c[2];
|
|
275
|
+
ge_dsm_precomp(c[0], &v[n]);
|
|
276
|
+
ge_dsm_precomp(c[1], &v[sz + n]);
|
|
277
|
+
rct::key sa, sb;
|
|
278
|
+
if (scale) sc_mul(sa.bytes, a.bytes, (*scale)[n].bytes); else sa = a;
|
|
279
|
+
if (scale) sc_mul(sb.bytes, b.bytes, (*scale)[sz + n].bytes); else sb = b;
|
|
280
|
+
ge_double_scalarmult_precomp_vartime2_p3(&v[n], sa.bytes, c[0], sb.bytes, c[1]);
|
|
281
|
+
}
|
|
282
|
+
v.resize(sz);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/* Add two vectors */
|
|
286
|
+
static rct::keyV vector_add(const rct::keyV &a, const rct::keyV &b)
|
|
287
|
+
{
|
|
288
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
289
|
+
rct::keyV res(a.size());
|
|
290
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
291
|
+
{
|
|
292
|
+
sc_add(res[i].bytes, a[i].bytes, b[i].bytes);
|
|
293
|
+
}
|
|
294
|
+
return res;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/* Add a scalar to all elements of a vector */
|
|
298
|
+
static rct::keyV vector_add(const rct::keyV &a, const rct::key &b)
|
|
299
|
+
{
|
|
300
|
+
rct::keyV res(a.size());
|
|
301
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
302
|
+
{
|
|
303
|
+
sc_add(res[i].bytes, a[i].bytes, b.bytes);
|
|
304
|
+
}
|
|
305
|
+
return res;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* Subtract a scalar from all elements of a vector */
|
|
309
|
+
static rct::keyV vector_subtract(const rct::keyV &a, const rct::key &b)
|
|
310
|
+
{
|
|
311
|
+
rct::keyV res(a.size());
|
|
312
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
313
|
+
{
|
|
314
|
+
sc_sub(res[i].bytes, a[i].bytes, b.bytes);
|
|
315
|
+
}
|
|
316
|
+
return res;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* Multiply a scalar and a vector */
|
|
320
|
+
static rct::keyV vector_scalar(const epee::span<const rct::key> &a, const rct::key &x)
|
|
321
|
+
{
|
|
322
|
+
rct::keyV res(a.size());
|
|
323
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
324
|
+
{
|
|
325
|
+
sc_mul(res[i].bytes, a[i].bytes, x.bytes);
|
|
326
|
+
}
|
|
327
|
+
return res;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
static rct::keyV vector_scalar(const rct::keyV &a, const rct::key &x)
|
|
331
|
+
{
|
|
332
|
+
return vector_scalar(epee::span<const rct::key>(a.data(), a.size()), x);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* Create a vector from copies of a single value */
|
|
336
|
+
static rct::keyV vector_dup(const rct::key &x, size_t N)
|
|
337
|
+
{
|
|
338
|
+
return rct::keyV(N, x);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
static rct::key sm(rct::key y, int n, const rct::key &x)
|
|
342
|
+
{
|
|
343
|
+
while (n--)
|
|
344
|
+
sc_mul(y.bytes, y.bytes, y.bytes);
|
|
345
|
+
sc_mul(y.bytes, y.bytes, x.bytes);
|
|
346
|
+
return y;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* Compute the inverse of a scalar, the clever way */
|
|
350
|
+
static rct::key invert(const rct::key &x)
|
|
351
|
+
{
|
|
352
|
+
rct::key _1, _10, _100, _11, _101, _111, _1001, _1011, _1111;
|
|
353
|
+
|
|
354
|
+
_1 = x;
|
|
355
|
+
sc_mul(_10.bytes, _1.bytes, _1.bytes);
|
|
356
|
+
sc_mul(_100.bytes, _10.bytes, _10.bytes);
|
|
357
|
+
sc_mul(_11.bytes, _10.bytes, _1.bytes);
|
|
358
|
+
sc_mul(_101.bytes, _10.bytes, _11.bytes);
|
|
359
|
+
sc_mul(_111.bytes, _10.bytes, _101.bytes);
|
|
360
|
+
sc_mul(_1001.bytes, _10.bytes, _111.bytes);
|
|
361
|
+
sc_mul(_1011.bytes, _10.bytes, _1001.bytes);
|
|
362
|
+
sc_mul(_1111.bytes, _100.bytes, _1011.bytes);
|
|
363
|
+
|
|
364
|
+
rct::key inv;
|
|
365
|
+
sc_mul(inv.bytes, _1111.bytes, _1.bytes);
|
|
366
|
+
|
|
367
|
+
inv = sm(inv, 123 + 3, _101);
|
|
368
|
+
inv = sm(inv, 2 + 2, _11);
|
|
369
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
370
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
371
|
+
inv = sm(inv, 4, _1001);
|
|
372
|
+
inv = sm(inv, 2, _11);
|
|
373
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
374
|
+
inv = sm(inv, 1 + 3, _101);
|
|
375
|
+
inv = sm(inv, 3 + 3, _101);
|
|
376
|
+
inv = sm(inv, 3, _111);
|
|
377
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
378
|
+
inv = sm(inv, 2 + 3, _111);
|
|
379
|
+
inv = sm(inv, 2 + 2, _11);
|
|
380
|
+
inv = sm(inv, 1 + 4, _1011);
|
|
381
|
+
inv = sm(inv, 2 + 4, _1011);
|
|
382
|
+
inv = sm(inv, 6 + 4, _1001);
|
|
383
|
+
inv = sm(inv, 2 + 2, _11);
|
|
384
|
+
inv = sm(inv, 3 + 2, _11);
|
|
385
|
+
inv = sm(inv, 3 + 2, _11);
|
|
386
|
+
inv = sm(inv, 1 + 4, _1001);
|
|
387
|
+
inv = sm(inv, 1 + 3, _111);
|
|
388
|
+
inv = sm(inv, 2 + 4, _1111);
|
|
389
|
+
inv = sm(inv, 1 + 4, _1011);
|
|
390
|
+
inv = sm(inv, 3, _101);
|
|
391
|
+
inv = sm(inv, 2 + 4, _1111);
|
|
392
|
+
inv = sm(inv, 3, _101);
|
|
393
|
+
inv = sm(inv, 1 + 2, _11);
|
|
394
|
+
|
|
395
|
+
#ifdef DEBUG_BP
|
|
396
|
+
rct::key tmp;
|
|
397
|
+
sc_mul(tmp.bytes, inv.bytes, x.bytes);
|
|
398
|
+
CHECK_AND_ASSERT_THROW_MES(tmp == rct::identity(), "invert failed");
|
|
399
|
+
#endif
|
|
400
|
+
return inv;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
static rct::keyV invert(rct::keyV x)
|
|
404
|
+
{
|
|
405
|
+
rct::keyV scratch;
|
|
406
|
+
scratch.reserve(x.size());
|
|
407
|
+
|
|
408
|
+
rct::key acc = rct::identity();
|
|
409
|
+
for (size_t n = 0; n < x.size(); ++n)
|
|
410
|
+
{
|
|
411
|
+
scratch.push_back(acc);
|
|
412
|
+
if (n == 0)
|
|
413
|
+
acc = x[0];
|
|
414
|
+
else
|
|
415
|
+
sc_mul(acc.bytes, acc.bytes, x[n].bytes);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
acc = invert(acc);
|
|
419
|
+
|
|
420
|
+
rct::key tmp;
|
|
421
|
+
for (int i = x.size(); i-- > 0; )
|
|
422
|
+
{
|
|
423
|
+
sc_mul(tmp.bytes, acc.bytes, x[i].bytes);
|
|
424
|
+
sc_mul(x[i].bytes, acc.bytes, scratch[i].bytes);
|
|
425
|
+
acc = tmp;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return x;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/* Compute the slice of a vector */
|
|
432
|
+
static epee::span<const rct::key> slice(const rct::keyV &a, size_t start, size_t stop)
|
|
433
|
+
{
|
|
434
|
+
CHECK_AND_ASSERT_THROW_MES(start < a.size(), "Invalid start index");
|
|
435
|
+
CHECK_AND_ASSERT_THROW_MES(stop <= a.size(), "Invalid stop index");
|
|
436
|
+
CHECK_AND_ASSERT_THROW_MES(start < stop, "Invalid start/stop indices");
|
|
437
|
+
return epee::span<const rct::key>(&a[start], stop - start);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
static rct::key hash_cache_mash(rct::key &hash_cache, const rct::key &mash0, const rct::key &mash1)
|
|
441
|
+
{
|
|
442
|
+
rct::key data[3];
|
|
443
|
+
data[0] = hash_cache;
|
|
444
|
+
data[1] = mash0;
|
|
445
|
+
data[2] = mash1;
|
|
446
|
+
rct::hash_to_scalar(hash_cache, data, sizeof(data));
|
|
447
|
+
return hash_cache;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
static rct::key hash_cache_mash(rct::key &hash_cache, const rct::key &mash0, const rct::key &mash1, const rct::key &mash2)
|
|
451
|
+
{
|
|
452
|
+
rct::key data[4];
|
|
453
|
+
data[0] = hash_cache;
|
|
454
|
+
data[1] = mash0;
|
|
455
|
+
data[2] = mash1;
|
|
456
|
+
data[3] = mash2;
|
|
457
|
+
rct::hash_to_scalar(hash_cache, data, sizeof(data));
|
|
458
|
+
return hash_cache;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
static rct::key hash_cache_mash(rct::key &hash_cache, const rct::key &mash0, const rct::key &mash1, const rct::key &mash2, const rct::key &mash3)
|
|
462
|
+
{
|
|
463
|
+
rct::key data[5];
|
|
464
|
+
data[0] = hash_cache;
|
|
465
|
+
data[1] = mash0;
|
|
466
|
+
data[2] = mash1;
|
|
467
|
+
data[3] = mash2;
|
|
468
|
+
data[4] = mash3;
|
|
469
|
+
rct::hash_to_scalar(hash_cache, data, sizeof(data));
|
|
470
|
+
return hash_cache;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/* Given a value v (0..2^N-1) and a mask gamma, construct a range proof */
|
|
474
|
+
Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma)
|
|
475
|
+
{
|
|
476
|
+
return bulletproof_PROVE(rct::keyV(1, sv), rct::keyV(1, gamma));
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
Bulletproof bulletproof_PROVE(uint64_t v, const rct::key &gamma)
|
|
480
|
+
{
|
|
481
|
+
return bulletproof_PROVE(std::vector<uint64_t>(1, v), rct::keyV(1, gamma));
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/* Given a set of values v (0..2^N-1) and masks gamma, construct a range proof */
|
|
485
|
+
Bulletproof bulletproof_PROVE(const rct::keyV &sv, const rct::keyV &gamma)
|
|
486
|
+
{
|
|
487
|
+
CHECK_AND_ASSERT_THROW_MES(sv.size() == gamma.size(), "Incompatible sizes of sv and gamma");
|
|
488
|
+
CHECK_AND_ASSERT_THROW_MES(!sv.empty(), "sv is empty");
|
|
489
|
+
for (const rct::key &sve: sv)
|
|
490
|
+
CHECK_AND_ASSERT_THROW_MES(is_reduced(sve), "Invalid sv input");
|
|
491
|
+
for (const rct::key &g: gamma)
|
|
492
|
+
CHECK_AND_ASSERT_THROW_MES(is_reduced(g), "Invalid gamma input");
|
|
493
|
+
|
|
494
|
+
init_exponents();
|
|
495
|
+
|
|
496
|
+
PERF_TIMER_UNIT(PROVE, 1000000);
|
|
497
|
+
|
|
498
|
+
constexpr size_t logN = 6; // log2(64)
|
|
499
|
+
constexpr size_t N = 1<<logN;
|
|
500
|
+
size_t M, logM;
|
|
501
|
+
for (logM = 0; (M = 1<<logM) <= maxM && M < sv.size(); ++logM);
|
|
502
|
+
CHECK_AND_ASSERT_THROW_MES(M <= maxM, "sv/gamma are too large");
|
|
503
|
+
const size_t logMN = logM + logN;
|
|
504
|
+
const size_t MN = M * N;
|
|
505
|
+
|
|
506
|
+
rct::keyV V(sv.size());
|
|
507
|
+
rct::keyV aL(MN), aR(MN);
|
|
508
|
+
rct::keyV aL8(MN), aR8(MN);
|
|
509
|
+
rct::key tmp, tmp2;
|
|
510
|
+
|
|
511
|
+
PERF_TIMER_START_BP(PROVE_v);
|
|
512
|
+
for (size_t i = 0; i < sv.size(); ++i)
|
|
513
|
+
{
|
|
514
|
+
rct::key gamma8, sv8;
|
|
515
|
+
sc_mul(gamma8.bytes, gamma[i].bytes, INV_EIGHT.bytes);
|
|
516
|
+
sc_mul(sv8.bytes, sv[i].bytes, INV_EIGHT.bytes);
|
|
517
|
+
rct::addKeys2(V[i], gamma8, sv8, rct::H);
|
|
518
|
+
}
|
|
519
|
+
PERF_TIMER_STOP_BP(PROVE_v);
|
|
520
|
+
|
|
521
|
+
// PAPER LINES 41-42
|
|
522
|
+
PERF_TIMER_START_BP(PROVE_aLaR);
|
|
523
|
+
for (size_t j = 0; j < M; ++j)
|
|
524
|
+
{
|
|
525
|
+
for (size_t i = N; i-- > 0; )
|
|
526
|
+
{
|
|
527
|
+
if (j < sv.size() && (sv[j][i/8] & (((uint64_t)1)<<(i%8))))
|
|
528
|
+
{
|
|
529
|
+
aL[j*N+i] = rct::identity();
|
|
530
|
+
aL8[j*N+i] = INV_EIGHT;
|
|
531
|
+
aR[j*N+i] = aR8[j*N+i] = rct::zero();
|
|
532
|
+
}
|
|
533
|
+
else
|
|
534
|
+
{
|
|
535
|
+
aL[j*N+i] = aL8[j*N+i] = rct::zero();
|
|
536
|
+
aR[j*N+i] = MINUS_ONE;
|
|
537
|
+
aR8[j*N+i] = MINUS_INV_EIGHT;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
PERF_TIMER_STOP_BP(PROVE_aLaR);
|
|
542
|
+
|
|
543
|
+
// DEBUG: Test to ensure this recovers the value
|
|
544
|
+
#ifdef DEBUG_BP
|
|
545
|
+
for (size_t j = 0; j < M; ++j)
|
|
546
|
+
{
|
|
547
|
+
uint64_t test_aL = 0, test_aR = 0;
|
|
548
|
+
for (size_t i = 0; i < N; ++i)
|
|
549
|
+
{
|
|
550
|
+
if (aL[j*N+i] == rct::identity())
|
|
551
|
+
test_aL += ((uint64_t)1)<<i;
|
|
552
|
+
if (aR[j*N+i] == rct::zero())
|
|
553
|
+
test_aR += ((uint64_t)1)<<i;
|
|
554
|
+
}
|
|
555
|
+
uint64_t v_test = 0;
|
|
556
|
+
if (j < sv.size())
|
|
557
|
+
for (int n = 0; n < 8; ++n) v_test |= (((uint64_t)sv[j][n]) << (8*n));
|
|
558
|
+
CHECK_AND_ASSERT_THROW_MES(test_aL == v_test, "test_aL failed");
|
|
559
|
+
CHECK_AND_ASSERT_THROW_MES(test_aR == v_test, "test_aR failed");
|
|
560
|
+
}
|
|
561
|
+
#endif
|
|
562
|
+
|
|
563
|
+
try_again:
|
|
564
|
+
rct::key hash_cache = rct::hash_to_scalar(V);
|
|
565
|
+
|
|
566
|
+
PERF_TIMER_START_BP(PROVE_step1);
|
|
567
|
+
// PAPER LINES 43-44
|
|
568
|
+
rct::key alpha = rct::skGen();
|
|
569
|
+
rct::key ve = vector_exponent(aL8, aR8);
|
|
570
|
+
rct::key A;
|
|
571
|
+
sc_mul(tmp.bytes, alpha.bytes, INV_EIGHT.bytes);
|
|
572
|
+
rct::addKeys(A, ve, rct::scalarmultBase(tmp));
|
|
573
|
+
|
|
574
|
+
// PAPER LINES 45-47
|
|
575
|
+
rct::keyV sL = rct::skvGen(MN), sR = rct::skvGen(MN);
|
|
576
|
+
rct::key rho = rct::skGen();
|
|
577
|
+
ve = vector_exponent(sL, sR);
|
|
578
|
+
rct::key S;
|
|
579
|
+
rct::addKeys(S, ve, rct::scalarmultBase(rho));
|
|
580
|
+
S = rct::scalarmultKey(S, INV_EIGHT);
|
|
581
|
+
|
|
582
|
+
// PAPER LINES 48-50
|
|
583
|
+
rct::key y = hash_cache_mash(hash_cache, A, S);
|
|
584
|
+
if (y == rct::zero())
|
|
585
|
+
{
|
|
586
|
+
PERF_TIMER_STOP_BP(PROVE_step1);
|
|
587
|
+
MINFO("y is 0, trying again");
|
|
588
|
+
goto try_again;
|
|
589
|
+
}
|
|
590
|
+
rct::key z = hash_cache = rct::hash_to_scalar(y);
|
|
591
|
+
if (z == rct::zero())
|
|
592
|
+
{
|
|
593
|
+
PERF_TIMER_STOP_BP(PROVE_step1);
|
|
594
|
+
MINFO("z is 0, trying again");
|
|
595
|
+
goto try_again;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Polynomial construction by coefficients
|
|
599
|
+
// PAPER LINES 70-71
|
|
600
|
+
rct::keyV l0 = vector_subtract(aL, z);
|
|
601
|
+
const rct::keyV &l1 = sL;
|
|
602
|
+
|
|
603
|
+
rct::keyV zero_twos(MN);
|
|
604
|
+
const rct::keyV zpow = vector_powers(z, M+2);
|
|
605
|
+
for (size_t j = 0; j < M; ++j)
|
|
606
|
+
{
|
|
607
|
+
for (size_t i = 0; i < N; ++i)
|
|
608
|
+
{
|
|
609
|
+
CHECK_AND_ASSERT_THROW_MES(j+2 < zpow.size(), "invalid zpow index");
|
|
610
|
+
CHECK_AND_ASSERT_THROW_MES(i < twoN.size(), "invalid twoN index");
|
|
611
|
+
sc_mul(zero_twos[j*N+i].bytes,zpow[j+2].bytes,twoN[i].bytes);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
rct::keyV r0 = vector_add(aR, z);
|
|
616
|
+
const auto yMN = vector_powers(y, MN);
|
|
617
|
+
r0 = hadamard(r0, yMN);
|
|
618
|
+
r0 = vector_add(r0, zero_twos);
|
|
619
|
+
rct::keyV r1 = hadamard(yMN, sR);
|
|
620
|
+
|
|
621
|
+
// Polynomial construction before PAPER LINE 51
|
|
622
|
+
rct::key t1_1 = inner_product(l0, r1);
|
|
623
|
+
rct::key t1_2 = inner_product(l1, r0);
|
|
624
|
+
rct::key t1;
|
|
625
|
+
sc_add(t1.bytes, t1_1.bytes, t1_2.bytes);
|
|
626
|
+
rct::key t2 = inner_product(l1, r1);
|
|
627
|
+
|
|
628
|
+
PERF_TIMER_STOP_BP(PROVE_step1);
|
|
629
|
+
|
|
630
|
+
PERF_TIMER_START_BP(PROVE_step2);
|
|
631
|
+
// PAPER LINES 52-53
|
|
632
|
+
rct::key tau1 = rct::skGen(), tau2 = rct::skGen();
|
|
633
|
+
|
|
634
|
+
rct::key T1, T2;
|
|
635
|
+
ge_p3 p3;
|
|
636
|
+
sc_mul(tmp.bytes, t1.bytes, INV_EIGHT.bytes);
|
|
637
|
+
sc_mul(tmp2.bytes, tau1.bytes, INV_EIGHT.bytes);
|
|
638
|
+
ge_double_scalarmult_base_vartime_p3(&p3, tmp.bytes, &ge_p3_H, tmp2.bytes);
|
|
639
|
+
ge_p3_tobytes(T1.bytes, &p3);
|
|
640
|
+
sc_mul(tmp.bytes, t2.bytes, INV_EIGHT.bytes);
|
|
641
|
+
sc_mul(tmp2.bytes, tau2.bytes, INV_EIGHT.bytes);
|
|
642
|
+
ge_double_scalarmult_base_vartime_p3(&p3, tmp.bytes, &ge_p3_H, tmp2.bytes);
|
|
643
|
+
ge_p3_tobytes(T2.bytes, &p3);
|
|
644
|
+
|
|
645
|
+
// PAPER LINES 54-56
|
|
646
|
+
rct::key x = hash_cache_mash(hash_cache, z, T1, T2);
|
|
647
|
+
if (x == rct::zero())
|
|
648
|
+
{
|
|
649
|
+
PERF_TIMER_STOP_BP(PROVE_step2);
|
|
650
|
+
MINFO("x is 0, trying again");
|
|
651
|
+
goto try_again;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// PAPER LINES 61-63
|
|
655
|
+
rct::key taux;
|
|
656
|
+
sc_mul(taux.bytes, tau1.bytes, x.bytes);
|
|
657
|
+
rct::key xsq;
|
|
658
|
+
sc_mul(xsq.bytes, x.bytes, x.bytes);
|
|
659
|
+
sc_muladd(taux.bytes, tau2.bytes, xsq.bytes, taux.bytes);
|
|
660
|
+
for (size_t j = 1; j <= sv.size(); ++j)
|
|
661
|
+
{
|
|
662
|
+
CHECK_AND_ASSERT_THROW_MES(j+1 < zpow.size(), "invalid zpow index");
|
|
663
|
+
sc_muladd(taux.bytes, zpow[j+1].bytes, gamma[j-1].bytes, taux.bytes);
|
|
664
|
+
}
|
|
665
|
+
rct::key mu;
|
|
666
|
+
sc_muladd(mu.bytes, x.bytes, rho.bytes, alpha.bytes);
|
|
667
|
+
|
|
668
|
+
// PAPER LINES 58-60
|
|
669
|
+
rct::keyV l = l0;
|
|
670
|
+
l = vector_add(l, vector_scalar(l1, x));
|
|
671
|
+
rct::keyV r = r0;
|
|
672
|
+
r = vector_add(r, vector_scalar(r1, x));
|
|
673
|
+
PERF_TIMER_STOP_BP(PROVE_step2);
|
|
674
|
+
|
|
675
|
+
PERF_TIMER_START_BP(PROVE_step3);
|
|
676
|
+
rct::key t = inner_product(l, r);
|
|
677
|
+
|
|
678
|
+
// DEBUG: Test if the l and r vectors match the polynomial forms
|
|
679
|
+
#ifdef DEBUG_BP
|
|
680
|
+
rct::key test_t;
|
|
681
|
+
const rct::key t0 = inner_product(l0, r0);
|
|
682
|
+
sc_muladd(test_t.bytes, t1.bytes, x.bytes, t0.bytes);
|
|
683
|
+
sc_muladd(test_t.bytes, t2.bytes, xsq.bytes, test_t.bytes);
|
|
684
|
+
CHECK_AND_ASSERT_THROW_MES(test_t == t, "test_t check failed");
|
|
685
|
+
#endif
|
|
686
|
+
|
|
687
|
+
// PAPER LINE 6
|
|
688
|
+
rct::key x_ip = hash_cache_mash(hash_cache, x, taux, mu, t);
|
|
689
|
+
if (x_ip == rct::zero())
|
|
690
|
+
{
|
|
691
|
+
PERF_TIMER_STOP_BP(PROVE_step3);
|
|
692
|
+
MINFO("x_ip is 0, trying again");
|
|
693
|
+
goto try_again;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// These are used in the inner product rounds
|
|
697
|
+
size_t nprime = MN;
|
|
698
|
+
std::vector<ge_p3> Gprime(MN);
|
|
699
|
+
std::vector<ge_p3> Hprime(MN);
|
|
700
|
+
rct::keyV aprime(MN);
|
|
701
|
+
rct::keyV bprime(MN);
|
|
702
|
+
const rct::key yinv = invert(y);
|
|
703
|
+
rct::keyV yinvpow(MN);
|
|
704
|
+
yinvpow[0] = rct::identity();
|
|
705
|
+
yinvpow[1] = yinv;
|
|
706
|
+
for (size_t i = 0; i < MN; ++i)
|
|
707
|
+
{
|
|
708
|
+
Gprime[i] = Gi_p3[i];
|
|
709
|
+
Hprime[i] = Hi_p3[i];
|
|
710
|
+
if (i > 1)
|
|
711
|
+
sc_mul(yinvpow[i].bytes, yinvpow[i-1].bytes, yinv.bytes);
|
|
712
|
+
aprime[i] = l[i];
|
|
713
|
+
bprime[i] = r[i];
|
|
714
|
+
}
|
|
715
|
+
rct::keyV L(logMN);
|
|
716
|
+
rct::keyV R(logMN);
|
|
717
|
+
int round = 0;
|
|
718
|
+
rct::keyV w(logMN); // this is the challenge x in the inner product protocol
|
|
719
|
+
PERF_TIMER_STOP_BP(PROVE_step3);
|
|
720
|
+
|
|
721
|
+
PERF_TIMER_START_BP(PROVE_step4);
|
|
722
|
+
const rct::keyV *scale = &yinvpow;
|
|
723
|
+
while (nprime > 1)
|
|
724
|
+
{
|
|
725
|
+
// PAPER LINE 20
|
|
726
|
+
nprime /= 2;
|
|
727
|
+
|
|
728
|
+
// PAPER LINES 21-22
|
|
729
|
+
PERF_TIMER_START_BP(PROVE_inner_product);
|
|
730
|
+
rct::key cL = inner_product(slice(aprime, 0, nprime), slice(bprime, nprime, bprime.size()));
|
|
731
|
+
rct::key cR = inner_product(slice(aprime, nprime, aprime.size()), slice(bprime, 0, nprime));
|
|
732
|
+
PERF_TIMER_STOP_BP(PROVE_inner_product);
|
|
733
|
+
|
|
734
|
+
// PAPER LINES 23-24
|
|
735
|
+
PERF_TIMER_START_BP(PROVE_LR);
|
|
736
|
+
sc_mul(tmp.bytes, cL.bytes, x_ip.bytes);
|
|
737
|
+
L[round] = cross_vector_exponent8(nprime, Gprime, nprime, Hprime, 0, aprime, 0, bprime, nprime, scale, &ge_p3_H, &tmp);
|
|
738
|
+
sc_mul(tmp.bytes, cR.bytes, x_ip.bytes);
|
|
739
|
+
R[round] = cross_vector_exponent8(nprime, Gprime, 0, Hprime, nprime, aprime, nprime, bprime, 0, scale, &ge_p3_H, &tmp);
|
|
740
|
+
PERF_TIMER_STOP_BP(PROVE_LR);
|
|
741
|
+
|
|
742
|
+
// PAPER LINES 25-27
|
|
743
|
+
w[round] = hash_cache_mash(hash_cache, L[round], R[round]);
|
|
744
|
+
if (w[round] == rct::zero())
|
|
745
|
+
{
|
|
746
|
+
PERF_TIMER_STOP_BP(PROVE_step4);
|
|
747
|
+
MINFO("w[round] is 0, trying again");
|
|
748
|
+
goto try_again;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// PAPER LINES 29-30
|
|
752
|
+
const rct::key winv = invert(w[round]);
|
|
753
|
+
if (nprime > 1)
|
|
754
|
+
{
|
|
755
|
+
PERF_TIMER_START_BP(PROVE_hadamard2);
|
|
756
|
+
hadamard_fold(Gprime, NULL, winv, w[round]);
|
|
757
|
+
hadamard_fold(Hprime, scale, w[round], winv);
|
|
758
|
+
PERF_TIMER_STOP_BP(PROVE_hadamard2);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// PAPER LINES 33-34
|
|
762
|
+
PERF_TIMER_START_BP(PROVE_prime);
|
|
763
|
+
aprime = vector_add(vector_scalar(slice(aprime, 0, nprime), w[round]), vector_scalar(slice(aprime, nprime, aprime.size()), winv));
|
|
764
|
+
bprime = vector_add(vector_scalar(slice(bprime, 0, nprime), winv), vector_scalar(slice(bprime, nprime, bprime.size()), w[round]));
|
|
765
|
+
PERF_TIMER_STOP_BP(PROVE_prime);
|
|
766
|
+
|
|
767
|
+
scale = NULL;
|
|
768
|
+
++round;
|
|
769
|
+
}
|
|
770
|
+
PERF_TIMER_STOP_BP(PROVE_step4);
|
|
771
|
+
|
|
772
|
+
return Bulletproof(std::move(V), A, S, T1, T2, taux, mu, std::move(L), std::move(R), aprime[0], bprime[0], t);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
Bulletproof bulletproof_PROVE(const std::vector<uint64_t> &v, const rct::keyV &gamma)
|
|
776
|
+
{
|
|
777
|
+
CHECK_AND_ASSERT_THROW_MES(v.size() == gamma.size(), "Incompatible sizes of v and gamma");
|
|
778
|
+
|
|
779
|
+
// vG + gammaH
|
|
780
|
+
PERF_TIMER_START_BP(PROVE_v);
|
|
781
|
+
rct::keyV sv(v.size());
|
|
782
|
+
for (size_t i = 0; i < v.size(); ++i)
|
|
783
|
+
{
|
|
784
|
+
sv[i] = rct::zero();
|
|
785
|
+
sv[i].bytes[0] = v[i] & 255;
|
|
786
|
+
sv[i].bytes[1] = (v[i] >> 8) & 255;
|
|
787
|
+
sv[i].bytes[2] = (v[i] >> 16) & 255;
|
|
788
|
+
sv[i].bytes[3] = (v[i] >> 24) & 255;
|
|
789
|
+
sv[i].bytes[4] = (v[i] >> 32) & 255;
|
|
790
|
+
sv[i].bytes[5] = (v[i] >> 40) & 255;
|
|
791
|
+
sv[i].bytes[6] = (v[i] >> 48) & 255;
|
|
792
|
+
sv[i].bytes[7] = (v[i] >> 56) & 255;
|
|
793
|
+
}
|
|
794
|
+
PERF_TIMER_STOP_BP(PROVE_v);
|
|
795
|
+
return bulletproof_PROVE(sv, gamma);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
struct proof_data_t
|
|
799
|
+
{
|
|
800
|
+
rct::key x, y, z, x_ip;
|
|
801
|
+
std::vector<rct::key> w;
|
|
802
|
+
size_t logM, inv_offset;
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
/* Given a range proof, determine if it is valid
|
|
806
|
+
* This uses the method in PAPER LINES 95-105,
|
|
807
|
+
* weighted across multiple proofs in a batch
|
|
808
|
+
*/
|
|
809
|
+
bool bulletproof_VERIFY(const std::vector<const Bulletproof*> &proofs)
|
|
810
|
+
{
|
|
811
|
+
init_exponents();
|
|
812
|
+
|
|
813
|
+
PERF_TIMER_START_BP(VERIFY);
|
|
814
|
+
|
|
815
|
+
const size_t logN = 6;
|
|
816
|
+
const size_t N = 1 << logN;
|
|
817
|
+
|
|
818
|
+
// sanity and figure out which proof is longest
|
|
819
|
+
size_t max_length = 0;
|
|
820
|
+
size_t nV = 0;
|
|
821
|
+
std::vector<proof_data_t> proof_data;
|
|
822
|
+
proof_data.reserve(proofs.size());
|
|
823
|
+
size_t inv_offset = 0;
|
|
824
|
+
std::vector<rct::key> to_invert;
|
|
825
|
+
to_invert.reserve(11 * proofs.size());
|
|
826
|
+
size_t max_logM = 0;
|
|
827
|
+
for (const Bulletproof *p: proofs)
|
|
828
|
+
{
|
|
829
|
+
const Bulletproof &proof = *p;
|
|
830
|
+
|
|
831
|
+
// check scalar range
|
|
832
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.taux), false, "Input scalar not in range");
|
|
833
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.mu), false, "Input scalar not in range");
|
|
834
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.a), false, "Input scalar not in range");
|
|
835
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.b), false, "Input scalar not in range");
|
|
836
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.t), false, "Input scalar not in range");
|
|
837
|
+
|
|
838
|
+
CHECK_AND_ASSERT_MES(proof.V.size() >= 1, false, "V does not have at least one element");
|
|
839
|
+
CHECK_AND_ASSERT_MES(proof.L.size() == proof.R.size(), false, "Mismatched L and R sizes");
|
|
840
|
+
CHECK_AND_ASSERT_MES(proof.L.size() > 0, false, "Empty proof");
|
|
841
|
+
|
|
842
|
+
max_length = std::max(max_length, proof.L.size());
|
|
843
|
+
nV += proof.V.size();
|
|
844
|
+
|
|
845
|
+
// Reconstruct the challenges
|
|
846
|
+
PERF_TIMER_START_BP(VERIFY_start);
|
|
847
|
+
proof_data.resize(proof_data.size() + 1);
|
|
848
|
+
proof_data_t &pd = proof_data.back();
|
|
849
|
+
rct::key hash_cache = rct::hash_to_scalar(proof.V);
|
|
850
|
+
pd.y = hash_cache_mash(hash_cache, proof.A, proof.S);
|
|
851
|
+
CHECK_AND_ASSERT_MES(!(pd.y == rct::zero()), false, "y == 0");
|
|
852
|
+
pd.z = hash_cache = rct::hash_to_scalar(pd.y);
|
|
853
|
+
CHECK_AND_ASSERT_MES(!(pd.z == rct::zero()), false, "z == 0");
|
|
854
|
+
pd.x = hash_cache_mash(hash_cache, pd.z, proof.T1, proof.T2);
|
|
855
|
+
CHECK_AND_ASSERT_MES(!(pd.x == rct::zero()), false, "x == 0");
|
|
856
|
+
pd.x_ip = hash_cache_mash(hash_cache, pd.x, proof.taux, proof.mu, proof.t);
|
|
857
|
+
CHECK_AND_ASSERT_MES(!(pd.x_ip == rct::zero()), false, "x_ip == 0");
|
|
858
|
+
PERF_TIMER_STOP_BP(VERIFY_start);
|
|
859
|
+
|
|
860
|
+
size_t M;
|
|
861
|
+
for (pd.logM = 0; (M = 1<<pd.logM) <= maxM && M < proof.V.size(); ++pd.logM);
|
|
862
|
+
CHECK_AND_ASSERT_MES(proof.L.size() == 6+pd.logM, false, "Proof is not the expected size");
|
|
863
|
+
max_logM = std::max(pd.logM, max_logM);
|
|
864
|
+
|
|
865
|
+
const size_t rounds = pd.logM+logN;
|
|
866
|
+
CHECK_AND_ASSERT_MES(rounds > 0, false, "Zero rounds");
|
|
867
|
+
|
|
868
|
+
PERF_TIMER_START_BP(VERIFY_line_21_22);
|
|
869
|
+
// The inner product challenges are computed per round
|
|
870
|
+
pd.w.resize(rounds);
|
|
871
|
+
for (size_t i = 0; i < rounds; ++i)
|
|
872
|
+
{
|
|
873
|
+
pd.w[i] = hash_cache_mash(hash_cache, proof.L[i], proof.R[i]);
|
|
874
|
+
CHECK_AND_ASSERT_MES(!(pd.w[i] == rct::zero()), false, "w[i] == 0");
|
|
875
|
+
}
|
|
876
|
+
PERF_TIMER_STOP_BP(VERIFY_line_21_22);
|
|
877
|
+
|
|
878
|
+
pd.inv_offset = inv_offset;
|
|
879
|
+
for (size_t i = 0; i < rounds; ++i)
|
|
880
|
+
to_invert.push_back(pd.w[i]);
|
|
881
|
+
to_invert.push_back(pd.y);
|
|
882
|
+
inv_offset += rounds + 1;
|
|
883
|
+
}
|
|
884
|
+
CHECK_AND_ASSERT_MES(max_length < 32, false, "At least one proof is too large");
|
|
885
|
+
size_t maxMN = 1u << max_length;
|
|
886
|
+
|
|
887
|
+
rct::key tmp;
|
|
888
|
+
|
|
889
|
+
std::vector<MultiexpData> multiexp_data;
|
|
890
|
+
multiexp_data.reserve(nV + (2 * (max_logM + logN) + 4) * proofs.size() + 2 * maxMN);
|
|
891
|
+
multiexp_data.resize(2 * maxMN);
|
|
892
|
+
|
|
893
|
+
PERF_TIMER_START_BP(VERIFY_line_24_25_invert);
|
|
894
|
+
const std::vector<rct::key> inverses = invert(std::move(to_invert));
|
|
895
|
+
to_invert.clear();
|
|
896
|
+
PERF_TIMER_STOP_BP(VERIFY_line_24_25_invert);
|
|
897
|
+
|
|
898
|
+
// setup weighted aggregates
|
|
899
|
+
rct::key z1 = rct::zero();
|
|
900
|
+
rct::key z3 = rct::zero();
|
|
901
|
+
rct::keyV m_z4(maxMN, rct::zero()), m_z5(maxMN, rct::zero());
|
|
902
|
+
rct::key m_y0 = rct::zero(), y1 = rct::zero();
|
|
903
|
+
int proof_data_index = 0;
|
|
904
|
+
rct::keyV w_cache;
|
|
905
|
+
std::vector<ge_p3> proof8_V, proof8_L, proof8_R;
|
|
906
|
+
for (const Bulletproof *p: proofs)
|
|
907
|
+
{
|
|
908
|
+
const Bulletproof &proof = *p;
|
|
909
|
+
const proof_data_t &pd = proof_data[proof_data_index++];
|
|
910
|
+
|
|
911
|
+
CHECK_AND_ASSERT_MES(proof.L.size() == 6+pd.logM, false, "Proof is not the expected size");
|
|
912
|
+
const size_t M = 1 << pd.logM;
|
|
913
|
+
const size_t MN = M*N;
|
|
914
|
+
const rct::key weight_y = rct::skGen();
|
|
915
|
+
const rct::key weight_z = rct::skGen();
|
|
916
|
+
|
|
917
|
+
// pre-multiply some points by 8
|
|
918
|
+
proof8_V.resize(proof.V.size()); for (size_t i = 0; i < proof.V.size(); ++i) rct::scalarmult8(proof8_V[i], proof.V[i]);
|
|
919
|
+
proof8_L.resize(proof.L.size()); for (size_t i = 0; i < proof.L.size(); ++i) rct::scalarmult8(proof8_L[i], proof.L[i]);
|
|
920
|
+
proof8_R.resize(proof.R.size()); for (size_t i = 0; i < proof.R.size(); ++i) rct::scalarmult8(proof8_R[i], proof.R[i]);
|
|
921
|
+
ge_p3 proof8_T1;
|
|
922
|
+
ge_p3 proof8_T2;
|
|
923
|
+
ge_p3 proof8_S;
|
|
924
|
+
ge_p3 proof8_A;
|
|
925
|
+
rct::scalarmult8(proof8_T1, proof.T1);
|
|
926
|
+
rct::scalarmult8(proof8_T2, proof.T2);
|
|
927
|
+
rct::scalarmult8(proof8_S, proof.S);
|
|
928
|
+
rct::scalarmult8(proof8_A, proof.A);
|
|
929
|
+
|
|
930
|
+
PERF_TIMER_START_BP(VERIFY_line_61);
|
|
931
|
+
sc_mulsub(m_y0.bytes, proof.taux.bytes, weight_y.bytes, m_y0.bytes);
|
|
932
|
+
|
|
933
|
+
const rct::keyV zpow = vector_powers(pd.z, M+3);
|
|
934
|
+
|
|
935
|
+
rct::key k;
|
|
936
|
+
const rct::key ip1y = vector_power_sum(pd.y, MN);
|
|
937
|
+
sc_mulsub(k.bytes, zpow[2].bytes, ip1y.bytes, rct::zero().bytes);
|
|
938
|
+
for (size_t j = 1; j <= M; ++j)
|
|
939
|
+
{
|
|
940
|
+
CHECK_AND_ASSERT_MES(j+2 < zpow.size(), false, "invalid zpow index");
|
|
941
|
+
sc_mulsub(k.bytes, zpow[j+2].bytes, ip12.bytes, k.bytes);
|
|
942
|
+
}
|
|
943
|
+
PERF_TIMER_STOP_BP(VERIFY_line_61);
|
|
944
|
+
|
|
945
|
+
PERF_TIMER_START_BP(VERIFY_line_61rl_new);
|
|
946
|
+
sc_muladd(tmp.bytes, pd.z.bytes, ip1y.bytes, k.bytes);
|
|
947
|
+
sc_sub(tmp.bytes, proof.t.bytes, tmp.bytes);
|
|
948
|
+
sc_muladd(y1.bytes, tmp.bytes, weight_y.bytes, y1.bytes);
|
|
949
|
+
for (size_t j = 0; j < proof8_V.size(); j++)
|
|
950
|
+
{
|
|
951
|
+
sc_mul(tmp.bytes, zpow[j+2].bytes, weight_y.bytes);
|
|
952
|
+
multiexp_data.emplace_back(tmp, proof8_V[j]);
|
|
953
|
+
}
|
|
954
|
+
sc_mul(tmp.bytes, pd.x.bytes, weight_y.bytes);
|
|
955
|
+
multiexp_data.emplace_back(tmp, proof8_T1);
|
|
956
|
+
rct::key xsq;
|
|
957
|
+
sc_mul(xsq.bytes, pd.x.bytes, pd.x.bytes);
|
|
958
|
+
sc_mul(tmp.bytes, xsq.bytes, weight_y.bytes);
|
|
959
|
+
multiexp_data.emplace_back(tmp, proof8_T2);
|
|
960
|
+
PERF_TIMER_STOP_BP(VERIFY_line_61rl_new);
|
|
961
|
+
|
|
962
|
+
PERF_TIMER_START_BP(VERIFY_line_62);
|
|
963
|
+
multiexp_data.emplace_back(weight_z, proof8_A);
|
|
964
|
+
sc_mul(tmp.bytes, pd.x.bytes, weight_z.bytes);
|
|
965
|
+
multiexp_data.emplace_back(tmp, proof8_S);
|
|
966
|
+
PERF_TIMER_STOP_BP(VERIFY_line_62);
|
|
967
|
+
|
|
968
|
+
// Compute the number of rounds for the inner product
|
|
969
|
+
const size_t rounds = pd.logM+logN;
|
|
970
|
+
CHECK_AND_ASSERT_MES(rounds > 0, false, "Zero rounds");
|
|
971
|
+
|
|
972
|
+
PERF_TIMER_START_BP(VERIFY_line_24_25);
|
|
973
|
+
// Compute the curvepoints from G[i] and H[i]
|
|
974
|
+
rct::key yinvpow = rct::identity();
|
|
975
|
+
rct::key ypow = rct::identity();
|
|
976
|
+
|
|
977
|
+
const rct::key *winv = &inverses[pd.inv_offset];
|
|
978
|
+
const rct::key yinv = inverses[pd.inv_offset + rounds];
|
|
979
|
+
|
|
980
|
+
// precalc
|
|
981
|
+
PERF_TIMER_START_BP(VERIFY_line_24_25_precalc);
|
|
982
|
+
w_cache.resize(1<<rounds);
|
|
983
|
+
w_cache[0] = winv[0];
|
|
984
|
+
w_cache[1] = pd.w[0];
|
|
985
|
+
for (size_t j = 1; j < rounds; ++j)
|
|
986
|
+
{
|
|
987
|
+
const size_t slots = 1<<(j+1);
|
|
988
|
+
for (size_t s = slots; s-- > 0; --s)
|
|
989
|
+
{
|
|
990
|
+
sc_mul(w_cache[s].bytes, w_cache[s/2].bytes, pd.w[j].bytes);
|
|
991
|
+
sc_mul(w_cache[s-1].bytes, w_cache[s/2].bytes, winv[j].bytes);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
PERF_TIMER_STOP_BP(VERIFY_line_24_25_precalc);
|
|
995
|
+
|
|
996
|
+
for (size_t i = 0; i < MN; ++i)
|
|
997
|
+
{
|
|
998
|
+
rct::key g_scalar = proof.a;
|
|
999
|
+
rct::key h_scalar;
|
|
1000
|
+
if (i == 0)
|
|
1001
|
+
h_scalar = proof.b;
|
|
1002
|
+
else
|
|
1003
|
+
sc_mul(h_scalar.bytes, proof.b.bytes, yinvpow.bytes);
|
|
1004
|
+
|
|
1005
|
+
// Convert the index to binary IN REVERSE and construct the scalar exponent
|
|
1006
|
+
sc_mul(g_scalar.bytes, g_scalar.bytes, w_cache[i].bytes);
|
|
1007
|
+
sc_mul(h_scalar.bytes, h_scalar.bytes, w_cache[(~i) & (MN-1)].bytes);
|
|
1008
|
+
|
|
1009
|
+
sc_add(g_scalar.bytes, g_scalar.bytes, pd.z.bytes);
|
|
1010
|
+
CHECK_AND_ASSERT_MES(2+i/N < zpow.size(), false, "invalid zpow index");
|
|
1011
|
+
CHECK_AND_ASSERT_MES(i%N < twoN.size(), false, "invalid twoN index");
|
|
1012
|
+
sc_mul(tmp.bytes, zpow[2+i/N].bytes, twoN[i%N].bytes);
|
|
1013
|
+
if (i == 0)
|
|
1014
|
+
{
|
|
1015
|
+
sc_add(tmp.bytes, tmp.bytes, pd.z.bytes);
|
|
1016
|
+
sc_sub(h_scalar.bytes, h_scalar.bytes, tmp.bytes);
|
|
1017
|
+
}
|
|
1018
|
+
else
|
|
1019
|
+
{
|
|
1020
|
+
sc_muladd(tmp.bytes, pd.z.bytes, ypow.bytes, tmp.bytes);
|
|
1021
|
+
sc_mulsub(h_scalar.bytes, tmp.bytes, yinvpow.bytes, h_scalar.bytes);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
sc_mulsub(m_z4[i].bytes, g_scalar.bytes, weight_z.bytes, m_z4[i].bytes);
|
|
1025
|
+
sc_mulsub(m_z5[i].bytes, h_scalar.bytes, weight_z.bytes, m_z5[i].bytes);
|
|
1026
|
+
|
|
1027
|
+
if (i == 0)
|
|
1028
|
+
{
|
|
1029
|
+
yinvpow = yinv;
|
|
1030
|
+
ypow = pd.y;
|
|
1031
|
+
}
|
|
1032
|
+
else if (i != MN-1)
|
|
1033
|
+
{
|
|
1034
|
+
sc_mul(yinvpow.bytes, yinvpow.bytes, yinv.bytes);
|
|
1035
|
+
sc_mul(ypow.bytes, ypow.bytes, pd.y.bytes);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
PERF_TIMER_STOP_BP(VERIFY_line_24_25);
|
|
1040
|
+
|
|
1041
|
+
PERF_TIMER_START_BP(VERIFY_line_26_new);
|
|
1042
|
+
sc_muladd(z1.bytes, proof.mu.bytes, weight_z.bytes, z1.bytes);
|
|
1043
|
+
for (size_t i = 0; i < rounds; ++i)
|
|
1044
|
+
{
|
|
1045
|
+
sc_mul(tmp.bytes, pd.w[i].bytes, pd.w[i].bytes);
|
|
1046
|
+
sc_mul(tmp.bytes, tmp.bytes, weight_z.bytes);
|
|
1047
|
+
multiexp_data.emplace_back(tmp, proof8_L[i]);
|
|
1048
|
+
sc_mul(tmp.bytes, winv[i].bytes, winv[i].bytes);
|
|
1049
|
+
sc_mul(tmp.bytes, tmp.bytes, weight_z.bytes);
|
|
1050
|
+
multiexp_data.emplace_back(tmp, proof8_R[i]);
|
|
1051
|
+
}
|
|
1052
|
+
sc_mulsub(tmp.bytes, proof.a.bytes, proof.b.bytes, proof.t.bytes);
|
|
1053
|
+
sc_mul(tmp.bytes, tmp.bytes, pd.x_ip.bytes);
|
|
1054
|
+
sc_muladd(z3.bytes, tmp.bytes, weight_z.bytes, z3.bytes);
|
|
1055
|
+
PERF_TIMER_STOP_BP(VERIFY_line_26_new);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// now check all proofs at once
|
|
1059
|
+
PERF_TIMER_START_BP(VERIFY_step2_check);
|
|
1060
|
+
sc_sub(tmp.bytes, m_y0.bytes, z1.bytes);
|
|
1061
|
+
multiexp_data.emplace_back(tmp, rct::G);
|
|
1062
|
+
sc_sub(tmp.bytes, z3.bytes, y1.bytes);
|
|
1063
|
+
multiexp_data.emplace_back(tmp, rct::H);
|
|
1064
|
+
for (size_t i = 0; i < maxMN; ++i)
|
|
1065
|
+
{
|
|
1066
|
+
multiexp_data[i * 2] = {m_z4[i], Gi_p3[i]};
|
|
1067
|
+
multiexp_data[i * 2 + 1] = {m_z5[i], Hi_p3[i]};
|
|
1068
|
+
}
|
|
1069
|
+
if (!(multiexp(multiexp_data, 2 * maxMN) == rct::identity()))
|
|
1070
|
+
{
|
|
1071
|
+
PERF_TIMER_STOP_BP(VERIFY_step2_check);
|
|
1072
|
+
MERROR("Verification failure");
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
PERF_TIMER_STOP_BP(VERIFY_step2_check);
|
|
1076
|
+
|
|
1077
|
+
PERF_TIMER_STOP_BP(VERIFY);
|
|
1078
|
+
return true;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
bool bulletproof_VERIFY(const std::vector<Bulletproof> &proofs)
|
|
1082
|
+
{
|
|
1083
|
+
std::vector<const Bulletproof*> proof_pointers;
|
|
1084
|
+
proof_pointers.reserve(proofs.size());
|
|
1085
|
+
for (const Bulletproof &proof: proofs)
|
|
1086
|
+
proof_pointers.push_back(&proof);
|
|
1087
|
+
return bulletproof_VERIFY(proof_pointers);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
bool bulletproof_VERIFY(const Bulletproof &proof)
|
|
1091
|
+
{
|
|
1092
|
+
std::vector<const Bulletproof*> proofs;
|
|
1093
|
+
proofs.push_back(&proof);
|
|
1094
|
+
return bulletproof_VERIFY(proofs);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
}
|