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,1120 @@
|
|
|
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
|
+
// Implements the Bulletproofs+ prover and verifier algorithms
|
|
30
|
+
//
|
|
31
|
+
// Preprint: https://eprint.iacr.org/2020/735, version 17 Jun 2020
|
|
32
|
+
//
|
|
33
|
+
// NOTE ON NOTATION:
|
|
34
|
+
// In the signature constructions used in Monero, commitments to zero are treated as
|
|
35
|
+
// public keys against the curve group generator `G`. This means that amount
|
|
36
|
+
// commitments must use another generator `H` for values in order to show balance.
|
|
37
|
+
// The result is that the roles of `g` and `h` in the preprint are effectively swapped
|
|
38
|
+
// in this code, taking on the roles of `H` and `G`, respectively. Read carefully!
|
|
39
|
+
|
|
40
|
+
#include <stdlib.h>
|
|
41
|
+
#include <mutex>
|
|
42
|
+
#include "misc_log_ex.h"
|
|
43
|
+
#include "span.h"
|
|
44
|
+
#include "cryptonote_config.h"
|
|
45
|
+
extern "C"
|
|
46
|
+
{
|
|
47
|
+
#include "crypto/crypto-ops.h"
|
|
48
|
+
}
|
|
49
|
+
#include "rctOps.h"
|
|
50
|
+
#include "multiexp.h"
|
|
51
|
+
#include "bulletproofs_plus.h"
|
|
52
|
+
|
|
53
|
+
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
54
|
+
#define MONERO_DEFAULT_LOG_CATEGORY "bulletproof_plus"
|
|
55
|
+
|
|
56
|
+
#define STRAUS_SIZE_LIMIT 232
|
|
57
|
+
#define PIPPENGER_SIZE_LIMIT 0
|
|
58
|
+
|
|
59
|
+
namespace rct
|
|
60
|
+
{
|
|
61
|
+
// Vector functions
|
|
62
|
+
static rct::key vector_exponent(const rct::keyV &a, const rct::keyV &b);
|
|
63
|
+
static rct::keyV vector_of_scalar_powers(const rct::key &x, size_t n);
|
|
64
|
+
|
|
65
|
+
// Proof bounds
|
|
66
|
+
static constexpr size_t maxN = 64; // maximum number of bits in range
|
|
67
|
+
static constexpr size_t maxM = BULLETPROOF_PLUS_MAX_OUTPUTS; // maximum number of outputs to aggregate into a single proof
|
|
68
|
+
|
|
69
|
+
// Cached public generators
|
|
70
|
+
static ge_p3 Hi_p3[maxN*maxM], Gi_p3[maxN*maxM];
|
|
71
|
+
static std::shared_ptr<straus_cached_data> straus_HiGi_cache;
|
|
72
|
+
static std::shared_ptr<pippenger_cached_data> pippenger_HiGi_cache;
|
|
73
|
+
|
|
74
|
+
// Useful scalar constants
|
|
75
|
+
static const constexpr rct::key ZERO = { {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,0x00 } }; // 0
|
|
76
|
+
static const constexpr rct::key ONE = { {0x01, 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 } }; // 1
|
|
77
|
+
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 } }; // 2
|
|
78
|
+
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 } }; // -1
|
|
79
|
+
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 } }; // -(8**(-1))
|
|
80
|
+
static rct::key TWO_SIXTY_FOUR_MINUS_ONE; // 2**64 - 1
|
|
81
|
+
|
|
82
|
+
// Initial transcript hash
|
|
83
|
+
static rct::key initial_transcript;
|
|
84
|
+
|
|
85
|
+
static std::mutex init_mutex;
|
|
86
|
+
|
|
87
|
+
// Use the generator caches to compute a multiscalar multiplication
|
|
88
|
+
static inline rct::key multiexp(const std::vector<MultiexpData> &data, size_t HiGi_size)
|
|
89
|
+
{
|
|
90
|
+
if (HiGi_size > 0)
|
|
91
|
+
{
|
|
92
|
+
static_assert(232 <= STRAUS_SIZE_LIMIT, "Straus in precalc mode can only be calculated till STRAUS_SIZE_LIMIT");
|
|
93
|
+
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()));
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
{
|
|
97
|
+
return data.size() <= 95 ? straus(data, NULL, 0) : pippenger(data, NULL, 0, get_pippenger_c(data.size()));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Confirm that a scalar is properly reduced
|
|
102
|
+
static inline bool is_reduced(const rct::key &scalar)
|
|
103
|
+
{
|
|
104
|
+
return sc_check(scalar.bytes) == 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Use hashed values to produce indexed public generators
|
|
108
|
+
static ge_p3 get_exponent(const rct::key &base, size_t idx)
|
|
109
|
+
{
|
|
110
|
+
std::string hashed = std::string((const char*)base.bytes, sizeof(base)) + config::HASH_KEY_BULLETPROOF_PLUS_EXPONENT + tools::get_varint_data(idx);
|
|
111
|
+
rct::key generator;
|
|
112
|
+
ge_p3 generator_p3;
|
|
113
|
+
rct::hash_to_p3(generator_p3, rct::hash2rct(crypto::cn_fast_hash(hashed.data(), hashed.size())));
|
|
114
|
+
ge_p3_tobytes(generator.bytes, &generator_p3);
|
|
115
|
+
CHECK_AND_ASSERT_THROW_MES(!(generator == rct::identity()), "Exponent is point at infinity");
|
|
116
|
+
return generator_p3;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Construct public generators
|
|
120
|
+
static void init_exponents()
|
|
121
|
+
{
|
|
122
|
+
std::lock_guard<std::mutex> lock(init_mutex);
|
|
123
|
+
|
|
124
|
+
// Only needs to be done once
|
|
125
|
+
static bool init_done = false;
|
|
126
|
+
if (init_done)
|
|
127
|
+
return;
|
|
128
|
+
|
|
129
|
+
std::vector<MultiexpData> data;
|
|
130
|
+
data.reserve(maxN*maxM*2);
|
|
131
|
+
for (size_t i = 0; i < maxN*maxM; ++i)
|
|
132
|
+
{
|
|
133
|
+
Hi_p3[i] = get_exponent(rct::H, i * 2);
|
|
134
|
+
Gi_p3[i] = get_exponent(rct::H, i * 2 + 1);
|
|
135
|
+
|
|
136
|
+
data.push_back({rct::zero(), Gi_p3[i]});
|
|
137
|
+
data.push_back({rct::zero(), Hi_p3[i]});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
straus_HiGi_cache = straus_init_cache(data, STRAUS_SIZE_LIMIT);
|
|
141
|
+
pippenger_HiGi_cache = pippenger_init_cache(data, 0, PIPPENGER_SIZE_LIMIT);
|
|
142
|
+
|
|
143
|
+
// Compute 2**64 - 1 for later use in simplifying verification
|
|
144
|
+
TWO_SIXTY_FOUR_MINUS_ONE = TWO;
|
|
145
|
+
for (size_t i = 0; i < 6; i++)
|
|
146
|
+
{
|
|
147
|
+
sc_mul(TWO_SIXTY_FOUR_MINUS_ONE.bytes, TWO_SIXTY_FOUR_MINUS_ONE.bytes, TWO_SIXTY_FOUR_MINUS_ONE.bytes);
|
|
148
|
+
}
|
|
149
|
+
sc_sub(TWO_SIXTY_FOUR_MINUS_ONE.bytes, TWO_SIXTY_FOUR_MINUS_ONE.bytes, ONE.bytes);
|
|
150
|
+
|
|
151
|
+
// Generate the initial Fiat-Shamir transcript hash, which is constant across all proofs
|
|
152
|
+
const std::string domain_separator(config::HASH_KEY_BULLETPROOF_PLUS_TRANSCRIPT);
|
|
153
|
+
ge_p3 initial_transcript_p3;
|
|
154
|
+
rct::hash_to_p3(initial_transcript_p3, rct::hash2rct(crypto::cn_fast_hash(domain_separator.data(), domain_separator.size())));
|
|
155
|
+
ge_p3_tobytes(initial_transcript.bytes, &initial_transcript_p3);
|
|
156
|
+
|
|
157
|
+
init_done = true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Given two scalar arrays, construct a vector pre-commitment:
|
|
161
|
+
//
|
|
162
|
+
// a = (a_0, ..., a_{n-1})
|
|
163
|
+
// b = (b_0, ..., b_{n-1})
|
|
164
|
+
//
|
|
165
|
+
// Outputs a_0*Gi_0 + ... + a_{n-1}*Gi_{n-1} +
|
|
166
|
+
// b_0*Hi_0 + ... + b_{n-1}*Hi_{n-1}
|
|
167
|
+
static rct::key vector_exponent(const rct::keyV &a, const rct::keyV &b)
|
|
168
|
+
{
|
|
169
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
170
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() <= maxN*maxM, "Incompatible sizes of a and maxN");
|
|
171
|
+
|
|
172
|
+
std::vector<MultiexpData> multiexp_data;
|
|
173
|
+
multiexp_data.reserve(a.size()*2);
|
|
174
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
175
|
+
{
|
|
176
|
+
multiexp_data.emplace_back(a[i], Gi_p3[i]);
|
|
177
|
+
multiexp_data.emplace_back(b[i], Hi_p3[i]);
|
|
178
|
+
}
|
|
179
|
+
return multiexp(multiexp_data, 2 * a.size());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Helper function used to compute the L and R terms used in the inner-product round function
|
|
183
|
+
static rct::key compute_LR(size_t size, const rct::key &y, const std::vector<ge_p3> &G, size_t G0, const std::vector<ge_p3> &H, size_t H0, const rct::keyV &a, size_t a0, const rct::keyV &b, size_t b0, const rct::key &c, const rct::key &d)
|
|
184
|
+
{
|
|
185
|
+
CHECK_AND_ASSERT_THROW_MES(size + G0 <= G.size(), "Incompatible size for G");
|
|
186
|
+
CHECK_AND_ASSERT_THROW_MES(size + H0 <= H.size(), "Incompatible size for H");
|
|
187
|
+
CHECK_AND_ASSERT_THROW_MES(size + a0 <= a.size(), "Incompatible size for a");
|
|
188
|
+
CHECK_AND_ASSERT_THROW_MES(size + b0 <= b.size(), "Incompatible size for b");
|
|
189
|
+
CHECK_AND_ASSERT_THROW_MES(size <= maxN*maxM, "size is too large");
|
|
190
|
+
|
|
191
|
+
std::vector<MultiexpData> multiexp_data;
|
|
192
|
+
multiexp_data.resize(size*2 + 2);
|
|
193
|
+
rct::key temp;
|
|
194
|
+
for (size_t i = 0; i < size; ++i)
|
|
195
|
+
{
|
|
196
|
+
sc_mul(temp.bytes, a[a0+i].bytes, y.bytes);
|
|
197
|
+
sc_mul(multiexp_data[i*2].scalar.bytes, temp.bytes, INV_EIGHT.bytes);
|
|
198
|
+
multiexp_data[i*2].point = G[G0+i];
|
|
199
|
+
|
|
200
|
+
sc_mul(multiexp_data[i*2+1].scalar.bytes, b[b0+i].bytes, INV_EIGHT.bytes);
|
|
201
|
+
multiexp_data[i*2+1].point = H[H0+i];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
sc_mul(multiexp_data[2*size].scalar.bytes, c.bytes, INV_EIGHT.bytes);
|
|
205
|
+
ge_p3 H_p3;
|
|
206
|
+
ge_frombytes_vartime(&H_p3, rct::H.bytes);
|
|
207
|
+
multiexp_data[2*size].point = H_p3;
|
|
208
|
+
|
|
209
|
+
sc_mul(multiexp_data[2*size+1].scalar.bytes, d.bytes, INV_EIGHT.bytes);
|
|
210
|
+
ge_p3 G_p3;
|
|
211
|
+
ge_frombytes_vartime(&G_p3, rct::G.bytes);
|
|
212
|
+
multiexp_data[2*size+1].point = G_p3;
|
|
213
|
+
|
|
214
|
+
return multiexp(multiexp_data, 0);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Given a scalar, construct a vector of its powers:
|
|
218
|
+
//
|
|
219
|
+
// Output (1,x,x**2,...,x**{n-1})
|
|
220
|
+
static rct::keyV vector_of_scalar_powers(const rct::key &x, size_t n)
|
|
221
|
+
{
|
|
222
|
+
CHECK_AND_ASSERT_THROW_MES(n != 0, "Need n > 0");
|
|
223
|
+
|
|
224
|
+
rct::keyV res(n);
|
|
225
|
+
res[0] = rct::identity();
|
|
226
|
+
if (n == 1)
|
|
227
|
+
return res;
|
|
228
|
+
res[1] = x;
|
|
229
|
+
for (size_t i = 2; i < n; ++i)
|
|
230
|
+
{
|
|
231
|
+
sc_mul(res[i].bytes, res[i-1].bytes, x.bytes);
|
|
232
|
+
}
|
|
233
|
+
return res;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Given a scalar, construct the sum of its powers from 2 to n (where n is a power of 2):
|
|
237
|
+
//
|
|
238
|
+
// Output x**2 + x**4 + x**6 + ... + x**n
|
|
239
|
+
static rct::key sum_of_even_powers(const rct::key &x, size_t n)
|
|
240
|
+
{
|
|
241
|
+
CHECK_AND_ASSERT_THROW_MES((n & (n - 1)) == 0, "Need n to be a power of 2");
|
|
242
|
+
CHECK_AND_ASSERT_THROW_MES(n != 0, "Need n > 0");
|
|
243
|
+
|
|
244
|
+
rct::key x1 = copy(x);
|
|
245
|
+
sc_mul(x1.bytes, x1.bytes, x1.bytes);
|
|
246
|
+
|
|
247
|
+
rct::key res = copy(x1);
|
|
248
|
+
while (n > 2)
|
|
249
|
+
{
|
|
250
|
+
sc_muladd(res.bytes, x1.bytes, res.bytes, res.bytes);
|
|
251
|
+
sc_mul(x1.bytes, x1.bytes, x1.bytes);
|
|
252
|
+
n /= 2;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return res;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Given a scalar, return the sum of its powers from 1 to n
|
|
259
|
+
//
|
|
260
|
+
// Output x**1 + x**2 + x**3 + ... + x**n
|
|
261
|
+
static rct::key sum_of_scalar_powers(const rct::key &x, size_t n)
|
|
262
|
+
{
|
|
263
|
+
CHECK_AND_ASSERT_THROW_MES(n != 0, "Need n > 0");
|
|
264
|
+
|
|
265
|
+
rct::key res = ONE;
|
|
266
|
+
if (n == 1)
|
|
267
|
+
return x;
|
|
268
|
+
|
|
269
|
+
n += 1;
|
|
270
|
+
rct::key x1 = copy(x);
|
|
271
|
+
|
|
272
|
+
const bool is_power_of_2 = (n & (n - 1)) == 0;
|
|
273
|
+
if (is_power_of_2)
|
|
274
|
+
{
|
|
275
|
+
sc_add(res.bytes, res.bytes, x1.bytes);
|
|
276
|
+
while (n > 2)
|
|
277
|
+
{
|
|
278
|
+
sc_mul(x1.bytes, x1.bytes, x1.bytes);
|
|
279
|
+
sc_muladd(res.bytes, x1.bytes, res.bytes, res.bytes);
|
|
280
|
+
n /= 2;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else
|
|
284
|
+
{
|
|
285
|
+
rct::key prev = x1;
|
|
286
|
+
for (size_t i = 1; i < n; ++i)
|
|
287
|
+
{
|
|
288
|
+
if (i > 1)
|
|
289
|
+
sc_mul(prev.bytes, prev.bytes, x1.bytes);
|
|
290
|
+
sc_add(res.bytes, res.bytes, prev.bytes);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
sc_sub(res.bytes, res.bytes, ONE.bytes);
|
|
294
|
+
|
|
295
|
+
return res;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Given two scalar arrays, construct the weighted inner product against another scalar
|
|
299
|
+
//
|
|
300
|
+
// Output a_0*b_0*y**1 + a_1*b_1*y**2 + ... + a_{n-1}*b_{n-1}*y**n
|
|
301
|
+
static rct::key weighted_inner_product(const epee::span<const rct::key> &a, const epee::span<const rct::key> &b, const rct::key &y)
|
|
302
|
+
{
|
|
303
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
304
|
+
rct::key res = rct::zero();
|
|
305
|
+
rct::key y_power = ONE;
|
|
306
|
+
rct::key temp;
|
|
307
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
308
|
+
{
|
|
309
|
+
sc_mul(temp.bytes, a[i].bytes, b[i].bytes);
|
|
310
|
+
sc_mul(y_power.bytes, y_power.bytes, y.bytes);
|
|
311
|
+
sc_muladd(res.bytes, temp.bytes, y_power.bytes, res.bytes);
|
|
312
|
+
}
|
|
313
|
+
return res;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
static rct::key weighted_inner_product(const rct::keyV &a, const epee::span<const rct::key> &b, const rct::key &y)
|
|
317
|
+
{
|
|
318
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
319
|
+
return weighted_inner_product(epee::to_span(a), b, y);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Fold inner-product point vectors
|
|
323
|
+
static void hadamard_fold(std::vector<ge_p3> &v, const rct::key &a, const rct::key &b)
|
|
324
|
+
{
|
|
325
|
+
CHECK_AND_ASSERT_THROW_MES((v.size() & 1) == 0, "Vector size should be even");
|
|
326
|
+
const size_t sz = v.size() / 2;
|
|
327
|
+
for (size_t n = 0; n < sz; ++n)
|
|
328
|
+
{
|
|
329
|
+
ge_dsmp c[2];
|
|
330
|
+
ge_dsm_precomp(c[0], &v[n]);
|
|
331
|
+
ge_dsm_precomp(c[1], &v[sz + n]);
|
|
332
|
+
ge_double_scalarmult_precomp_vartime2_p3(&v[n], a.bytes, c[0], b.bytes, c[1]);
|
|
333
|
+
}
|
|
334
|
+
v.resize(sz);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Add vectors componentwise
|
|
338
|
+
static rct::keyV vector_add(const rct::keyV &a, const rct::keyV &b)
|
|
339
|
+
{
|
|
340
|
+
CHECK_AND_ASSERT_THROW_MES(a.size() == b.size(), "Incompatible sizes of a and b");
|
|
341
|
+
rct::keyV res(a.size());
|
|
342
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
343
|
+
{
|
|
344
|
+
sc_add(res[i].bytes, a[i].bytes, b[i].bytes);
|
|
345
|
+
}
|
|
346
|
+
return res;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Add a scalar to all elements of a vector
|
|
350
|
+
static rct::keyV vector_add(const rct::keyV &a, const rct::key &b)
|
|
351
|
+
{
|
|
352
|
+
rct::keyV res(a.size());
|
|
353
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
354
|
+
{
|
|
355
|
+
sc_add(res[i].bytes, a[i].bytes, b.bytes);
|
|
356
|
+
}
|
|
357
|
+
return res;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Subtract a scalar from all elements of a vector
|
|
361
|
+
static rct::keyV vector_subtract(const rct::keyV &a, const rct::key &b)
|
|
362
|
+
{
|
|
363
|
+
rct::keyV res(a.size());
|
|
364
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
365
|
+
{
|
|
366
|
+
sc_sub(res[i].bytes, a[i].bytes, b.bytes);
|
|
367
|
+
}
|
|
368
|
+
return res;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Multiply a scalar by all elements of a vector
|
|
372
|
+
static rct::keyV vector_scalar(const epee::span<const rct::key> &a, const rct::key &x)
|
|
373
|
+
{
|
|
374
|
+
rct::keyV res(a.size());
|
|
375
|
+
for (size_t i = 0; i < a.size(); ++i)
|
|
376
|
+
{
|
|
377
|
+
sc_mul(res[i].bytes, a[i].bytes, x.bytes);
|
|
378
|
+
}
|
|
379
|
+
return res;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Inversion helper function
|
|
383
|
+
static rct::key sm(rct::key y, int n, const rct::key &x)
|
|
384
|
+
{
|
|
385
|
+
while (n--)
|
|
386
|
+
sc_mul(y.bytes, y.bytes, y.bytes);
|
|
387
|
+
sc_mul(y.bytes, y.bytes, x.bytes);
|
|
388
|
+
return y;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Compute the inverse of a nonzero
|
|
392
|
+
static rct::key invert(const rct::key &x)
|
|
393
|
+
{
|
|
394
|
+
CHECK_AND_ASSERT_THROW_MES(!(x == ZERO), "Cannot invert zero!");
|
|
395
|
+
rct::key _1, _10, _100, _11, _101, _111, _1001, _1011, _1111;
|
|
396
|
+
|
|
397
|
+
_1 = x;
|
|
398
|
+
sc_mul(_10.bytes, _1.bytes, _1.bytes);
|
|
399
|
+
sc_mul(_100.bytes, _10.bytes, _10.bytes);
|
|
400
|
+
sc_mul(_11.bytes, _10.bytes, _1.bytes);
|
|
401
|
+
sc_mul(_101.bytes, _10.bytes, _11.bytes);
|
|
402
|
+
sc_mul(_111.bytes, _10.bytes, _101.bytes);
|
|
403
|
+
sc_mul(_1001.bytes, _10.bytes, _111.bytes);
|
|
404
|
+
sc_mul(_1011.bytes, _10.bytes, _1001.bytes);
|
|
405
|
+
sc_mul(_1111.bytes, _100.bytes, _1011.bytes);
|
|
406
|
+
|
|
407
|
+
rct::key inv;
|
|
408
|
+
sc_mul(inv.bytes, _1111.bytes, _1.bytes);
|
|
409
|
+
|
|
410
|
+
inv = sm(inv, 123 + 3, _101);
|
|
411
|
+
inv = sm(inv, 2 + 2, _11);
|
|
412
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
413
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
414
|
+
inv = sm(inv, 4, _1001);
|
|
415
|
+
inv = sm(inv, 2, _11);
|
|
416
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
417
|
+
inv = sm(inv, 1 + 3, _101);
|
|
418
|
+
inv = sm(inv, 3 + 3, _101);
|
|
419
|
+
inv = sm(inv, 3, _111);
|
|
420
|
+
inv = sm(inv, 1 + 4, _1111);
|
|
421
|
+
inv = sm(inv, 2 + 3, _111);
|
|
422
|
+
inv = sm(inv, 2 + 2, _11);
|
|
423
|
+
inv = sm(inv, 1 + 4, _1011);
|
|
424
|
+
inv = sm(inv, 2 + 4, _1011);
|
|
425
|
+
inv = sm(inv, 6 + 4, _1001);
|
|
426
|
+
inv = sm(inv, 2 + 2, _11);
|
|
427
|
+
inv = sm(inv, 3 + 2, _11);
|
|
428
|
+
inv = sm(inv, 3 + 2, _11);
|
|
429
|
+
inv = sm(inv, 1 + 4, _1001);
|
|
430
|
+
inv = sm(inv, 1 + 3, _111);
|
|
431
|
+
inv = sm(inv, 2 + 4, _1111);
|
|
432
|
+
inv = sm(inv, 1 + 4, _1011);
|
|
433
|
+
inv = sm(inv, 3, _101);
|
|
434
|
+
inv = sm(inv, 2 + 4, _1111);
|
|
435
|
+
inv = sm(inv, 3, _101);
|
|
436
|
+
inv = sm(inv, 1 + 2, _11);
|
|
437
|
+
|
|
438
|
+
return inv;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Invert a batch of scalars, all of which _must_ be nonzero
|
|
442
|
+
static rct::keyV invert(rct::keyV x)
|
|
443
|
+
{
|
|
444
|
+
rct::keyV scratch;
|
|
445
|
+
scratch.reserve(x.size());
|
|
446
|
+
|
|
447
|
+
rct::key acc = rct::identity();
|
|
448
|
+
for (size_t n = 0; n < x.size(); ++n)
|
|
449
|
+
{
|
|
450
|
+
CHECK_AND_ASSERT_THROW_MES(!(x[n] == ZERO), "Cannot invert zero!");
|
|
451
|
+
scratch.push_back(acc);
|
|
452
|
+
if (n == 0)
|
|
453
|
+
acc = x[0];
|
|
454
|
+
else
|
|
455
|
+
sc_mul(acc.bytes, acc.bytes, x[n].bytes);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
acc = invert(acc);
|
|
459
|
+
|
|
460
|
+
rct::key tmp;
|
|
461
|
+
for (int i = x.size(); i-- > 0; )
|
|
462
|
+
{
|
|
463
|
+
sc_mul(tmp.bytes, acc.bytes, x[i].bytes);
|
|
464
|
+
sc_mul(x[i].bytes, acc.bytes, scratch[i].bytes);
|
|
465
|
+
acc = tmp;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return x;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Compute the slice of a vector
|
|
472
|
+
static epee::span<const rct::key> slice(const rct::keyV &a, size_t start, size_t stop)
|
|
473
|
+
{
|
|
474
|
+
CHECK_AND_ASSERT_THROW_MES(start < a.size(), "Invalid start index");
|
|
475
|
+
CHECK_AND_ASSERT_THROW_MES(stop <= a.size(), "Invalid stop index");
|
|
476
|
+
CHECK_AND_ASSERT_THROW_MES(start < stop, "Invalid start/stop indices");
|
|
477
|
+
return epee::span<const rct::key>(&a[start], stop - start);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Update the transcript
|
|
481
|
+
static rct::key transcript_update(rct::key &transcript, const rct::key &update_0)
|
|
482
|
+
{
|
|
483
|
+
rct::key data[2];
|
|
484
|
+
data[0] = transcript;
|
|
485
|
+
data[1] = update_0;
|
|
486
|
+
rct::hash_to_scalar(transcript, data, sizeof(data));
|
|
487
|
+
return transcript;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
static rct::key transcript_update(rct::key &transcript, const rct::key &update_0, const rct::key &update_1)
|
|
491
|
+
{
|
|
492
|
+
rct::key data[3];
|
|
493
|
+
data[0] = transcript;
|
|
494
|
+
data[1] = update_0;
|
|
495
|
+
data[2] = update_1;
|
|
496
|
+
rct::hash_to_scalar(transcript, data, sizeof(data));
|
|
497
|
+
return transcript;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Given a value v [0..2**N) and a mask gamma, construct a range proof
|
|
501
|
+
BulletproofPlus bulletproof_plus_PROVE(const rct::key &sv, const rct::key &gamma)
|
|
502
|
+
{
|
|
503
|
+
return bulletproof_plus_PROVE(rct::keyV(1, sv), rct::keyV(1, gamma));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
BulletproofPlus bulletproof_plus_PROVE(uint64_t v, const rct::key &gamma)
|
|
507
|
+
{
|
|
508
|
+
return bulletproof_plus_PROVE(std::vector<uint64_t>(1, v), rct::keyV(1, gamma));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Given a set of values v [0..2**N) and masks gamma, construct a range proof
|
|
512
|
+
BulletproofPlus bulletproof_plus_PROVE(const rct::keyV &sv, const rct::keyV &gamma)
|
|
513
|
+
{
|
|
514
|
+
// Sanity check on inputs
|
|
515
|
+
CHECK_AND_ASSERT_THROW_MES(sv.size() == gamma.size(), "Incompatible sizes of sv and gamma");
|
|
516
|
+
CHECK_AND_ASSERT_THROW_MES(!sv.empty(), "sv is empty");
|
|
517
|
+
for (const rct::key &sve: sv)
|
|
518
|
+
CHECK_AND_ASSERT_THROW_MES(is_reduced(sve), "Invalid sv input");
|
|
519
|
+
for (const rct::key &g: gamma)
|
|
520
|
+
CHECK_AND_ASSERT_THROW_MES(is_reduced(g), "Invalid gamma input");
|
|
521
|
+
|
|
522
|
+
init_exponents();
|
|
523
|
+
|
|
524
|
+
// Useful proof bounds
|
|
525
|
+
//
|
|
526
|
+
// N: number of bits in each range (here, 64)
|
|
527
|
+
// logN: base-2 logarithm
|
|
528
|
+
// M: first power of 2 greater than or equal to the number of range proofs to aggregate
|
|
529
|
+
// logM: base-2 logarithm
|
|
530
|
+
constexpr size_t logN = 6; // log2(64)
|
|
531
|
+
constexpr size_t N = 1<<logN;
|
|
532
|
+
size_t M, logM;
|
|
533
|
+
for (logM = 0; (M = 1<<logM) <= maxM && M < sv.size(); ++logM);
|
|
534
|
+
CHECK_AND_ASSERT_THROW_MES(M <= maxM, "sv/gamma are too large");
|
|
535
|
+
const size_t logMN = logM + logN;
|
|
536
|
+
const size_t MN = M * N;
|
|
537
|
+
|
|
538
|
+
rct::keyV V(sv.size());
|
|
539
|
+
rct::keyV aL(MN), aR(MN);
|
|
540
|
+
rct::keyV aL8(MN), aR8(MN);
|
|
541
|
+
rct::key temp;
|
|
542
|
+
rct::key temp2;
|
|
543
|
+
|
|
544
|
+
// Prepare output commitments and offset by a factor of 8**(-1)
|
|
545
|
+
//
|
|
546
|
+
// This offset is applied to other group elements as well;
|
|
547
|
+
// it allows us to apply a multiply-by-8 operation in the verifier efficiently
|
|
548
|
+
// to ensure that the resulting group elements are in the prime-order point subgroup
|
|
549
|
+
// and avoid much more constly multiply-by-group-order operations.
|
|
550
|
+
for (size_t i = 0; i < sv.size(); ++i)
|
|
551
|
+
{
|
|
552
|
+
rct::key gamma8, sv8;
|
|
553
|
+
sc_mul(gamma8.bytes, gamma[i].bytes, INV_EIGHT.bytes);
|
|
554
|
+
sc_mul(sv8.bytes, sv[i].bytes, INV_EIGHT.bytes);
|
|
555
|
+
rct::addKeys2(V[i], gamma8, sv8, rct::H);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Decompose values
|
|
559
|
+
//
|
|
560
|
+
// Note that this effectively pads the set to a power of 2, which is required for the inner-product argument later.
|
|
561
|
+
for (size_t j = 0; j < M; ++j)
|
|
562
|
+
{
|
|
563
|
+
for (size_t i = N; i-- > 0; )
|
|
564
|
+
{
|
|
565
|
+
if (j < sv.size() && (sv[j][i/8] & (((uint64_t)1)<<(i%8))))
|
|
566
|
+
{
|
|
567
|
+
aL[j*N+i] = rct::identity();
|
|
568
|
+
aL8[j*N+i] = INV_EIGHT;
|
|
569
|
+
aR[j*N+i] = aR8[j*N+i] = rct::zero();
|
|
570
|
+
}
|
|
571
|
+
else
|
|
572
|
+
{
|
|
573
|
+
aL[j*N+i] = aL8[j*N+i] = rct::zero();
|
|
574
|
+
aR[j*N+i] = MINUS_ONE;
|
|
575
|
+
aR8[j*N+i] = MINUS_INV_EIGHT;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
try_again:
|
|
581
|
+
// This is a Fiat-Shamir transcript
|
|
582
|
+
rct::key transcript = copy(initial_transcript);
|
|
583
|
+
transcript = transcript_update(transcript, rct::hash_to_scalar(V));
|
|
584
|
+
|
|
585
|
+
// A
|
|
586
|
+
rct::key alpha = rct::skGen();
|
|
587
|
+
rct::key pre_A = vector_exponent(aL8, aR8);
|
|
588
|
+
rct::key A;
|
|
589
|
+
sc_mul(temp.bytes, alpha.bytes, INV_EIGHT.bytes);
|
|
590
|
+
rct::addKeys(A, pre_A, rct::scalarmultBase(temp));
|
|
591
|
+
|
|
592
|
+
// Challenges
|
|
593
|
+
rct::key y = transcript_update(transcript, A);
|
|
594
|
+
if (y == rct::zero())
|
|
595
|
+
{
|
|
596
|
+
MINFO("y is 0, trying again");
|
|
597
|
+
goto try_again;
|
|
598
|
+
}
|
|
599
|
+
rct::key z = transcript = rct::hash_to_scalar(y);
|
|
600
|
+
if (z == rct::zero())
|
|
601
|
+
{
|
|
602
|
+
MINFO("z is 0, trying again");
|
|
603
|
+
goto try_again;
|
|
604
|
+
}
|
|
605
|
+
rct::key z_squared;
|
|
606
|
+
sc_mul(z_squared.bytes, z.bytes, z.bytes);
|
|
607
|
+
|
|
608
|
+
// Windowed vector
|
|
609
|
+
// d[j*N+i] = z**(2*(j+1)) * 2**i
|
|
610
|
+
//
|
|
611
|
+
// We compute this iteratively in order to reduce scalar operations.
|
|
612
|
+
rct::keyV d(MN, rct::zero());
|
|
613
|
+
d[0] = z_squared;
|
|
614
|
+
for (size_t i = 1; i < N; i++)
|
|
615
|
+
{
|
|
616
|
+
sc_mul(d[i].bytes, d[i-1].bytes, TWO.bytes);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
for (size_t j = 1; j < M; j++)
|
|
620
|
+
{
|
|
621
|
+
for (size_t i = 0; i < N; i++)
|
|
622
|
+
{
|
|
623
|
+
sc_mul(d[j*N+i].bytes, d[(j-1)*N+i].bytes, z_squared.bytes);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
rct::keyV y_powers = vector_of_scalar_powers(y, MN+2);
|
|
628
|
+
|
|
629
|
+
// Prepare inner product terms
|
|
630
|
+
rct::keyV aL1 = vector_subtract(aL, z);
|
|
631
|
+
|
|
632
|
+
rct::keyV aR1 = vector_add(aR, z);
|
|
633
|
+
rct::keyV d_y(MN);
|
|
634
|
+
for (size_t i = 0; i < MN; i++)
|
|
635
|
+
{
|
|
636
|
+
sc_mul(d_y[i].bytes, d[i].bytes, y_powers[MN-i].bytes);
|
|
637
|
+
}
|
|
638
|
+
aR1 = vector_add(aR1, d_y);
|
|
639
|
+
|
|
640
|
+
rct::key alpha1 = alpha;
|
|
641
|
+
temp = ONE;
|
|
642
|
+
for (size_t j = 0; j < sv.size(); j++)
|
|
643
|
+
{
|
|
644
|
+
sc_mul(temp.bytes, temp.bytes, z_squared.bytes);
|
|
645
|
+
sc_mul(temp2.bytes, y_powers[MN+1].bytes, temp.bytes);
|
|
646
|
+
sc_muladd(alpha1.bytes, temp2.bytes, gamma[j].bytes, alpha1.bytes);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// These are used in the inner product rounds
|
|
650
|
+
size_t nprime = MN;
|
|
651
|
+
std::vector<ge_p3> Gprime(MN);
|
|
652
|
+
std::vector<ge_p3> Hprime(MN);
|
|
653
|
+
rct::keyV aprime(MN);
|
|
654
|
+
rct::keyV bprime(MN);
|
|
655
|
+
|
|
656
|
+
const rct::key yinv = invert(y);
|
|
657
|
+
rct::keyV yinvpow(MN);
|
|
658
|
+
yinvpow[0] = ONE;
|
|
659
|
+
for (size_t i = 0; i < MN; ++i)
|
|
660
|
+
{
|
|
661
|
+
Gprime[i] = Gi_p3[i];
|
|
662
|
+
Hprime[i] = Hi_p3[i];
|
|
663
|
+
if (i > 0)
|
|
664
|
+
{
|
|
665
|
+
sc_mul(yinvpow[i].bytes, yinvpow[i-1].bytes, yinv.bytes);
|
|
666
|
+
}
|
|
667
|
+
aprime[i] = aL1[i];
|
|
668
|
+
bprime[i] = aR1[i];
|
|
669
|
+
}
|
|
670
|
+
rct::keyV L(logMN);
|
|
671
|
+
rct::keyV R(logMN);
|
|
672
|
+
int round = 0;
|
|
673
|
+
|
|
674
|
+
// Inner-product rounds
|
|
675
|
+
while (nprime > 1)
|
|
676
|
+
{
|
|
677
|
+
nprime /= 2;
|
|
678
|
+
|
|
679
|
+
rct::key cL = weighted_inner_product(slice(aprime, 0, nprime), slice(bprime, nprime, bprime.size()), y);
|
|
680
|
+
rct::key cR = weighted_inner_product(vector_scalar(slice(aprime, nprime, aprime.size()), y_powers[nprime]), slice(bprime, 0, nprime), y);
|
|
681
|
+
|
|
682
|
+
rct::key dL = rct::skGen();
|
|
683
|
+
rct::key dR = rct::skGen();
|
|
684
|
+
|
|
685
|
+
L[round] = compute_LR(nprime, yinvpow[nprime], Gprime, nprime, Hprime, 0, aprime, 0, bprime, nprime, cL, dL);
|
|
686
|
+
R[round] = compute_LR(nprime, y_powers[nprime], Gprime, 0, Hprime, nprime, aprime, nprime, bprime, 0, cR, dR);
|
|
687
|
+
|
|
688
|
+
const rct::key challenge = transcript_update(transcript, L[round], R[round]);
|
|
689
|
+
if (challenge == rct::zero())
|
|
690
|
+
{
|
|
691
|
+
MINFO("challenge is 0, trying again");
|
|
692
|
+
goto try_again;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const rct::key challenge_inv = invert(challenge);
|
|
696
|
+
|
|
697
|
+
sc_mul(temp.bytes, yinvpow[nprime].bytes, challenge.bytes);
|
|
698
|
+
hadamard_fold(Gprime, challenge_inv, temp);
|
|
699
|
+
hadamard_fold(Hprime, challenge, challenge_inv);
|
|
700
|
+
|
|
701
|
+
sc_mul(temp.bytes, challenge_inv.bytes, y_powers[nprime].bytes);
|
|
702
|
+
aprime = vector_add(vector_scalar(slice(aprime, 0, nprime), challenge), vector_scalar(slice(aprime, nprime, aprime.size()), temp));
|
|
703
|
+
bprime = vector_add(vector_scalar(slice(bprime, 0, nprime), challenge_inv), vector_scalar(slice(bprime, nprime, bprime.size()), challenge));
|
|
704
|
+
|
|
705
|
+
rct::key challenge_squared;
|
|
706
|
+
sc_mul(challenge_squared.bytes, challenge.bytes, challenge.bytes);
|
|
707
|
+
rct::key challenge_squared_inv;
|
|
708
|
+
sc_mul(challenge_squared_inv.bytes, challenge_inv.bytes, challenge_inv.bytes);
|
|
709
|
+
sc_muladd(alpha1.bytes, dL.bytes, challenge_squared.bytes, alpha1.bytes);
|
|
710
|
+
sc_muladd(alpha1.bytes, dR.bytes, challenge_squared_inv.bytes, alpha1.bytes);
|
|
711
|
+
|
|
712
|
+
++round;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// Final round computations
|
|
716
|
+
rct::key r = rct::skGen();
|
|
717
|
+
rct::key s = rct::skGen();
|
|
718
|
+
rct::key d_ = rct::skGen();
|
|
719
|
+
rct::key eta = rct::skGen();
|
|
720
|
+
|
|
721
|
+
std::vector<MultiexpData> A1_data;
|
|
722
|
+
A1_data.reserve(4);
|
|
723
|
+
A1_data.resize(4);
|
|
724
|
+
|
|
725
|
+
sc_mul(A1_data[0].scalar.bytes, r.bytes, INV_EIGHT.bytes);
|
|
726
|
+
A1_data[0].point = Gprime[0];
|
|
727
|
+
|
|
728
|
+
sc_mul(A1_data[1].scalar.bytes, s.bytes, INV_EIGHT.bytes);
|
|
729
|
+
A1_data[1].point = Hprime[0];
|
|
730
|
+
|
|
731
|
+
sc_mul(A1_data[2].scalar.bytes, d_.bytes, INV_EIGHT.bytes);
|
|
732
|
+
ge_p3 G_p3;
|
|
733
|
+
ge_frombytes_vartime(&G_p3, rct::G.bytes);
|
|
734
|
+
A1_data[2].point = G_p3;
|
|
735
|
+
|
|
736
|
+
sc_mul(temp.bytes, r.bytes, y.bytes);
|
|
737
|
+
sc_mul(temp.bytes, temp.bytes, bprime[0].bytes);
|
|
738
|
+
sc_mul(temp2.bytes, s.bytes, y.bytes);
|
|
739
|
+
sc_mul(temp2.bytes, temp2.bytes, aprime[0].bytes);
|
|
740
|
+
sc_add(temp.bytes, temp.bytes, temp2.bytes);
|
|
741
|
+
sc_mul(A1_data[3].scalar.bytes, temp.bytes, INV_EIGHT.bytes);
|
|
742
|
+
ge_p3 H_p3;
|
|
743
|
+
ge_frombytes_vartime(&H_p3, rct::H.bytes);
|
|
744
|
+
A1_data[3].point = H_p3;
|
|
745
|
+
|
|
746
|
+
rct::key A1 = multiexp(A1_data, 0);
|
|
747
|
+
|
|
748
|
+
sc_mul(temp.bytes, r.bytes, y.bytes);
|
|
749
|
+
sc_mul(temp.bytes, temp.bytes, s.bytes);
|
|
750
|
+
sc_mul(temp.bytes, temp.bytes, INV_EIGHT.bytes);
|
|
751
|
+
sc_mul(temp2.bytes, eta.bytes, INV_EIGHT.bytes);
|
|
752
|
+
rct::key B;
|
|
753
|
+
rct::addKeys2(B, temp2, temp, rct::H);
|
|
754
|
+
|
|
755
|
+
rct::key e = transcript_update(transcript, A1, B);
|
|
756
|
+
if (e == rct::zero())
|
|
757
|
+
{
|
|
758
|
+
MINFO("e is 0, trying again");
|
|
759
|
+
goto try_again;
|
|
760
|
+
}
|
|
761
|
+
rct::key e_squared;
|
|
762
|
+
sc_mul(e_squared.bytes, e.bytes, e.bytes);
|
|
763
|
+
|
|
764
|
+
rct::key r1;
|
|
765
|
+
sc_muladd(r1.bytes, aprime[0].bytes, e.bytes, r.bytes);
|
|
766
|
+
|
|
767
|
+
rct::key s1;
|
|
768
|
+
sc_muladd(s1.bytes, bprime[0].bytes, e.bytes, s.bytes);
|
|
769
|
+
|
|
770
|
+
rct::key d1;
|
|
771
|
+
sc_muladd(d1.bytes, d_.bytes, e.bytes, eta.bytes);
|
|
772
|
+
sc_muladd(d1.bytes, alpha1.bytes, e_squared.bytes, d1.bytes);
|
|
773
|
+
|
|
774
|
+
return BulletproofPlus(std::move(V), A, A1, B, r1, s1, d1, std::move(L), std::move(R));
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
BulletproofPlus bulletproof_plus_PROVE(const std::vector<uint64_t> &v, const rct::keyV &gamma)
|
|
778
|
+
{
|
|
779
|
+
CHECK_AND_ASSERT_THROW_MES(v.size() == gamma.size(), "Incompatible sizes of v and gamma");
|
|
780
|
+
|
|
781
|
+
// vG + gammaH
|
|
782
|
+
rct::keyV sv(v.size());
|
|
783
|
+
for (size_t i = 0; i < v.size(); ++i)
|
|
784
|
+
{
|
|
785
|
+
sv[i] = rct::d2h(v[i]);
|
|
786
|
+
}
|
|
787
|
+
return bulletproof_plus_PROVE(sv, gamma);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
struct bp_plus_proof_data_t
|
|
791
|
+
{
|
|
792
|
+
rct::key y, z, e;
|
|
793
|
+
std::vector<rct::key> challenges;
|
|
794
|
+
size_t logM, inv_offset;
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// Given a batch of range proofs, determine if they are all valid
|
|
798
|
+
bool bulletproof_plus_VERIFY(const std::vector<const BulletproofPlus*> &proofs)
|
|
799
|
+
{
|
|
800
|
+
init_exponents();
|
|
801
|
+
|
|
802
|
+
const size_t logN = 6;
|
|
803
|
+
const size_t N = 1 << logN;
|
|
804
|
+
|
|
805
|
+
// Set up
|
|
806
|
+
size_t max_length = 0; // size of each of the longest proof's inner-product vectors
|
|
807
|
+
size_t nV = 0; // number of output commitments across all proofs
|
|
808
|
+
size_t inv_offset = 0;
|
|
809
|
+
size_t max_logM = 0;
|
|
810
|
+
|
|
811
|
+
std::vector<bp_plus_proof_data_t> proof_data;
|
|
812
|
+
proof_data.reserve(proofs.size());
|
|
813
|
+
|
|
814
|
+
// We'll perform only a single batch inversion across all proofs in the batch,
|
|
815
|
+
// since batch inversion requires only one scalar inversion operation.
|
|
816
|
+
std::vector<rct::key> to_invert;
|
|
817
|
+
to_invert.reserve(11 * proofs.size()); // maximal size, given the aggregation limit
|
|
818
|
+
|
|
819
|
+
for (const BulletproofPlus *p: proofs)
|
|
820
|
+
{
|
|
821
|
+
const BulletproofPlus &proof = *p;
|
|
822
|
+
|
|
823
|
+
// Sanity checks
|
|
824
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.r1), false, "Input scalar not in range");
|
|
825
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.s1), false, "Input scalar not in range");
|
|
826
|
+
CHECK_AND_ASSERT_MES(is_reduced(proof.d1), false, "Input scalar not in range");
|
|
827
|
+
|
|
828
|
+
CHECK_AND_ASSERT_MES(proof.V.size() >= 1, false, "V does not have at least one element");
|
|
829
|
+
CHECK_AND_ASSERT_MES(proof.L.size() == proof.R.size(), false, "Mismatched L and R sizes");
|
|
830
|
+
CHECK_AND_ASSERT_MES(proof.L.size() > 0, false, "Empty proof");
|
|
831
|
+
|
|
832
|
+
max_length = std::max(max_length, proof.L.size());
|
|
833
|
+
nV += proof.V.size();
|
|
834
|
+
|
|
835
|
+
proof_data.push_back({});
|
|
836
|
+
bp_plus_proof_data_t &pd = proof_data.back();
|
|
837
|
+
|
|
838
|
+
// Reconstruct the challenges
|
|
839
|
+
rct::key transcript = copy(initial_transcript);
|
|
840
|
+
transcript = transcript_update(transcript, rct::hash_to_scalar(proof.V));
|
|
841
|
+
pd.y = transcript_update(transcript, proof.A);
|
|
842
|
+
CHECK_AND_ASSERT_MES(!(pd.y == rct::zero()), false, "y == 0");
|
|
843
|
+
pd.z = transcript = rct::hash_to_scalar(pd.y);
|
|
844
|
+
CHECK_AND_ASSERT_MES(!(pd.z == rct::zero()), false, "z == 0");
|
|
845
|
+
|
|
846
|
+
// Determine the number of inner-product rounds based on proof size
|
|
847
|
+
size_t M;
|
|
848
|
+
for (pd.logM = 0; (M = 1<<pd.logM) <= maxM && M < proof.V.size(); ++pd.logM);
|
|
849
|
+
CHECK_AND_ASSERT_MES(proof.L.size() == 6+pd.logM, false, "Proof is not the expected size");
|
|
850
|
+
max_logM = std::max(pd.logM, max_logM);
|
|
851
|
+
|
|
852
|
+
const size_t rounds = pd.logM+logN;
|
|
853
|
+
CHECK_AND_ASSERT_MES(rounds > 0, false, "Zero rounds");
|
|
854
|
+
|
|
855
|
+
// The inner-product challenges are computed per round
|
|
856
|
+
pd.challenges.resize(rounds);
|
|
857
|
+
for (size_t j = 0; j < rounds; ++j)
|
|
858
|
+
{
|
|
859
|
+
pd.challenges[j] = transcript_update(transcript, proof.L[j], proof.R[j]);
|
|
860
|
+
CHECK_AND_ASSERT_MES(!(pd.challenges[j] == rct::zero()), false, "challenges[j] == 0");
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// Final challenge
|
|
864
|
+
pd.e = transcript_update(transcript,proof.A1,proof.B);
|
|
865
|
+
CHECK_AND_ASSERT_MES(!(pd.e == rct::zero()), false, "e == 0");
|
|
866
|
+
|
|
867
|
+
// Batch scalar inversions
|
|
868
|
+
pd.inv_offset = inv_offset;
|
|
869
|
+
for (size_t j = 0; j < rounds; ++j)
|
|
870
|
+
to_invert.push_back(pd.challenges[j]);
|
|
871
|
+
to_invert.push_back(pd.y);
|
|
872
|
+
inv_offset += rounds + 1;
|
|
873
|
+
}
|
|
874
|
+
CHECK_AND_ASSERT_MES(max_length < 32, false, "At least one proof is too large");
|
|
875
|
+
size_t maxMN = 1u << max_length;
|
|
876
|
+
|
|
877
|
+
rct::key temp;
|
|
878
|
+
rct::key temp2;
|
|
879
|
+
|
|
880
|
+
// Final batch proof data
|
|
881
|
+
std::vector<MultiexpData> multiexp_data;
|
|
882
|
+
multiexp_data.reserve(nV + (2 * (max_logM + logN) + 3) * proofs.size() + 2 * maxMN);
|
|
883
|
+
multiexp_data.resize(2 * maxMN);
|
|
884
|
+
|
|
885
|
+
const std::vector<rct::key> inverses = invert(std::move(to_invert));
|
|
886
|
+
to_invert.clear();
|
|
887
|
+
|
|
888
|
+
// Weights and aggregates
|
|
889
|
+
//
|
|
890
|
+
// The idea is to take the single multiscalar multiplication used in the verification
|
|
891
|
+
// of each proof in the batch and weight it using a random weighting factor, resulting
|
|
892
|
+
// in just one multiscalar multiplication check to zero for the entire batch.
|
|
893
|
+
// We can further simplify the verifier complexity by including common group elements
|
|
894
|
+
// only once in this single multiscalar multiplication.
|
|
895
|
+
// Common group elements' weighted scalar sums are tracked across proofs for this reason.
|
|
896
|
+
//
|
|
897
|
+
// To build a multiscalar multiplication for each proof, we use the method described in
|
|
898
|
+
// Section 6.1 of the preprint. Note that the result given there does not account for
|
|
899
|
+
// the construction of the inner-product inputs that are produced in the range proof
|
|
900
|
+
// verifier algorithm; we have done so here.
|
|
901
|
+
rct::key G_scalar = rct::zero();
|
|
902
|
+
rct::key H_scalar = rct::zero();
|
|
903
|
+
rct::keyV Gi_scalars(maxMN, rct::zero());
|
|
904
|
+
rct::keyV Hi_scalars(maxMN, rct::zero());
|
|
905
|
+
|
|
906
|
+
int proof_data_index = 0;
|
|
907
|
+
rct::keyV challenges_cache;
|
|
908
|
+
std::vector<ge_p3> proof8_V, proof8_L, proof8_R;
|
|
909
|
+
|
|
910
|
+
// Process each proof and add to the weighted batch
|
|
911
|
+
for (const BulletproofPlus *p: proofs)
|
|
912
|
+
{
|
|
913
|
+
const BulletproofPlus &proof = *p;
|
|
914
|
+
const bp_plus_proof_data_t &pd = proof_data[proof_data_index++];
|
|
915
|
+
|
|
916
|
+
CHECK_AND_ASSERT_MES(proof.L.size() == 6+pd.logM, false, "Proof is not the expected size");
|
|
917
|
+
const size_t M = 1 << pd.logM;
|
|
918
|
+
const size_t MN = M*N;
|
|
919
|
+
|
|
920
|
+
// Random weighting factor must be nonzero, which is exceptionally unlikely!
|
|
921
|
+
rct::key weight = ZERO;
|
|
922
|
+
while (weight == ZERO)
|
|
923
|
+
{
|
|
924
|
+
weight = rct::skGen();
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// Rescale previously offset proof elements
|
|
928
|
+
//
|
|
929
|
+
// This ensures that all such group elements are in the prime-order subgroup.
|
|
930
|
+
proof8_V.resize(proof.V.size()); for (size_t i = 0; i < proof.V.size(); ++i) rct::scalarmult8(proof8_V[i], proof.V[i]);
|
|
931
|
+
proof8_L.resize(proof.L.size()); for (size_t i = 0; i < proof.L.size(); ++i) rct::scalarmult8(proof8_L[i], proof.L[i]);
|
|
932
|
+
proof8_R.resize(proof.R.size()); for (size_t i = 0; i < proof.R.size(); ++i) rct::scalarmult8(proof8_R[i], proof.R[i]);
|
|
933
|
+
ge_p3 proof8_A1;
|
|
934
|
+
ge_p3 proof8_B;
|
|
935
|
+
ge_p3 proof8_A;
|
|
936
|
+
rct::scalarmult8(proof8_A1, proof.A1);
|
|
937
|
+
rct::scalarmult8(proof8_B, proof.B);
|
|
938
|
+
rct::scalarmult8(proof8_A, proof.A);
|
|
939
|
+
|
|
940
|
+
// Compute necessary powers of the y-challenge
|
|
941
|
+
rct::key y_MN = copy(pd.y);
|
|
942
|
+
rct::key y_MN_1;
|
|
943
|
+
size_t temp_MN = MN;
|
|
944
|
+
while (temp_MN > 1)
|
|
945
|
+
{
|
|
946
|
+
sc_mul(y_MN.bytes, y_MN.bytes, y_MN.bytes);
|
|
947
|
+
temp_MN /= 2;
|
|
948
|
+
}
|
|
949
|
+
sc_mul(y_MN_1.bytes, y_MN.bytes, pd.y.bytes);
|
|
950
|
+
|
|
951
|
+
// V_j: -e**2 * z**(2*j+1) * y**(MN+1) * weight
|
|
952
|
+
rct::key e_squared;
|
|
953
|
+
sc_mul(e_squared.bytes, pd.e.bytes, pd.e.bytes);
|
|
954
|
+
|
|
955
|
+
rct::key z_squared;
|
|
956
|
+
sc_mul(z_squared.bytes, pd.z.bytes, pd.z.bytes);
|
|
957
|
+
|
|
958
|
+
sc_sub(temp.bytes, ZERO.bytes, e_squared.bytes);
|
|
959
|
+
sc_mul(temp.bytes, temp.bytes, y_MN_1.bytes);
|
|
960
|
+
sc_mul(temp.bytes, temp.bytes, weight.bytes);
|
|
961
|
+
for (size_t j = 0; j < proof8_V.size(); j++)
|
|
962
|
+
{
|
|
963
|
+
sc_mul(temp.bytes, temp.bytes, z_squared.bytes);
|
|
964
|
+
multiexp_data.emplace_back(temp, proof8_V[j]);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// B: -weight
|
|
968
|
+
sc_mul(temp.bytes, MINUS_ONE.bytes, weight.bytes);
|
|
969
|
+
multiexp_data.emplace_back(temp, proof8_B);
|
|
970
|
+
|
|
971
|
+
// A1: -weight*e
|
|
972
|
+
sc_mul(temp.bytes, temp.bytes, pd.e.bytes);
|
|
973
|
+
multiexp_data.emplace_back(temp, proof8_A1);
|
|
974
|
+
|
|
975
|
+
// A: -weight*e*e
|
|
976
|
+
rct::key minus_weight_e_squared;
|
|
977
|
+
sc_mul(minus_weight_e_squared.bytes, temp.bytes, pd.e.bytes);
|
|
978
|
+
multiexp_data.emplace_back(minus_weight_e_squared, proof8_A);
|
|
979
|
+
|
|
980
|
+
// G: weight*d1
|
|
981
|
+
sc_muladd(G_scalar.bytes, weight.bytes, proof.d1.bytes, G_scalar.bytes);
|
|
982
|
+
|
|
983
|
+
// Windowed vector
|
|
984
|
+
// d[j*N+i] = z**(2*(j+1)) * 2**i
|
|
985
|
+
rct::keyV d(MN, rct::zero());
|
|
986
|
+
d[0] = z_squared;
|
|
987
|
+
for (size_t i = 1; i < N; i++)
|
|
988
|
+
{
|
|
989
|
+
sc_add(d[i].bytes, d[i-1].bytes, d[i-1].bytes);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
for (size_t j = 1; j < M; j++)
|
|
993
|
+
{
|
|
994
|
+
for (size_t i = 0; i < N; i++)
|
|
995
|
+
{
|
|
996
|
+
sc_mul(d[j*N+i].bytes, d[(j-1)*N+i].bytes, z_squared.bytes);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// More efficient computation of sum(d)
|
|
1001
|
+
rct::key sum_d;
|
|
1002
|
+
sc_mul(sum_d.bytes, TWO_SIXTY_FOUR_MINUS_ONE.bytes, sum_of_even_powers(pd.z, 2*M).bytes);
|
|
1003
|
+
|
|
1004
|
+
// H: weight*( r1*y*s1 + e**2*( y**(MN+1)*z*sum(d) + (z**2-z)*sum(y) ) )
|
|
1005
|
+
rct::key sum_y = sum_of_scalar_powers(pd.y, MN);
|
|
1006
|
+
sc_sub(temp.bytes, z_squared.bytes, pd.z.bytes);
|
|
1007
|
+
sc_mul(temp.bytes, temp.bytes, sum_y.bytes);
|
|
1008
|
+
|
|
1009
|
+
sc_mul(temp2.bytes, y_MN_1.bytes, pd.z.bytes);
|
|
1010
|
+
sc_mul(temp2.bytes, temp2.bytes, sum_d.bytes);
|
|
1011
|
+
sc_add(temp.bytes, temp.bytes, temp2.bytes);
|
|
1012
|
+
sc_mul(temp.bytes, temp.bytes, e_squared.bytes);
|
|
1013
|
+
sc_mul(temp2.bytes, proof.r1.bytes, pd.y.bytes);
|
|
1014
|
+
sc_mul(temp2.bytes, temp2.bytes, proof.s1.bytes);
|
|
1015
|
+
sc_add(temp.bytes, temp.bytes, temp2.bytes);
|
|
1016
|
+
sc_muladd(H_scalar.bytes, temp.bytes, weight.bytes, H_scalar.bytes);
|
|
1017
|
+
|
|
1018
|
+
// Compute the number of rounds for the inner-product argument
|
|
1019
|
+
const size_t rounds = pd.logM+logN;
|
|
1020
|
+
CHECK_AND_ASSERT_MES(rounds > 0, false, "Zero rounds");
|
|
1021
|
+
|
|
1022
|
+
const rct::key *challenges_inv = &inverses[pd.inv_offset];
|
|
1023
|
+
const rct::key yinv = inverses[pd.inv_offset + rounds];
|
|
1024
|
+
|
|
1025
|
+
// Compute challenge products
|
|
1026
|
+
challenges_cache.resize(1<<rounds);
|
|
1027
|
+
challenges_cache[0] = challenges_inv[0];
|
|
1028
|
+
challenges_cache[1] = pd.challenges[0];
|
|
1029
|
+
for (size_t j = 1; j < rounds; ++j)
|
|
1030
|
+
{
|
|
1031
|
+
const size_t slots = 1<<(j+1);
|
|
1032
|
+
for (size_t s = slots; s-- > 0; --s)
|
|
1033
|
+
{
|
|
1034
|
+
sc_mul(challenges_cache[s].bytes, challenges_cache[s/2].bytes, pd.challenges[j].bytes);
|
|
1035
|
+
sc_mul(challenges_cache[s-1].bytes, challenges_cache[s/2].bytes, challenges_inv[j].bytes);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// Gi and Hi
|
|
1040
|
+
rct::key e_r1_w_y;
|
|
1041
|
+
sc_mul(e_r1_w_y.bytes, pd.e.bytes, proof.r1.bytes);
|
|
1042
|
+
sc_mul(e_r1_w_y.bytes, e_r1_w_y.bytes, weight.bytes);
|
|
1043
|
+
rct::key e_s1_w;
|
|
1044
|
+
sc_mul(e_s1_w.bytes, pd.e.bytes, proof.s1.bytes);
|
|
1045
|
+
sc_mul(e_s1_w.bytes, e_s1_w.bytes, weight.bytes);
|
|
1046
|
+
rct::key e_squared_z_w;
|
|
1047
|
+
sc_mul(e_squared_z_w.bytes, e_squared.bytes, pd.z.bytes);
|
|
1048
|
+
sc_mul(e_squared_z_w.bytes, e_squared_z_w.bytes, weight.bytes);
|
|
1049
|
+
rct::key minus_e_squared_z_w;
|
|
1050
|
+
sc_sub(minus_e_squared_z_w.bytes, ZERO.bytes, e_squared_z_w.bytes);
|
|
1051
|
+
rct::key minus_e_squared_w_y;
|
|
1052
|
+
sc_sub(minus_e_squared_w_y.bytes, ZERO.bytes, e_squared.bytes);
|
|
1053
|
+
sc_mul(minus_e_squared_w_y.bytes, minus_e_squared_w_y.bytes, weight.bytes);
|
|
1054
|
+
sc_mul(minus_e_squared_w_y.bytes, minus_e_squared_w_y.bytes, y_MN.bytes);
|
|
1055
|
+
for (size_t i = 0; i < MN; ++i)
|
|
1056
|
+
{
|
|
1057
|
+
rct::key g_scalar = copy(e_r1_w_y);
|
|
1058
|
+
rct::key h_scalar;
|
|
1059
|
+
|
|
1060
|
+
// Use the binary decomposition of the index
|
|
1061
|
+
sc_muladd(g_scalar.bytes, g_scalar.bytes, challenges_cache[i].bytes, e_squared_z_w.bytes);
|
|
1062
|
+
sc_muladd(h_scalar.bytes, e_s1_w.bytes, challenges_cache[(~i) & (MN-1)].bytes, minus_e_squared_z_w.bytes);
|
|
1063
|
+
|
|
1064
|
+
// Complete the scalar derivation
|
|
1065
|
+
sc_add(Gi_scalars[i].bytes, Gi_scalars[i].bytes, g_scalar.bytes);
|
|
1066
|
+
sc_muladd(h_scalar.bytes, minus_e_squared_w_y.bytes, d[i].bytes, h_scalar.bytes);
|
|
1067
|
+
sc_add(Hi_scalars[i].bytes, Hi_scalars[i].bytes, h_scalar.bytes);
|
|
1068
|
+
|
|
1069
|
+
// Update iterated values
|
|
1070
|
+
sc_mul(e_r1_w_y.bytes, e_r1_w_y.bytes, yinv.bytes);
|
|
1071
|
+
sc_mul(minus_e_squared_w_y.bytes, minus_e_squared_w_y.bytes, yinv.bytes);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// L_j: -weight*e*e*challenges[j]**2
|
|
1075
|
+
// R_j: -weight*e*e*challenges[j]**(-2)
|
|
1076
|
+
for (size_t j = 0; j < rounds; ++j)
|
|
1077
|
+
{
|
|
1078
|
+
sc_mul(temp.bytes, pd.challenges[j].bytes, pd.challenges[j].bytes);
|
|
1079
|
+
sc_mul(temp.bytes, temp.bytes, minus_weight_e_squared.bytes);
|
|
1080
|
+
multiexp_data.emplace_back(temp, proof8_L[j]);
|
|
1081
|
+
|
|
1082
|
+
sc_mul(temp.bytes, challenges_inv[j].bytes, challenges_inv[j].bytes);
|
|
1083
|
+
sc_mul(temp.bytes, temp.bytes, minus_weight_e_squared.bytes);
|
|
1084
|
+
multiexp_data.emplace_back(temp, proof8_R[j]);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// Verify all proofs in the weighted batch
|
|
1089
|
+
multiexp_data.emplace_back(G_scalar, rct::G);
|
|
1090
|
+
multiexp_data.emplace_back(H_scalar, rct::H);
|
|
1091
|
+
for (size_t i = 0; i < maxMN; ++i)
|
|
1092
|
+
{
|
|
1093
|
+
multiexp_data[i * 2] = {Gi_scalars[i], Gi_p3[i]};
|
|
1094
|
+
multiexp_data[i * 2 + 1] = {Hi_scalars[i], Hi_p3[i]};
|
|
1095
|
+
}
|
|
1096
|
+
if (!(multiexp(multiexp_data, 2 * maxMN) == rct::identity()))
|
|
1097
|
+
{
|
|
1098
|
+
MERROR("Verification failure");
|
|
1099
|
+
return false;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
return true;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
bool bulletproof_plus_VERIFY(const std::vector<BulletproofPlus> &proofs)
|
|
1106
|
+
{
|
|
1107
|
+
std::vector<const BulletproofPlus*> proof_pointers;
|
|
1108
|
+
proof_pointers.reserve(proofs.size());
|
|
1109
|
+
for (const BulletproofPlus &proof: proofs)
|
|
1110
|
+
proof_pointers.push_back(&proof);
|
|
1111
|
+
return bulletproof_plus_VERIFY(proof_pointers);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
bool bulletproof_plus_VERIFY(const BulletproofPlus &proof)
|
|
1115
|
+
{
|
|
1116
|
+
std::vector<const BulletproofPlus*> proofs;
|
|
1117
|
+
proofs.push_back(&proof);
|
|
1118
|
+
return bulletproof_plus_VERIFY(proofs);
|
|
1119
|
+
}
|
|
1120
|
+
}
|