@onekeyfe/react-native-lite-card 6.7.0-alpha.407 → 6.7.0-alpha.411
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/README.md +9 -1
- package/ReactNativeLiteCard.podspec +25 -2
- package/android/build.gradle +7 -0
- package/android/src/main/cpp/CMakeLists.txt +6 -2
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +7 -7
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt +6 -3
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +5 -1
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +21 -7
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +4 -1
- package/ios/Classes/OKNFCBridge.mm +1 -1
- package/ios/Classes/OKNFTLite/OKLiteV1.m +6 -3
- package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
- package/package.json +2 -2
- package/sdk/CMakeLists.txt +120 -0
- package/sdk/README.md +175 -0
- package/sdk/android/implJni.cpp +177 -0
- package/sdk/deps/jsoncpp/LICENSE +55 -0
- package/sdk/deps/jsoncpp/include/CMakeLists.txt +2 -0
- package/sdk/deps/jsoncpp/include/json/allocator.h +98 -0
- package/sdk/deps/jsoncpp/include/json/assertions.h +54 -0
- package/sdk/deps/jsoncpp/include/json/autolink.h +25 -0
- package/sdk/deps/jsoncpp/include/json/config.h +187 -0
- package/sdk/deps/jsoncpp/include/json/features.h +61 -0
- package/sdk/deps/jsoncpp/include/json/forwards.h +37 -0
- package/sdk/deps/jsoncpp/include/json/json.h +15 -0
- package/sdk/deps/jsoncpp/include/json/reader.h +411 -0
- package/sdk/deps/jsoncpp/include/json/value.h +888 -0
- package/sdk/deps/jsoncpp/include/json/version.h +20 -0
- package/sdk/deps/jsoncpp/include/json/writer.h +357 -0
- package/sdk/deps/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_tool.h +114 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_value.cpp +1661 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
- package/sdk/deps/jsoncpp/src/lib_json/version.h.in +20 -0
- package/sdk/deps/trezor-crypto/AUTHORS +2 -0
- package/sdk/deps/trezor-crypto/LICENSE +22 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/TrezorCrypto.h +29 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/address.h +44 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/aes.h +224 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/base32.h +49 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/base58.h +58 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/bignum.h +169 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip32.h +114 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip39.h +66 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake256.h +61 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2b.h +50 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2s.h +49 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/cash_addr.h +109 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-config.h +316 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-sync.h +289 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-types.h +53 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/poly1305-donna.h +28 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305.h +27 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/cmac.h +44 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/curves.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ecdsa.h +112 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-32bit.h +87 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-helpers.h +30 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-blake2b.h +21 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h +25 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-basepoint-table.h +10 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-impl-base.h +110 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-portable.h +32 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-keccak.h +21 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-sha3.h +21 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/modm-donna-32bit.h +87 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519.h +42 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/endian.h +132 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/groestl.h +104 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/hasher.h +90 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/hmac.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/memzero.h +16 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/base58.h +42 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/monero.h +13 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/range_proof.h +30 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/serialize.h +15 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/xmr.h +67 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/nano.h +56 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/nem.h +199 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/nist256p1.h +35 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/pbkdf2.h +64 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/rand.h +44 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/rc4.h +37 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/rfc6979.h +40 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripemd160.h +28 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripple/base58.h +45 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/schnorr.h +48 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/script.h +30 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/scrypt.h +68 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/secp256k1.h +59 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha2.h +125 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha3.h +86 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/keypair.h +20 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10.h +85 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10_fe_25_5.h +43 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/constants.h +29 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/fe.h +25 -0
- package/sdk/deps/trezor-crypto/src/address.c +87 -0
- package/sdk/deps/trezor-crypto/src/aes/aes_modes.c +959 -0
- package/sdk/deps/trezor-crypto/src/aes/aescrypt.c +307 -0
- package/sdk/deps/trezor-crypto/src/aes/aeskey.c +560 -0
- package/sdk/deps/trezor-crypto/src/aes/aesopt.h +784 -0
- package/sdk/deps/trezor-crypto/src/aes/aestab.c +418 -0
- package/sdk/deps/trezor-crypto/src/aes/aestab.h +173 -0
- package/sdk/deps/trezor-crypto/src/base32.c +233 -0
- package/sdk/deps/trezor-crypto/src/base58.c +298 -0
- package/sdk/deps/trezor-crypto/src/bignum.c +808 -0
- package/sdk/deps/trezor-crypto/src/bip32.c +852 -0
- package/sdk/deps/trezor-crypto/src/bip39.c +266 -0
- package/sdk/deps/trezor-crypto/src/bip39_english.h +2074 -0
- package/sdk/deps/trezor-crypto/src/blake256.c +235 -0
- package/sdk/deps/trezor-crypto/src/blake2_common.h +39 -0
- package/sdk/deps/trezor-crypto/src/blake2b.c +333 -0
- package/sdk/deps/trezor-crypto/src/blake2s.c +318 -0
- package/sdk/deps/trezor-crypto/src/cash_addr.c +195 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha20poly1305.c +60 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha_merged.c +246 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-machine.h +49 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-portable.h +275 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna-32.h +219 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna.c +179 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.c +48 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.h +10 -0
- package/sdk/deps/trezor-crypto/src/check_mem.h +30 -0
- package/sdk/deps/trezor-crypto/src/cmac.c +342 -0
- package/sdk/deps/trezor-crypto/src/curves.c +48 -0
- package/sdk/deps/trezor-crypto/src/ecdsa.c +1355 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/README.md +183 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-32bit.c +681 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-helpers.c +66 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.c +67 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.h +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-blake2b.c +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-32bit-tables.c +63 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-basepoint-table.c +261 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-impl-base.c +722 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-blake2b.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-keccak.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-sha3.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-keccak.c +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-sha3.c +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519.c +311 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/modm-donna-32bit.c +517 -0
- package/sdk/deps/trezor-crypto/src/groestl.c +783 -0
- package/sdk/deps/trezor-crypto/src/groestl_internal.h +419 -0
- package/sdk/deps/trezor-crypto/src/hasher.c +186 -0
- package/sdk/deps/trezor-crypto/src/hmac.c +179 -0
- package/sdk/deps/trezor-crypto/src/memzero.c +6 -0
- package/sdk/deps/trezor-crypto/src/monero/base58.c +245 -0
- package/sdk/deps/trezor-crypto/src/monero/int-util.h +77 -0
- package/sdk/deps/trezor-crypto/src/monero/range_proof.c +115 -0
- package/sdk/deps/trezor-crypto/src/monero/serialize.c +54 -0
- package/sdk/deps/trezor-crypto/src/monero/xmr.c +136 -0
- package/sdk/deps/trezor-crypto/src/nano.c +151 -0
- package/sdk/deps/trezor-crypto/src/nem.c +569 -0
- package/sdk/deps/trezor-crypto/src/nist256p1.c +63 -0
- package/sdk/deps/trezor-crypto/src/nist256p1.table +1664 -0
- package/sdk/deps/trezor-crypto/src/options.h +43 -0
- package/sdk/deps/trezor-crypto/src/pbkdf2.c +177 -0
- package/sdk/deps/trezor-crypto/src/rand.c +51 -0
- package/sdk/deps/trezor-crypto/src/rc4.c +56 -0
- package/sdk/deps/trezor-crypto/src/ripemd160.c +343 -0
- package/sdk/deps/trezor-crypto/src/ripple/base58.c +76 -0
- package/sdk/deps/trezor-crypto/src/schnorr.c +208 -0
- package/sdk/deps/trezor-crypto/src/script.c +64 -0
- package/sdk/deps/trezor-crypto/src/scrypt.c +343 -0
- package/sdk/deps/trezor-crypto/src/secp256k1.c +160 -0
- package/sdk/deps/trezor-crypto/src/secp256k1.table +1664 -0
- package/sdk/deps/trezor-crypto/src/setup.py +38 -0
- package/sdk/deps/trezor-crypto/src/sha2.c +1314 -0
- package/sdk/deps/trezor-crypto/src/sha3.c +395 -0
- package/sdk/deps/trezor-crypto/src/shell.nix +6 -0
- package/sdk/deps/trezor-crypto/src/sodium/keypair.c +63 -0
- package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10.c +481 -0
- package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10_fe_25_5.c +885 -0
- package/sdk/deps/trezor-crypto/src/sodium/private/fe_25_5/fe.c +237 -0
- package/sdk/gpc/include/scp03/scp03.hpp +80 -0
- package/sdk/gpc/include/scp11/scp11.hpp +492 -0
- package/sdk/gpc/include/scp11/scp11c.hpp +58 -0
- package/sdk/gpc/include/tag.h +68 -0
- package/sdk/gpc/include/tlv.hpp +94 -0
- package/sdk/gpc/include/tlvparse.hpp +24 -0
- package/sdk/gpc/src/scp03.cpp +243 -0
- package/sdk/gpc/src/scp11.cpp +798 -0
- package/sdk/gpc/src/scp11c.cpp +136 -0
- package/sdk/gpc/src/tlv.cpp +159 -0
- package/sdk/gpc/src/tlvparse.c +174 -0
- package/{framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers → sdk/include}/GPChannelSDK.h +0 -0
- package/sdk/include/GPChannelSDKCore.h +10 -0
- package/sdk/include/context/BaseContext.h +56 -0
- package/sdk/include/device/ApduBuilder.hpp +72 -0
- package/sdk/include/mSIGNA/stdutils/uchar_vector.h +36 -0
- package/sdk/include/utility/Apdu.hpp +172 -0
- package/sdk/include/utility/Debug.hpp +3 -0
- package/sdk/include/utility/util.h +104 -0
- package/sdk/src/ApduBuilder.cpp +332 -0
- package/sdk/src/GPChannelSDK.cpp +252 -0
- package/sdk/src/random.c +25 -0
- package/sdk/src/version.c +2 -0
- package/sdk/tests/android/GPChannelProxy.java +55 -0
- package/sdk/tests/android_verify.py +121 -0
- package/sdk/tests/safety.cpp +603 -0
- package/sdk/tests/verify.py +267 -0
- package/android/src/main/jniLibs/arm64-v8a/libgpchannelNDK.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libgpchannelNDK.so +0 -0
- package/framework/GPChannelSDKCore.xcframework/Info.plist +0 -52
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Info.plist +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +0 -315
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Info.plist +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
|
2
|
+
// Run CMake configure step to update it.
|
|
3
|
+
#ifndef JSON_VERSION_H_INCLUDED
|
|
4
|
+
# define JSON_VERSION_H_INCLUDED
|
|
5
|
+
|
|
6
|
+
# define JSONCPP_VERSION_STRING "@JSONCPP_VERSION@"
|
|
7
|
+
# define JSONCPP_VERSION_MAJOR @JSONCPP_VERSION_MAJOR@
|
|
8
|
+
# define JSONCPP_VERSION_MINOR @JSONCPP_VERSION_MINOR@
|
|
9
|
+
# define JSONCPP_VERSION_PATCH @JSONCPP_VERSION_PATCH@
|
|
10
|
+
# define JSONCPP_VERSION_QUALIFIER
|
|
11
|
+
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
|
12
|
+
|
|
13
|
+
#ifdef JSONCPP_USING_SECURE_MEMORY
|
|
14
|
+
#undef JSONCPP_USING_SECURE_MEMORY
|
|
15
|
+
#endif
|
|
16
|
+
#define JSONCPP_USING_SECURE_MEMORY @JSONCPP_USE_SECURE_MEMORY@
|
|
17
|
+
// If non-zero, the library zeroes any memory that it has allocated before
|
|
18
|
+
// it frees its memory.
|
|
19
|
+
|
|
20
|
+
#endif // JSON_VERSION_H_INCLUDED
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 Tomas Dzetkulic
|
|
4
|
+
Copyright (c) 2013 Pavol Rusnak
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright © 2017-2020 Trust Wallet.
|
|
2
|
+
//
|
|
3
|
+
// This file is part of Trust. The full Trust copyright notice, including
|
|
4
|
+
// terms governing use, modification, and redistribution, is contained in the
|
|
5
|
+
// file LICENSE at the root of the source code distribution tree.
|
|
6
|
+
|
|
7
|
+
#include <TrezorCrypto/address.h>
|
|
8
|
+
#include <TrezorCrypto/aes.h>
|
|
9
|
+
#include <TrezorCrypto/base32.h>
|
|
10
|
+
#include <TrezorCrypto/bignum.h>
|
|
11
|
+
#include <TrezorCrypto/bip32.h>
|
|
12
|
+
#include <TrezorCrypto/bip39.h>
|
|
13
|
+
#include <TrezorCrypto/blake2b.h>
|
|
14
|
+
#include <TrezorCrypto/blake256.h>
|
|
15
|
+
#include <TrezorCrypto/cash_addr.h>
|
|
16
|
+
#include <TrezorCrypto/curves.h>
|
|
17
|
+
#include <TrezorCrypto/ed25519.h>
|
|
18
|
+
#include <TrezorCrypto/hasher.h>
|
|
19
|
+
#include <TrezorCrypto/hmac.h>
|
|
20
|
+
#include <TrezorCrypto/memzero.h>
|
|
21
|
+
#include <TrezorCrypto/monero.h>
|
|
22
|
+
#include <TrezorCrypto/nem.h>
|
|
23
|
+
#include <TrezorCrypto/nist256p1.h>
|
|
24
|
+
#include <TrezorCrypto/pbkdf2.h>
|
|
25
|
+
#include <TrezorCrypto/rand.h>
|
|
26
|
+
#include <TrezorCrypto/ripemd160.h>
|
|
27
|
+
#include <TrezorCrypto/secp256k1.h>
|
|
28
|
+
#include <TrezorCrypto/sha2.h>
|
|
29
|
+
#include <TrezorCrypto/sha3.h>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016 Daira Hopwood
|
|
3
|
+
* Copyright (c) 2016 Pavol Rusnak
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files (the "Software"),
|
|
7
|
+
* to deal in the Software without restriction, including without limitation
|
|
8
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
9
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
10
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included
|
|
13
|
+
* in all copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
19
|
+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
20
|
+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
21
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#ifndef __ADDRESS_H__
|
|
25
|
+
#define __ADDRESS_H__
|
|
26
|
+
|
|
27
|
+
#include <stdint.h>
|
|
28
|
+
#include <stdbool.h>
|
|
29
|
+
#include <stddef.h>
|
|
30
|
+
|
|
31
|
+
#ifdef __cplusplus
|
|
32
|
+
extern "C" {
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
size_t address_prefix_bytes_len(uint32_t address_type);
|
|
36
|
+
void address_write_prefix_bytes(uint32_t address_type, uint8_t *out);
|
|
37
|
+
bool address_check_prefix(const uint8_t *addr, uint32_t address_type);
|
|
38
|
+
void ethereum_address_checksum(const uint8_t *addr, char *address, bool rskip60, uint32_t chain_id);
|
|
39
|
+
|
|
40
|
+
#ifdef __cplusplus
|
|
41
|
+
} /* extern "C" */
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
#endif
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/*
|
|
2
|
+
---------------------------------------------------------------------------
|
|
3
|
+
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
|
4
|
+
|
|
5
|
+
The redistribution and use of this software (with or without changes)
|
|
6
|
+
is allowed without the payment of fees or royalties provided that:
|
|
7
|
+
|
|
8
|
+
source code distributions include the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer;
|
|
10
|
+
|
|
11
|
+
binary distributions include the above copyright notice, this list
|
|
12
|
+
of conditions and the following disclaimer in their documentation.
|
|
13
|
+
|
|
14
|
+
This software is provided 'as is' with no explicit or implied warranties
|
|
15
|
+
in respect of its operation, including, but not limited to, correctness
|
|
16
|
+
and fitness for purpose.
|
|
17
|
+
---------------------------------------------------------------------------
|
|
18
|
+
Issue Date: 02/08/2018
|
|
19
|
+
|
|
20
|
+
This file contains the definitions required to use AES in C. See aesopt.h
|
|
21
|
+
for optimisation details.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#ifndef _AES_H
|
|
25
|
+
#define _AES_H
|
|
26
|
+
|
|
27
|
+
#include <stdlib.h>
|
|
28
|
+
#include <stdint.h>
|
|
29
|
+
|
|
30
|
+
#define VOID_RETURN void
|
|
31
|
+
#define INT_RETURN int
|
|
32
|
+
#define ALIGN_OFFSET(x,n) (((intptr_t)(x)) & ((n) - 1))
|
|
33
|
+
#define ALIGN_FLOOR(x,n) ((uint8_t*)(x) - ( ((intptr_t)(x)) & ((n) - 1)))
|
|
34
|
+
#define ALIGN_CEIL(x,n) ((uint8_t*)(x) + (-((intptr_t)(x)) & ((n) - 1)))
|
|
35
|
+
|
|
36
|
+
#if defined(__cplusplus)
|
|
37
|
+
extern "C"
|
|
38
|
+
{
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
#define AES_128 /* if a fast 128 bit key scheduler is needed */
|
|
42
|
+
// #define AES_192 /* if a fast 192 bit key scheduler is needed */
|
|
43
|
+
#define AES_256 /* if a fast 256 bit key scheduler is needed */
|
|
44
|
+
#define AES_VAR /* if variable key size scheduler is needed */
|
|
45
|
+
#define AES_MODES /* if support is needed for modes in the C code */
|
|
46
|
+
#if 0 /* add this to make direct calls to the AES_NI */
|
|
47
|
+
# /* implemented CBC and CTR modes available */
|
|
48
|
+
# define ADD_AESNI_MODE_CALLS
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
/* The following must also be set in assembler files if being used */
|
|
52
|
+
|
|
53
|
+
#define AES_ENCRYPT /* if support for encryption is needed */
|
|
54
|
+
#define AES_DECRYPT /* if support for decryption is needed */
|
|
55
|
+
|
|
56
|
+
#define AES_BLOCK_SIZE_P2 4 /* AES block size as a power of 2 */
|
|
57
|
+
#define AES_BLOCK_SIZE (1 << AES_BLOCK_SIZE_P2) /* AES block size */
|
|
58
|
+
#define N_COLS 4 /* the number of columns in the state */
|
|
59
|
+
|
|
60
|
+
/* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */
|
|
61
|
+
/* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */
|
|
62
|
+
/* or 44, 52 or 60 32-bit words. */
|
|
63
|
+
|
|
64
|
+
#if defined( AES_VAR ) || defined( AES_256 )
|
|
65
|
+
#define KS_LENGTH 60
|
|
66
|
+
#elif defined( AES_192 )
|
|
67
|
+
#define KS_LENGTH 52
|
|
68
|
+
#else
|
|
69
|
+
#define KS_LENGTH 44
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
#define AES_RETURN INT_RETURN
|
|
73
|
+
|
|
74
|
+
/* the character array 'inf' in the following structures is used */
|
|
75
|
+
/* to hold AES context information. This AES code uses cx->inf.b[0] */
|
|
76
|
+
/* to hold the number of rounds multiplied by 16. The other three */
|
|
77
|
+
/* elements can be used by code that implements additional modes */
|
|
78
|
+
|
|
79
|
+
typedef union
|
|
80
|
+
{ uint32_t l;
|
|
81
|
+
uint8_t b[4];
|
|
82
|
+
} aes_inf;
|
|
83
|
+
|
|
84
|
+
#ifdef _MSC_VER
|
|
85
|
+
# pragma warning( disable : 4324 )
|
|
86
|
+
#endif
|
|
87
|
+
|
|
88
|
+
#if defined(_MSC_VER) && defined(_WIN64)
|
|
89
|
+
#define ALIGNED_(x) __declspec(align(x))
|
|
90
|
+
#elif defined(__GNUC__) && defined(__x86_64__)
|
|
91
|
+
#define ALIGNED_(x) __attribute__ ((aligned(x)))
|
|
92
|
+
#else
|
|
93
|
+
#define ALIGNED_(x)
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
typedef struct ALIGNED_(16)
|
|
97
|
+
{ uint32_t ks[KS_LENGTH];
|
|
98
|
+
aes_inf inf;
|
|
99
|
+
} aes_encrypt_ctx;
|
|
100
|
+
|
|
101
|
+
typedef struct ALIGNED_(16)
|
|
102
|
+
{ uint32_t ks[KS_LENGTH];
|
|
103
|
+
aes_inf inf;
|
|
104
|
+
} aes_decrypt_ctx;
|
|
105
|
+
|
|
106
|
+
#ifdef _MSC_VER
|
|
107
|
+
# pragma warning( default : 4324 )
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
/* This routine must be called before first use if non-static */
|
|
111
|
+
/* tables are being used */
|
|
112
|
+
|
|
113
|
+
AES_RETURN aes_init(void);
|
|
114
|
+
|
|
115
|
+
/* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */
|
|
116
|
+
/* those in the range 128 <= key_len <= 256 are given in bits */
|
|
117
|
+
|
|
118
|
+
#if defined( AES_ENCRYPT )
|
|
119
|
+
|
|
120
|
+
#if defined( AES_128 ) || defined( AES_VAR)
|
|
121
|
+
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
|
122
|
+
#endif
|
|
123
|
+
|
|
124
|
+
#if defined( AES_192 ) || defined( AES_VAR)
|
|
125
|
+
AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
|
126
|
+
#endif
|
|
127
|
+
|
|
128
|
+
#if defined( AES_256 ) || defined( AES_VAR)
|
|
129
|
+
AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
#if defined( AES_VAR )
|
|
133
|
+
AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]);
|
|
134
|
+
#endif
|
|
135
|
+
|
|
136
|
+
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]);
|
|
137
|
+
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
#if defined( AES_DECRYPT )
|
|
141
|
+
|
|
142
|
+
#if defined( AES_128 ) || defined( AES_VAR)
|
|
143
|
+
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
#if defined( AES_192 ) || defined( AES_VAR)
|
|
147
|
+
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
#if defined( AES_256 ) || defined( AES_VAR)
|
|
151
|
+
AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
|
152
|
+
#endif
|
|
153
|
+
|
|
154
|
+
#if defined( AES_VAR )
|
|
155
|
+
AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]);
|
|
156
|
+
#endif
|
|
157
|
+
|
|
158
|
+
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]);
|
|
159
|
+
|
|
160
|
+
#endif
|
|
161
|
+
|
|
162
|
+
#if defined( AES_MODES )
|
|
163
|
+
|
|
164
|
+
/* Multiple calls to the following subroutines for multiple block */
|
|
165
|
+
/* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */
|
|
166
|
+
/* long messages incrementally provided that the context AND the iv */
|
|
167
|
+
/* are preserved between all such calls. For the ECB and CBC modes */
|
|
168
|
+
/* each individual call within a series of incremental calls must */
|
|
169
|
+
/* process only full blocks (i.e. len must be a multiple of 16) but */
|
|
170
|
+
/* the CFB, OFB and CTR mode calls can handle multiple incremental */
|
|
171
|
+
/* calls of any length. Each mode is reset when a new AES key is */
|
|
172
|
+
/* set but ECB needs no reset and CBC can be reset without setting */
|
|
173
|
+
/* a new key by setting a new IV value. To reset CFB, OFB and CTR */
|
|
174
|
+
/* without setting the key, aes_mode_reset() must be called and the */
|
|
175
|
+
/* IV must be set. NOTE: All these calls update the IV on exit so */
|
|
176
|
+
/* this has to be reset if a new operation with the same IV as the */
|
|
177
|
+
/* previous one is required (or decryption follows encryption with */
|
|
178
|
+
/* the same IV array). */
|
|
179
|
+
|
|
180
|
+
AES_RETURN aes_test_alignment_detection(unsigned int n);
|
|
181
|
+
|
|
182
|
+
AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
183
|
+
int len, const aes_encrypt_ctx cx[1]);
|
|
184
|
+
|
|
185
|
+
AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
186
|
+
int len, const aes_decrypt_ctx cx[1]);
|
|
187
|
+
|
|
188
|
+
AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
189
|
+
int len, unsigned char *iv, const aes_encrypt_ctx cx[1]);
|
|
190
|
+
|
|
191
|
+
AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
192
|
+
int len, unsigned char *iv, const aes_decrypt_ctx cx[1]);
|
|
193
|
+
|
|
194
|
+
AES_RETURN aes_mode_reset(aes_encrypt_ctx cx[1]);
|
|
195
|
+
|
|
196
|
+
AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
197
|
+
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
|
|
198
|
+
|
|
199
|
+
AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
200
|
+
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
|
|
201
|
+
|
|
202
|
+
#define aes_ofb_encrypt aes_ofb_crypt
|
|
203
|
+
#define aes_ofb_decrypt aes_ofb_crypt
|
|
204
|
+
|
|
205
|
+
AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
206
|
+
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
|
|
207
|
+
|
|
208
|
+
typedef void cbuf_inc(unsigned char *cbuf);
|
|
209
|
+
|
|
210
|
+
#define aes_ctr_encrypt aes_ctr_crypt
|
|
211
|
+
#define aes_ctr_decrypt aes_ctr_crypt
|
|
212
|
+
|
|
213
|
+
AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf,
|
|
214
|
+
int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]);
|
|
215
|
+
|
|
216
|
+
void aes_ctr_cbuf_inc(unsigned char *cbuf);
|
|
217
|
+
|
|
218
|
+
#endif
|
|
219
|
+
|
|
220
|
+
#ifdef __cplusplus
|
|
221
|
+
} /* extern "C" */
|
|
222
|
+
#endif
|
|
223
|
+
|
|
224
|
+
#endif
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 Saleem Rashid
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
* a copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
* to deal in the Software without restriction, including without limitation
|
|
7
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included
|
|
12
|
+
* in all copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
18
|
+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
20
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
#ifndef __BASE32_H__
|
|
24
|
+
#define __BASE32_H__
|
|
25
|
+
|
|
26
|
+
#include <stdbool.h>
|
|
27
|
+
#include <stddef.h>
|
|
28
|
+
#include <stdint.h>
|
|
29
|
+
|
|
30
|
+
#ifdef __cplusplus
|
|
31
|
+
extern "C" {
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
extern const char *BASE32_ALPHABET_RFC4648;
|
|
35
|
+
|
|
36
|
+
char *base32_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen, const char *alphabet);
|
|
37
|
+
void base32_encode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out);
|
|
38
|
+
|
|
39
|
+
uint8_t *base32_decode(const char *in, size_t inlen, uint8_t *out, size_t outlen, const char *alphabet);
|
|
40
|
+
bool base32_decode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out, const char *alphabet);
|
|
41
|
+
|
|
42
|
+
size_t base32_encoded_length(size_t inlen);
|
|
43
|
+
size_t base32_decoded_length(size_t inlen);
|
|
44
|
+
|
|
45
|
+
#ifdef __cplusplus
|
|
46
|
+
} /* extern "C" */
|
|
47
|
+
#endif
|
|
48
|
+
|
|
49
|
+
#endif
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2013-2014 Tomas Dzetkulic
|
|
3
|
+
* Copyright (c) 2013-2014 Pavol Rusnak
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files (the "Software"),
|
|
7
|
+
* to deal in the Software without restriction, including without limitation
|
|
8
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
9
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
10
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included
|
|
13
|
+
* in all copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
19
|
+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
20
|
+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
21
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#ifndef __BASE58_H__
|
|
25
|
+
#define __BASE58_H__
|
|
26
|
+
|
|
27
|
+
#include <stdint.h>
|
|
28
|
+
#include <stdbool.h>
|
|
29
|
+
#include <TrezorCrypto/hasher.h>
|
|
30
|
+
|
|
31
|
+
#ifdef __cplusplus
|
|
32
|
+
extern "C" {
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
extern const char b58digits_ordered[];
|
|
36
|
+
extern const int8_t b58digits_map[];
|
|
37
|
+
|
|
38
|
+
int base58_encode_check(const uint8_t *data, int len, HasherType hasher_type, char *str, int strsize);
|
|
39
|
+
int base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen);
|
|
40
|
+
|
|
41
|
+
bool base58_to_bin(void *bin, size_t *binszp, const char *b58, const char digits[], const int8_t digits_map[]);
|
|
42
|
+
int base58_check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str, const char digits[]);
|
|
43
|
+
bool base58_encode(char *b58, size_t *b58sz, const void *data, size_t binsz, const char digits[]);
|
|
44
|
+
|
|
45
|
+
// Private
|
|
46
|
+
bool b58tobin(void *bin, size_t *binszp, const char *b58);
|
|
47
|
+
int b58check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str);
|
|
48
|
+
bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz);
|
|
49
|
+
|
|
50
|
+
int base58gph_encode_check(const uint8_t *data, int datalen, char *str, int strsize);
|
|
51
|
+
int base58gph_decode_check(const char *str, uint8_t *data, int datalen);
|
|
52
|
+
int b58gphcheck(const void *bin, size_t binsz, const char *base58str);
|
|
53
|
+
|
|
54
|
+
#ifdef __cplusplus
|
|
55
|
+
} /* extern "C" */
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
#endif
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2013-2014 Tomas Dzetkulic
|
|
3
|
+
* Copyright (c) 2013-2014 Pavol Rusnak
|
|
4
|
+
* Copyright (c) 2016 Alex Beregszaszi
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
* a copy of this software and associated documentation files (the "Software"),
|
|
8
|
+
* to deal in the Software without restriction, including without limitation
|
|
9
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
10
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
|
11
|
+
* Software is furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
19
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
20
|
+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#ifndef __BIGNUM_H__
|
|
26
|
+
#define __BIGNUM_H__
|
|
27
|
+
|
|
28
|
+
#include <stdbool.h>
|
|
29
|
+
#include <stddef.h>
|
|
30
|
+
#include <stdint.h>
|
|
31
|
+
|
|
32
|
+
#ifdef __cplusplus
|
|
33
|
+
extern "C" {
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
// bignum256 are 256 bits stored as 8*30 bit + 1*16 bit
|
|
37
|
+
// val[0] are lowest 30 bits, val[8] highest 16 bits
|
|
38
|
+
typedef struct {
|
|
39
|
+
uint32_t val[9];
|
|
40
|
+
} bignum256;
|
|
41
|
+
|
|
42
|
+
// read 4 big endian bytes into uint32
|
|
43
|
+
uint32_t read_be(const uint8_t *data);
|
|
44
|
+
|
|
45
|
+
// write 4 big endian bytes
|
|
46
|
+
void write_be(uint8_t *data, uint32_t x);
|
|
47
|
+
|
|
48
|
+
// read 4 little endian bytes into uint32
|
|
49
|
+
uint32_t read_le(const uint8_t *data);
|
|
50
|
+
|
|
51
|
+
// write 4 little endian bytes
|
|
52
|
+
void write_le(uint8_t *data, uint32_t x);
|
|
53
|
+
|
|
54
|
+
void bn_read_be(const uint8_t *in_number, bignum256 *out_number);
|
|
55
|
+
|
|
56
|
+
void bn_write_be(const bignum256 *in_number, uint8_t *out_number);
|
|
57
|
+
|
|
58
|
+
void bn_read_le(const uint8_t *in_number, bignum256 *out_number);
|
|
59
|
+
|
|
60
|
+
void bn_write_le(const bignum256 *in_number, uint8_t *out_number);
|
|
61
|
+
|
|
62
|
+
void bn_read_uint32(uint32_t in_number, bignum256 *out_number);
|
|
63
|
+
|
|
64
|
+
void bn_read_uint64(uint64_t in_number, bignum256 *out_number);
|
|
65
|
+
|
|
66
|
+
static inline uint32_t bn_write_uint32(const bignum256 *in_number)
|
|
67
|
+
{
|
|
68
|
+
return in_number->val[0] | (in_number->val[1] << 30);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static inline uint64_t bn_write_uint64(const bignum256 *in_number)
|
|
72
|
+
{
|
|
73
|
+
uint64_t tmp;
|
|
74
|
+
tmp = in_number->val[2];
|
|
75
|
+
tmp <<= 30;
|
|
76
|
+
tmp |= in_number->val[1];
|
|
77
|
+
tmp <<= 30;
|
|
78
|
+
tmp |= in_number->val[0];
|
|
79
|
+
return tmp;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// copies number a to b
|
|
83
|
+
static inline void bn_copy(const bignum256 *a, bignum256 *b) {
|
|
84
|
+
*b = *a;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
int bn_bitcount(const bignum256 *a);
|
|
88
|
+
|
|
89
|
+
unsigned int bn_digitcount(const bignum256 *a);
|
|
90
|
+
|
|
91
|
+
void bn_zero(bignum256 *a);
|
|
92
|
+
|
|
93
|
+
int bn_is_zero(const bignum256 *a);
|
|
94
|
+
|
|
95
|
+
void bn_one(bignum256 *a);
|
|
96
|
+
|
|
97
|
+
static inline int bn_is_even(const bignum256 *a) {
|
|
98
|
+
return (a->val[0] & 1) == 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static inline int bn_is_odd(const bignum256 *a) {
|
|
102
|
+
return (a->val[0] & 1) == 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
int bn_is_less(const bignum256 *a, const bignum256 *b);
|
|
106
|
+
|
|
107
|
+
int bn_is_equal(const bignum256 *a, const bignum256 *b);
|
|
108
|
+
|
|
109
|
+
void bn_cmov(bignum256 *res, int cond, const bignum256 *truecase, const bignum256 *falsecase);
|
|
110
|
+
|
|
111
|
+
void bn_lshift(bignum256 *a);
|
|
112
|
+
|
|
113
|
+
void bn_rshift(bignum256 *a);
|
|
114
|
+
|
|
115
|
+
void bn_setbit(bignum256 *a, uint8_t bit);
|
|
116
|
+
|
|
117
|
+
void bn_clearbit(bignum256 *a, uint8_t bit);
|
|
118
|
+
|
|
119
|
+
uint32_t bn_testbit(bignum256 *a, uint8_t bit);
|
|
120
|
+
|
|
121
|
+
void bn_xor(bignum256 *a, const bignum256 *b, const bignum256 *c);
|
|
122
|
+
|
|
123
|
+
void bn_mult_half(bignum256 *x, const bignum256 *prime);
|
|
124
|
+
|
|
125
|
+
void bn_mult_k(bignum256 *x, uint8_t k, const bignum256 *prime);
|
|
126
|
+
|
|
127
|
+
void bn_mod(bignum256 *x, const bignum256 *prime);
|
|
128
|
+
|
|
129
|
+
void bn_multiply(const bignum256 *k, bignum256 *x, const bignum256 *prime);
|
|
130
|
+
|
|
131
|
+
void bn_fast_mod(bignum256 *x, const bignum256 *prime);
|
|
132
|
+
|
|
133
|
+
void bn_sqrt(bignum256 *x, const bignum256 *prime);
|
|
134
|
+
|
|
135
|
+
void bn_inverse(bignum256 *x, const bignum256 *prime);
|
|
136
|
+
|
|
137
|
+
void bn_normalize(bignum256 *a);
|
|
138
|
+
|
|
139
|
+
void bn_add(bignum256 *a, const bignum256 *b);
|
|
140
|
+
|
|
141
|
+
void bn_addmod(bignum256 *a, const bignum256 *b, const bignum256 *prime);
|
|
142
|
+
|
|
143
|
+
void bn_addi(bignum256 *a, uint32_t b);
|
|
144
|
+
|
|
145
|
+
void bn_subi(bignum256 *a, uint32_t b, const bignum256 *prime);
|
|
146
|
+
|
|
147
|
+
void bn_subtractmod(const bignum256 *a, const bignum256 *b, bignum256 *res, const bignum256 *prime);
|
|
148
|
+
|
|
149
|
+
void bn_subtract(const bignum256 *a, const bignum256 *b, bignum256 *res);
|
|
150
|
+
|
|
151
|
+
void bn_divmod58(bignum256 *a, uint32_t *r);
|
|
152
|
+
|
|
153
|
+
void bn_divmod1000(bignum256 *a, uint32_t *r);
|
|
154
|
+
|
|
155
|
+
size_t bn_format(const bignum256 *amnt, const char *prefix, const char *suffix, unsigned int decimals, int exponent, bool trailing, char *out, size_t outlen);
|
|
156
|
+
|
|
157
|
+
static inline size_t bn_format_uint64(uint64_t amount, const char *prefix, const char *suffix, unsigned int decimals, int exponent, bool trailing, char *out, size_t outlen)
|
|
158
|
+
{
|
|
159
|
+
bignum256 amnt;
|
|
160
|
+
bn_read_uint64(amount, &amnt);
|
|
161
|
+
|
|
162
|
+
return bn_format(&amnt, prefix, suffix, decimals, exponent, trailing, out, outlen);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#ifdef __cplusplus
|
|
166
|
+
} /* extern "C" */
|
|
167
|
+
#endif
|
|
168
|
+
|
|
169
|
+
#endif
|