react-native-privyx-crypto 0.1.0
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 +113 -0
- package/android/build/generated/source/buildConfig/debug/com/privyx/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +7 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
- package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +1 -0
- package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/react-native-privyx-crypto_debug.kotlin_module +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/privyx/BuildConfig.class +0 -0
- package/android/build/intermediates/library_and_local_jars_jni/debug/copyDebugJniLibsProjectAndLocalJars/jni/arm64-v8a/libprivyx_crypto.so +0 -0
- package/android/build/intermediates/library_and_local_jars_jni/debug/copyDebugJniLibsProjectAndLocalJars/jni/armeabi-v7a/libprivyx_crypto.so +0 -0
- package/android/build/intermediates/library_and_local_jars_jni/debug/copyDebugJniLibsProjectAndLocalJars/jni/x86_64/libprivyx_crypto.so +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +7 -0
- package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-react-native-privyx-crypto.jar +0 -0
- package/android/build/intermediates/merged_jni_libs/debug/mergeDebugJniLibFolders/out/arm64-v8a/libprivyx_crypto.so +0 -0
- package/android/build/intermediates/merged_jni_libs/debug/mergeDebugJniLibFolders/out/armeabi-v7a/libprivyx_crypto.so +0 -0
- package/android/build/intermediates/merged_jni_libs/debug/mergeDebugJniLibFolders/out/x86_64/libprivyx_crypto.so +0 -0
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +7 -0
- package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +1 -0
- package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +1 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +1 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +2 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/aar/react-native-privyx-crypto-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +17 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/react-native-privyx-crypto_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/privyx/PrivyxCryptoModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/privyx/PrivyxCryptoModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/privyx/PrivyxCryptoPackage.class +0 -0
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/privyx/PrivyxCryptoModule.kt +133 -0
- package/android/src/main/java/com/privyx/PrivyxCryptoPackage.kt +17 -0
- package/android/src/main/jni/jni.c +134 -0
- package/include/libprivyx_crypto.h +18 -0
- package/include/module.modulemap +4 -0
- package/ios/PrivyxCrypto.mm +128 -0
- package/ios/react-native-privyx-crypto.podspec +25 -0
- package/libs/android/arm64-v8a/libprivyx_crypto.so +0 -0
- package/libs/android/armeabi-v7a/libprivyx_crypto.so +0 -0
- package/libs/android/x86_64/libprivyx_crypto.so +0 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/Info.plist +48 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64/Headers/libprivyx_crypto.h +18 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64/Headers/module.modulemap +4 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64/libprivyx.a +0 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator/Headers/libprivyx_crypto.h +18 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap +4 -0
- package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator/libprivyx-sim.a +0 -0
- package/package.json +23 -0
- package/react-native.config.js +10 -0
- package/src/NativePrivyxCrypto.ts +16 -0
- package/src/index.tsx +16 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// android/app/src/main/java/com/privyx/PrivyxCryptoPackage.kt
|
|
2
|
+
package com.privyx
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
9
|
+
|
|
10
|
+
class PrivyxCryptoModule(reactContext: ReactApplicationContext) :
|
|
11
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
12
|
+
|
|
13
|
+
override fun getName() = "PrivyxCrypto"
|
|
14
|
+
|
|
15
|
+
companion object {
|
|
16
|
+
init {
|
|
17
|
+
System.loadLibrary("privyx_crypto")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// JNI declarations
|
|
21
|
+
@JvmStatic
|
|
22
|
+
private external fun jniGenerateX25519KeyPair(): Array<String>
|
|
23
|
+
@JvmStatic
|
|
24
|
+
private external fun jniX25519DeriveSecret(privKey: String, pubKey: String): String
|
|
25
|
+
@JvmStatic
|
|
26
|
+
private external fun jniGenerateMlKemKeyPair(): Array<String>
|
|
27
|
+
@JvmStatic
|
|
28
|
+
private external fun jniMlKemEncapsulate(pubKey: String): Array<String>
|
|
29
|
+
@JvmStatic
|
|
30
|
+
private external fun jniMlKemDecapsulate(privKey: String, ct: String): String
|
|
31
|
+
@JvmStatic
|
|
32
|
+
private external fun jniDeriveHybridSecret(x25519: String, mlkem: String): String
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private external fun jniEncrypt(pt: String, ss: String, iv: String): String
|
|
35
|
+
@JvmStatic
|
|
36
|
+
private external fun jniDecrypt(ct: String, iv: String, ss: String): String
|
|
37
|
+
@JvmStatic
|
|
38
|
+
private external fun jniGenerateIV(): String
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ReactMethod
|
|
42
|
+
fun generateX25519KeyPair(promise: Promise) {
|
|
43
|
+
try {
|
|
44
|
+
val keys = jniGenerateX25519KeyPair()
|
|
45
|
+
val result = WritableNativeMap()
|
|
46
|
+
result.putString("publicKey", keys[0])
|
|
47
|
+
result.putString("privateKey", keys[1])
|
|
48
|
+
promise.resolve(result)
|
|
49
|
+
} catch (e: Exception) {
|
|
50
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun generateMlKemKeyPair(promise: Promise) {
|
|
56
|
+
try {
|
|
57
|
+
val keys = jniGenerateMlKemKeyPair()
|
|
58
|
+
val result = WritableNativeMap()
|
|
59
|
+
result.putString("publicKey", keys[0])
|
|
60
|
+
result.putString("privateKey", keys[1])
|
|
61
|
+
promise.resolve(result)
|
|
62
|
+
} catch (e: Exception) {
|
|
63
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@ReactMethod
|
|
68
|
+
fun x25519DeriveSecret(privateKey: String, publicKey: String, promise: Promise) {
|
|
69
|
+
try {
|
|
70
|
+
promise.resolve(jniX25519DeriveSecret(privateKey, publicKey))
|
|
71
|
+
} catch (e: Exception) {
|
|
72
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod
|
|
77
|
+
fun mlKemEncapsulate(publicKey: String, promise: Promise) {
|
|
78
|
+
try {
|
|
79
|
+
val result = jniMlKemEncapsulate(publicKey)
|
|
80
|
+
val map = WritableNativeMap()
|
|
81
|
+
map.putString("sharedSecret", result[0])
|
|
82
|
+
map.putString("ciphertext", result[1])
|
|
83
|
+
promise.resolve(map)
|
|
84
|
+
} catch (e: Exception) {
|
|
85
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
fun mlKemDecapsulate(privateKey: String, ciphertext: String, promise: Promise) {
|
|
91
|
+
try {
|
|
92
|
+
promise.resolve(jniMlKemDecapsulate(privateKey, ciphertext))
|
|
93
|
+
} catch (e: Exception) {
|
|
94
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
fun deriveHybridSecret(x25519Secret: String, mlkemSecret: String, promise: Promise) {
|
|
100
|
+
try {
|
|
101
|
+
promise.resolve(jniDeriveHybridSecret(x25519Secret, mlkemSecret))
|
|
102
|
+
} catch (e: Exception) {
|
|
103
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactMethod
|
|
108
|
+
fun encrypt(plaintext: String, sharedSecret: String, iv: String, promise: Promise) {
|
|
109
|
+
try {
|
|
110
|
+
promise.resolve(jniEncrypt(plaintext, sharedSecret, iv))
|
|
111
|
+
} catch (e: Exception) {
|
|
112
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
fun decrypt(ciphertext: String, iv: String, sharedSecret: String, promise: Promise) {
|
|
118
|
+
try {
|
|
119
|
+
promise.resolve(jniDecrypt(ciphertext, iv, sharedSecret))
|
|
120
|
+
} catch (e: Exception) {
|
|
121
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@ReactMethod
|
|
126
|
+
fun generateIV(promise: Promise) {
|
|
127
|
+
try {
|
|
128
|
+
promise.resolve(jniGenerateIV())
|
|
129
|
+
} catch (e: Exception) {
|
|
130
|
+
promise.reject("CRYPTO_ERROR", e.message, e)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// android/app/src/main/java/com/privyx/PrivyxCryptoPackage.kt
|
|
2
|
+
package com.privyx
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.ReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
|
|
9
|
+
class PrivyxCryptoPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(PrivyxCryptoModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// native/privyx-crypto/src/jni.c
|
|
2
|
+
#include <jni.h>
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
|
|
6
|
+
// Declarations from Rust FFI
|
|
7
|
+
extern void privyx_generate_x25519_keypair(char **out_pub, char **out_priv);
|
|
8
|
+
extern char *privyx_x25519_derive_secret(const char *private_key, const char *public_key);
|
|
9
|
+
extern void privyx_generate_mlkem_keypair(char **out_pub, char **out_priv);
|
|
10
|
+
extern void privyx_mlkem_encapsulate(const char *public_key, char **out_shared, char **out_ct);
|
|
11
|
+
extern char *privyx_mlkem_decapsulate(const char *private_key, const char *ciphertext);
|
|
12
|
+
extern char *privyx_derive_hybrid_secret(const char *x25519_secret, const char *mlkem_secret);
|
|
13
|
+
extern char *privyx_encrypt(const char *plaintext, const char *shared_secret, const char *iv);
|
|
14
|
+
extern char *privyx_decrypt(const char *ciphertext, const char *iv, const char *shared_secret);
|
|
15
|
+
extern char *privyx_generate_iv(void);
|
|
16
|
+
extern void privyx_free_string(char *s);
|
|
17
|
+
|
|
18
|
+
// Helper: convert Java string to malloc'd C string
|
|
19
|
+
static char *jstring_to_c(JNIEnv *env, jstring js) {
|
|
20
|
+
const char *utf = (*env)->GetStringUTFChars(env, js, NULL);
|
|
21
|
+
char *c = strdup(utf);
|
|
22
|
+
(*env)->ReleaseStringUTFChars(env, js, utf);
|
|
23
|
+
return c;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Helper: convert C string to Java string, then free the C string
|
|
27
|
+
static jstring c_to_jstring_free(JNIEnv *env, char *cs) {
|
|
28
|
+
jstring js = (*env)->NewStringUTF(env, cs);
|
|
29
|
+
privyx_free_string(cs);
|
|
30
|
+
return js;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
JNIEXPORT jobjectArray JNICALL
|
|
34
|
+
Java_com_privyx_PrivyxCryptoModule_jniGenerateX25519KeyPair(JNIEnv *env, jclass clazz) {
|
|
35
|
+
char *pub = NULL, *priv = NULL;
|
|
36
|
+
privyx_generate_x25519_keypair(&pub, &priv);
|
|
37
|
+
|
|
38
|
+
jclass strClass = (*env)->FindClass(env, "java/lang/String");
|
|
39
|
+
jobjectArray arr = (*env)->NewObjectArray(env, 2, strClass, NULL);
|
|
40
|
+
(*env)->SetObjectArrayElement(env, arr, 0, (*env)->NewStringUTF(env, pub));
|
|
41
|
+
(*env)->SetObjectArrayElement(env, arr, 1, (*env)->NewStringUTF(env, priv));
|
|
42
|
+
privyx_free_string(pub);
|
|
43
|
+
privyx_free_string(priv);
|
|
44
|
+
return arr;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
JNIEXPORT jstring JNICALL
|
|
48
|
+
Java_com_privyx_PrivyxCryptoModule_jniX25519DeriveSecret(JNIEnv *env, jclass clazz, jstring priv, jstring pub) {
|
|
49
|
+
char *cpriv = jstring_to_c(env, priv);
|
|
50
|
+
char *cpub = jstring_to_c(env, pub);
|
|
51
|
+
char *result = privyx_x25519_derive_secret(cpriv, cpub);
|
|
52
|
+
free(cpriv);
|
|
53
|
+
free(cpub);
|
|
54
|
+
return c_to_jstring_free(env, result);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
JNIEXPORT jobjectArray JNICALL
|
|
58
|
+
Java_com_privyx_PrivyxCryptoModule_jniGenerateMlKemKeyPair(JNIEnv *env, jclass clazz) {
|
|
59
|
+
char *pub = NULL, *priv = NULL;
|
|
60
|
+
privyx_generate_mlkem_keypair(&pub, &priv);
|
|
61
|
+
|
|
62
|
+
jclass strClass = (*env)->FindClass(env, "java/lang/String");
|
|
63
|
+
jobjectArray arr = (*env)->NewObjectArray(env, 2, strClass, NULL);
|
|
64
|
+
(*env)->SetObjectArrayElement(env, arr, 0, (*env)->NewStringUTF(env, pub));
|
|
65
|
+
(*env)->SetObjectArrayElement(env, arr, 1, (*env)->NewStringUTF(env, priv));
|
|
66
|
+
privyx_free_string(pub);
|
|
67
|
+
privyx_free_string(priv);
|
|
68
|
+
return arr;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
JNIEXPORT jobjectArray JNICALL
|
|
72
|
+
Java_com_privyx_PrivyxCryptoModule_jniMlKemEncapsulate(JNIEnv *env, jclass clazz, jstring pub) {
|
|
73
|
+
char *cpub = jstring_to_c(env, pub);
|
|
74
|
+
char *shared = NULL, *ct = NULL;
|
|
75
|
+
privyx_mlkem_encapsulate(cpub, &shared, &ct);
|
|
76
|
+
free(cpub);
|
|
77
|
+
|
|
78
|
+
jclass strClass = (*env)->FindClass(env, "java/lang/String");
|
|
79
|
+
jobjectArray arr = (*env)->NewObjectArray(env, 2, strClass, NULL);
|
|
80
|
+
(*env)->SetObjectArrayElement(env, arr, 0, (*env)->NewStringUTF(env, shared));
|
|
81
|
+
(*env)->SetObjectArrayElement(env, arr, 1, (*env)->NewStringUTF(env, ct));
|
|
82
|
+
privyx_free_string(shared);
|
|
83
|
+
privyx_free_string(ct);
|
|
84
|
+
return arr;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
JNIEXPORT jstring JNICALL
|
|
88
|
+
Java_com_privyx_PrivyxCryptoModule_jniMlKemDecapsulate(JNIEnv *env, jclass clazz, jstring priv, jstring ct) {
|
|
89
|
+
char *cpriv = jstring_to_c(env, priv);
|
|
90
|
+
char *cct = jstring_to_c(env, ct);
|
|
91
|
+
char *result = privyx_mlkem_decapsulate(cpriv, cct);
|
|
92
|
+
free(cpriv);
|
|
93
|
+
free(cct);
|
|
94
|
+
return c_to_jstring_free(env, result);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
JNIEXPORT jstring JNICALL
|
|
98
|
+
Java_com_privyx_PrivyxCryptoModule_jniDeriveHybridSecret(JNIEnv *env, jclass clazz, jstring x, jstring m) {
|
|
99
|
+
char *cx = jstring_to_c(env, x);
|
|
100
|
+
char *cm = jstring_to_c(env, m);
|
|
101
|
+
char *result = privyx_derive_hybrid_secret(cx, cm);
|
|
102
|
+
free(cx);
|
|
103
|
+
free(cm);
|
|
104
|
+
return c_to_jstring_free(env, result);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
JNIEXPORT jstring JNICALL
|
|
108
|
+
Java_com_privyx_PrivyxCryptoModule_jniEncrypt(JNIEnv *env, jclass clazz, jstring pt, jstring ss, jstring iv) {
|
|
109
|
+
char *cpt = jstring_to_c(env, pt);
|
|
110
|
+
char *css = jstring_to_c(env, ss);
|
|
111
|
+
char *civ = jstring_to_c(env, iv);
|
|
112
|
+
char *result = privyx_encrypt(cpt, css, civ);
|
|
113
|
+
free(cpt);
|
|
114
|
+
free(css);
|
|
115
|
+
free(civ);
|
|
116
|
+
return c_to_jstring_free(env, result);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
JNIEXPORT jstring JNICALL
|
|
120
|
+
Java_com_privyx_PrivyxCryptoModule_jniDecrypt(JNIEnv *env, jclass clazz, jstring ct, jstring iv, jstring ss) {
|
|
121
|
+
char *cct = jstring_to_c(env, ct);
|
|
122
|
+
char *civ = jstring_to_c(env, iv);
|
|
123
|
+
char *css = jstring_to_c(env, ss);
|
|
124
|
+
char *result = privyx_decrypt(cct, civ, css);
|
|
125
|
+
free(cct);
|
|
126
|
+
free(civ);
|
|
127
|
+
free(css);
|
|
128
|
+
return c_to_jstring_free(env, result);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
JNIEXPORT jstring JNICALL
|
|
132
|
+
Java_com_privyx_PrivyxCryptoModule_jniGenerateIV(JNIEnv *env, jclass clazz) {
|
|
133
|
+
return c_to_jstring_free(env, privyx_generate_iv());
|
|
134
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#ifndef libprivyx_crypto_h
|
|
2
|
+
#define libprivyx_crypto_h
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
|
|
6
|
+
void privyx_free_string(char *s);
|
|
7
|
+
|
|
8
|
+
void privyx_generate_x25519_keypair(char **out_pub, char **out_priv);
|
|
9
|
+
char *privyx_x25519_derive_secret(const char *private_key, const char *public_key);
|
|
10
|
+
void privyx_generate_mlkem_keypair(char **out_pub, char **out_priv);
|
|
11
|
+
void privyx_mlkem_encapsulate(const char *public_key, char **out_shared, char **out_ct);
|
|
12
|
+
char *privyx_mlkem_decapsulate(const char *private_key, const char *ciphertext);
|
|
13
|
+
char *privyx_derive_hybrid_secret(const char *x25519_secret, const char *mlkem_secret);
|
|
14
|
+
char *privyx_encrypt(const char *plaintext, const char *shared_secret, const char *iv);
|
|
15
|
+
char *privyx_decrypt(const char *ciphertext, const char *iv, const char *shared_secret);
|
|
16
|
+
char *privyx_generate_iv(void);
|
|
17
|
+
|
|
18
|
+
#endif
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
extern "C" {
|
|
4
|
+
#include "../include/libprivyx_crypto.h"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@interface PrivyxCrypto : NSObject <RCTBridgeModule>
|
|
8
|
+
@end
|
|
9
|
+
|
|
10
|
+
@implementation PrivyxCrypto
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_MODULE()
|
|
13
|
+
|
|
14
|
+
+ (BOOL)requiresMainQueueSetup { return NO; }
|
|
15
|
+
|
|
16
|
+
RCT_EXPORT_METHOD(generateX25519KeyPair:(RCTPromiseResolveBlock)resolve
|
|
17
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
18
|
+
{
|
|
19
|
+
char *pubKey = NULL;
|
|
20
|
+
char *privKey = NULL;
|
|
21
|
+
privyx_generate_x25519_keypair(&pubKey, &privKey);
|
|
22
|
+
|
|
23
|
+
NSString *pubStr = [NSString stringWithUTF8String:pubKey];
|
|
24
|
+
NSString *privStr = [NSString stringWithUTF8String:privKey];
|
|
25
|
+
privyx_free_string(pubKey);
|
|
26
|
+
privyx_free_string(privKey);
|
|
27
|
+
|
|
28
|
+
resolve(@{ @"publicKey": pubStr, @"privateKey": privStr });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
RCT_EXPORT_METHOD(generateMlKemKeyPair:(RCTPromiseResolveBlock)resolve
|
|
32
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
33
|
+
{
|
|
34
|
+
char *pubKey = NULL;
|
|
35
|
+
char *privKey = NULL;
|
|
36
|
+
privyx_generate_mlkem_keypair(&pubKey, &privKey);
|
|
37
|
+
|
|
38
|
+
NSString *pubStr = [NSString stringWithUTF8String:pubKey];
|
|
39
|
+
NSString *privStr = [NSString stringWithUTF8String:privKey];
|
|
40
|
+
privyx_free_string(pubKey);
|
|
41
|
+
privyx_free_string(privKey);
|
|
42
|
+
|
|
43
|
+
resolve(@{ @"publicKey": pubStr, @"privateKey": privStr });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
RCT_EXPORT_METHOD(x25519DeriveSecret:(NSString *)privateKey
|
|
47
|
+
publicKey:(NSString *)publicKey
|
|
48
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
49
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
50
|
+
{
|
|
51
|
+
char *result = privyx_x25519_derive_secret(privateKey.UTF8String, publicKey.UTF8String);
|
|
52
|
+
NSString *str = [NSString stringWithUTF8String:result];
|
|
53
|
+
privyx_free_string(result);
|
|
54
|
+
resolve(str);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
RCT_EXPORT_METHOD(mlKemEncapsulate:(NSString *)publicKey
|
|
58
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
59
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
60
|
+
{
|
|
61
|
+
char *shared = NULL;
|
|
62
|
+
char *ct = NULL;
|
|
63
|
+
privyx_mlkem_encapsulate(publicKey.UTF8String, &shared, &ct);
|
|
64
|
+
|
|
65
|
+
NSString *sharedStr = [NSString stringWithUTF8String:shared];
|
|
66
|
+
NSString *ctStr = [NSString stringWithUTF8String:ct];
|
|
67
|
+
privyx_free_string(shared);
|
|
68
|
+
privyx_free_string(ct);
|
|
69
|
+
|
|
70
|
+
resolve(@{ @"sharedSecret": sharedStr, @"ciphertext": ctStr });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
RCT_EXPORT_METHOD(mlKemDecapsulate:(NSString *)privateKey
|
|
74
|
+
ciphertext:(NSString *)ciphertext
|
|
75
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
76
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
77
|
+
{
|
|
78
|
+
char *result = privyx_mlkem_decapsulate(privateKey.UTF8String, ciphertext.UTF8String);
|
|
79
|
+
NSString *str = [NSString stringWithUTF8String:result];
|
|
80
|
+
privyx_free_string(result);
|
|
81
|
+
resolve(str);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
RCT_EXPORT_METHOD(deriveHybridSecret:(NSString *)x25519Secret
|
|
85
|
+
mlkemSecret:(NSString *)mlkemSecret
|
|
86
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
87
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
88
|
+
{
|
|
89
|
+
char *result = privyx_derive_hybrid_secret(x25519Secret.UTF8String, mlkemSecret.UTF8String);
|
|
90
|
+
NSString *str = [NSString stringWithUTF8String:result];
|
|
91
|
+
privyx_free_string(result);
|
|
92
|
+
resolve(str);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
RCT_EXPORT_METHOD(encrypt:(NSString *)plaintext
|
|
96
|
+
sharedSecret:(NSString *)sharedSecret
|
|
97
|
+
iv:(NSString *)iv
|
|
98
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
99
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
100
|
+
{
|
|
101
|
+
char *result = privyx_encrypt(plaintext.UTF8String, sharedSecret.UTF8String, iv.UTF8String);
|
|
102
|
+
NSString *str = [NSString stringWithUTF8String:result];
|
|
103
|
+
privyx_free_string(result);
|
|
104
|
+
resolve(str);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
RCT_EXPORT_METHOD(decrypt:(NSString *)ciphertext
|
|
108
|
+
iv:(NSString *)iv
|
|
109
|
+
sharedSecret:(NSString *)sharedSecret
|
|
110
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
111
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
112
|
+
{
|
|
113
|
+
char *result = privyx_decrypt(ciphertext.UTF8String, iv.UTF8String, sharedSecret.UTF8String);
|
|
114
|
+
NSString *str = [NSString stringWithUTF8String:result];
|
|
115
|
+
privyx_free_string(result);
|
|
116
|
+
resolve(str);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
RCT_EXPORT_METHOD(generateIV:(RCTPromiseResolveBlock)resolve
|
|
120
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
121
|
+
{
|
|
122
|
+
char *result = privyx_generate_iv();
|
|
123
|
+
NSString *str = [NSString stringWithUTF8String:result];
|
|
124
|
+
privyx_free_string(result);
|
|
125
|
+
resolve(str);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Pod::Spec.new do |s|
|
|
2
|
+
s.name = 'react-native-privyx-crypto'
|
|
3
|
+
s.version = '0.1.0'
|
|
4
|
+
s.summary = 'Post-quantum crypto native module for React Native'
|
|
5
|
+
s.authors = { 'Privyx' => 'dev@privyx.network' }
|
|
6
|
+
s.homepage = 'https://privyx.network'
|
|
7
|
+
s.source = { :path => '..' }
|
|
8
|
+
s.license = { :type => 'MIT' }
|
|
9
|
+
s.source_files = 'PrivyxCrypto.mm'
|
|
10
|
+
|
|
11
|
+
s.vendored_libraries = '../libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator/libprivyx-sim.a', '../libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64/libprivyx.a'
|
|
12
|
+
|
|
13
|
+
s.pod_target_xcconfig = {
|
|
14
|
+
'HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../../sdk_privyx/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator/Headers"',
|
|
15
|
+
'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../../sdk_privyx/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator"',
|
|
16
|
+
'OTHER_LDFLAGS' => '-lprivyx-sim'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
s.user_target_xcconfig = {
|
|
20
|
+
'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../../sdk_privyx/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator"',
|
|
21
|
+
'OTHER_LDFLAGS' => '-lprivyx-sim'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
s.dependency 'React-Core'
|
|
25
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>libprivyx.a</string>
|
|
10
|
+
<key>HeadersPath</key>
|
|
11
|
+
<string>Headers</string>
|
|
12
|
+
<key>LibraryIdentifier</key>
|
|
13
|
+
<string>ios-arm64</string>
|
|
14
|
+
<key>LibraryPath</key>
|
|
15
|
+
<string>libprivyx.a</string>
|
|
16
|
+
<key>SupportedArchitectures</key>
|
|
17
|
+
<array>
|
|
18
|
+
<string>arm64</string>
|
|
19
|
+
</array>
|
|
20
|
+
<key>SupportedPlatform</key>
|
|
21
|
+
<string>ios</string>
|
|
22
|
+
</dict>
|
|
23
|
+
<dict>
|
|
24
|
+
<key>BinaryPath</key>
|
|
25
|
+
<string>libprivyx-sim.a</string>
|
|
26
|
+
<key>HeadersPath</key>
|
|
27
|
+
<string>Headers</string>
|
|
28
|
+
<key>LibraryIdentifier</key>
|
|
29
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
30
|
+
<key>LibraryPath</key>
|
|
31
|
+
<string>libprivyx-sim.a</string>
|
|
32
|
+
<key>SupportedArchitectures</key>
|
|
33
|
+
<array>
|
|
34
|
+
<string>arm64</string>
|
|
35
|
+
<string>x86_64</string>
|
|
36
|
+
</array>
|
|
37
|
+
<key>SupportedPlatform</key>
|
|
38
|
+
<string>ios</string>
|
|
39
|
+
<key>SupportedPlatformVariant</key>
|
|
40
|
+
<string>simulator</string>
|
|
41
|
+
</dict>
|
|
42
|
+
</array>
|
|
43
|
+
<key>CFBundlePackageType</key>
|
|
44
|
+
<string>XFWK</string>
|
|
45
|
+
<key>XCFrameworkFormatVersion</key>
|
|
46
|
+
<string>1.0</string>
|
|
47
|
+
</dict>
|
|
48
|
+
</plist>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#ifndef libprivyx_crypto_h
|
|
2
|
+
#define libprivyx_crypto_h
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
|
|
6
|
+
void privyx_free_string(char *s);
|
|
7
|
+
|
|
8
|
+
void privyx_generate_x25519_keypair(char **out_pub, char **out_priv);
|
|
9
|
+
char *privyx_x25519_derive_secret(const char *private_key, const char *public_key);
|
|
10
|
+
void privyx_generate_mlkem_keypair(char **out_pub, char **out_priv);
|
|
11
|
+
void privyx_mlkem_encapsulate(const char *public_key, char **out_shared, char **out_ct);
|
|
12
|
+
char *privyx_mlkem_decapsulate(const char *private_key, const char *ciphertext);
|
|
13
|
+
char *privyx_derive_hybrid_secret(const char *x25519_secret, const char *mlkem_secret);
|
|
14
|
+
char *privyx_encrypt(const char *plaintext, const char *shared_secret, const char *iv);
|
|
15
|
+
char *privyx_decrypt(const char *ciphertext, const char *iv, const char *shared_secret);
|
|
16
|
+
char *privyx_generate_iv(void);
|
|
17
|
+
|
|
18
|
+
#endif
|
|
Binary file
|
package/libs/ios/PrivyxCryptoFFI.xcframework/ios-arm64_x86_64-simulator/Headers/libprivyx_crypto.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#ifndef libprivyx_crypto_h
|
|
2
|
+
#define libprivyx_crypto_h
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
|
|
6
|
+
void privyx_free_string(char *s);
|
|
7
|
+
|
|
8
|
+
void privyx_generate_x25519_keypair(char **out_pub, char **out_priv);
|
|
9
|
+
char *privyx_x25519_derive_secret(const char *private_key, const char *public_key);
|
|
10
|
+
void privyx_generate_mlkem_keypair(char **out_pub, char **out_priv);
|
|
11
|
+
void privyx_mlkem_encapsulate(const char *public_key, char **out_shared, char **out_ct);
|
|
12
|
+
char *privyx_mlkem_decapsulate(const char *private_key, const char *ciphertext);
|
|
13
|
+
char *privyx_derive_hybrid_secret(const char *x25519_secret, const char *mlkem_secret);
|
|
14
|
+
char *privyx_encrypt(const char *plaintext, const char *shared_secret, const char *iv);
|
|
15
|
+
char *privyx_decrypt(const char *ciphertext, const char *iv, const char *shared_secret);
|
|
16
|
+
char *privyx_generate_iv(void);
|
|
17
|
+
|
|
18
|
+
#endif
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-privyx-crypto",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Post-quantum hybrid cryptography for React Native (X25519 + ML-KEM-768 + AES-256-GCM)",
|
|
5
|
+
"main": "src/index.tsx",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest"
|
|
8
|
+
},
|
|
9
|
+
"keywords": ["react-native", "cryptography", "post-quantum", "ml-kem", "x25519", "aes-gcm"],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"react": "*",
|
|
13
|
+
"react-native": "*"
|
|
14
|
+
},
|
|
15
|
+
"codegenConfig": {
|
|
16
|
+
"name": "PrivyxCryptoSpec",
|
|
17
|
+
"type": "modules",
|
|
18
|
+
"jsSrcsDir": "src",
|
|
19
|
+
"android": {
|
|
20
|
+
"javaPackageName": "com.privyx"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
generateX25519KeyPair(): Promise<{ publicKey: string; privateKey: string }>;
|
|
6
|
+
generateMlKemKeyPair(): Promise<{ publicKey: string; privateKey: string }>;
|
|
7
|
+
x25519DeriveSecret(privateKey: string, publicKey: string): Promise<string>;
|
|
8
|
+
mlKemEncapsulate(publicKey: string): Promise<{ sharedSecret: string; ciphertext: string }>;
|
|
9
|
+
mlKemDecapsulate(privateKey: string, ciphertext: string): Promise<string>;
|
|
10
|
+
deriveHybridSecret(x25519Secret: string, mlkemSecret: string): Promise<string>;
|
|
11
|
+
encrypt(plaintext: string, sharedSecret: string, iv: string): Promise<string>;
|
|
12
|
+
decrypt(ciphertext: string, iv: string, sharedSecret: string): Promise<string>;
|
|
13
|
+
generateIV(): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('PrivyxCrypto');
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import NativePrivyxCrypto from './NativePrivyxCrypto';
|
|
2
|
+
|
|
3
|
+
export const generateX25519KeyPair = () => NativePrivyxCrypto.generateX25519KeyPair();
|
|
4
|
+
export const generateMlKemKeyPair = () => NativePrivyxCrypto.generateMlKemKeyPair();
|
|
5
|
+
export const x25519DeriveSecret = (privateKey: string, publicKey: string) =>
|
|
6
|
+
NativePrivyxCrypto.x25519DeriveSecret(privateKey, publicKey);
|
|
7
|
+
export const mlKemEncapsulate = (publicKey: string) => NativePrivyxCrypto.mlKemEncapsulate(publicKey);
|
|
8
|
+
export const mlKemDecapsulate = (privateKey: string, ciphertext: string) =>
|
|
9
|
+
NativePrivyxCrypto.mlKemDecapsulate(privateKey, ciphertext);
|
|
10
|
+
export const deriveHybridSecret = (x25519Secret: string, mlkemSecret: string) =>
|
|
11
|
+
NativePrivyxCrypto.deriveHybridSecret(x25519Secret, mlkemSecret);
|
|
12
|
+
export const encrypt = (plaintext: string, sharedSecret: string, iv: string) =>
|
|
13
|
+
NativePrivyxCrypto.encrypt(plaintext, sharedSecret, iv);
|
|
14
|
+
export const decrypt = (ciphertext: string, iv: string, sharedSecret: string) =>
|
|
15
|
+
NativePrivyxCrypto.decrypt(ciphertext, iv, sharedSecret);
|
|
16
|
+
export const generateIV = () => NativePrivyxCrypto.generateIV();
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"jsx": "react-jsx",
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"outDir": "lib"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|