@onekeyfe/react-native-lite-card 6.7.0-6 → 6.7.0-61
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 +134 -43
- package/ReactNativeLiteCard.podspec +31 -2
- package/android/build.gradle +8 -0
- package/android/consumer-rules.pro +4 -0
- package/android/src/main/cpp/CMakeLists.txt +6 -2
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardModule.kt +60 -49
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +7 -7
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/OnekeyLiteCard.kt +117 -39
- 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 +24 -2
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +46 -19
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +38 -1
- package/ios/Classes/OKNFCBridge.mm +24 -1
- package/ios/Classes/OKNFTLite/OKLiteV1.m +20 -10
- package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
- package/ios/Classes/OKNFTLite/OKNFCManager.h +2 -2
- package/ios/Classes/OKNFTLite/OKNFCManager.m +110 -18
- package/ios/ReactNativeLiteCard.mm +23 -11
- package/lib/module/index.js +4 -4
- package/lib/typescript/src/NativeReactNativeLiteCard.d.ts +4 -4
- package/lib/typescript/src/index.d.ts +2 -2
- package/package.json +9 -8
- package/sdk/CMakeLists.txt +121 -0
- package/sdk/README.md +190 -0
- package/sdk/android/implJni.cpp +216 -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/scripts/generate-source-id.rb +22 -0
- package/sdk/source-id-manifest.txt +19 -0
- package/sdk/source-id.cmake +31 -0
- package/sdk/src/ApduBuilder.cpp +332 -0
- package/sdk/src/GPChannelSDK.cpp +258 -0
- package/sdk/src/random.c +25 -0
- package/sdk/src/version.c +3 -0
- package/sdk/tests/android/GPChannelProxy.java +55 -0
- package/sdk/tests/android_verify.py +124 -0
- package/sdk/tests/safety.cpp +757 -0
- package/sdk/tests/verify.py +284 -0
- package/src/NativeReactNativeLiteCard.ts +4 -2
- package/src/index.tsx +14 -3
- 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,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 tools.ietf.org
|
|
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 HMAC_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
|
+
// code from: https://tools.ietf.org/html/rfc4493
|
|
23
|
+
// check: https://artjomb.github.io/cryptojs-extension/
|
|
24
|
+
#ifndef __CMAC_H__
|
|
25
|
+
#define __CMAC_H__
|
|
26
|
+
|
|
27
|
+
#include <stdint.h>
|
|
28
|
+
#include <TrezorCrypto/aes.h>
|
|
29
|
+
|
|
30
|
+
#ifdef __cplusplus
|
|
31
|
+
extern "C" {
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
extern unsigned char const_Zero[16];
|
|
35
|
+
|
|
36
|
+
void AES_CMAC(unsigned char *key, unsigned char *input, int length,
|
|
37
|
+
unsigned char *mac);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#ifdef __cplusplus
|
|
41
|
+
} /* extern "C" */
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
#endif
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016 Jochen Hoenicke
|
|
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 __CURVES_H__
|
|
24
|
+
#define __CURVES_H__
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
extern const char SECP256K1_NAME[];
|
|
31
|
+
// JuBiter-defined
|
|
32
|
+
extern const char SECP256K1_ETH_NAME[];
|
|
33
|
+
// JuBiter-defined
|
|
34
|
+
extern const char SECP256K1_XRP_NAME[];
|
|
35
|
+
// JuBiter-defined
|
|
36
|
+
extern const char SECP256K1_HCASH_NAME[];
|
|
37
|
+
// JuBiter-defined
|
|
38
|
+
extern const char SECP256K1_EOS_NAME[];
|
|
39
|
+
// JuBiter-defined
|
|
40
|
+
extern const char SECP256K1_TRX_NAME[];
|
|
41
|
+
// JuBiter-defined
|
|
42
|
+
extern const char SECP256K1_FIL_NAME[];
|
|
43
|
+
// JuBiter-defined
|
|
44
|
+
extern const char SECP256K1_CKB_NAME[];
|
|
45
|
+
extern const char SECP256K1_DECRED_NAME[];
|
|
46
|
+
extern const char SECP256K1_GROESTL_NAME[];
|
|
47
|
+
extern const char SECP256K1_SMART_NAME[];
|
|
48
|
+
extern const char NIST256P1_NAME[];
|
|
49
|
+
extern const char ED25519_NAME[];
|
|
50
|
+
extern const char ED25519_CARDANO_NAME[];
|
|
51
|
+
extern const char ED25519_BLAKE2B_NANO_NAME[];
|
|
52
|
+
extern const char ED25519_SHA3_NAME[];
|
|
53
|
+
extern const char ED25519_KECCAK_NAME[];
|
|
54
|
+
extern const char CURVE25519_NAME[];
|
|
55
|
+
|
|
56
|
+
#ifdef __cplusplus
|
|
57
|
+
} /* extern "C" */
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#endif
|
|
@@ -0,0 +1,112 @@
|
|
|
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 __ECDSA_H__
|
|
25
|
+
#define __ECDSA_H__
|
|
26
|
+
|
|
27
|
+
#include <stdint.h>
|
|
28
|
+
#include <TrezorCrypto/bignum.h>
|
|
29
|
+
#include <TrezorCrypto/hasher.h>
|
|
30
|
+
|
|
31
|
+
#if defined(__cplusplus)
|
|
32
|
+
extern "C"
|
|
33
|
+
{
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
// curve point x and y
|
|
37
|
+
typedef struct {
|
|
38
|
+
bignum256 x, y;
|
|
39
|
+
} curve_point;
|
|
40
|
+
|
|
41
|
+
typedef struct {
|
|
42
|
+
|
|
43
|
+
bignum256 prime; // prime order of the finite field
|
|
44
|
+
curve_point G; // initial curve point
|
|
45
|
+
bignum256 order; // order of G
|
|
46
|
+
bignum256 order_half; // order of G divided by 2
|
|
47
|
+
int a; // coefficient 'a' of the elliptic curve
|
|
48
|
+
bignum256 b; // coefficient 'b' of the elliptic curve
|
|
49
|
+
|
|
50
|
+
const curve_point cp[64][8];
|
|
51
|
+
} ecdsa_curve;
|
|
52
|
+
|
|
53
|
+
// 4 byte prefix + 40 byte data (segwit)
|
|
54
|
+
// 1 byte prefix + 64 byte data (cashaddr)
|
|
55
|
+
#define MAX_ADDR_RAW_SIZE 65
|
|
56
|
+
// bottle neck is cashaddr
|
|
57
|
+
// segwit is at most 90 characters plus NUL separator
|
|
58
|
+
// cashaddr: human readable prefix + 1 separator + 104 data + 8 checksum + 1 NUL
|
|
59
|
+
// we choose 130 as maximum (including NUL character)
|
|
60
|
+
#define MAX_ADDR_SIZE 130
|
|
61
|
+
// 4 byte prefix + 32 byte privkey + 1 byte compressed marker
|
|
62
|
+
#define MAX_WIF_RAW_SIZE (4 + 32 + 1)
|
|
63
|
+
// (4 + 32 + 1 + 4 [checksum]) * 8 / log2(58) plus NUL.
|
|
64
|
+
#define MAX_WIF_SIZE (57)
|
|
65
|
+
|
|
66
|
+
void point_copy(const curve_point *cp1, curve_point *cp2);
|
|
67
|
+
void point_add(const ecdsa_curve *curve, const curve_point *cp1, curve_point *cp2);
|
|
68
|
+
void point_double(const ecdsa_curve *curve, curve_point *cp);
|
|
69
|
+
void point_multiply(const ecdsa_curve *curve, const bignum256 *k, const curve_point *p, curve_point *res);
|
|
70
|
+
void point_set_infinity(curve_point *p);
|
|
71
|
+
int point_is_infinity(const curve_point *p);
|
|
72
|
+
int point_is_equal(const curve_point *p, const curve_point *q);
|
|
73
|
+
int point_is_negative_of(const curve_point *p, const curve_point *q);
|
|
74
|
+
void scalar_multiply(const ecdsa_curve *curve, const bignum256 *k, curve_point *res);
|
|
75
|
+
int ecdh_multiply(const ecdsa_curve *curve, const uint8_t *priv_key, const uint8_t *pub_key, uint8_t *session_key);
|
|
76
|
+
void compress_coords(const curve_point *cp, uint8_t *compressed);
|
|
77
|
+
void uncompress_coords(const ecdsa_curve *curve, uint8_t odd, const bignum256 *x, bignum256 *y);
|
|
78
|
+
int ecdsa_uncompress_pubkey(const ecdsa_curve *curve, const uint8_t *pub_key, uint8_t *uncompressed);
|
|
79
|
+
|
|
80
|
+
int ecdsa_sign(const ecdsa_curve *curve, HasherType hasher_sign, const uint8_t *priv_key, const uint8_t *msg, uint32_t msg_len, uint8_t *sig, uint8_t *pby, int (*is_canonical)(uint8_t by, uint8_t sig[64]));
|
|
81
|
+
int ecdsa_sign_digest(const ecdsa_curve *curve, const uint8_t *priv_key, const uint8_t *digest, uint8_t *sig, uint8_t *pby, int (*is_canonical)(uint8_t by, uint8_t sig[64]));
|
|
82
|
+
void ecdsa_get_public_key33(const ecdsa_curve *curve, const uint8_t *priv_key, uint8_t *pub_key);
|
|
83
|
+
void ecdsa_get_public_key65(const ecdsa_curve *curve, const uint8_t *priv_key, uint8_t *pub_key);
|
|
84
|
+
void ecdsa_get_pubkeyhash(const uint8_t *pub_key, HasherType hasher_pubkey, uint8_t *pubkeyhash);
|
|
85
|
+
void ecdsa_get_address_raw(const uint8_t *pub_key, uint32_t version, HasherType hasher_pubkey, uint8_t *addr_raw);
|
|
86
|
+
void ecdsa_get_address(const uint8_t *pub_key, uint32_t version, HasherType hasher_pubkey, HasherType hasher_base58, char *addr, int addrsize);
|
|
87
|
+
void ecdsa_get_address_segwit_p2sh_raw(const uint8_t *pub_key, uint32_t version, HasherType hasher_pubkey, uint8_t *addr_raw);
|
|
88
|
+
void ecdsa_get_address_segwit_p2sh(const uint8_t *pub_key, uint32_t version, HasherType hasher_pubkey, HasherType hasher_base58, char *addr, int addrsize);
|
|
89
|
+
void ecdsa_get_wif(const uint8_t *priv_key, uint32_t version, HasherType hasher_base58, char *wif, int wifsize);
|
|
90
|
+
|
|
91
|
+
int ecdsa_address_decode(const char *addr, uint32_t version, HasherType hasher_base58, uint8_t *out);
|
|
92
|
+
int ecdsa_read_pubkey(const ecdsa_curve *curve, const uint8_t *pub_key, curve_point *pub);
|
|
93
|
+
int ecdsa_validate_pubkey(const ecdsa_curve *curve, const curve_point *pub);
|
|
94
|
+
int ecdsa_verify(const ecdsa_curve *curve, HasherType hasher_sign, const uint8_t *pub_key, const uint8_t *sig, const uint8_t *msg, uint32_t msg_len);
|
|
95
|
+
int ecdsa_verify_digest(const ecdsa_curve *curve, const uint8_t *pub_key, const uint8_t *sig, const uint8_t *digest);
|
|
96
|
+
int ecdsa_recover_pub_from_sig(const ecdsa_curve *curve, uint8_t *pub_key, const uint8_t *sig, const uint8_t *digest, int recid);
|
|
97
|
+
// JuBiter-defined
|
|
98
|
+
// check recover id, if it's wrong, recover it.
|
|
99
|
+
int ecdsa_recover_sig(const ecdsa_curve *curve, const uint8_t *pub_key, const uint8_t *sig, const uint8_t *digest, int *recid);
|
|
100
|
+
int ecdsa_sig_to_der(const uint8_t *sig, uint8_t *der);
|
|
101
|
+
// JuBiter-defined
|
|
102
|
+
int der_to_ecdsa_sig(const uint8_t *der, uint8_t *sig);
|
|
103
|
+
int ecdsa_der_to_sig(const uint8_t *der, uint8_t *sig);
|
|
104
|
+
|
|
105
|
+
int zil_schnorr_sign(const ecdsa_curve *curve, const uint8_t *priv_key, const uint8_t *digest, uint8_t *sig);
|
|
106
|
+
int zil_schnorr_verify(const ecdsa_curve *curve, const uint8_t *pub_key, const uint8_t *sig, const uint8_t *digest);
|
|
107
|
+
|
|
108
|
+
#ifdef __cplusplus
|
|
109
|
+
} /* extern "C" */
|
|
110
|
+
#endif
|
|
111
|
+
|
|
112
|
+
#endif
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Public domain by Andrew M. <liquidsun@gmail.com>
|
|
3
|
+
See: https://github.com/floodyberry/curve25519-donna
|
|
4
|
+
|
|
5
|
+
32 bit integer curve25519 implementation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
extern "C" {
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
typedef uint32_t bignum25519[10];
|
|
13
|
+
|
|
14
|
+
/* out = in */
|
|
15
|
+
void curve25519_copy(bignum25519 out, const bignum25519 in);
|
|
16
|
+
|
|
17
|
+
/* out = a + b */
|
|
18
|
+
void curve25519_add(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
19
|
+
|
|
20
|
+
void curve25519_add_after_basic(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
21
|
+
|
|
22
|
+
void curve25519_add_reduce(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
23
|
+
|
|
24
|
+
/* out = a - b */
|
|
25
|
+
void curve25519_sub(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
26
|
+
|
|
27
|
+
/* out = in * scalar */
|
|
28
|
+
void curve25519_scalar_product(bignum25519 out, const bignum25519 in, const uint32_t scalar);
|
|
29
|
+
|
|
30
|
+
/* out = a - b, where a is the result of a basic op (add,sub) */
|
|
31
|
+
void curve25519_sub_after_basic(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
32
|
+
|
|
33
|
+
void curve25519_sub_reduce(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
34
|
+
|
|
35
|
+
/* out = -a */
|
|
36
|
+
void curve25519_neg(bignum25519 out, const bignum25519 a);
|
|
37
|
+
|
|
38
|
+
/* out = a * b */
|
|
39
|
+
#define curve25519_mul_noinline curve25519_mul
|
|
40
|
+
void curve25519_mul(bignum25519 out, const bignum25519 a, const bignum25519 b);
|
|
41
|
+
|
|
42
|
+
/* out = in * in */
|
|
43
|
+
void curve25519_square(bignum25519 out, const bignum25519 in);
|
|
44
|
+
|
|
45
|
+
/* out = in ^ (2 * count) */
|
|
46
|
+
void curve25519_square_times(bignum25519 out, const bignum25519 in, int count);
|
|
47
|
+
|
|
48
|
+
/* Take a little-endian, 32-byte number and expand it into polynomial form */
|
|
49
|
+
void curve25519_expand(bignum25519 out, const unsigned char in[32]);
|
|
50
|
+
|
|
51
|
+
/* Take a fully reduced polynomial form number and contract it into a
|
|
52
|
+
* little-endian, 32-byte array
|
|
53
|
+
*/
|
|
54
|
+
void curve25519_contract(unsigned char out[32], const bignum25519 in);
|
|
55
|
+
|
|
56
|
+
/* if (iswap) swap(a, b) */
|
|
57
|
+
void curve25519_swap_conditional(bignum25519 a, bignum25519 b, uint32_t iswap);
|
|
58
|
+
|
|
59
|
+
/* uint32_t to Zmod(2^255-19) */
|
|
60
|
+
void curve25519_set(bignum25519 r, uint32_t x);
|
|
61
|
+
|
|
62
|
+
/* set d */
|
|
63
|
+
void curve25519_set_d(bignum25519 r);
|
|
64
|
+
|
|
65
|
+
/* set 2d */
|
|
66
|
+
void curve25519_set_2d(bignum25519 r);
|
|
67
|
+
|
|
68
|
+
/* set sqrt(-1) */
|
|
69
|
+
void curve25519_set_sqrtneg1(bignum25519 r);
|
|
70
|
+
|
|
71
|
+
/* constant time Zmod(2^255-19) negative test */
|
|
72
|
+
int curve25519_isnegative(const bignum25519 f);
|
|
73
|
+
|
|
74
|
+
/* constant time Zmod(2^255-19) non-zero test */
|
|
75
|
+
int curve25519_isnonzero(const bignum25519 f);
|
|
76
|
+
|
|
77
|
+
/* reduce Zmod(2^255-19) */
|
|
78
|
+
void curve25519_reduce(bignum25519 r, const bignum25519 in);
|
|
79
|
+
|
|
80
|
+
void curve25519_divpowm1(bignum25519 r, const bignum25519 u, const bignum25519 v);
|
|
81
|
+
|
|
82
|
+
/* Zmod(2^255-19) from byte array to bignum25519 expansion with modular reduction */
|
|
83
|
+
void curve25519_expand_reduce(bignum25519 out, const unsigned char in[32]);
|
|
84
|
+
|
|
85
|
+
#ifdef __cplusplus
|
|
86
|
+
} /* extern "C" */
|
|
87
|
+
#endif
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Public domain by Andrew M. <liquidsun@gmail.com>
|
|
3
|
+
See: https://github.com/floodyberry/curve25519-donna
|
|
4
|
+
|
|
5
|
+
Curve25519 implementation agnostic helpers
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
extern "C" {
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* In: b = 2^5 - 2^0
|
|
14
|
+
* Out: b = 2^250 - 2^0
|
|
15
|
+
*/
|
|
16
|
+
void curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b);
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* z^(p - 2) = z(2^255 - 21)
|
|
20
|
+
*/
|
|
21
|
+
void curve25519_recip(bignum25519 out, const bignum25519 z);
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* z^((p-5)/8) = z^(2^252 - 3)
|
|
25
|
+
*/
|
|
26
|
+
void curve25519_pow_two252m3(bignum25519 two252m3, const bignum25519 z);
|
|
27
|
+
|
|
28
|
+
#ifdef __cplusplus
|
|
29
|
+
} /* extern "C" */
|
|
30
|
+
#endif
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef ED25519_BLAKE2B_H
|
|
2
|
+
#define ED25519_BLAKE2B_H
|
|
3
|
+
|
|
4
|
+
#include <TrezorCrypto/ed25519.h>
|
|
5
|
+
|
|
6
|
+
#if defined(__cplusplus)
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
void ed25519_publickey_blake2b(const ed25519_secret_key sk, ed25519_public_key pk);
|
|
11
|
+
|
|
12
|
+
int ed25519_sign_open_blake2b(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
|
|
13
|
+
void ed25519_sign_blake2b(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS);
|
|
14
|
+
|
|
15
|
+
int ed25519_scalarmult_blake2b(ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk);
|
|
16
|
+
|
|
17
|
+
#if defined(__cplusplus)
|
|
18
|
+
}
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#endif // ED25519_BLAKE2B_H
|
package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
extern "C" {
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
extern const ge25519 ALIGN(16) ge25519_basepoint;
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
d
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
extern const bignum25519 ALIGN(16) ge25519_ecd;
|
|
12
|
+
|
|
13
|
+
extern const bignum25519 ALIGN(16) ge25519_ec2d;
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
sqrt(-1)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
extern const bignum25519 ALIGN(16) ge25519_sqrtneg1;
|
|
20
|
+
|
|
21
|
+
extern const ge25519_niels ALIGN(16) ge25519_niels_sliding_multiples[32];
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
} /* extern "C" */
|
|
25
|
+
#endif
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
extern "C" {
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Timing safe memory compare
|
|
7
|
+
*/
|
|
8
|
+
int ed25519_verify(const unsigned char *x, const unsigned char *y, size_t len);
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
conversions
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
void ge25519_p1p1_to_partial(ge25519 *r, const ge25519_p1p1 *p);
|
|
15
|
+
|
|
16
|
+
void ge25519_p1p1_to_full(ge25519 *r, const ge25519_p1p1 *p);
|
|
17
|
+
|
|
18
|
+
void ge25519_full_to_pniels(ge25519_pniels *p, const ge25519 *r);
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
adding & doubling
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
void ge25519_double_p1p1(ge25519_p1p1 *r, const ge25519 *p);
|
|
25
|
+
|
|
26
|
+
#ifndef ED25519_NO_PRECOMP
|
|
27
|
+
void ge25519_nielsadd2_p1p1(ge25519_p1p1 *r, const ge25519 *p, const ge25519_niels *q, unsigned char signbit);
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/* computes [s1]p1 + [s2]p2 */
|
|
31
|
+
void ge25519_double_scalarmult_vartime2(ge25519 *r, const ge25519 *p1, const bignum256modm s1, const ge25519 *p2, const bignum256modm s2);
|
|
32
|
+
|
|
33
|
+
void ge25519_pnielsadd_p1p1(ge25519_p1p1 *r, const ge25519 *p, const ge25519_pniels *q, unsigned char signbit);
|
|
34
|
+
|
|
35
|
+
void ge25519_double_partial(ge25519 *r, const ge25519 *p);
|
|
36
|
+
|
|
37
|
+
void ge25519_double(ge25519 *r, const ge25519 *p);
|
|
38
|
+
|
|
39
|
+
void ge25519_nielsadd2(ge25519 *r, const ge25519_niels *q);
|
|
40
|
+
|
|
41
|
+
void ge25519_pnielsadd(ge25519_pniels *r, const ge25519 *p, const ge25519_pniels *q);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
pack & unpack
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
void ge25519_pack(unsigned char r[32], const ge25519 *p);
|
|
49
|
+
|
|
50
|
+
int ge25519_unpack_negative_vartime(ge25519 *r, const unsigned char p[32]);
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
scalarmults
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
void ge25519_set_neutral(ge25519 *r);
|
|
57
|
+
|
|
58
|
+
/* computes [s1]p1 + [s2]base */
|
|
59
|
+
void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const bignum256modm s1, const bignum256modm s2);
|
|
60
|
+
|
|
61
|
+
/* computes [s1]p1, constant time */
|
|
62
|
+
void ge25519_scalarmult(ge25519 *r, const ge25519 *p1, const bignum256modm s1);
|
|
63
|
+
|
|
64
|
+
void ge25519_scalarmult_base_choose_niels(ge25519_niels *t, const uint8_t table[256][96], uint32_t pos, signed char b);
|
|
65
|
+
|
|
66
|
+
/* computes [s]basepoint */
|
|
67
|
+
void ge25519_scalarmult_base_niels(ge25519 *r, const uint8_t basepoint_table[256][96], const bignum256modm s);
|
|
68
|
+
|
|
69
|
+
/* check if r is on curve */
|
|
70
|
+
int ge25519_check(const ge25519 *r);
|
|
71
|
+
|
|
72
|
+
/* a == b */
|
|
73
|
+
int ge25519_eq(const ge25519 *a, const ge25519 *b);
|
|
74
|
+
|
|
75
|
+
/* copies one point to another */
|
|
76
|
+
void ge25519_copy(ge25519 *dst, const ge25519 *src);
|
|
77
|
+
|
|
78
|
+
/* sets B point to r */
|
|
79
|
+
void ge25519_set_base(ge25519 *r);
|
|
80
|
+
|
|
81
|
+
/* 8*P */
|
|
82
|
+
void ge25519_mul8(ge25519 *r, const ge25519 *t);
|
|
83
|
+
|
|
84
|
+
/* -P */
|
|
85
|
+
void ge25519_neg_partial(ge25519 *r);
|
|
86
|
+
|
|
87
|
+
/* -P */
|
|
88
|
+
void ge25519_neg_full(ge25519 *r);
|
|
89
|
+
|
|
90
|
+
/* reduce all coords */
|
|
91
|
+
void ge25519_reduce(ge25519 *r, const ge25519 *t);
|
|
92
|
+
|
|
93
|
+
/* normalizes coords. (x, y, 1, x*y) */
|
|
94
|
+
void ge25519_norm(ge25519 *r, const ge25519 * t);
|
|
95
|
+
|
|
96
|
+
/* Simple addition */
|
|
97
|
+
void ge25519_add(ge25519 *r, const ge25519 *a, const ge25519 *b, unsigned char signbit);
|
|
98
|
+
|
|
99
|
+
/* point from bytes, used in H_p() */
|
|
100
|
+
void ge25519_fromfe_frombytes_vartime(ge25519 *r, const unsigned char *s);
|
|
101
|
+
|
|
102
|
+
/* point from bytes */
|
|
103
|
+
int ge25519_unpack_vartime(ge25519 *r, const unsigned char *s);
|
|
104
|
+
|
|
105
|
+
/* aG, wrapper for niels base mult. */
|
|
106
|
+
void ge25519_scalarmult_base_wrapper(ge25519 *r, const bignum256modm s);
|
|
107
|
+
|
|
108
|
+
#ifdef __cplusplus
|
|
109
|
+
} /* extern "C" */
|
|
110
|
+
#endif
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#define mul32x32_64(a,b) (((uint64_t)(a))*(b))
|
|
2
|
+
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
7
|
+
#ifdef __cplusplus
|
|
8
|
+
extern "C" {
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
#define DONNA_INLINE
|
|
12
|
+
#undef ALIGN
|
|
13
|
+
#define ALIGN(x) __attribute__((aligned(x)))
|
|
14
|
+
|
|
15
|
+
static inline void U32TO8_LE(unsigned char *p, const uint32_t v) {
|
|
16
|
+
p[0] = (unsigned char)(v );
|
|
17
|
+
p[1] = (unsigned char)(v >> 8);
|
|
18
|
+
p[2] = (unsigned char)(v >> 16);
|
|
19
|
+
p[3] = (unsigned char)(v >> 24);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static inline uint32_t U8TO32_LE(const unsigned char *p) {
|
|
23
|
+
return
|
|
24
|
+
(((uint32_t)(p[0]) ) |
|
|
25
|
+
((uint32_t)(p[1]) << 8) |
|
|
26
|
+
((uint32_t)(p[2]) << 16) |
|
|
27
|
+
((uint32_t)(p[3]) << 24));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#ifdef __cplusplus
|
|
31
|
+
} /* extern "C" */
|
|
32
|
+
#endif
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Public domain by Andrew M. <liquidsun@gmail.com>
|
|
3
|
+
Modified from the amd64-51-30k implementation by
|
|
4
|
+
Daniel J. Bernstein
|
|
5
|
+
Niels Duif
|
|
6
|
+
Tanja Lange
|
|
7
|
+
Peter Schwabe
|
|
8
|
+
Bo-Yin Yang
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef ED25519_DONNA_H
|
|
12
|
+
#define ED25519_DONNA_H
|
|
13
|
+
|
|
14
|
+
#include <TrezorCrypto/ed25519-donna/ed25519-donna-portable.h>
|
|
15
|
+
|
|
16
|
+
#include <TrezorCrypto/ed25519-donna/curve25519-donna-32bit.h>
|
|
17
|
+
|
|
18
|
+
#include <TrezorCrypto/ed25519-donna/curve25519-donna-helpers.h>
|
|
19
|
+
|
|
20
|
+
#include <TrezorCrypto/ed25519-donna/modm-donna-32bit.h>
|
|
21
|
+
|
|
22
|
+
#ifdef __cplusplus
|
|
23
|
+
extern "C" {
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
typedef unsigned char hash_512bits[64];
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Arithmetic on the twisted Edwards curve -x^2 + y^2 = 1 + dx^2y^2
|
|
30
|
+
* with d = -(121665/121666) = 37095705934669439343138083508754565189542113879843219016388785533085940283555
|
|
31
|
+
* Base point: (15112221349535400772501151409588531511454012693041857206046113283949847762202,46316835694926478169428394003475163141307993866256225615783033603165251855960);
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
typedef struct ge25519_t {
|
|
35
|
+
bignum25519 x, y, z, t;
|
|
36
|
+
} ge25519;
|
|
37
|
+
|
|
38
|
+
typedef struct ge25519_p1p1_t {
|
|
39
|
+
bignum25519 x, y, z, t;
|
|
40
|
+
} ge25519_p1p1;
|
|
41
|
+
|
|
42
|
+
typedef struct ge25519_niels_t {
|
|
43
|
+
bignum25519 ysubx, xaddy, t2d;
|
|
44
|
+
} ge25519_niels;
|
|
45
|
+
|
|
46
|
+
typedef struct ge25519_pniels_t {
|
|
47
|
+
bignum25519 ysubx, xaddy, z, t2d;
|
|
48
|
+
} ge25519_pniels;
|
|
49
|
+
|
|
50
|
+
#include <TrezorCrypto/ed25519-donna/ed25519-donna-basepoint-table.h>
|
|
51
|
+
|
|
52
|
+
#include <TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h>
|
|
53
|
+
|
|
54
|
+
#include <TrezorCrypto/ed25519-donna/ed25519-donna-impl-base.h>
|
|
55
|
+
|
|
56
|
+
#ifdef __cplusplus
|
|
57
|
+
} /* extern "C" */
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#endif
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef ED25519_KECCAK_H
|
|
2
|
+
#define ED25519_KECCAK_H
|
|
3
|
+
|
|
4
|
+
#include <TrezorCrypto/ed25519.h>
|
|
5
|
+
|
|
6
|
+
#if defined(__cplusplus)
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
void ed25519_publickey_keccak(const ed25519_secret_key sk, ed25519_public_key pk);
|
|
11
|
+
|
|
12
|
+
int ed25519_sign_open_keccak(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
|
|
13
|
+
void ed25519_sign_keccak(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS);
|
|
14
|
+
|
|
15
|
+
int ed25519_scalarmult_keccak(ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk);
|
|
16
|
+
|
|
17
|
+
#if defined(__cplusplus)
|
|
18
|
+
}
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#endif // ED25519_KECCAK_H
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef ED25519_SHA3_H
|
|
2
|
+
#define ED25519_SHA3_H
|
|
3
|
+
|
|
4
|
+
#include <TrezorCrypto/ed25519.h>
|
|
5
|
+
|
|
6
|
+
#if defined(__cplusplus)
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
void ed25519_publickey_sha3(const ed25519_secret_key sk, ed25519_public_key pk);
|
|
11
|
+
|
|
12
|
+
int ed25519_sign_open_sha3(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
|
|
13
|
+
void ed25519_sign_sha3(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS);
|
|
14
|
+
|
|
15
|
+
int ed25519_scalarmult_sha3(ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk);
|
|
16
|
+
|
|
17
|
+
#if defined(__cplusplus)
|
|
18
|
+
}
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#endif // ED25519_SHA3_H
|