@onekeyfe/react-native-lite-card 6.7.0-4 → 6.7.0-41

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.
Files changed (237) hide show
  1. package/README.md +12 -2
  2. package/ReactNativeLiteCard.podspec +31 -2
  3. package/android/build.gradle +8 -0
  4. package/android/consumer-rules.pro +4 -0
  5. package/android/src/main/cpp/CMakeLists.txt +6 -2
  6. package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardModule.kt +60 -49
  7. package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +7 -7
  8. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/OnekeyLiteCard.kt +117 -39
  9. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt +6 -3
  10. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +24 -2
  11. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +46 -19
  12. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
  13. package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +38 -1
  14. package/ios/Classes/OKNFCBridge.mm +24 -1
  15. package/ios/Classes/OKNFTLite/OKLiteV1.m +20 -10
  16. package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
  17. package/ios/Classes/OKNFTLite/OKNFCManager.h +2 -2
  18. package/ios/Classes/OKNFTLite/OKNFCManager.m +110 -18
  19. package/ios/ReactNativeLiteCard.mm +23 -11
  20. package/lib/module/index.js +4 -4
  21. package/lib/typescript/src/NativeReactNativeLiteCard.d.ts +4 -4
  22. package/lib/typescript/src/index.d.ts +2 -2
  23. package/package.json +8 -8
  24. package/sdk/CMakeLists.txt +121 -0
  25. package/sdk/README.md +190 -0
  26. package/sdk/android/implJni.cpp +216 -0
  27. package/sdk/deps/jsoncpp/LICENSE +55 -0
  28. package/sdk/deps/jsoncpp/include/CMakeLists.txt +2 -0
  29. package/sdk/deps/jsoncpp/include/json/allocator.h +98 -0
  30. package/sdk/deps/jsoncpp/include/json/assertions.h +54 -0
  31. package/sdk/deps/jsoncpp/include/json/autolink.h +25 -0
  32. package/sdk/deps/jsoncpp/include/json/config.h +187 -0
  33. package/sdk/deps/jsoncpp/include/json/features.h +61 -0
  34. package/sdk/deps/jsoncpp/include/json/forwards.h +37 -0
  35. package/sdk/deps/jsoncpp/include/json/json.h +15 -0
  36. package/sdk/deps/jsoncpp/include/json/reader.h +411 -0
  37. package/sdk/deps/jsoncpp/include/json/value.h +888 -0
  38. package/sdk/deps/jsoncpp/include/json/version.h +20 -0
  39. package/sdk/deps/jsoncpp/include/json/writer.h +357 -0
  40. package/sdk/deps/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
  41. package/sdk/deps/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
  42. package/sdk/deps/jsoncpp/src/lib_json/json_tool.h +114 -0
  43. package/sdk/deps/jsoncpp/src/lib_json/json_value.cpp +1661 -0
  44. package/sdk/deps/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
  45. package/sdk/deps/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
  46. package/sdk/deps/jsoncpp/src/lib_json/version.h.in +20 -0
  47. package/sdk/deps/trezor-crypto/AUTHORS +2 -0
  48. package/sdk/deps/trezor-crypto/LICENSE +22 -0
  49. package/sdk/deps/trezor-crypto/include/TrezorCrypto/TrezorCrypto.h +29 -0
  50. package/sdk/deps/trezor-crypto/include/TrezorCrypto/address.h +44 -0
  51. package/sdk/deps/trezor-crypto/include/TrezorCrypto/aes.h +224 -0
  52. package/sdk/deps/trezor-crypto/include/TrezorCrypto/base32.h +49 -0
  53. package/sdk/deps/trezor-crypto/include/TrezorCrypto/base58.h +58 -0
  54. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bignum.h +169 -0
  55. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip32.h +114 -0
  56. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip39.h +66 -0
  57. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake256.h +61 -0
  58. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2b.h +50 -0
  59. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2s.h +49 -0
  60. package/sdk/deps/trezor-crypto/include/TrezorCrypto/cash_addr.h +109 -0
  61. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-config.h +316 -0
  62. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-sync.h +289 -0
  63. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-types.h +53 -0
  64. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/poly1305-donna.h +28 -0
  65. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305.h +27 -0
  66. package/sdk/deps/trezor-crypto/include/TrezorCrypto/cmac.h +44 -0
  67. package/sdk/deps/trezor-crypto/include/TrezorCrypto/curves.h +60 -0
  68. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ecdsa.h +112 -0
  69. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-32bit.h +87 -0
  70. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-helpers.h +30 -0
  71. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-blake2b.h +21 -0
  72. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h +25 -0
  73. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-basepoint-table.h +10 -0
  74. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-impl-base.h +110 -0
  75. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-portable.h +32 -0
  76. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna.h +60 -0
  77. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-keccak.h +21 -0
  78. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-sha3.h +21 -0
  79. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/modm-donna-32bit.h +87 -0
  80. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna.h +60 -0
  81. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519.h +42 -0
  82. package/sdk/deps/trezor-crypto/include/TrezorCrypto/endian.h +132 -0
  83. package/sdk/deps/trezor-crypto/include/TrezorCrypto/groestl.h +104 -0
  84. package/sdk/deps/trezor-crypto/include/TrezorCrypto/hasher.h +90 -0
  85. package/sdk/deps/trezor-crypto/include/TrezorCrypto/hmac.h +60 -0
  86. package/sdk/deps/trezor-crypto/include/TrezorCrypto/memzero.h +16 -0
  87. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/base58.h +42 -0
  88. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/monero.h +13 -0
  89. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/range_proof.h +30 -0
  90. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/serialize.h +15 -0
  91. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/xmr.h +67 -0
  92. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nano.h +56 -0
  93. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nem.h +199 -0
  94. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nist256p1.h +35 -0
  95. package/sdk/deps/trezor-crypto/include/TrezorCrypto/pbkdf2.h +64 -0
  96. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rand.h +44 -0
  97. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rc4.h +37 -0
  98. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rfc6979.h +40 -0
  99. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripemd160.h +28 -0
  100. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripple/base58.h +45 -0
  101. package/sdk/deps/trezor-crypto/include/TrezorCrypto/schnorr.h +48 -0
  102. package/sdk/deps/trezor-crypto/include/TrezorCrypto/script.h +30 -0
  103. package/sdk/deps/trezor-crypto/include/TrezorCrypto/scrypt.h +68 -0
  104. package/sdk/deps/trezor-crypto/include/TrezorCrypto/secp256k1.h +59 -0
  105. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha2.h +125 -0
  106. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha3.h +86 -0
  107. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/keypair.h +20 -0
  108. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10.h +85 -0
  109. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10_fe_25_5.h +43 -0
  110. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/constants.h +29 -0
  111. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/fe.h +25 -0
  112. package/sdk/deps/trezor-crypto/src/address.c +87 -0
  113. package/sdk/deps/trezor-crypto/src/aes/aes_modes.c +959 -0
  114. package/sdk/deps/trezor-crypto/src/aes/aescrypt.c +307 -0
  115. package/sdk/deps/trezor-crypto/src/aes/aeskey.c +560 -0
  116. package/sdk/deps/trezor-crypto/src/aes/aesopt.h +784 -0
  117. package/sdk/deps/trezor-crypto/src/aes/aestab.c +418 -0
  118. package/sdk/deps/trezor-crypto/src/aes/aestab.h +173 -0
  119. package/sdk/deps/trezor-crypto/src/base32.c +233 -0
  120. package/sdk/deps/trezor-crypto/src/base58.c +298 -0
  121. package/sdk/deps/trezor-crypto/src/bignum.c +808 -0
  122. package/sdk/deps/trezor-crypto/src/bip32.c +852 -0
  123. package/sdk/deps/trezor-crypto/src/bip39.c +266 -0
  124. package/sdk/deps/trezor-crypto/src/bip39_english.h +2074 -0
  125. package/sdk/deps/trezor-crypto/src/blake256.c +235 -0
  126. package/sdk/deps/trezor-crypto/src/blake2_common.h +39 -0
  127. package/sdk/deps/trezor-crypto/src/blake2b.c +333 -0
  128. package/sdk/deps/trezor-crypto/src/blake2s.c +318 -0
  129. package/sdk/deps/trezor-crypto/src/cash_addr.c +195 -0
  130. package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha20poly1305.c +60 -0
  131. package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha_merged.c +246 -0
  132. package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-machine.h +49 -0
  133. package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-portable.h +275 -0
  134. package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna-32.h +219 -0
  135. package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna.c +179 -0
  136. package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.c +48 -0
  137. package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.h +10 -0
  138. package/sdk/deps/trezor-crypto/src/check_mem.h +30 -0
  139. package/sdk/deps/trezor-crypto/src/cmac.c +342 -0
  140. package/sdk/deps/trezor-crypto/src/curves.c +48 -0
  141. package/sdk/deps/trezor-crypto/src/ecdsa.c +1355 -0
  142. package/sdk/deps/trezor-crypto/src/ed25519-donna/README.md +183 -0
  143. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-32bit.c +681 -0
  144. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-helpers.c +66 -0
  145. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.c +67 -0
  146. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.h +8 -0
  147. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-blake2b.c +8 -0
  148. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-32bit-tables.c +63 -0
  149. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-basepoint-table.c +261 -0
  150. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-impl-base.c +722 -0
  151. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-blake2b.h +23 -0
  152. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-keccak.h +23 -0
  153. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-sha3.h +23 -0
  154. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom.h +23 -0
  155. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-keccak.c +8 -0
  156. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-sha3.c +8 -0
  157. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519.c +311 -0
  158. package/sdk/deps/trezor-crypto/src/ed25519-donna/modm-donna-32bit.c +517 -0
  159. package/sdk/deps/trezor-crypto/src/groestl.c +783 -0
  160. package/sdk/deps/trezor-crypto/src/groestl_internal.h +419 -0
  161. package/sdk/deps/trezor-crypto/src/hasher.c +186 -0
  162. package/sdk/deps/trezor-crypto/src/hmac.c +179 -0
  163. package/sdk/deps/trezor-crypto/src/memzero.c +6 -0
  164. package/sdk/deps/trezor-crypto/src/monero/base58.c +245 -0
  165. package/sdk/deps/trezor-crypto/src/monero/int-util.h +77 -0
  166. package/sdk/deps/trezor-crypto/src/monero/range_proof.c +115 -0
  167. package/sdk/deps/trezor-crypto/src/monero/serialize.c +54 -0
  168. package/sdk/deps/trezor-crypto/src/monero/xmr.c +136 -0
  169. package/sdk/deps/trezor-crypto/src/nano.c +151 -0
  170. package/sdk/deps/trezor-crypto/src/nem.c +569 -0
  171. package/sdk/deps/trezor-crypto/src/nist256p1.c +63 -0
  172. package/sdk/deps/trezor-crypto/src/nist256p1.table +1664 -0
  173. package/sdk/deps/trezor-crypto/src/options.h +43 -0
  174. package/sdk/deps/trezor-crypto/src/pbkdf2.c +177 -0
  175. package/sdk/deps/trezor-crypto/src/rand.c +51 -0
  176. package/sdk/deps/trezor-crypto/src/rc4.c +56 -0
  177. package/sdk/deps/trezor-crypto/src/ripemd160.c +343 -0
  178. package/sdk/deps/trezor-crypto/src/ripple/base58.c +76 -0
  179. package/sdk/deps/trezor-crypto/src/schnorr.c +208 -0
  180. package/sdk/deps/trezor-crypto/src/script.c +64 -0
  181. package/sdk/deps/trezor-crypto/src/scrypt.c +343 -0
  182. package/sdk/deps/trezor-crypto/src/secp256k1.c +160 -0
  183. package/sdk/deps/trezor-crypto/src/secp256k1.table +1664 -0
  184. package/sdk/deps/trezor-crypto/src/setup.py +38 -0
  185. package/sdk/deps/trezor-crypto/src/sha2.c +1314 -0
  186. package/sdk/deps/trezor-crypto/src/sha3.c +395 -0
  187. package/sdk/deps/trezor-crypto/src/shell.nix +6 -0
  188. package/sdk/deps/trezor-crypto/src/sodium/keypair.c +63 -0
  189. package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10.c +481 -0
  190. package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10_fe_25_5.c +885 -0
  191. package/sdk/deps/trezor-crypto/src/sodium/private/fe_25_5/fe.c +237 -0
  192. package/sdk/gpc/include/scp03/scp03.hpp +80 -0
  193. package/sdk/gpc/include/scp11/scp11.hpp +492 -0
  194. package/sdk/gpc/include/scp11/scp11c.hpp +58 -0
  195. package/sdk/gpc/include/tag.h +68 -0
  196. package/sdk/gpc/include/tlv.hpp +94 -0
  197. package/sdk/gpc/include/tlvparse.hpp +24 -0
  198. package/sdk/gpc/src/scp03.cpp +243 -0
  199. package/sdk/gpc/src/scp11.cpp +798 -0
  200. package/sdk/gpc/src/scp11c.cpp +136 -0
  201. package/sdk/gpc/src/tlv.cpp +159 -0
  202. package/sdk/gpc/src/tlvparse.c +174 -0
  203. package/{framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers → sdk/include}/GPChannelSDK.h +0 -0
  204. package/sdk/include/GPChannelSDKCore.h +10 -0
  205. package/sdk/include/context/BaseContext.h +56 -0
  206. package/sdk/include/device/ApduBuilder.hpp +72 -0
  207. package/sdk/include/mSIGNA/stdutils/uchar_vector.h +36 -0
  208. package/sdk/include/utility/Apdu.hpp +172 -0
  209. package/sdk/include/utility/Debug.hpp +3 -0
  210. package/sdk/include/utility/util.h +104 -0
  211. package/sdk/scripts/generate-source-id.rb +22 -0
  212. package/sdk/source-id-manifest.txt +19 -0
  213. package/sdk/source-id.cmake +31 -0
  214. package/sdk/src/ApduBuilder.cpp +332 -0
  215. package/sdk/src/GPChannelSDK.cpp +258 -0
  216. package/sdk/src/random.c +25 -0
  217. package/sdk/src/version.c +3 -0
  218. package/sdk/tests/android/GPChannelProxy.java +55 -0
  219. package/sdk/tests/android_verify.py +124 -0
  220. package/sdk/tests/safety.cpp +757 -0
  221. package/sdk/tests/verify.py +284 -0
  222. package/src/NativeReactNativeLiteCard.ts +4 -2
  223. package/src/index.tsx +14 -3
  224. package/android/src/main/jniLibs/arm64-v8a/libgpchannelNDK.so +0 -0
  225. package/android/src/main/jniLibs/armeabi-v7a/libgpchannelNDK.so +0 -0
  226. package/framework/GPChannelSDKCore.xcframework/Info.plist +0 -52
  227. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
  228. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
  229. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Info.plist +0 -0
  230. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
  231. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
  232. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
  233. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +0 -315
  234. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
  235. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Info.plist +0 -0
  236. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
  237. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
@@ -0,0 +1,15 @@
1
+ //
2
+ // Created by Dusan Klinec on 02/05/2018.
3
+ //
4
+
5
+ #ifndef TREZOR_XMR_SERIALIZE_H
6
+ #define TREZOR_XMR_SERIALIZE_H
7
+
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
11
+ int xmr_size_varint(uint64_t num);
12
+ int xmr_write_varint(uint8_t * buff, size_t buff_size, uint64_t num);
13
+ int xmr_read_varint(uint8_t * buff, size_t buff_size, uint64_t *val);
14
+
15
+ #endif //TREZOR_XMR_SERIALIZE_H
@@ -0,0 +1,67 @@
1
+ //
2
+ // Created by Dusan Klinec on 10/05/2018.
3
+ //
4
+
5
+ #ifndef TREZOR_CRYPTO_XMR_H
6
+ #define TREZOR_CRYPTO_XMR_H
7
+
8
+ #include <TrezorCrypto/ed25519-donna.h>
9
+ #include <TrezorCrypto/hasher.h>
10
+
11
+ extern const ge25519 ALIGN(16) xmr_h;
12
+
13
+ typedef unsigned char xmr_key_t[32];
14
+
15
+ typedef struct xmr_ctkey {
16
+ xmr_key_t dest;
17
+ xmr_key_t mask;
18
+ } xmr_ctkey_t;
19
+
20
+ /* sets H point to r */
21
+ void ge25519_set_xmr_h(ge25519 *r);
22
+
23
+ /* random scalar value */
24
+ void xmr_random_scalar(bignum256modm m);
25
+
26
+ /* cn_fast_hash */
27
+ void xmr_fast_hash(uint8_t * hash, const void *data, size_t length);
28
+
29
+ /* incremental hashing wrappers */
30
+ void xmr_hasher_init(Hasher * hasher);
31
+ void xmr_hasher_update(Hasher * hasher, const void *data, size_t length);
32
+ void xmr_hasher_final(Hasher * hasher, uint8_t * hash);
33
+ void xmr_hasher_copy(Hasher * dst, const Hasher * src);
34
+
35
+ /* H_s(buffer) */
36
+ void xmr_hash_to_scalar(bignum256modm r, const void *data, size_t length);
37
+
38
+ /* H_p(buffer) */
39
+ void xmr_hash_to_ec(ge25519 *P, const void *data, size_t length);
40
+
41
+ /* derivation to scalar value */
42
+ void xmr_derivation_to_scalar(bignum256modm s, const ge25519 * p, uint32_t output_index);
43
+
44
+ /* derivation */
45
+ void xmr_generate_key_derivation(ge25519 * r, const ge25519 * A, const bignum256modm b);
46
+
47
+ /* H_s(derivation || varint(output_index)) + base */
48
+ void xmr_derive_private_key(bignum256modm s, const ge25519 * deriv, uint32_t idx, const bignum256modm base);
49
+
50
+ /* H_s(derivation || varint(output_index))G + base */
51
+ void xmr_derive_public_key(ge25519 * r, const ge25519 * deriv, uint32_t idx, const ge25519 * base);
52
+
53
+ /* aG + bB, G is basepoint */
54
+ void xmr_add_keys2(ge25519 * r, const bignum256modm a, const bignum256modm b, const ge25519 * B);
55
+ void xmr_add_keys2_vartime(ge25519 * r, const bignum256modm a, const bignum256modm b, const ge25519 * B);
56
+
57
+ /* aA + bB */
58
+ void xmr_add_keys3(ge25519 * r, const bignum256modm a, const ge25519 * A, const bignum256modm b, const ge25519 * B);
59
+ void xmr_add_keys3_vartime(ge25519 * r, const bignum256modm a, const ge25519 * A, const bignum256modm b, const ge25519 * B);
60
+
61
+ /* subaddress secret */
62
+ void xmr_get_subaddress_secret_key(bignum256modm r, uint32_t major, uint32_t minor, const bignum256modm m);
63
+
64
+ /* Generates Pedersen commitment C = aG + bH */
65
+ void xmr_gen_c(ge25519 * r, const bignum256modm a, uint64_t amount);
66
+
67
+ #endif //TREZOR_CRYPTO_XMR_H
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) 2019 Mart Roosmaa
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 __NANO_H__
24
+ #define __NANO_H__
25
+
26
+ #include <stdbool.h>
27
+ #include <stddef.h>
28
+ #include <stdint.h>
29
+
30
+ #include <TrezorCrypto/ed25519.h>
31
+
32
+ #ifdef __cplusplus
33
+ extern "C" {
34
+ #endif
35
+
36
+ extern const char *BASE32_ALPHABET_NANO;
37
+
38
+ size_t nano_get_address(
39
+ const ed25519_public_key public_key,
40
+ const char *prefix,
41
+ const size_t prefix_len,
42
+ char *out,
43
+ size_t out_len);
44
+
45
+ bool nano_validate_address(
46
+ const char *prefix,
47
+ const size_t prefix_len,
48
+ const char *address,
49
+ const size_t address_len,
50
+ ed25519_public_key out_public_key);
51
+
52
+ #ifdef __cplusplus
53
+ } /* extern "C" */
54
+ #endif
55
+
56
+ #endif
@@ -0,0 +1,199 @@
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 __NEM_H__
24
+ #define __NEM_H__
25
+
26
+ #include <stdbool.h>
27
+ #include <stddef.h>
28
+ #include <stdint.h>
29
+
30
+ #include <TrezorCrypto/bip32.h>
31
+ #include <TrezorCrypto/ed25519.h>
32
+
33
+ #ifdef __cplusplus
34
+ extern "C" {
35
+ #endif
36
+
37
+ #define NEM_LEVY_PERCENTILE_DIVISOR 4
38
+ #define NEM_MAX_DIVISIBILITY 6
39
+ #define NEM_MAX_SUPPLY 9000000000
40
+
41
+ #define NEM_NETWORK_MAINNET 0x68
42
+ #define NEM_NETWORK_TESTNET 0x98
43
+ #define NEM_NETWORK_MIJIN 0x60
44
+
45
+ #define NEM_ADDRESS_SIZE 40
46
+ #define NEM_ADDRESS_SIZE_RAW 25
47
+
48
+ #define NEM_TRANSACTION_TYPE_TRANSFER 0x0101
49
+ #define NEM_TRANSACTION_TYPE_IMPORTANCE_TRANSFER 0x0801
50
+ #define NEM_TRANSACTION_TYPE_AGGREGATE_MODIFICATION 0x1001
51
+ #define NEM_TRANSACTION_TYPE_MULTISIG_SIGNATURE 0x1002
52
+ #define NEM_TRANSACTION_TYPE_MULTISIG 0x1004
53
+ #define NEM_TRANSACTION_TYPE_PROVISION_NAMESPACE 0x2001
54
+ #define NEM_TRANSACTION_TYPE_MOSAIC_CREATION 0x4001
55
+ #define NEM_TRANSACTION_TYPE_MOSAIC_SUPPLY_CHANGE 0x4002
56
+
57
+ #define NEM_SALT_SIZE sizeof(ed25519_public_key)
58
+
59
+ #define NEM_ENCRYPTED_SIZE(size) (((size) + AES_BLOCK_SIZE) / AES_BLOCK_SIZE * AES_BLOCK_SIZE)
60
+ #define NEM_ENCRYPTED_PAYLOAD_SIZE(size) (AES_BLOCK_SIZE + NEM_SALT_SIZE + NEM_ENCRYPTED_SIZE(size))
61
+
62
+ #define _NEM_PADDING_SIZE(buffer, size) ((buffer)[(size) - 1])
63
+ #define NEM_PADDING_SIZE(buffer, size) (_NEM_PADDING_SIZE(buffer, size) > (size) ? (size) : _NEM_PADDING_SIZE(buffer, size))
64
+
65
+ #define NEM_DECRYPTED_SIZE(buffer, size) ((size) - NEM_PADDING_SIZE(buffer, size))
66
+
67
+ typedef struct {
68
+ ed25519_public_key public_key;
69
+ uint8_t *buffer;
70
+ size_t offset;
71
+ size_t size;
72
+ } nem_transaction_ctx;
73
+
74
+ const char *nem_network_name(uint8_t network);
75
+
76
+ void nem_get_address_raw(const ed25519_public_key public_key, uint8_t version, uint8_t *address);
77
+ bool nem_get_address(const ed25519_public_key public_key, uint8_t version, char *address);
78
+
79
+ bool nem_validate_address_raw(const uint8_t *address, uint8_t network);
80
+ bool nem_validate_address(const char *address, uint8_t network);
81
+
82
+ void nem_transaction_start(nem_transaction_ctx *ctx, const ed25519_public_key public_key, uint8_t *buffer, size_t size);
83
+ size_t nem_transaction_end(nem_transaction_ctx *ctx, const ed25519_secret_key private_key, ed25519_signature signature);
84
+
85
+ bool nem_transaction_write_common(nem_transaction_ctx *context,
86
+ uint32_t type,
87
+ uint32_t version,
88
+ uint32_t timestamp,
89
+ const ed25519_public_key signer,
90
+ uint64_t fee,
91
+ uint32_t deadline);
92
+
93
+ bool nem_transaction_create_transfer(nem_transaction_ctx *context,
94
+ uint8_t network,
95
+ uint32_t timestamp,
96
+ const ed25519_public_key signer,
97
+ uint64_t fee,
98
+ uint32_t deadline,
99
+ const char *recipient,
100
+ uint64_t amount,
101
+ const uint8_t *payload,
102
+ uint32_t length,
103
+ bool encrypted,
104
+ uint32_t mosaics);
105
+
106
+ bool nem_transaction_write_mosaic(nem_transaction_ctx *ctx,
107
+ const char *namespace,
108
+ const char *mosaic,
109
+ uint64_t quantity);
110
+
111
+ bool nem_transaction_create_multisig(nem_transaction_ctx *ctx,
112
+ uint8_t network,
113
+ uint32_t timestamp,
114
+ const ed25519_public_key signer,
115
+ uint64_t fee,
116
+ uint32_t deadline,
117
+ const nem_transaction_ctx *inner);
118
+
119
+ bool nem_transaction_create_multisig_signature(nem_transaction_ctx *ctx,
120
+ uint8_t network,
121
+ uint32_t timestamp,
122
+ const ed25519_public_key signer,
123
+ uint64_t fee,
124
+ uint32_t deadline,
125
+ const nem_transaction_ctx *inner);
126
+
127
+ bool nem_transaction_create_provision_namespace(nem_transaction_ctx *ctx,
128
+ uint8_t network,
129
+ uint32_t timestamp,
130
+ const ed25519_public_key signer,
131
+ uint64_t fee,
132
+ uint32_t deadline,
133
+ const char *namespace,
134
+ const char *parent,
135
+ const char *rental_sink,
136
+ uint64_t rental_fee);
137
+
138
+ bool nem_transaction_create_mosaic_creation(nem_transaction_ctx *ctx,
139
+ uint8_t network,
140
+ uint32_t timestamp,
141
+ const ed25519_public_key signer,
142
+ uint64_t fee,
143
+ uint32_t deadline,
144
+ const char *namespace,
145
+ const char *mosaic,
146
+ const char *description,
147
+ uint32_t divisibility,
148
+ uint64_t supply,
149
+ bool mutable_supply,
150
+ bool transferable,
151
+ uint32_t levy_type,
152
+ uint64_t levy_fee,
153
+ const char *levy_address,
154
+ const char *levy_namespace,
155
+ const char *levy_mosaic,
156
+ const char *creation_sink,
157
+ uint64_t creation_fee);
158
+
159
+ bool nem_transaction_create_mosaic_supply_change(nem_transaction_ctx *ctx,
160
+ uint8_t network,
161
+ uint32_t timestamp,
162
+ const ed25519_public_key signer,
163
+ uint64_t fee,
164
+ uint32_t deadline,
165
+ const char *namespace,
166
+ const char *mosaic,
167
+ uint32_t type,
168
+ uint64_t delta);
169
+
170
+ bool nem_transaction_create_aggregate_modification(nem_transaction_ctx *ctx,
171
+ uint8_t network,
172
+ uint32_t timestamp,
173
+ const ed25519_public_key signer,
174
+ uint64_t fee,
175
+ uint32_t deadline,
176
+ uint32_t modifications,
177
+ bool relative_change);
178
+
179
+ bool nem_transaction_write_cosignatory_modification(nem_transaction_ctx *ctx,
180
+ uint32_t type,
181
+ const ed25519_public_key cosignatory);
182
+
183
+ bool nem_transaction_write_minimum_cosignatories(nem_transaction_ctx *ctx,
184
+ int32_t relative_change);
185
+
186
+ bool nem_transaction_create_importance_transfer(nem_transaction_ctx *ctx,
187
+ uint8_t network,
188
+ uint32_t timestamp,
189
+ const ed25519_public_key signer,
190
+ uint64_t fee,
191
+ uint32_t deadline,
192
+ uint32_t mode,
193
+ const ed25519_public_key remote);
194
+
195
+ #ifdef __cplusplus
196
+ } /* extern "C" */
197
+ #endif
198
+
199
+ #endif
@@ -0,0 +1,35 @@
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 __NIST256P1_H__
25
+ #define __NIST256P1_H__
26
+
27
+ #include <stdint.h>
28
+
29
+ #include "ecdsa.h"
30
+ #include "bip32.h"
31
+
32
+ extern const ecdsa_curve nist256p1;
33
+ extern const curve_info nist256p1_info;
34
+
35
+ #endif
@@ -0,0 +1,64 @@
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 __PBKDF2_H__
25
+ #define __PBKDF2_H__
26
+
27
+ #include <stdint.h>
28
+ #include <TrezorCrypto/sha2.h>
29
+
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+
34
+ typedef struct _PBKDF2_HMAC_SHA256_CTX {
35
+ uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)];
36
+ uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)];
37
+ uint32_t f[SHA256_DIGEST_LENGTH / sizeof(uint32_t)];
38
+ uint32_t g[SHA256_BLOCK_LENGTH / sizeof(uint32_t)];
39
+ char first;
40
+ } PBKDF2_HMAC_SHA256_CTX;
41
+
42
+ typedef struct _PBKDF2_HMAC_SHA512_CTX {
43
+ uint64_t odig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)];
44
+ uint64_t idig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)];
45
+ uint64_t f[SHA512_DIGEST_LENGTH / sizeof(uint64_t)];
46
+ uint64_t g[SHA512_BLOCK_LENGTH / sizeof(uint64_t)];
47
+ char first;
48
+ } PBKDF2_HMAC_SHA512_CTX;
49
+
50
+ void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, size_t passlen, const uint8_t *salt, size_t saltlen, uint32_t blocknr);
51
+ void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, uint32_t iterations);
52
+ void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key);
53
+ void pbkdf2_hmac_sha256(const uint8_t *pass, size_t passlen, const uint8_t *salt, size_t saltlen, uint32_t iterations, uint8_t *key, size_t keylen);
54
+
55
+ void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, size_t passlen, const uint8_t *salt, size_t saltlen, uint32_t blocknr);
56
+ void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, uint32_t iterations);
57
+ void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key);
58
+ void pbkdf2_hmac_sha512(const uint8_t *pass, size_t passlen, const uint8_t *salt, size_t saltlen, uint32_t iterations, uint8_t *key, size_t keylen);
59
+
60
+ #ifdef __cplusplus
61
+ } /* extern "C" */
62
+ #endif
63
+
64
+ #endif
@@ -0,0 +1,44 @@
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 __RAND_H__
25
+ #define __RAND_H__
26
+
27
+ #include <stdint.h>
28
+ #include <stdlib.h>
29
+
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+
34
+ uint32_t random32(void);
35
+ void random_buffer(uint8_t *buf, size_t len);
36
+
37
+ uint32_t random_uniform(uint32_t n);
38
+ void random_permute(char *buf, size_t len);
39
+
40
+ #ifdef __cplusplus
41
+ } /* extern "C" */
42
+ #endif
43
+
44
+ #endif
@@ -0,0 +1,37 @@
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 __RC4_H__
24
+ #define __RC4_H__
25
+
26
+ #include <stdint.h>
27
+ #include <stddef.h>
28
+
29
+ typedef struct {
30
+ uint8_t S[256];
31
+ uint8_t i, j;
32
+ } RC4_CTX;
33
+
34
+ void rc4_init(RC4_CTX *ctx, const uint8_t *key, size_t length);
35
+ void rc4_encrypt(RC4_CTX *ctx, uint8_t *buffer, size_t length);
36
+
37
+ #endif
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) 2013-2014 Tomas Dzetkulic
3
+ * Copyright (c) 2013-2014 Pavol Rusnak
4
+ * Copyright (c) 2015-2017 Jochen Hoenicke
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 __RFC6979_H__
26
+ #define __RFC6979_H__
27
+
28
+ #include <stdint.h>
29
+ #include <TrezorCrypto/bignum.h>
30
+
31
+ // rfc6979 pseudo random number generator state
32
+ typedef struct {
33
+ uint8_t v[32], k[32];
34
+ } rfc6979_state;
35
+
36
+ void init_rfc6979(const uint8_t *priv_key, const uint8_t *hash, rfc6979_state *rng);
37
+ void generate_rfc6979(uint8_t rnd[32], rfc6979_state *rng);
38
+ void generate_k_rfc6979(bignum256 *k, rfc6979_state *rng);
39
+
40
+ #endif
@@ -0,0 +1,28 @@
1
+ #ifndef __RIPEMD160_H__
2
+ #define __RIPEMD160_H__
3
+
4
+ #include <stdint.h>
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ #define RIPEMD160_BLOCK_LENGTH 64
11
+ #define RIPEMD160_DIGEST_LENGTH 20
12
+
13
+ typedef struct _RIPEMD160_CTX {
14
+ uint32_t total[2]; /*!< number of bytes processed */
15
+ uint32_t state[5]; /*!< intermediate digest state */
16
+ uint8_t buffer[RIPEMD160_BLOCK_LENGTH]; /*!< data block being processed */
17
+ } RIPEMD160_CTX;
18
+
19
+ void ripemd160_Init(RIPEMD160_CTX *ctx);
20
+ void ripemd160_Update(RIPEMD160_CTX *ctx, const uint8_t *input, uint32_t ilen);
21
+ void ripemd160_Final(RIPEMD160_CTX *ctx, uint8_t output[RIPEMD160_DIGEST_LENGTH]);
22
+ void ripemd160(const uint8_t *msg, uint32_t msg_len, uint8_t hash[RIPEMD160_DIGEST_LENGTH]);
23
+
24
+ #ifdef __cplusplus
25
+ } /* extern "C" */
26
+ #endif
27
+
28
+ #endif
@@ -0,0 +1,45 @@
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 __XRP_BASE58_H__
25
+ #define __XRP_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 xrp_b58digits[];
36
+ extern const int8_t xrp_b58digits_map[];
37
+
38
+ int xrp_base58_encode_check(const uint8_t *data, int len, HasherType hasher_type, char *str, int strsize);
39
+ int xrp_base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen);
40
+
41
+ #ifdef __cplusplus
42
+ } /* extern "C" */
43
+ #endif
44
+
45
+ #endif
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright (c) 2019 Anatolii Kurotych
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 __SCHNORR_H__
24
+ #define __SCHNORR_H__
25
+
26
+ #include <TrezorCrypto/ecdsa.h>
27
+
28
+ #if defined(__cplusplus)
29
+ extern "C"
30
+ {
31
+ #endif
32
+
33
+ // result of sign operation
34
+ typedef struct {
35
+ uint8_t r[32];
36
+ uint8_t s[32];
37
+ } schnorr_sign_pair;
38
+
39
+ // sign/verify returns 0 if operation succeeded
40
+
41
+ // k is a random from [1, ..., order-1]
42
+ int schnorr_sign(const ecdsa_curve *curve, const uint8_t *sk, const bignum256 *k, const uint8_t *m, schnorr_sign_pair *sig);
43
+ int schnorr_verify(const ecdsa_curve *curve, const uint8_t *pk, const uint8_t *m, const schnorr_sign_pair *sig);
44
+ #ifdef __cplusplus
45
+ } /* extern "C" */
46
+ #endif
47
+
48
+ #endif