@aws-amplify/react-native 1.0.1-console-preview.deaebd5.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/AmplifyRTNCore.podspec +35 -0
- package/LICENSE +201 -0
- package/android/build.gradle +85 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/AmplifyRTNCoreModule.kt +29 -0
- package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/AmplifyRTNCorePackage.kt +17 -0
- package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/BigInteger.kt +65 -0
- package/ios/AmplifyRTNCore-Bridging-Header.h +5 -0
- package/ios/AmplifyRTNCore.mm +21 -0
- package/ios/AmplifyRTNCore.swift +29 -0
- package/ios/AmplifyRTNCore.xcodeproj/project.pbxproj +283 -0
- package/ios/AmplifyRTNCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/BigInteger.swift +78 -0
- package/ios/JKBigInteger/JKBigDecimal.h +40 -0
- package/ios/JKBigInteger/JKBigDecimal.m +224 -0
- package/ios/JKBigInteger/JKBigInteger.h +58 -0
- package/ios/JKBigInteger/JKBigInteger.m +419 -0
- package/ios/JKBigInteger/LICENSE.txt +18 -0
- package/ios/JKBigInteger/LibTomMath/tommath.c +6925 -0
- package/ios/JKBigInteger/LibTomMath/tommath.h +584 -0
- package/ios/JKBigInteger/LibTomMath/tommath_class.h +999 -0
- package/ios/JKBigInteger/LibTomMath/tommath_superclass.h +76 -0
- package/lib/apis/computeModPow.d.ts +2 -0
- package/lib/apis/computeModPow.js +9 -0
- package/lib/apis/computeModPow.js.map +1 -0
- package/lib/apis/computeS.d.ts +2 -0
- package/lib/apis/computeS.js +9 -0
- package/lib/apis/computeS.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/nativeModule.d.ts +2 -0
- package/lib/nativeModule.js +18 -0
- package/lib/nativeModule.js.map +1 -0
- package/lib/types.d.ts +15 -0
- package/lib/types.js +5 -0
- package/lib/types.js.map +1 -0
- package/lib-esm/apis/computeModPow.d.ts +2 -0
- package/lib-esm/apis/computeModPow.js +5 -0
- package/lib-esm/apis/computeModPow.js.map +1 -0
- package/lib-esm/apis/computeS.d.ts +2 -0
- package/lib-esm/apis/computeS.js +5 -0
- package/lib-esm/apis/computeS.js.map +1 -0
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +5 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/nativeModule.d.ts +2 -0
- package/lib-esm/nativeModule.js +15 -0
- package/lib-esm/nativeModule.js.map +1 -0
- package/lib-esm/types.d.ts +15 -0
- package/lib-esm/types.js +4 -0
- package/lib-esm/types.js.map +1 -0
- package/package.json +57 -0
- package/src/apis/computeModPow.ts +8 -0
- package/src/apis/computeS.ts +8 -0
- package/src/index.ts +5 -0
- package/src/nativeModule.ts +22 -0
- package/src/types.ts +19 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 46;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
5E555C0D2413F4C50049A1A2 /* AmplifyRTNCore.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* AmplifyRTNCore.mm */; };
|
|
11
|
+
F4FF95D7245B92E800C19C63 /* AmplifyRTNCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* AmplifyRTNCore.swift */; };
|
|
12
|
+
/* End PBXBuildFile section */
|
|
13
|
+
|
|
14
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
15
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
|
16
|
+
isa = PBXCopyFilesBuildPhase;
|
|
17
|
+
buildActionMask = 2147483647;
|
|
18
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
19
|
+
dstSubfolderSpec = 16;
|
|
20
|
+
files = (
|
|
21
|
+
);
|
|
22
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
23
|
+
};
|
|
24
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
25
|
+
|
|
26
|
+
/* Begin PBXFileReference section */
|
|
27
|
+
134814201AA4EA6300B7C361 /* libAmplifyRTNCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAmplifyRTNCore.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
28
|
+
B3E7B5891CC2AC0600A0062D /* AmplifyRTNCore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AmplifyRTNCore.mm; sourceTree = "<group>"; };
|
|
29
|
+
F4FF95D5245B92E700C19C63 /* AmplifyRTNCore-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AmplifyRTNCore-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
30
|
+
F4FF95D6245B92E800C19C63 /* AmplifyRTNCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmplifyRTNCore.swift; sourceTree = "<group>"; };
|
|
31
|
+
/* End PBXFileReference section */
|
|
32
|
+
|
|
33
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
34
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
|
35
|
+
isa = PBXFrameworksBuildPhase;
|
|
36
|
+
buildActionMask = 2147483647;
|
|
37
|
+
files = (
|
|
38
|
+
);
|
|
39
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
40
|
+
};
|
|
41
|
+
/* End PBXFrameworksBuildPhase section */
|
|
42
|
+
|
|
43
|
+
/* Begin PBXGroup section */
|
|
44
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
45
|
+
isa = PBXGroup;
|
|
46
|
+
children = (
|
|
47
|
+
134814201AA4EA6300B7C361 /* libAmplifyRTNCore.a */,
|
|
48
|
+
);
|
|
49
|
+
name = Products;
|
|
50
|
+
sourceTree = "<group>";
|
|
51
|
+
};
|
|
52
|
+
58B511D21A9E6C8500147676 = {
|
|
53
|
+
isa = PBXGroup;
|
|
54
|
+
children = (
|
|
55
|
+
F4FF95D6245B92E800C19C63 /* AmplifyRTNCore.swift */,
|
|
56
|
+
B3E7B5891CC2AC0600A0062D /* AmplifyRTNCore.mm */,
|
|
57
|
+
F4FF95D5245B92E700C19C63 /* AmplifyRTNCore-Bridging-Header.h */,
|
|
58
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
59
|
+
);
|
|
60
|
+
sourceTree = "<group>";
|
|
61
|
+
};
|
|
62
|
+
/* End PBXGroup section */
|
|
63
|
+
|
|
64
|
+
/* Begin PBXNativeTarget section */
|
|
65
|
+
58B511DA1A9E6C8500147676 /* AmplifyRTNCore */ = {
|
|
66
|
+
isa = PBXNativeTarget;
|
|
67
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AmplifyRTNCore" */;
|
|
68
|
+
buildPhases = (
|
|
69
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
|
70
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
|
71
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
|
72
|
+
);
|
|
73
|
+
buildRules = (
|
|
74
|
+
);
|
|
75
|
+
dependencies = (
|
|
76
|
+
);
|
|
77
|
+
name = AmplifyRTNCore;
|
|
78
|
+
productName = RCTDataManager;
|
|
79
|
+
productReference = 134814201AA4EA6300B7C361 /* libAmplifyRTNCore.a */;
|
|
80
|
+
productType = "com.apple.product-type.library.static";
|
|
81
|
+
};
|
|
82
|
+
/* End PBXNativeTarget section */
|
|
83
|
+
|
|
84
|
+
/* Begin PBXProject section */
|
|
85
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
86
|
+
isa = PBXProject;
|
|
87
|
+
attributes = {
|
|
88
|
+
LastUpgradeCheck = 0920;
|
|
89
|
+
ORGANIZATIONNAME = Facebook;
|
|
90
|
+
TargetAttributes = {
|
|
91
|
+
58B511DA1A9E6C8500147676 = {
|
|
92
|
+
CreatedOnToolsVersion = 6.1.1;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AmplifyRTNCore" */;
|
|
97
|
+
compatibilityVersion = "Xcode 3.2";
|
|
98
|
+
developmentRegion = English;
|
|
99
|
+
hasScannedForEncodings = 0;
|
|
100
|
+
knownRegions = (
|
|
101
|
+
English,
|
|
102
|
+
en,
|
|
103
|
+
);
|
|
104
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
|
105
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
|
106
|
+
projectDirPath = "";
|
|
107
|
+
projectRoot = "";
|
|
108
|
+
targets = (
|
|
109
|
+
58B511DA1A9E6C8500147676 /* AmplifyRTNCore */,
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
/* End PBXProject section */
|
|
113
|
+
|
|
114
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
115
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
|
116
|
+
isa = PBXSourcesBuildPhase;
|
|
117
|
+
buildActionMask = 2147483647;
|
|
118
|
+
files = (
|
|
119
|
+
F4FF95D7245B92E800C19C63 /* AmplifyRTNCore.swift in Sources */,
|
|
120
|
+
B3E7B58A1CC2AC0600A0062D /* AmplifyRTNCore.mm in Sources */,
|
|
121
|
+
);
|
|
122
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
123
|
+
};
|
|
124
|
+
/* End PBXSourcesBuildPhase section */
|
|
125
|
+
|
|
126
|
+
/* Begin XCBuildConfiguration section */
|
|
127
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
128
|
+
isa = XCBuildConfiguration;
|
|
129
|
+
buildSettings = {
|
|
130
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
131
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
132
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
133
|
+
CLANG_ENABLE_MODULES = YES;
|
|
134
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
135
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
136
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
137
|
+
CLANG_WARN_COMMA = YES;
|
|
138
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
139
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
140
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
141
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
142
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
143
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
144
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
145
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
146
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
147
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
148
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
149
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
150
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
151
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
152
|
+
COPY_PHASE_STRIP = NO;
|
|
153
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
154
|
+
ENABLE_TESTABILITY = YES;
|
|
155
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
156
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
157
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
158
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
159
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
160
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
161
|
+
"DEBUG=1",
|
|
162
|
+
"$(inherited)",
|
|
163
|
+
);
|
|
164
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
165
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
166
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
167
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
168
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
169
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
170
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
171
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
172
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
173
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
174
|
+
SDKROOT = iphoneos;
|
|
175
|
+
};
|
|
176
|
+
name = Debug;
|
|
177
|
+
};
|
|
178
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
|
179
|
+
isa = XCBuildConfiguration;
|
|
180
|
+
buildSettings = {
|
|
181
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
182
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
183
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
184
|
+
CLANG_ENABLE_MODULES = YES;
|
|
185
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
186
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
187
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
188
|
+
CLANG_WARN_COMMA = YES;
|
|
189
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
190
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
191
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
192
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
193
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
194
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
195
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
196
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
197
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
198
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
199
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
200
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
201
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
202
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
203
|
+
COPY_PHASE_STRIP = YES;
|
|
204
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
205
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
206
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
207
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
208
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
209
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
210
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
211
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
212
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
213
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
214
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
215
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
216
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
217
|
+
SDKROOT = iphoneos;
|
|
218
|
+
VALIDATE_PRODUCT = YES;
|
|
219
|
+
};
|
|
220
|
+
name = Release;
|
|
221
|
+
};
|
|
222
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
223
|
+
isa = XCBuildConfiguration;
|
|
224
|
+
buildSettings = {
|
|
225
|
+
HEADER_SEARCH_PATHS = (
|
|
226
|
+
"$(inherited)",
|
|
227
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
228
|
+
"$(SRCROOT)/../../../React/**",
|
|
229
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
230
|
+
);
|
|
231
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
232
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
233
|
+
PRODUCT_NAME = AmplifyRTNCore;
|
|
234
|
+
SKIP_INSTALL = YES;
|
|
235
|
+
SWIFT_OBJC_BRIDGING_HEADER = "AmplifyRTNCore-Bridging-Header.h";
|
|
236
|
+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
|
237
|
+
SWIFT_VERSION = 5.0;
|
|
238
|
+
};
|
|
239
|
+
name = Debug;
|
|
240
|
+
};
|
|
241
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
|
242
|
+
isa = XCBuildConfiguration;
|
|
243
|
+
buildSettings = {
|
|
244
|
+
HEADER_SEARCH_PATHS = (
|
|
245
|
+
"$(inherited)",
|
|
246
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
247
|
+
"$(SRCROOT)/../../../React/**",
|
|
248
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
249
|
+
);
|
|
250
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
251
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
252
|
+
PRODUCT_NAME = AmplifyRTNCore;
|
|
253
|
+
SKIP_INSTALL = YES;
|
|
254
|
+
SWIFT_OBJC_BRIDGING_HEADER = "AmplifyRTNCore-Bridging-Header.h";
|
|
255
|
+
SWIFT_VERSION = 5.0;
|
|
256
|
+
};
|
|
257
|
+
name = Release;
|
|
258
|
+
};
|
|
259
|
+
/* End XCBuildConfiguration section */
|
|
260
|
+
|
|
261
|
+
/* Begin XCConfigurationList section */
|
|
262
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AmplifyRTNCore" */ = {
|
|
263
|
+
isa = XCConfigurationList;
|
|
264
|
+
buildConfigurations = (
|
|
265
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
|
266
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
|
267
|
+
);
|
|
268
|
+
defaultConfigurationIsVisible = 0;
|
|
269
|
+
defaultConfigurationName = Release;
|
|
270
|
+
};
|
|
271
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AmplifyRTNCore" */ = {
|
|
272
|
+
isa = XCConfigurationList;
|
|
273
|
+
buildConfigurations = (
|
|
274
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
|
275
|
+
58B511F11A9E6C8500147676 /* Release */,
|
|
276
|
+
);
|
|
277
|
+
defaultConfigurationIsVisible = 0;
|
|
278
|
+
defaultConfigurationName = Release;
|
|
279
|
+
};
|
|
280
|
+
/* End XCConfigurationList section */
|
|
281
|
+
};
|
|
282
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
|
283
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
|
|
6
|
+
enum ParseError: Error {
|
|
7
|
+
case missingValue(String)
|
|
8
|
+
case invalidValue(String)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc(BigInteger)
|
|
12
|
+
class BigInteger: NSObject {
|
|
13
|
+
static let nInHex: String = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
|
|
14
|
+
|
|
15
|
+
@objc(computeModPow:withResolver:withRejecter:)
|
|
16
|
+
static func computeModPow(
|
|
17
|
+
_ payload: [String: String],
|
|
18
|
+
resolve: RCTPromiseResolveBlock,
|
|
19
|
+
reject: RCTPromiseRejectBlock) -> Void {
|
|
20
|
+
do {
|
|
21
|
+
let base = try parseBigInteger("base", from: payload)
|
|
22
|
+
let exponent = try parseBigInteger("exponent", from: payload)
|
|
23
|
+
let divisor = try parseBigInteger("divisor", from: payload)
|
|
24
|
+
let result = base.pow(exponent, andMod: divisor) as! JKBigInteger
|
|
25
|
+
|
|
26
|
+
resolve(result.stringValue(withRadix: 16))
|
|
27
|
+
} catch let error as ParseError {
|
|
28
|
+
reject("ERROR", error.localizedDescription, nil)
|
|
29
|
+
} catch {
|
|
30
|
+
reject("ERROR", "An unexpected error occurred", nil)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static func computeS(
|
|
35
|
+
_ payload: [String: String],
|
|
36
|
+
resolve: RCTPromiseResolveBlock,
|
|
37
|
+
reject: RCTPromiseRejectBlock
|
|
38
|
+
) -> Void {
|
|
39
|
+
do {
|
|
40
|
+
let N = JKBigInteger(string: nInHex, andRadix: 16)!
|
|
41
|
+
|
|
42
|
+
let g = try parseBigInteger("g", from: payload)
|
|
43
|
+
let x = try parseBigInteger("x", from: payload)
|
|
44
|
+
let k = try parseBigInteger("k", from: payload)
|
|
45
|
+
let a = try parseBigInteger("a", from: payload)
|
|
46
|
+
let b = try parseBigInteger("b", from: payload)
|
|
47
|
+
let u = try parseBigInteger("u", from: payload)
|
|
48
|
+
|
|
49
|
+
let exponent = a.add((u.multiply(x) as! JKBigInteger)) as! JKBigInteger
|
|
50
|
+
var base = b.subtract((k.multiply((g.pow(x, andMod: N) as! JKBigInteger)) as! JKBigInteger)) as! JKBigInteger
|
|
51
|
+
base = self.mod(base, by: N)
|
|
52
|
+
var result = base.pow(exponent, andMod: N) as! JKBigInteger
|
|
53
|
+
result = self.mod(result, by: N)
|
|
54
|
+
|
|
55
|
+
resolve(result.stringValue(withRadix: 16))
|
|
56
|
+
} catch let error as ParseError {
|
|
57
|
+
reject("ERROR", error.localizedDescription, nil)
|
|
58
|
+
} catch {
|
|
59
|
+
reject("ERROR", "An unexpected error occurred", nil)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static private func mod(_ dividend: JKBigInteger, by divisor: JKBigInteger ) -> JKBigInteger {
|
|
64
|
+
return (divisor.add((dividend.remainder(divisor) as! JKBigInteger)) as! JKBigInteger).remainder(divisor) as! JKBigInteger
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static private func parseBigInteger(_ key: String, from payload: [String: String]) throws -> JKBigInteger {
|
|
68
|
+
guard let value = payload[key] else {
|
|
69
|
+
throw ParseError.missingValue("Payload is missing `\(key)`")
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
guard let parsedValue = JKBigInteger(string: value, andRadix: 16) else {
|
|
73
|
+
throw ParseError.invalidValue("Invalid value for `\(key)`")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return parsedValue
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JKBigDecimal.h
|
|
3
|
+
// JKBigInteger
|
|
4
|
+
//
|
|
5
|
+
// Created by Midfar Sun on 5/4/15.
|
|
6
|
+
// Copyright (c) 2015 Midfar Sun. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
// Licensed under the MIT License
|
|
10
|
+
|
|
11
|
+
#import <Foundation/Foundation.h>
|
|
12
|
+
#import "JKBigInteger.h"
|
|
13
|
+
|
|
14
|
+
@interface JKBigDecimal : NSObject <NSSecureCoding>
|
|
15
|
+
|
|
16
|
+
@property(nonatomic, retain)JKBigInteger *bigInteger;
|
|
17
|
+
@property(nonatomic, assign)NSUInteger figure;//小数位数
|
|
18
|
+
|
|
19
|
+
+ (id)decimalWithString:(NSString *)string;
|
|
20
|
+
- (id)initWithString:(NSString *)string;
|
|
21
|
+
|
|
22
|
+
- (id)add:(JKBigDecimal *)bigDecimal;
|
|
23
|
+
- (id)subtract:(JKBigDecimal *)bigDecimal;
|
|
24
|
+
- (id)multiply:(JKBigDecimal *)bigDecimal;
|
|
25
|
+
- (id)divide:(JKBigDecimal *)bigDecimal;
|
|
26
|
+
|
|
27
|
+
- (id)remainder:(JKBigDecimal *)bigInteger;
|
|
28
|
+
//- (NSArray *)divideAndRemainder:(JKBigDecimal *)bigInteger;
|
|
29
|
+
|
|
30
|
+
- (NSComparisonResult) compare:(JKBigDecimal *)other;
|
|
31
|
+
- (id)pow:(unsigned int)exponent;
|
|
32
|
+
|
|
33
|
+
- (id)negate;
|
|
34
|
+
- (id)abs;
|
|
35
|
+
|
|
36
|
+
- (NSString *)stringValue;
|
|
37
|
+
|
|
38
|
+
- (NSString *)description;
|
|
39
|
+
|
|
40
|
+
@end
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JKBigDecimal.m
|
|
3
|
+
// JKBigInteger
|
|
4
|
+
//
|
|
5
|
+
// Created by Midfar Sun on 5/4/15.
|
|
6
|
+
// Copyright (c) 2015 Midfar Sun. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
// Licensed under the MIT License
|
|
10
|
+
|
|
11
|
+
#import "JKBigDecimal.h"
|
|
12
|
+
|
|
13
|
+
@implementation JKBigDecimal
|
|
14
|
+
@synthesize bigInteger, figure;
|
|
15
|
+
|
|
16
|
+
+ (BOOL)supportsSecureCoding {
|
|
17
|
+
return YES;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (id)init
|
|
21
|
+
{
|
|
22
|
+
return [self initWithString:@"0"];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (id)initWithString:(NSString *)string
|
|
26
|
+
{
|
|
27
|
+
self = [super init];
|
|
28
|
+
if (self) {
|
|
29
|
+
figure = 0;
|
|
30
|
+
if ([string containsString:@"."]) {
|
|
31
|
+
NSRange range = [string rangeOfString:@"."];
|
|
32
|
+
figure = string.length-range.location-range.length;
|
|
33
|
+
string = [string stringByReplacingCharactersInRange:range withString:@""];
|
|
34
|
+
}
|
|
35
|
+
bigInteger = [[JKBigInteger alloc] initWithString:string];
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+ (id)decimalWithString:(NSString *)string
|
|
41
|
+
{
|
|
42
|
+
return [[JKBigDecimal alloc] initWithString:string];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
-(id)initWithBigInteger:(JKBigInteger *)i figure:(NSInteger)f
|
|
46
|
+
{
|
|
47
|
+
self = [super init];
|
|
48
|
+
if (self) {
|
|
49
|
+
bigInteger = i;
|
|
50
|
+
figure = f;
|
|
51
|
+
}
|
|
52
|
+
return self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (instancetype)initWithCoder:(NSCoder *)decoder
|
|
56
|
+
{
|
|
57
|
+
self = [super init];
|
|
58
|
+
if (self) {
|
|
59
|
+
bigInteger = [[JKBigInteger alloc] initWithCoder:decoder];
|
|
60
|
+
figure = [decoder decodeInt32ForKey:@"JKBigDecimalFigure"];
|
|
61
|
+
}
|
|
62
|
+
return self;
|
|
63
|
+
}
|
|
64
|
+
-(void)encodeWithCoder:(NSCoder *)encoder
|
|
65
|
+
{
|
|
66
|
+
[bigInteger encodeWithCoder:encoder];
|
|
67
|
+
[encoder encodeInteger:figure forKey:@"JKBigDecimalFigure"];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (id)add:(JKBigDecimal *)bigDecimal
|
|
71
|
+
{
|
|
72
|
+
NSInteger maxFigure = 0;
|
|
73
|
+
if (figure>=bigDecimal.figure) {
|
|
74
|
+
maxFigure = figure;
|
|
75
|
+
NSInteger exponent = maxFigure-bigDecimal.figure;
|
|
76
|
+
JKBigInteger *mInteger = [[JKBigInteger alloc] initWithString:@"10"];
|
|
77
|
+
JKBigInteger *newInteger = [mInteger pow:(unsigned int)exponent];
|
|
78
|
+
bigDecimal.bigInteger = [bigDecimal.bigInteger multiply:newInteger];
|
|
79
|
+
bigDecimal.figure = maxFigure;
|
|
80
|
+
|
|
81
|
+
}else{
|
|
82
|
+
maxFigure = bigDecimal.figure;
|
|
83
|
+
NSInteger exponent = maxFigure-figure;
|
|
84
|
+
JKBigInteger *mInteger = [[JKBigInteger alloc] initWithString:@"10"];
|
|
85
|
+
JKBigInteger *newInteger = [mInteger pow:(unsigned int)exponent];
|
|
86
|
+
bigInteger = [bigInteger multiply:newInteger];
|
|
87
|
+
figure = maxFigure;
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
JKBigInteger *newBigInteger = [bigInteger add:bigDecimal.bigInteger];
|
|
91
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:maxFigure];
|
|
92
|
+
return newBigDecimal;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (id)subtract:(JKBigDecimal *)bigDecimal
|
|
96
|
+
{
|
|
97
|
+
NSInteger maxFigure = 0;
|
|
98
|
+
if (figure>=bigDecimal.figure) {
|
|
99
|
+
maxFigure = figure;
|
|
100
|
+
NSInteger exponent = maxFigure-bigDecimal.figure;
|
|
101
|
+
JKBigInteger *mInteger = [[JKBigInteger alloc] initWithString:@"10"];
|
|
102
|
+
JKBigInteger *newInteger = [mInteger pow:(unsigned int)exponent];
|
|
103
|
+
bigDecimal.bigInteger = [bigDecimal.bigInteger multiply:newInteger];
|
|
104
|
+
bigDecimal.figure = maxFigure;
|
|
105
|
+
|
|
106
|
+
}else{
|
|
107
|
+
maxFigure = bigDecimal.figure;
|
|
108
|
+
NSInteger exponent = maxFigure-figure;
|
|
109
|
+
JKBigInteger *mInteger = [[JKBigInteger alloc] initWithString:@"10"];
|
|
110
|
+
JKBigInteger *newInteger = [mInteger pow:(unsigned int)exponent];
|
|
111
|
+
bigInteger = [bigDecimal.bigInteger multiply:newInteger];
|
|
112
|
+
figure = maxFigure;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
JKBigInteger *newBigInteger = [bigInteger subtract:bigDecimal.bigInteger];
|
|
116
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:maxFigure];
|
|
117
|
+
return newBigDecimal;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (id)multiply:(JKBigDecimal *)bigDecimal
|
|
121
|
+
{
|
|
122
|
+
NSInteger totalFigure = figure+bigDecimal.figure;
|
|
123
|
+
JKBigInteger *newBigInteger = [bigInteger multiply:bigDecimal.bigInteger];
|
|
124
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:totalFigure];
|
|
125
|
+
return newBigDecimal;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
- (id)divide:(JKBigDecimal *)bigDecimal
|
|
129
|
+
{
|
|
130
|
+
NSInteger totalFigure = figure-bigDecimal.figure;
|
|
131
|
+
if (totalFigure<0) {
|
|
132
|
+
NSInteger exponent = -totalFigure;
|
|
133
|
+
totalFigure=0;
|
|
134
|
+
JKBigInteger *mInteger = [[JKBigInteger alloc] initWithString:@"10"];
|
|
135
|
+
JKBigInteger *newInteger = [mInteger pow:(unsigned int)exponent];
|
|
136
|
+
bigInteger = [bigInteger multiply:newInteger];
|
|
137
|
+
}
|
|
138
|
+
JKBigInteger *newBigInteger = [bigInteger divide:bigDecimal.bigInteger];
|
|
139
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:totalFigure];
|
|
140
|
+
return newBigDecimal;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (id)remainder:(JKBigDecimal *)bigDecimal
|
|
144
|
+
{
|
|
145
|
+
NSInteger totalFigure = figure-bigDecimal.figure;
|
|
146
|
+
if (totalFigure<0) {
|
|
147
|
+
NSInteger exponent = -totalFigure;
|
|
148
|
+
totalFigure=0;
|
|
149
|
+
JKBigInteger *mInteger = [[JKBigInteger alloc] initWithString:@"10"];
|
|
150
|
+
JKBigInteger *newInteger = [mInteger pow:(unsigned int)exponent];
|
|
151
|
+
bigInteger = [bigInteger multiply:newInteger];
|
|
152
|
+
}
|
|
153
|
+
JKBigInteger *newBigInteger = [bigInteger remainder:bigDecimal.bigInteger];
|
|
154
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:bigDecimal.figure];
|
|
155
|
+
return newBigDecimal;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//- (NSArray *)divideAndRemainder:(JKBigDecimal *)bigInteger
|
|
159
|
+
//{
|
|
160
|
+
//
|
|
161
|
+
//}
|
|
162
|
+
|
|
163
|
+
-(NSComparisonResult) compare:(JKBigDecimal *)other {
|
|
164
|
+
JKBigDecimal *tens = [[JKBigDecimal alloc] initWithString:@"10"];
|
|
165
|
+
JKBigInteger *scaledNum;
|
|
166
|
+
JKBigInteger *scaledCompareTo;
|
|
167
|
+
|
|
168
|
+
if (figure > other.figure){
|
|
169
|
+
tens = [tens pow:(int)figure];
|
|
170
|
+
} else {
|
|
171
|
+
tens = [tens pow:(int)other.figure];
|
|
172
|
+
}
|
|
173
|
+
//scale my value to integer value
|
|
174
|
+
scaledNum = [[JKBigInteger alloc] initWithString:[[self multiply:tens] stringValue]];
|
|
175
|
+
//scale other value to integer
|
|
176
|
+
scaledCompareTo = [[JKBigInteger alloc] initWithString:[[other multiply:tens] stringValue]];
|
|
177
|
+
NSComparisonResult compareBigInteger = [scaledNum compare:scaledCompareTo];
|
|
178
|
+
return compareBigInteger;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
- (id)pow:(unsigned int)exponent
|
|
182
|
+
{
|
|
183
|
+
NSInteger totalFigure = figure*exponent;
|
|
184
|
+
JKBigInteger *newBigInteger = [bigInteger pow:exponent];
|
|
185
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:totalFigure];
|
|
186
|
+
return newBigDecimal;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (id)negate
|
|
190
|
+
{
|
|
191
|
+
JKBigInteger *newBigInteger = [bigInteger negate];
|
|
192
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:figure];
|
|
193
|
+
return newBigDecimal;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
- (id)abs
|
|
197
|
+
{
|
|
198
|
+
JKBigInteger *newBigInteger = [bigInteger abs];
|
|
199
|
+
JKBigDecimal *newBigDecimal = [[JKBigDecimal alloc] initWithBigInteger:newBigInteger figure:figure];
|
|
200
|
+
return newBigDecimal;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
- (NSString *)stringValue
|
|
204
|
+
{
|
|
205
|
+
NSString *string = [bigInteger stringValue];
|
|
206
|
+
if (figure==0) {
|
|
207
|
+
return string;
|
|
208
|
+
}
|
|
209
|
+
NSMutableString *mString = [NSMutableString stringWithString:string];
|
|
210
|
+
NSInteger newFigure = string.length-figure;
|
|
211
|
+
while (newFigure<=0) {
|
|
212
|
+
[mString insertString:@"0" atIndex:0];
|
|
213
|
+
newFigure++;
|
|
214
|
+
}
|
|
215
|
+
[mString insertString:@"." atIndex:newFigure];
|
|
216
|
+
return mString;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
- (NSString *)description
|
|
220
|
+
{
|
|
221
|
+
return [self stringValue];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JKBigInteger.h
|
|
3
|
+
// JKBigInteger
|
|
4
|
+
//
|
|
5
|
+
// Created by Jānis Kiršteins on 5/21/13.
|
|
6
|
+
// Copyright (c) 2013 Jānis Kiršteins. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
// Licensed under the MIT License
|
|
10
|
+
|
|
11
|
+
#import <Foundation/Foundation.h>
|
|
12
|
+
#include "tommath.h"
|
|
13
|
+
|
|
14
|
+
@interface JKBigInteger : NSObject <NSSecureCoding>
|
|
15
|
+
|
|
16
|
+
- (id)initWithValue:(mp_int *)value;
|
|
17
|
+
- (mp_int *)value;
|
|
18
|
+
|
|
19
|
+
- (id)initWithUnsignedLong:(unsigned long)ul;
|
|
20
|
+
- (id)initWithString:(NSString *)string;
|
|
21
|
+
- (id)initWithString:(NSString *)string andRadix:(int)radix;
|
|
22
|
+
- (id)initWithCString:(char *)cString;
|
|
23
|
+
- (id)initWithCString:(char *)cString andRadix:(int)radix;
|
|
24
|
+
|
|
25
|
+
- (id)add:(JKBigInteger *)bigInteger;
|
|
26
|
+
- (id)subtract:(JKBigInteger *)bigInteger;
|
|
27
|
+
- (id)multiply:(JKBigInteger *)bigInteger;
|
|
28
|
+
- (id)divide:(JKBigInteger *)bigInteger;
|
|
29
|
+
|
|
30
|
+
- (id)remainder:(JKBigInteger *)bigInteger;
|
|
31
|
+
- (NSArray *)divideAndRemainder:(JKBigInteger *)bigInteger;
|
|
32
|
+
|
|
33
|
+
- (id)pow:(unsigned int)exponent;
|
|
34
|
+
- (id)pow:(JKBigInteger*)exponent andMod:(JKBigInteger*)modulus;
|
|
35
|
+
- (id)negate;
|
|
36
|
+
- (id)abs;
|
|
37
|
+
|
|
38
|
+
- (id)bitwiseXor:(JKBigInteger *)bigInteger;
|
|
39
|
+
- (id)bitwiseOr:(JKBigInteger *)bigInteger;
|
|
40
|
+
- (id)bitwiseAnd:(JKBigInteger *)bigInteger;
|
|
41
|
+
- (id)shiftLeft:(unsigned int)n;
|
|
42
|
+
- (id)shiftRight:(unsigned int)n;
|
|
43
|
+
|
|
44
|
+
- (id)gcd:(JKBigInteger *)bigInteger;
|
|
45
|
+
|
|
46
|
+
- (NSComparisonResult) compare:(JKBigInteger *)bigInteger;
|
|
47
|
+
|
|
48
|
+
- (unsigned long)unsignedIntValue;
|
|
49
|
+
- (NSString *)stringValue;
|
|
50
|
+
- (NSString *)stringValueWithRadix:(int)radix;
|
|
51
|
+
|
|
52
|
+
- (NSString *)description;
|
|
53
|
+
|
|
54
|
+
- (unsigned int)countBytes;
|
|
55
|
+
- (void)toByteArraySigned: (unsigned char*) byteArray;
|
|
56
|
+
- (void)toByteArrayUnsigned: (unsigned char*) byteArray;
|
|
57
|
+
|
|
58
|
+
@end
|