diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index d53f46027..2168b0bc9 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -78,3 +78,60 @@ jobs: emcc -v sh emsdk_build.sh sh js_test.sh + + drive_ios: + #Create a construction matrix + strategy: + #Set up different configurations for a set of virtual environments + matrix: + device: + - "iPhone 8 (14.4)" + - "iPhone 11 Pro Max (14.4)" + #When set to true, GitHub cancels all in progress jobs if any of the matrix jobs fail. + fail-fast: false + runs-on: macOS-latest + steps: + - name: "List all simulators" + run: "xcrun instruments -s" + - name: "Start Simulator" + run: | + UDID=$( + xcrun instruments -s | + awk \ + -F ' *[][]' \ + -v 'device=${{ matrix.device }}' \ + '$1 == device { print $2 }' + ) + xcrun simctl boot "${UDID:?No Simulator with this name found}" + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: 'stable' + - name: "Test flutter bindings" + run: | + cd flutter-bindings/bls_signatures_ffi/example + flutter drive --driver=test_driver/integration_test.dart --target=test_driver/main.dart + + drive_android: + runs-on: macos-latest + strategy: + matrix: + api-level: [21, 29] + target: [default] + steps: + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: 'stable' + - name: "Test flutter bindings" + #Operation for installing, configuring and running Android emulator (MAC OS only) + # https://github.com/marketplace/actions/android-emulator-runner + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: x86_64 + profile: Nexus 6 + script: | + cd flutter-bindings/bls_signatures_ffi/example + flutter drive --driver=test_driver/integration_test.dart --target=test_driver/main.dart diff --git a/CMakeLists.txt b/CMakeLists.txt index 79226528b..e58a4ff6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(MULTI "OPENMP" CACHE STRING "") else() set(TIMER "CYCLE" CACHE STRING "") - set(MULTI "PTHREAD" CACHE STRING "") + if(BUILD_BLS_FLUTTER_BINDINGS) + # Android doesn't need pthread + set(MULTI "" CACHE STRING "") + else() + set(MULTI "PTHREAD" CACHE STRING "") + endif() endif() set(CHECK "off" CACHE STRING "") @@ -132,12 +137,15 @@ FetchContent_MakeAvailable(relic) add_subdirectory(src) -if(EMSCRIPTEN) - add_subdirectory(js-bindings) -else() - # emscripten can't build python bindings, it produces only javascript - # add_subdirectory(contrib/pybind11) - if(BUILD_BLS_PYTHON_BINDINGS) - add_subdirectory(python-bindings) +if (NOT BUILD_BLS_FLUTTER_BINDINGS) + # flutter bindings don't need to include subdirectory + if(EMSCRIPTEN) + add_subdirectory(js-bindings) + else() + # emscripten can't build python bindings, it produces only javascript + # add_subdirectory(contrib/pybind11) + if(BUILD_BLS_PYTHON_BINDINGS) + add_subdirectory(python-bindings) + endif() endif() endif() diff --git a/flutter-bindings/bls_signatures_ffi/.gitignore b/flutter-bindings/bls_signatures_ffi/.gitignore new file mode 100644 index 000000000..33155526d --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/.gitignore @@ -0,0 +1,31 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ + +!main \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/.metadata b/flutter-bindings/bls_signatures_ffi/.metadata new file mode 100644 index 000000000..db9312a7b --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 5464c5bac742001448fe4fc0597be939379f88ea + channel: stable + +project_type: plugin diff --git a/flutter-bindings/bls_signatures_ffi/CHANGELOG.md b/flutter-bindings/bls_signatures_ffi/CHANGELOG.md new file mode 100644 index 000000000..fc1caae83 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/CHANGELOG.md @@ -0,0 +1,4 @@ +## 0.1.0 + +* Flutter plugin for android. +* Flutter plugin for iOS. diff --git a/flutter-bindings/bls_signatures_ffi/LICENSE b/flutter-bindings/bls_signatures_ffi/LICENSE new file mode 100644 index 000000000..f433b1a53 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/flutter-bindings/bls_signatures_ffi/README.md b/flutter-bindings/bls_signatures_ffi/README.md new file mode 100644 index 000000000..f01f6d4b9 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/README.md @@ -0,0 +1,181 @@ +# bls_signatures_ffi + +Flutter plugin for Chia's BLS-Signatures. + +## Usage + +To use this plugin, add `bls_signatures_ffi` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels). + +## Requirements + +### Android + +Building `bls-signatures` require cmake version `3.14.0+`, but most recent Android Studio shipped with cmake version `3.10.2`, so you need to update cmake within SDK Manager in Android Studio. + +### iOS + +iOS build C/C++ code with XCode instead of cmake. But you still need to download cmake nonetheless, to build `bls-signatures`. Make sure it's version is above `3.14.0`. +Also, your iOS deployment must be above `11.0`. + +## Creating keys and signature + +```dart +// Example seed, used to generate private key. Always use +// a secure RNG with sufficient entropy to generate a seed (at least 32 bytes). +final seed = Uint8List.fromList([ + 0, 50, 6, 244, 24, 199,1, 25, 52, 88, 192, 19, + 18, 12, 89, 6, 220, 18, 102, 58, 209, 82, 12, + 62, 89, 110, 182, 9, 44, 20, 254, 22 +]); + +// Create a scheme. +final scheme = AugSchemeMPL(); + +try { + final sk = scheme.keyGen(seed); + final pk = sk.g1Element(); + + final message = Uint8List.fromList( + [1, 2, 3, 4, 5]); // Message is passed in as a byte vector + final signature = scheme.sign(sk, message); + + // Verify the signature + print('Verification result: ${scheme.verify(pk, message, signature)}'); + + // Free all bls resource + scheme.free(); + sk.free(); + pk.free(); + signature.free(); +} catch (e) { + print(e); +} +``` + +## Serializing keys and signatures to bytes + +```dart +final skBytes = sk.serialize(); +final pkBytes = pk.serialize(); +final sigBytes = sig.serialize(); +``` + +## Loading keys and signature from bytes + +```dart +// Takes int list of 32 bytes +final sk = PrivateKey.fromBytes(data: skBytes); + +// Takes int list of 48 bytes +final pk = G1Element.fromBytes(data: pkBytes); + +// Takes int list of 96 bytes +final sig = G2Element.fromBytes(data: sigBytes); + +print(sk.hexString()); // 32 bytes printed in hex +print(pk.hexString()); // 48 bytes printed in hex +print(sig.hexString()); // 96 bytes printed in hex +``` + +## Create aggregate signature + +```dart +// Generate some more private keys. +final sk1 = scheme.keyGen(Uint8List.fromList(seed)..[0] = 1); +final sk2 = scheme.keyGen(Uint8List.fromList(seed)..[0] = 2); +final message2 = Uint8List.fromList([1, 2, 3, 4, 5]); + +// Generate first sig +final pk1 = sk1.g1Element(); +final sig1 = scheme.sign(sk1, message); + +// Generate second sig +final pk2 = sk2.g1Element(); +final sig2 = scheme.sign(sk2, message2); + +// Signatures can be non-interactively combined by anyone +final aggSig = scheme.aggregateSigs([sig1, sig2]); + +print('Verification result: ${scheme.aggregateVerify( + [pk1, pk2], + [message, message2], + aggSig)}'); +``` + +## Arbitrary trees of aggregates + +```dart +final sk3 = scheme.keyGen(Uint8List.fromList(seed)..[0] = 3); +final pk3 = sk3.g1Element(); +final message3 = Uint8List.fromList([100, 2, 254, 88, 90, 45, 23]); +final sig3 = scheme.sign(sk3, message3); + +final aggSigFinal = scheme.aggregateSigs([aggSig, sig3]); +print('Verification result: ${scheme.aggregateVerify( + [pk1, pk2, pk3], + [message, message2, message3], + aggSigFinal)}');, +``` + +## Very fast verification with Proof of Possession scheme + +```dart +// If the same message is signed, you can use Proof of Posession (PopScheme) for efficiency +// A proof of possession MUST be passed around with the PK to ensure security. + +final popScheme = PopSchemeMPL(); +final popSig1 = popScheme.sign(sk1, message); +final popSig2 = popScheme.sign(sk2, message); +final popSig3 = popScheme.sign(sk3, message); +final pop1 = popScheme.popProve(sk1); +final pop2 = popScheme.popProve(sk2); +final pop3 = popScheme.popProve(sk3); + +print('Verification result: ${popScheme.popVerify(pk1, pop1)}'); +print('Verification result: ${popScheme.popVerify(pk2, pop2)}'); +print('Verification result: ${popScheme.popVerify(pk3, pop3)}'); +final popSigAgg = + popScheme.aggregateSigs([popSig1, popSig2, popSig3]); +print('Verification result: ${popScheme.fastAggregateVerify( + [pk1, pk2, pk3], message, popSigAgg)}'); + +// Aggregate public key, indistinguishable from a single public key +final popAggPk = pk1 + pk2 + pk3; +print('Verification result: ${popScheme.verify(popAggPk, message, popSigAgg)}'); + +// Aggregate private keys +final aggSk = PrivateKey.aggregate([sk1, sk2, sk3]); +print('Verification result: ${popScheme.sign(aggSk, message) == popSigAgg}'); +``` + +## HD keys using [EIP-2333](https://github.com/ethereum/EIPs/pull/2333) + +```dart +// You can derive 'child' keys from any key, to create arbitrary trees. 4 byte indeces are used. +// Hardened (more secure, but no parent pk -> child pk) +final masterSk = scheme.keyGen(seed); +final child = scheme.deriveChildSk(masterSk, 152); +final grandChild = scheme.deriveChildSk(child, 952); + +// Unhardened (less secure, but can go from parent pk -> child pk), BIP32 style +final masterPk = masterSk.g1Element(); +final childU = scheme.deriveChildSkUnhardened(masterSk, 22); +final grandChildU = scheme.deriveChildSkUnhardened(childU, 0); + +final childUPk = scheme.deriveChildPkUnhardened(masterPk, 22); +final grandChildUPk = scheme.deriveChildPkUnhardened(childUPk, 0); +print('Verification result: ${grandChildUPk == grandChildU.g1Element()}'); +``` + +## IMPORTANT NOTES + +Any instance created by this library WOULD NOT cleared from memory by Dart GC. For now, it's your responsibility to call `free()` of said instance. +In the future, we might implement finalizer. Related issue: [this](https://github.com/dart-lang/sdk/issues/35770) and [this](https://github.com/dart-lang/language/issues/1847). + +## Run tests + +Running test require connected device (pyshical or emulator), then cd to `example` directory and run flutter drive. +```bash +cd example +flutter drive --driver=test_driver/integration_test.dart --target=test_driver/main.dart +``` \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/analysis_options.yaml b/flutter-bindings/bls_signatures_ffi/analysis_options.yaml new file mode 100644 index 000000000..9bdc2e686 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/analysis_options.yaml @@ -0,0 +1,8 @@ +include: package:very_good_analysis/analysis_options.2.4.0.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options + +analyzer: + exclude: + - "**/*.h.dart" \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/android/.gitignore b/flutter-bindings/bls_signatures_ffi/android/.gitignore new file mode 100644 index 000000000..17dc4534f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/android/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures + +.cxx \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/android/CMakeLists.txt b/flutter-bindings/bls_signatures_ffi/android/CMakeLists.txt new file mode 100644 index 000000000..77acff2a6 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/android/CMakeLists.txt @@ -0,0 +1,27 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.14.0 FATAL_ERROR) + +project(blsflutter) +include(FetchContent) +FetchContent_Declare( + bls + GIT_REPOSITORY https://github.com/MegaGrindStone/bls-signatures.git + GIT_TAG origin/flutter-bindings +) +FetchContent_MakeAvailable(bls) + +add_library(blsflutter + SHARED + ../ios/bls/utils.cpp + ../ios/bls/blschia.cpp + ../ios/bls/elements.cpp + ../ios/bls/privatekey.cpp + ../ios/bls/schemes.cpp +) + +target_include_directories(blsflutter + PUBLIC + ${bls_SOURCE_DIR}/include/chiabls + ${bls_BINARY_DIR}/include/chiabls +) + +target_link_libraries(blsflutter PRIVATE bls) \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/android/build.gradle b/flutter-bindings/bls_signatures_ffi/android/build.gradle new file mode 100644 index 000000000..521b96053 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/android/build.gradle @@ -0,0 +1,62 @@ +group 'net.chia.bls_signatures_ffi' +version '1.0-SNAPSHOT' + +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 31 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + minSdkVersion 16 + externalNativeBuild { + cmake { + arguments "-DBUILD_BLS_FLUTTER_BINDINGS=1 -DBUILD_BLS_TESTS=0 -DBUILD_BLS_BENCHMARKS=0" + } + } + } + + externalNativeBuild { + cmake { + path "CMakeLists.txt" + version "3.14.0+" + } + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/flutter-bindings/bls_signatures_ffi/android/settings.gradle b/flutter-bindings/bls_signatures_ffi/android/settings.gradle new file mode 100644 index 000000000..280f5bfa2 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'bls_signatures_ffi' diff --git a/flutter-bindings/bls_signatures_ffi/android/src/main/AndroidManifest.xml b/flutter-bindings/bls_signatures_ffi/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..19a8f7ed4 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/flutter-bindings/bls_signatures_ffi/android/src/main/kotlin/net/chia/bls_signatures_ffi/BlsSignaturesFfiPlugin.kt b/flutter-bindings/bls_signatures_ffi/android/src/main/kotlin/net/chia/bls_signatures_ffi/BlsSignaturesFfiPlugin.kt new file mode 100644 index 000000000..6a17cf6c4 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/android/src/main/kotlin/net/chia/bls_signatures_ffi/BlsSignaturesFfiPlugin.kt @@ -0,0 +1,35 @@ +package net.chia.bls_signatures_ffi + +import androidx.annotation.NonNull + +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result + +/** BlsSignaturesFfiPlugin */ +class BlsSignaturesFfiPlugin: FlutterPlugin, MethodCallHandler { + /// The MethodChannel that will the communication between Flutter and native Android + /// + /// This local reference serves to register the plugin with the Flutter Engine and unregister it + /// when the Flutter Engine is detached from the Activity + private lateinit var channel : MethodChannel + + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + channel = MethodChannel(flutterPluginBinding.binaryMessenger, "bls_signatures_ffi") + channel.setMethodCallHandler(this) + } + + override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { + if (call.method == "getPlatformVersion") { + result.success("Android ${android.os.Build.VERSION.RELEASE}") + } else { + result.notImplemented() + } + } + + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + channel.setMethodCallHandler(null) + } +} diff --git a/flutter-bindings/bls_signatures_ffi/example/.gitignore b/flutter-bindings/bls_signatures_ffi/example/.gitignore new file mode 100644 index 000000000..0fa6b675c --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/.gitignore @@ -0,0 +1,46 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter-bindings/bls_signatures_ffi/example/.metadata b/flutter-bindings/bls_signatures_ffi/example/.metadata new file mode 100644 index 000000000..3c3e4b52f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 5464c5bac742001448fe4fc0597be939379f88ea + channel: stable + +project_type: app diff --git a/flutter-bindings/bls_signatures_ffi/example/README.md b/flutter-bindings/bls_signatures_ffi/example/README.md new file mode 100644 index 000000000..0520f7fba --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/README.md @@ -0,0 +1,16 @@ +# bls_signatures_ffi_example + +Demonstrates how to use the bls_signatures_ffi plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/flutter-bindings/bls_signatures_ffi/example/analysis_options.yaml b/flutter-bindings/bls_signatures_ffi/example/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter-bindings/bls_signatures_ffi/example/android/.gitignore b/flutter-bindings/bls_signatures_ffi/example/android/.gitignore new file mode 100644 index 000000000..6f568019d --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/build.gradle b/flutter-bindings/bls_signatures_ffi/example/android/app/build.gradle new file mode 100644 index 000000000..4c4103b4c --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/build.gradle @@ -0,0 +1,68 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "net.chia.bls_signatures_ffi_example" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/debug/AndroidManifest.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..7c5850d5f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/AndroidManifest.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..5901a5265 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/kotlin/net/chia/bls_signatures_ffi_example/MainActivity.kt b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/kotlin/net/chia/bls_signatures_ffi_example/MainActivity.kt new file mode 100644 index 000000000..2fb2b87d1 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/kotlin/net/chia/bls_signatures_ffi_example/MainActivity.kt @@ -0,0 +1,6 @@ +package net.chia.bls_signatures_ffi_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/drawable/launch_background.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..db77bb4b7 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..17987b79b Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..09d439148 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..d5f1c8d34 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/values-night/styles.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..3db14bb53 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/values/styles.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..d460d1e92 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/app/src/profile/AndroidManifest.xml b/flutter-bindings/bls_signatures_ffi/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..7c5850d5f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/android/build.gradle b/flutter-bindings/bls_signatures_ffi/example/android/build.gradle new file mode 100644 index 000000000..4256f9173 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/flutter-bindings/bls_signatures_ffi/example/android/gradle.properties b/flutter-bindings/bls_signatures_ffi/example/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/flutter-bindings/bls_signatures_ffi/example/android/gradle/wrapper/gradle-wrapper.properties b/flutter-bindings/bls_signatures_ffi/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..bc6a58afd --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/flutter-bindings/bls_signatures_ffi/example/android/settings.gradle b/flutter-bindings/bls_signatures_ffi/example/android/settings.gradle new file mode 100644 index 000000000..44e62bcf0 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/.gitignore b/flutter-bindings/bls_signatures_ffi/example/ios/.gitignore new file mode 100644 index 000000000..7a7f9873a --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/AppFrameworkInfo.plist b/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000..8d4492f97 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 9.0 + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/Debug.xcconfig b/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000..ec97fc6f3 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/Release.xcconfig b/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000..c4855bfe2 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Podfile b/flutter-bindings/bls_signatures_ffi/example/ios/Podfile new file mode 100644 index 000000000..1e8c3c90a --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Podfile.lock b/flutter-bindings/bls_signatures_ffi/example/ios/Podfile.lock new file mode 100644 index 000000000..3838cf3e0 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - bls_signatures_ffi (0.0.1): + - Flutter + - Flutter (1.0.0) + - integration_test (0.0.1): + - Flutter + +DEPENDENCIES: + - bls_signatures_ffi (from `.symlinks/plugins/bls_signatures_ffi/ios`) + - Flutter (from `Flutter`) + - integration_test (from `.symlinks/plugins/integration_test/ios`) + +EXTERNAL SOURCES: + bls_signatures_ffi: + :path: ".symlinks/plugins/bls_signatures_ffi/ios" + Flutter: + :path: Flutter + integration_test: + :path: ".symlinks/plugins/integration_test/ios" + +SPEC CHECKSUMS: + bls_signatures_ffi: a92ecb63712d572c2693c6d17b88a1659c1e380f + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 + +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c + +COCOAPODS: 1.11.2 diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.pbxproj b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..1fa76a70b --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,555 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + B91C90BA76422BFF5F87A714 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A0551345B3A83C3C7FAE2F53 /* Pods_Runner.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 2B76C0A67C1BD16FC29D80BE /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A0551345B3A83C3C7FAE2F53 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A9EF0E9A197AB8F4CC3CEFF8 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + B36B76D9EDA7AA06C19CBD69 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + B91C90BA76422BFF5F87A714 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 49CD7744183B5D9F810272E4 /* Pods */ = { + isa = PBXGroup; + children = ( + 2B76C0A67C1BD16FC29D80BE /* Pods-Runner.debug.xcconfig */, + B36B76D9EDA7AA06C19CBD69 /* Pods-Runner.release.xcconfig */, + A9EF0E9A197AB8F4CC3CEFF8 /* Pods-Runner.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 49CD7744183B5D9F810272E4 /* Pods */, + CD75E7A0477C82C3CD95F11F /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + CD75E7A0477C82C3CD95F11F /* Frameworks */ = { + isa = PBXGroup; + children = ( + A0551345B3A83C3C7FAE2F53 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + A9E6B64D247DDA0BE26AE225 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + C451874655B8D0A877B2A111 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + A9E6B64D247DDA0BE26AE225 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + C451874655B8D0A877B2A111 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; + INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = net.chia.blsSignaturesFfiExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; + INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = net.chia.blsSignaturesFfiExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; + INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = net.chia.blsSignaturesFfiExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..c87d15a33 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..21a3cc14c --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/AppDelegate.swift b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/AppDelegate.swift new file mode 100644 index 000000000..70693e4a8 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d36b1fab2 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 000000000..dc9ada472 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..28c6bf030 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..2ccbfd967 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..f091b6b0b Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..4cde12118 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..d0ef06e7e Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..dcdc2306c Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..2ccbfd967 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000..c8f9ed8f5 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..a6d6b8609 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000..a6d6b8609 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000..75b2d164a Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..c4df70d39 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..6a84f41e1 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..d0e1f5853 Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 000000000..0bedcf2fd --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 000000000..89c2725b7 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..f2e259c7c --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Base.lproj/Main.storyboard b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f3c28516f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Info.plist b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Info.plist new file mode 100644 index 000000000..d6f8ea8d0 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Bls Signatures Ffi + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + bls_signatures_ffi_example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Runner-Bridging-Header.h b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 000000000..308a2a560 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/flutter-bindings/bls_signatures_ffi/example/lib/main.dart b/flutter-bindings/bls_signatures_ffi/example/lib/main.dart new file mode 100644 index 000000000..36826e4c8 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/lib/main.dart @@ -0,0 +1,117 @@ +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + Uint8List? _seed; + PrivateKey? _sk; + G1Element? _pk; + int? _fingerprint; + Exception? _exception; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('BLS example app'), + ), + body: Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 15), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () async { + await genKey(); + }, + child: const Text('Generate Key'), + ), + const SizedBox(height: 5), + if (_exception != null) Text(_exception.toString()), + const SizedBox(height: 5), + const SizedBox(height: 10), + const Text('Seed'), + const SizedBox(height: 5), + Text(_seed == null ? 'Press Generate Key' : _seed.toString()), + const SizedBox(height: 10), + const Text('Secret Key'), + const SizedBox(height: 5), + Text(_sk == null ? 'Press Generate Key' : _sk!.hexString()), + const SizedBox(height: 10), + const Text('Public Key'), + const SizedBox(height: 5), + Text(_pk == null ? 'Press Generate Key' : _pk!.hexString()), + const SizedBox(height: 10), + const Text('Fingerprint'), + const SizedBox(height: 5), + Text( + _fingerprint == null + ? 'Press Generate Key' + : _fingerprint.toString(), + ), + ], + ), + ), + ), + ); + } + + Future genKey() async { + setState(() { + _exception = null; + }); + final seed = genSeed(); + final scheme = AugSchemeMPL(); + try { + final sk = scheme.keyGen(seed); + final pk = sk.g1Element(); + final fingerprint = pk.fingerprint(); + + setState(() { + _seed = seed; + _sk = sk; + _pk = pk; + _fingerprint = fingerprint; + }); + } on Exception catch (e) { + setState(() { + _exception = e; + }); + } finally { + scheme.free(); + } + } + + Uint8List genSeed() { + final data = []; + final random = Random(); + for (var i = 0; i < 32; i++) { + data.add(random.nextInt(255)); + } + return Uint8List.fromList(data); + } + + @override + void dispose() { + _sk?.free(); + _pk?.free(); + super.dispose(); + } +} diff --git a/flutter-bindings/bls_signatures_ffi/example/pubspec.lock b/flutter-bindings/bls_signatures_ffi/example/pubspec.lock new file mode 100644 index 000000000..f977497d3 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/pubspec.lock @@ -0,0 +1,267 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.6" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + bls_signatures_ffi: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.1.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + convert: + dependency: "direct main" + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + sync_http: + dependency: transitive + description: + name: sync_http + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.8" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + very_good_analysis: + dependency: "direct dev" + description: + name: very_good_analysis + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "7.5.0" + webdriver: + dependency: transitive + description: + name: webdriver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" +sdks: + dart: ">=2.16.2 <3.0.0" + flutter: ">=2.5.0" diff --git a/flutter-bindings/bls_signatures_ffi/example/pubspec.yaml b/flutter-bindings/bls_signatures_ffi/example/pubspec.yaml new file mode 100644 index 000000000..651dcf346 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/pubspec.yaml @@ -0,0 +1,25 @@ +name: bls_signatures_ffi_example +description: Demonstrates how to use the bls_signatures_ffi plugin. +version: 1.0.0+1 +publish_to: 'none' + +environment: + sdk: ">=2.16.2 <3.0.0" + +dependencies: + bls_signatures_ffi: + path: ../ + convert: ^3.0.1 + flutter: + sdk: flutter + +dev_dependencies: + flutter_lints: ^1.0.0 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + very_good_analysis: ^2.4.0 + +flutter: + uses-material-design: true diff --git a/flutter-bindings/bls_signatures_ffi/example/test/aggregate_test.dart b/flutter-bindings/bls_signatures_ffi/example/test/aggregate_test.dart new file mode 100644 index 000000000..4a2bd17d6 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/aggregate_test.dart @@ -0,0 +1,217 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'util.dart'; + +void main() { + final schemes = [BasicSchemeMPL(), AugSchemeMPL(), PopSchemeMPL()]; + + tearDownAll(() { + (schemes[0] as BasicSchemeMPL).free(); + (schemes[1] as AugSchemeMPL).free(); + (schemes[2] as PopSchemeMPL).free(); + }); + + group('test aggregate', () { + final seed = [ + 0, + 50, + 6, + 244, + 24, + 199, + 1, + 25, + 52, + 88, + 192, + 19, + 18, + 12, + 89, + 6, + 220, + 18, + 102, + 58, + 209, + 82, + 12, + 62, + 89, + 110, + 182, + 9, + 44, + 20, + 254, + 22, + ]; + final msg1 = Uint8List.fromList([100, 2, 254, 88, 90, 45, 23]); + final msg2 = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + + for (final scheme in schemes) { + test(scheme.runtimeType, () async { + final seed1 = Uint8List.fromList(seed)..[0] = 1; + final seed2 = Uint8List.fromList(seed)..[0] = 1; + final sk1 = scheme.keyGen(seed1); + final pk1 = sk1.g1Element(); + final sk2 = scheme.keyGen(seed2); + final pk2 = sk2.g1Element(); + final aggPk = pk1 + pk2; + + final sigs1 = []; + if (scheme is AugSchemeMPL) { + sigs1.addAll([ + scheme.signPrepend(sk1, msg1, aggPk), + scheme.signPrepend(sk2, msg1, aggPk), + ]); + } else { + sigs1.addAll([ + scheme.sign(sk1, msg1), + scheme.sign(sk2, msg1), + ]); + } + + final aggSig1 = scheme.aggregateSigs(sigs1); + expect(scheme.verify(aggPk, msg1, aggSig1), true); + + final sigs2 = [ + scheme.sign(sk1, msg1), + scheme.sign(sk2, msg2), + ]; + final aggSig2 = scheme.aggregateSigs(sigs2); + expect( + scheme.aggregateVerify( + [pk1, pk2], + [msg1, msg2], + aggSig2, + ), + true, + ); + + final child = scheme.deriveChildSk(sk1, 123); + final childU = scheme.deriveChildSkUnhardened(sk1, 123); + final childUPk = scheme.deriveChildPkUnhardened(pk1, 123); + final sigChild = scheme.sign(child, msg1); + final sigChildPk = child.g1Element(); + expect(scheme.verify(sigChildPk, msg1, sigChild), true); + + final sigUChild = scheme.sign(childU, msg1); + expect(scheme.verify(childUPk, msg1, sigUChild), true); + + sk1.free(); + pk1.free(); + sk2.free(); + pk2.free(); + aggPk.free(); + for (final sig in sigs1) { + sig.free(); + } + aggSig1.free(); + for (final sig in sigs2) { + sig.free(); + } + aggSig2.free(); + child.free(); + childU.free(); + childUPk.free(); + sigChild.free(); + sigChildPk.free(); + sigUChild.free(); + }); + } + }); + + test('test aggregate secret keys', () async { + final msg = Uint8List.fromList([100, 2, 254, 88, 90, 45, 23]); + final scheme = BasicSchemeMPL(); + final sk1 = scheme.keyGen(genSeed(value: 7)); + final pk1 = sk1.g1Element(); + final sk2 = scheme.keyGen(genSeed(value: 8)); + final pk2 = sk2.g1Element(); + final aggSk = PrivateKey.aggregate([sk1, sk2]); + final aggSkAlt = PrivateKey.aggregate([sk2, sk1]); + expect(aggSk == aggSkAlt, true); + + final aggPubKey = pk1 + pk2; + final aggPk = aggSk.g1Element(); + expect(aggPubKey == aggPk, true); + + final sig1 = scheme.sign(sk1, msg); + final sig2 = scheme.sign(sk2, msg); + final aggSig2 = scheme.sign(aggSk, msg); + final aggSig = scheme.aggregateSigs([sig1, sig2]); + expect(aggSig == aggSig2, true); + + expect(scheme.verify(aggPubKey, msg, aggSig), true); + expect(scheme.verify(aggPubKey, msg, aggSig2), true); + + expect( + scheme.aggregateVerify( + [pk1, pk2], + [msg, msg], + aggSig, + ), + false, + ); + expect( + scheme.aggregateVerify( + [pk1, pk2], + [msg, msg], + aggSig2, + ), + false, + ); + + final msg2 = Uint8List.fromList([200, 29, 54, 8, 9, 29, 155, 55]); + final sig3 = scheme.sign(sk2, msg2); + final aggSigFinal = scheme.aggregateSigs([aggSig, sig3]); + final aggSigAlt = scheme.aggregateSigs([sig1, sig2, sig3]); + final aggSigAlt2 = scheme.aggregateSigs([sig1, sig3, sig2]); + expect(aggSigFinal == aggSigAlt, true); + expect(aggSigFinal == aggSigAlt2, true); + + final skFinal = PrivateKey.aggregate([aggSk, sk2]); + final skFinalAlt = PrivateKey.aggregate([sk2, sk1, sk2]); + expect(skFinal == skFinalAlt, true); + expect(skFinal != aggSk, true); + + final pkFinal = aggPubKey + pk2; + final pkFinalAlt = pk2 + pk1 + pk2; + expect(pkFinal == pkFinalAlt, true); + expect(pkFinal != aggPubKey, true); + + expect( + scheme.aggregateVerify( + [aggPubKey, pk2], + [msg, msg2], + aggSigFinal, + ), + true, + ); + + scheme.free(); + sk1.free(); + pk1.free(); + sk2.free(); + pk2.free(); + aggSk.free(); + aggSkAlt.free(); + aggPubKey.free(); + aggPk.free(); + sig1.free(); + sig2.free(); + aggSig2.free(); + aggSig.free(); + sig3.free(); + aggSigFinal.free(); + aggSigAlt.free(); + skFinal.free(); + skFinalAlt.free(); + pkFinal.free(); + pkFinalAlt.free(); + }); +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/aug_scheme_mpl_test.dart b/flutter-bindings/bls_signatures_ffi/example/test/aug_scheme_mpl_test.dart new file mode 100644 index 000000000..94a1ba56a --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/aug_scheme_mpl_test.dart @@ -0,0 +1,57 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'util.dart'; + +void main() { + test('test aug scheme mpl', () async { + final msg1 = Uint8List.fromList([1, 2, 3, 40]); + final msg2 = Uint8List.fromList([5, 6, 70, 201]); + final msg3 = Uint8List.fromList([9, 10, 11, 12, 13]); + final msg4 = Uint8List.fromList([15, 63, 244, 92, 0, 1]); + + final scheme = AugSchemeMPL(); + final sk1 = scheme.keyGen(genSeed(value: 2)); + final sk2 = scheme.keyGen(genSeed(value: 3)); + final pk1 = sk1.g1Element(); + final pk2 = sk2.g1Element(); + + final sig1 = scheme.sign(sk1, msg1); + final sig2 = scheme.sign(sk2, msg2); + final sig3 = scheme.sign(sk2, msg1); + final sig4 = scheme.sign(sk1, msg3); + final sig5 = scheme.sign(sk1, msg1); + final sig6 = scheme.sign(sk1, msg4); + + final aggSigL = scheme.aggregateSigs([sig1, sig2]); + final aggSigR = scheme.aggregateSigs([sig3, sig4, sig5]); + final aggSig = scheme.aggregateSigs([aggSigL, aggSigR, sig6]); + + final pks = [pk1, pk2, pk2, pk1, pk1, pk1]; + final msgs = [msg1, msg2, msg1, msg3, msg1, msg4]; + expect(scheme.aggregateVerify(pks, msgs, aggSig), true); + expect( + aggSig.hexString() == + ''' +0xa1d5360dcb418d33b29b90b912b4accde535cf0e52caf467a005dc632d9f7af44b6c4e9acd46eac218b28cdb07a3e3bc087df1cd1e3213aa4e11322a3ff3847bbba0b2fd19ddc25ca964871997b9bceeab37a4c2565876da19382ea32a962200''', + true, + ); + + scheme.free(); + sk1.free(); + sk2.free(); + pk1.free(); + pk2.free(); + sig1.free(); + sig2.free(); + sig3.free(); + sig4.free(); + sig5.free(); + sig6.free(); + aggSigL.free(); + aggSigR.free(); + aggSig.free(); + }); +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/basic_scheme_mpl_test.dart b/flutter-bindings/bls_signatures_ffi/example/test/basic_scheme_mpl_test.dart new file mode 100644 index 000000000..be1469b75 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/basic_scheme_mpl_test.dart @@ -0,0 +1,174 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'util.dart'; + +void main() { + final testCases = [ + TestCase( + index: 1, + scheme: BasicSchemeMPL(), + msgs: [ + Uint8List.fromList([7, 8, 9]), + Uint8List.fromList([10, 11, 12]), + Uint8List.fromList([1, 2, 3]), + Uint8List.fromList([1, 2, 3, 4]), + Uint8List.fromList([1, 2]), + ], + refSig1: ''' +0xb8faa6d6a3881c9fdbad803b170d70ca5cbf1e6ba5a586262df368c75acd1d1ffa3ab6ee21c71f844494659878f5eb230c958dd576b08b8564aad2ee0992e85a1e565f299cd53a285de729937f70dc176a1f01432129bb2b94d3d5031f8065a1''', + refSk1: + '0x4a353be3dac091a0a7e640620372f5e1e2e4401717c1e79cac6ffba8f6905604', + refPk1: ''' +0x85695fcbc06cc4c4c9451f4dce21cbf8de3e5a13bf48f44cdbb18e2038ba7b8bb1632d7911ef1e2e08749bddbf165352''', + refSig2: ''' +0xa9c4d3e689b82c7ec7e838dac2380cb014f9a08f6cd6ba044c263746e39a8f7a60ffee4afb78f146c2e421360784d58f0029491e3bd8ab84f0011d258471ba4e87059de295d9aba845c044ee83f6cf2411efd379ef38bf4cf41d5f3c0ae1205d''', + refAggSig1: ''' +0xaee003c8cdaf3531b6b0ca354031b0819f7586b5846796615aee8108fec75ef838d181f9d244a94d195d7b0231d4afcf06f27f0cc4d3c72162545c240de7d5034a7ef3a2a03c0159de982fbc2e7790aeb455e27beae91d64e077c70b5506dea3''', + refAggSig2: ''' +0xa0b1378d518bea4d1100adbc7bdbc4ff64f2c219ed6395cd36fe5d2aa44a4b8e710b607afd965e505a5ac3283291b75413d09478ab4b5cfbafbeea366de2d0c0bcf61deddaa521f6020460fd547ab37659ae207968b545727beba0a3c5572b9c''', + pk1FingerPrint: 0xb40dd58a, + pk2FingerPrint: 0xb839add1, + ), + ]; + + tearDownAll(() { + for (final tc in testCases) { + final scheme = tc.scheme; + if (scheme is BasicSchemeMPL) { + scheme.free(); + } else if (scheme is AugSchemeMPL) { + scheme.free(); + } else if (scheme is PopSchemeMPL) { + scheme.free(); + } + } + }); + + group('test basic scheme mpl', () { + for (final tc in testCases) { + test('case ${tc.index}', () async { + final sk1 = tc.scheme.keyGen(genSeed(value: 0)); + final pk1 = sk1.g1Element(); + final sig1 = tc.scheme.sign(sk1, tc.msgs[0]); + + final sk2 = tc.scheme.keyGen(genSeed(value: 1)); + final pk2 = sk2.g1Element(); + final sig2 = tc.scheme.sign(sk2, tc.msgs[1]); + + expect(pk1.fingerprint() == 0xb40dd58a, true); + expect(pk2.fingerprint() == 0xb839add1, true); + + expect(sig1.hexString() == tc.refSig1, true); + expect(sig2.hexString() == tc.refSig2, true); + expect(sk1.hexString() == tc.refSk1, true); + expect(pk1.hexString() == tc.refPk1, true); + + final aggSig1 = tc.scheme.aggregateSigs([sig1, sig2]); + expect(aggSig1.hexString() == tc.refAggSig1, true); + + final pks = [pk1, pk2]; + expect( + tc.scheme.aggregateVerify( + pks, + [tc.msgs[0], tc.msgs[1]], + aggSig1, + ), + true, + ); + expect( + tc.scheme.aggregateVerify( + pks, + [tc.msgs[0], tc.msgs[1]], + sig1, + ), + false, + ); + expect(tc.scheme.verify(pk1, tc.msgs[0], sig2), false); + expect(tc.scheme.verify(pk1, tc.msgs[1], sig1), false); + + final sig3 = tc.scheme.sign(sk1, tc.msgs[2]); + final sig4 = tc.scheme.sign(sk1, tc.msgs[3]); + final sig5 = tc.scheme.sign(sk2, tc.msgs[4]); + final aggSig2 = tc.scheme.aggregateSigs([sig3, sig4, sig5]); + expect(aggSig2.hexString() == tc.refAggSig2, true); + expect( + tc.scheme.aggregateVerify( + [pk1, pk1, pk2], + tc.msgs.sublist(2), + aggSig2, + ), + true, + ); + expect( + tc.scheme.aggregateVerify( + [pk1, pk1, pk2], + tc.msgs.sublist(2), + aggSig1, + ), + false, + ); + + sk1.free(); + pk1.free(); + sig1.free(); + sk2.free(); + pk2.free(); + sig2.free(); + aggSig1.free(); + sig3.free(); + sig4.free(); + sig5.free(); + aggSig2.free(); + }); + } + }); + + test('test basic scheme mpl keygen', () async { + final scheme = BasicSchemeMPL(); + final seed1 = genSeed(value: 8, length: 31); + final seed2 = genSeed(value: 8); + try { + scheme.keyGen(seed1); + } catch (e) { + expect(e, const TypeMatcher()); + } + final sk = scheme.keyGen(seed2); + final pk = sk.g1Element(); + expect(pk.fingerprint(), 0x8ee7ba56); + + scheme.free(); + sk.free(); + pk.free(); + }); +} + +class TestCase { + const TestCase({ + required this.index, + required this.scheme, + required this.msgs, + required this.refSig1, + required this.refSk1, + required this.refPk1, + required this.refSig2, + required this.refAggSig1, + required this.refAggSig2, + required this.pk1FingerPrint, + required this.pk2FingerPrint, + }); + + final int index; + final CoreMPL scheme; + final List msgs; + final String refSig1; + final String refSk1; + final String refPk1; + final String refSig2; + final String refAggSig1; + final String refAggSig2; + final int pk1FingerPrint; + final int pk2FingerPrint; +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/pop_scheme_mpl_test.dart b/flutter-bindings/bls_signatures_ffi/example/test/pop_scheme_mpl_test.dart new file mode 100644 index 000000000..2d561b0a0 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/pop_scheme_mpl_test.dart @@ -0,0 +1,25 @@ +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'util.dart'; + +void main() { + test('test pop scheme mpl', () async { + final scheme = PopSchemeMPL(); + final sk1 = scheme.keyGen(genSeed(value: 4)); + final pop = scheme.popProve(sk1); + final pk1 = sk1.g1Element(); + expect(scheme.popVerify(pk1, pop), true); + expect( + pop.hexString() == + ''' +0x84f709159435f0dc73b3e8bf6c78d85282d19231555a8ee3b6e2573aaf66872d9203fefa1ef700e34e7c3f3fb28210100558c6871c53f1ef6055b9f06b0d1abe22ad584ad3b957f3018a8f58227c6c716b1e15791459850f2289168fa0cf9115''', + true, + ); + + scheme.free(); + sk1.free(); + pop.free(); + pk1.free(); + }); +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/readme_test.dart b/flutter-bindings/bls_signatures_ffi/example/test/readme_test.dart new file mode 100644 index 000000000..6c3e38fff --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/readme_test.dart @@ -0,0 +1,161 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('test readme', () async { + final seed = Uint8List.fromList([ + 0, + 50, + 6, + 244, + 24, + 199, + 1, + 25, + 52, + 88, + 192, + 19, + 18, + 12, + 89, + 6, + 220, + 18, + 102, + 58, + 209, + 82, + 12, + 62, + 89, + 110, + 182, + 9, + 44, + 20, + 254, + 22, + ]); + + final scheme = AugSchemeMPL(); + var sk = scheme.keyGen(seed); + var pk = sk.g1Element(); + final msg = Uint8List.fromList([1, 2, 3, 4, 5]); + var sig = scheme.sign(sk, msg); + expect(scheme.verify(pk, msg, sig), true); + + final skRaw = sk.serialize(); + final pkRaw = pk.serialize(); + final sigRaw = sig.serialize(); + + sk = PrivateKey.fromBytes(data: skRaw); + pk = G1Element.fromBytes(data: pkRaw); + sig = G2Element.fromBytes(data: sigRaw); + + final sk1 = scheme.keyGen(Uint8List.fromList(seed)..[0] = 1); + final sk2 = scheme.keyGen(Uint8List.fromList(seed)..[0] = 2); + final msg2 = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7]); + final pk1 = sk1.g1Element(); + final sig1 = scheme.sign(sk1, msg); + final pk2 = sk2.g1Element(); + final sig2 = scheme.sign(sk2, msg2); + final aggSig = scheme.aggregateSigs([sig1, sig2]); + expect( + scheme.aggregateVerify( + [pk1, pk2], + [msg, msg2], + aggSig, + ), + true, + ); + + final sk3 = scheme.keyGen(Uint8List.fromList(seed)..[0] = 2); + final pk3 = sk3.g1Element(); + final msg3 = Uint8List.fromList([100, 2, 254, 88, 90, 45, 23]); + final sig3 = scheme.sign(sk3, msg3); + final aggSigFinal = scheme.aggregateSigs([aggSig, sig3]); + expect( + scheme.aggregateVerify( + [pk1, pk2, pk3], + [msg, msg2, msg3], + aggSigFinal, + ), + true, + ); + + final popScheme = PopSchemeMPL(); + final popSig1 = popScheme.sign(sk1, msg); + final popSig2 = popScheme.sign(sk2, msg); + final popSig3 = popScheme.sign(sk3, msg); + final pop1 = popScheme.popProve(sk1); + final pop2 = popScheme.popProve(sk2); + final pop3 = popScheme.popProve(sk3); + expect(popScheme.popVerify(pk1, pop1), true); + expect(popScheme.popVerify(pk2, pop2), true); + expect(popScheme.popVerify(pk3, pop3), true); + + final popSigAgg = + popScheme.aggregateSigs([popSig1, popSig2, popSig3]); + expect( + popScheme.fastAggregateVerify([pk1, pk2, pk3], msg, popSigAgg), + true, + ); + + final popAggPk = pk1 + pk2 + pk3; + final tPopAggPk1 = pk1 + (pk2 + pk3); + expect(popAggPk.serialize() == tPopAggPk1.serialize(), true); + expect(popScheme.verify(popAggPk, msg, popSigAgg), true); + + final popAggSk = PrivateKey.aggregate([sk1, sk2, sk3]); + final popEqTest = popScheme.sign(popAggSk, msg); + expect(popEqTest == popSigAgg, true); + expect(popEqTest.serialize() == popSigAgg.serialize(), true); + + final masterSk = scheme.keyGen(seed); + final masterPk = masterSk.g1Element(); + final childU = scheme.deriveChildSkUnhardened(masterSk, 22); + final grandChildU = scheme.deriveChildSkUnhardened(childU, 0); + final childUPk = scheme.deriveChildPkUnhardened(masterPk, 22); + final grandChildUPk = scheme.deriveChildPkUnhardened(childUPk, 0); + final grandChildUPkAlt = grandChildU.g1Element(); + expect(grandChildUPk.serialize() == grandChildUPkAlt.serialize(), true); + + scheme.free(); + sk.free(); + pk.free(); + sig.free(); + sk1.free(); + sk2.free(); + pk1.free(); + sig1.free(); + pk2.free(); + sig2.free(); + aggSig.free(); + sk3.free(); + pk3.free(); + sig3.free(); + aggSigFinal.free(); + popScheme.free(); + popSig1.free(); + popSig2.free(); + popSig3.free(); + pop1.free(); + pop2.free(); + pop3.free(); + popSigAgg.free(); + popAggPk.free(); + tPopAggPk1.free(); + popAggSk.free(); + popEqTest.free(); + masterSk.free(); + masterPk.free(); + childU.free(); + grandChildU.free(); + childUPk.free(); + grandChildUPk.free(); + grandChildUPkAlt.free(); + }); +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/sign_verify_test.dart b/flutter-bindings/bls_signatures_ffi/example/test/sign_verify_test.dart new file mode 100644 index 000000000..ab267925c --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/sign_verify_test.dart @@ -0,0 +1,32 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'util.dart'; + +void main() { + final schemes = [BasicSchemeMPL(), AugSchemeMPL(), PopSchemeMPL()]; + + tearDownAll(() { + (schemes[0] as BasicSchemeMPL).free(); + (schemes[1] as AugSchemeMPL).free(); + (schemes[2] as PopSchemeMPL).free(); + }); + + group('test sign and verification', () { + final msg = Uint8List.fromList([100, 2, 254, 88, 90, 45, 23]); + for (final scheme in schemes) { + test(scheme.runtimeType, () async { + final sk = scheme.keyGen(genSeed(value: 1)); + final pk = sk.g1Element(); + final sig = scheme.sign(sk, msg); + expect(scheme.verify(pk, msg, sig), true); + + sk.free(); + pk.free(); + sig.free(); + }); + } + }); +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/util.dart b/flutter-bindings/bls_signatures_ffi/example/test/util.dart new file mode 100644 index 000000000..0f51682c9 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/util.dart @@ -0,0 +1,33 @@ +// import 'package:flutter_test/flutter_test.dart'; + +// Future sleep({ +// required WidgetTester tester, +// int explicitMs = 0, +// int multiplier = 1, +// }) async { +// const speedString = String.fromEnvironment('SPEED'); +// var speed = 0; +// if (speedString.isNotEmpty) { +// speed = int.parse(speedString); +// } +// const speedNumerator = 10000; + +// var sleepTime = explicitMs; +// if (sleepTime == 0) { +// if (speed != 0) { +// sleepTime = (speedNumerator * multiplier) ~/ speed; +// } +// } + +// await tester.pump(Duration(milliseconds: sleepTime)); +// } + +import 'dart:typed_data'; + +Uint8List genSeed({required int value, int length = 32}) { + final data = []; + for (var i = 0; i < length; i++) { + data.add(value); + } + return Uint8List.fromList(data); +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/vector_invalid.dart b/flutter-bindings/bls_signatures_ffi/example/test/vector_invalid.dart new file mode 100644 index 000000000..4363ba588 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/vector_invalid.dart @@ -0,0 +1,156 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:convert/convert.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + final g1TestCases = [ + const TestCase( + name: 'infinity points: not all zeros', + data: [ + ''' +c00000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000''', + ''' +400000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ''' +400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ], + ), + const TestCase( + name: 'bad tags', + data: [ + ''' +3a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa''', + ''' +7a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa''', + ''' +fa0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa''', + ], + ), + const TestCase( + name: 'wrong length for comporessed point', + data: [ + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa''', + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaaaa''', + ], + ), + const TestCase( + name: 'invalid x-coord', + data: [ + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa''', + ], + ), + const TestCase( + name: 'invalid elm of Fp --- equal to p (must be strictly less)', + data: [ + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab''', + ], + ), + const TestCase( + name: 'point not on curve', + data: [ + ''' +1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa''', + ], + ), + ]; + + final g2TestCases = [ + const TestCase( + name: 'infinity points: not all zeros', + data: [ + ''' +c00000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ''' +c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000''', + ], + ), + const TestCase( + name: 'bad tags 1', + data: [ + ''' +3a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ''' +7a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ''' +fa0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ], + ), + const TestCase( + name: 'invalid x-coord', + data: [ + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaa7''', + ], + ), + const TestCase( + name: 'invalid elm of Fp --- equal to p (must be strictly less)', + data: [ + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''', + ''' +9a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab''', + ], + ), + const TestCase( + name: 'point not on curve', + data: [ + ''' +1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa''', + ], + ), + ]; + final testCollections = [ + TestCollection( + name: 'G1Element', + cases: g1TestCases, + fn: (Uint8List data) => G1Element.fromBytes(data: data), + ), + TestCollection( + name: 'G2Element', + cases: g2TestCases, + fn: (Uint8List data) => G2Element.fromBytes(data: data), + ), + ]; + + group('test vector invalid', () { + for (final tc in testCollections) { + for (final c in tc.cases) { + test('${tc.name} ${c.name}', () async { + for (final input in c.data) { + final data = Uint8List.fromList(hex.decode(input)); + try { + tc.fn(data); + } catch (e) { + expect(e, const TypeMatcher()); + } + } + }); + } + } + }); +} + +class TestCase { + const TestCase({required this.name, required this.data}); + + final String name; + final List data; +} + +class TestCollection { + const TestCollection({ + required this.name, + required this.cases, + required this.fn, + }); + + final String name; + final List cases; + final Function(Uint8List) fn; +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test/vector_valid.dart b/flutter-bindings/bls_signatures_ffi/example/test/vector_valid.dart new file mode 100644 index 000000000..5c8f88b73 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test/vector_valid.dart @@ -0,0 +1,98 @@ +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + final secret1 = []; + final secret2 = []; + for (var i = 0; i < 32; i++) { + secret1.add(1); + secret2.add(i * 314159 % 256); + } + final sk1 = PrivateKey.fromBytes(data: Uint8List.fromList(secret1)); + final sk2 = PrivateKey.fromBytes(data: Uint8List.fromList(secret2)); + final msg = Uint8List.fromList([3, 1, 4, 1, 5, 9]); + + final testCases = [ + TestCase( + name: 'testing of signature serialization of the basic scheme', + scheme: BasicSchemeMPL(), + refSig1: ''' +0x96ba34fac33c7f129d602a0bc8a3d43f9abc014eceaab7359146b4b150e57b808645738f35671e9e10e0d862a30cab70074eb5831d13e6a5b162d01eebe687d0164adbd0a864370a7c222a2768d7704da254f1bf1823665bc2361f9dd8c00e99''', + refSig2: ''' +0xa402790932130f766af11ba716536683d8c4cfa51947e4f9081fedd692d6dc0cac5b904bee5ea6e25569e36d7be4ca59069a96e34b7f700758b716f9494aaa59a96e74d14a3b552a9a6bc129e717195b9d6006fd6d5cef4768c022e0f7316abf''', + refSigA: ''' +0x987cfd3bcd62280287027483f29c55245ed831f51dd6bd999a6ff1a1f1f1f0b647778b0167359c71505558a76e158e66181ee5125905a642246b01e7fa5ee53d68a4fe9bfb29a8e26601f0b9ad577ddd18876a73317c216ea61f430414ec51c5''', + ), + TestCase( + name: 'testing of signature serialization of the augmented scheme', + scheme: AugSchemeMPL(), + refSig1: ''' +0x8180f02ccb72e922b152fcedbe0e1d195210354f70703658e8e08cbebf11d4970eab6ac3ccf715f3fb876df9a9797abd0c1af61aaeadc92c2cfe5c0a56c146cc8c3f7151a073cf5f16df38246724c4aed73ff30ef5daa6aacaed1a26ecaa336b''', + refSig2: ''' +0x99111eeafb412da61e4c37d3e806c6fd6ac9f3870e54da9222ba4e494822c5b7656731fa7a645934d04b559e9261b86201bbee57055250a459a2da10e51f9c1a6941297ffc5d970a557236d0bdeb7cf8ff18800b08633871a0f0a7ea42f47480''', + refSigA: ''' +0x8c5d03f9dae77e19a5945a06a214836edb8e03b851525d84b9de6440e68fc0ca7303eeed390d863c9b55a8cf6d59140a01b58847881eb5af67734d44b2555646c6616c39ab88d253299acc1eb1b19ddb9bfcbe76e28addf671d116c052bb1847''', + ), + TestCase( + name: ''' +testing of signature serialization of the proof of possession scheme''', + scheme: PopSchemeMPL(), + refSig1: ''' +0x9550fb4e7f7e8cc4a90be8560ab5a798b0b23000b6a54a2117520210f986f3f281b376f259c0b78062d1eb3192b3d9bb049f59ecc1b03a7049eb665e0df36494ae4cb5f1136ccaeefc9958cb30c3333d3d43f07148c386299a7b1bfc0dc5cf7c''', + refSig2: ''' +0xa69036bc11ae5efcbf6180afe39addde7e27731ec40257bfdc3c37f17b8df68306a34ebd10e9e32a35253750df5c87c2142f8207e8d5654712b4e554f585fb6846ff3804e429a9f8a1b4c56b75d0869ed67580d789870babe2c7c8a9d51e7b2a''', + refSigA: ''' +0xa4ea742bcdc1553e9ca4e560be7e5e6c6efa6a64dddf9ca3bb2854233d85a6aac1b76ec7d103db4e33148b82af9923db05934a6ece9a7101cd8a9d47ce27978056b0f5900021818c45698afdd6cf8a6b6f7fee1f0b43716f55e413d4b87a6039''', + ), + ]; + + tearDownAll(() { + sk1.free(); + sk2.free(); + for (final tc in testCases) { + final scheme = tc.scheme; + if (scheme is BasicSchemeMPL) { + scheme.free(); + } else if (scheme is AugSchemeMPL) { + scheme.free(); + } else if (scheme is PopSchemeMPL) { + scheme.free(); + } + } + }); + + group('test vector valid', () { + for (final tc in testCases) { + test(tc.name, () async { + final sig1 = tc.scheme.sign(sk1, msg); + final sig2 = tc.scheme.sign(sk2, msg); + final sigA = tc.scheme.aggregateSigs([sig1, sig2]); + expect(sig1.hexString() == tc.refSig1, true); + expect(sig2.hexString() == tc.refSig2, true); + expect(sigA.hexString() == tc.refSigA, true); + + sig1.free(); + sig2.free(); + sigA.free(); + }); + } + }); +} + +class TestCase { + const TestCase({ + required this.name, + required this.scheme, + required this.refSig1, + required this.refSig2, + required this.refSigA, + }); + + final String name; + final CoreMPL scheme; + final String refSig1; + final String refSig2; + final String refSigA; +} diff --git a/flutter-bindings/bls_signatures_ffi/example/test_driver/integration_test.dart b/flutter-bindings/bls_signatures_ffi/example/test_driver/integration_test.dart new file mode 100644 index 000000000..b38629cca --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test_driver/integration_test.dart @@ -0,0 +1,3 @@ +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/flutter-bindings/bls_signatures_ffi/example/test_driver/main.dart b/flutter-bindings/bls_signatures_ffi/example/test_driver/main.dart new file mode 100644 index 000000000..af8db1fae --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/example/test_driver/main.dart @@ -0,0 +1,19 @@ +import 'package:integration_test/integration_test.dart'; +import '../test/aggregate_test.dart' as aggregate; +import '../test/aug_scheme_mpl_test.dart' as augschemempl; +import '../test/basic_scheme_mpl_test.dart' as basicschemempl; +import '../test/pop_scheme_mpl_test.dart' as popschemempl; +import '../test/sign_verify_test.dart' as signverify; +import '../test/vector_invalid.dart' as vectorinvalid; +import '../test/vector_valid.dart' as vectorvalid; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + aggregate.main(); + augschemempl.main(); + basicschemempl.main(); + popschemempl.main(); + signverify.main(); + vectorinvalid.main(); + vectorvalid.main(); +} diff --git a/flutter-bindings/bls_signatures_ffi/ios/.gitignore b/flutter-bindings/bls_signatures_ffi/ios/.gitignore new file mode 100644 index 000000000..0c885071e --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/.gitignore @@ -0,0 +1,38 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/Generated.xcconfig +/Flutter/ephemeral/ +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/Assets/.gitkeep b/flutter-bindings/bls_signatures_ffi/ios/Assets/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/flutter-bindings/bls_signatures_ffi/ios/Classes/BlsSignaturesFfiPlugin.h b/flutter-bindings/bls_signatures_ffi/ios/Classes/BlsSignaturesFfiPlugin.h new file mode 100644 index 000000000..65ec40acd --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/Classes/BlsSignaturesFfiPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface BlsSignaturesFfiPlugin : NSObject +@end diff --git a/flutter-bindings/bls_signatures_ffi/ios/Classes/BlsSignaturesFfiPlugin.m b/flutter-bindings/bls_signatures_ffi/ios/Classes/BlsSignaturesFfiPlugin.m new file mode 100644 index 000000000..e47b9269b --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/Classes/BlsSignaturesFfiPlugin.m @@ -0,0 +1,15 @@ +#import "BlsSignaturesFfiPlugin.h" +#if __has_include() +#import +#else +// Support project import fallback if the generated compatibility header +// is not copied when this plugin is created as a library. +// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 +#import "bls_signatures_ffi-Swift.h" +#endif + +@implementation BlsSignaturesFfiPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + [SwiftBlsSignaturesFfiPlugin registerWithRegistrar:registrar]; +} +@end diff --git a/flutter-bindings/bls_signatures_ffi/ios/Classes/SwiftBlsSignaturesFfiPlugin.swift b/flutter-bindings/bls_signatures_ffi/ios/Classes/SwiftBlsSignaturesFfiPlugin.swift new file mode 100644 index 000000000..618e030a4 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/Classes/SwiftBlsSignaturesFfiPlugin.swift @@ -0,0 +1,14 @@ +import Flutter +import UIKit + +public class SwiftBlsSignaturesFfiPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "bls_signatures_ffi", binaryMessenger: registrar.messenger()) + let instance = SwiftBlsSignaturesFfiPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + result("iOS " + UIDevice.current.systemVersion) + } +} diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/blschia.cpp b/flutter-bindings/bls_signatures_ffi/ios/bls/blschia.cpp new file mode 100644 index 000000000..92ffd0a57 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/blschia.cpp @@ -0,0 +1,48 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "blschia.h" + +#include + +#include + +#include "bls.hpp" +#include "error.h" + +std::string fErrMsg; + +void SecFree(void* p) { bls::Util::SecFree(p); } + +void** AllocPtrArray(size_t len) +{ + // caller to free + return (void**)bls::Util::SecAlloc(sizeof(void*) * len); +} + +void SetPtrArray(void** arrPtr, void* elemPtr, int index) +{ + arrPtr[index] = elemPtr; +} + +void FreePtrArray(void** inPtr) { bls::Util::SecFree(inPtr); } + +void* GetPtrAtIndex(void** arrPtr, int index) { return arrPtr[index]; } + +uint8_t* SecAllocBytes(size_t len) +{ + return (uint8_t*)bls::Util::SecAlloc(sizeof(uint8_t) * len); +} + +void* GetAddressAtIndex(uint8_t* ptr, int index) { return (void*)&ptr[index]; } + +const char* GetLastErrorMsg() { return fErrMsg.c_str(); } \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/blschia.h b/flutter-bindings/bls_signatures_ffi/ios/bls/blschia.h new file mode 100644 index 000000000..a0fcdb270 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/blschia.h @@ -0,0 +1,46 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FLUTTER_BINDINGS_BLSCHIA_H +#define FLUTTER_BINDINGS_BLSCHIA_H + +#include +#include +#include "privatekey.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Export the BLS SecFree method +void SecFree(void *p); + +typedef void** carr; + +// Additional C++ helper funcs for allocations +void** AllocPtrArray(size_t len); +void SetPtrArray(void **arrPtr, void *elemPtr, int index); +void FreePtrArray(void **inPtr); +void* GetPtrAtIndex(void **arrPtr, int index); + +// Allocates an array of bytes with size of passed in len argument +uint8_t* SecAllocBytes(size_t len); + +void* GetAddressAtIndex(uint8_t *ptr, int index); + +const char* GetLastErrorMsg(); + +#ifdef __cplusplus +} +#endif + +#endif // FLUTTER_BINDINGS_BLSCHIA_H diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/elements.cpp b/flutter-bindings/bls_signatures_ffi/ios/bls/elements.cpp new file mode 100644 index 000000000..c79ab8d5a --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/elements.cpp @@ -0,0 +1,167 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "elements.h" + +#include + +#include "bls.hpp" +#include "blschia.h" +#include "error.h" + +// G1Element +int CG1ElementSize() { return bls::G1Element::SIZE; } + +CG1Element CG1ElementFromBytes(const void* data, bool* didErr) +{ + bls::G1Element* el = nullptr; + try { + el = new bls::G1Element(bls::G1Element::FromBytes( + bls::Bytes((uint8_t*)(data), bls::G1Element::SIZE))); + } catch (const std::exception& ex) { + fErrMsg = ex.what(); + *didErr = true; + return nullptr; + } + *didErr = false; + return el; +} + +CG1Element CG1ElementGenerator() +{ + return new bls::G1Element(bls::G1Element::Generator()); +} + +bool CG1ElementIsValid(const CG1Element el) +{ + const bls::G1Element* elPtr = (bls::G1Element*)el; + return elPtr->IsValid(); +} + +uint32_t CG1ElementGetFingerprint(const CG1Element el) +{ + const bls::G1Element* elPtr = (bls::G1Element*)el; + return elPtr->GetFingerprint(); +} + +void* CG1ElementSerialize(const CG1Element el) +{ + const bls::G1Element* elPtr = (bls::G1Element*)el; + const std::vector serialized = elPtr->Serialize(); + uint8_t* buffer = (uint8_t*)malloc(bls::G1Element::SIZE); + memcpy(buffer, serialized.data(), bls::G1Element::SIZE); + return (void*)buffer; +} + +bool CG1ElementIsEqual(const CG1Element el1, const CG1Element el2) +{ + const bls::G1Element* el1Ptr = (bls::G1Element*)el1; + const bls::G1Element* el2Ptr = (bls::G1Element*)el2; + return *el1Ptr == *el2Ptr; +} + +CG1Element CG1ElementAdd(const CG1Element el1, const CG1Element el2) +{ + const bls::G1Element* el1Ptr = (bls::G1Element*)el1; + const bls::G1Element* el2Ptr = (bls::G1Element*)el2; + return new bls::G1Element((*el1Ptr) + (*el2Ptr)); +} + +CG1Element CG1ElementMul(const CG1Element el, const CPrivateKey sk) +{ + const bls::G1Element* elPtr = (bls::G1Element*)el; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G1Element(*elPtr * *skPtr); +} + +CG1Element CG1ElementNegate(const CG1Element el) +{ + const bls::G1Element* elPtr = (bls::G1Element*)el; + return new bls::G1Element(elPtr->Negate()); +} + +void CG1ElementFree(const CG1Element el) +{ + const bls::G1Element* elPtr = (bls::G1Element*)el; + delete elPtr; +} + +// G2Element +int CG2ElementSize() { return bls::G2Element::SIZE; } + +CG2Element CG2ElementFromBytes(const void* data, bool* didErr) +{ + bls::G2Element* el = nullptr; + try { + el = new bls::G2Element(bls::G2Element::FromBytes( + bls::Bytes((uint8_t*)data, bls::G2Element::SIZE))); + *didErr = false; + } catch (const std::exception& ex) { + fErrMsg = ex.what(); + *didErr = true; + return nullptr; + } + return el; +} + +CG2Element CG2ElementGenerator() +{ + return new bls::G2Element(bls::G2Element::Generator()); +} + +bool CG2ElementIsValid(const CG2Element el) +{ + const bls::G2Element* elPtr = (bls::G2Element*)el; + return elPtr->IsValid(); +} + +void* CG2ElementSerialize(const CG2Element el) +{ + const bls::G2Element* elPtr = (bls::G2Element*)el; + const std::vector serialized = elPtr->Serialize(); + uint8_t* buffer = (uint8_t*)malloc(bls::G2Element::SIZE); + memcpy(buffer, serialized.data(), bls::G2Element::SIZE); + return (void*)buffer; +} + +bool CG2ElementIsEqual(const CG2Element el1, const CG2Element el2) +{ + const bls::G2Element* el1Ptr = (bls::G2Element*)el1; + const bls::G2Element* el2Ptr = (bls::G2Element*)el2; + return *el1Ptr == *el2Ptr; +} + +CG2Element CG2ElementAdd(const CG2Element el1, const CG2Element el2) +{ + bls::G2Element* el1Ptr = (bls::G2Element*)el1; + bls::G2Element* el2Ptr = (bls::G2Element*)el2; + return new bls::G2Element(*el1Ptr + *el2Ptr); +} + +CG2Element CG2ElementMul(const CG2Element el, const CPrivateKey sk) +{ + const bls::G2Element* elPtr = (bls::G2Element*)el; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G2Element(*elPtr * *skPtr); +} + +CG2Element CG2ElementNegate(const CG2Element el) +{ + const bls::G2Element* elPtr = (bls::G2Element*)el; + return new bls::G2Element(elPtr->Negate()); +} + +void CG2ElementFree(const CG2Element el) +{ + bls::G2Element* elPtr = (bls::G2Element*)el; + delete elPtr; +} \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/elements.h b/flutter-bindings/bls_signatures_ffi/ios/bls/elements.h new file mode 100644 index 000000000..73b46b7d9 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/elements.h @@ -0,0 +1,54 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FLUTTER_BINDINGS_ELEMENTS_H_ +#define FLUTTER_BINDINGS_ELEMENTS_H_ +#include +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* CG1Element; +typedef void* CG2Element; +typedef void* CPrivateKey; + +// G1Element +int CG1ElementSize(); +CG1Element CG1ElementFromBytes(const void* data, bool* didErr); +CG1Element CG1ElementGenerator(); +bool CG1ElementIsValid(const CG1Element el); +uint32_t CG1ElementGetFingerprint(const CG1Element el); +bool CG1ElementIsEqual(const CG1Element el1, const CG1Element el2); +CG1Element CG1ElementAdd(const CG1Element el1, const CG1Element el2); +CG1Element CG1ElementMul(const CG1Element el, const CPrivateKey sk); +CG1Element CG1ElementNegate(const CG1Element el); +void* CG1ElementSerialize(const CG1Element el); +void CG1ElementFree(const CG1Element el); + +// G2Element +int CG2ElementSize(); +CG2Element CG2ElementFromBytes(const void* data, bool* didErr); +CG2Element CG2ElementGenerator(); +bool CG2ElementIsValid(const CG2Element el); +bool CG2ElementIsEqual(const CG2Element el1, const CG2Element el2); +CG2Element CG2ElementAdd(const CG2Element el1, const CG2Element el2); +CG2Element CG2ElementMul(const CG2Element el, const CPrivateKey sk); +CG2Element CG2ElementNegate(const CG2Element el); +void* CG2ElementSerialize(const CG2Element el); +void CG2ElementFree(const CG2Element el); + +#ifdef __cplusplus +} +#endif +#endif // FLUTTER_BINDINGS_ELEMENTS_H_ \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/error.h b/flutter-bindings/bls_signatures_ffi/ios/bls/error.h new file mode 100644 index 000000000..37d68935d --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/error.h @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FLUTTER_BINDINGS_ERROR_H_ +#define FLUTTER_BINDINGS_ERROR_H_ +#include + +extern std::string fErrMsg; + +#endif // FLUTTER_BINDINGS_ERROR_H_ \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/privatekey.cpp b/flutter-bindings/bls_signatures_ffi/ios/bls/privatekey.cpp new file mode 100644 index 000000000..176e88637 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/privatekey.cpp @@ -0,0 +1,121 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "privatekey.h" + +#include + +#include "bls.hpp" +#include "blschia.h" +#include "error.h" +#include "utils.hpp" + +// private key bindings implementation +CPrivateKey CPrivateKeyFromBytes( + const void* data, + const bool modOrder, + bool* didErr) +{ + bls::PrivateKey* skPtr = nullptr; + try { + skPtr = new bls::PrivateKey(bls::PrivateKey::FromBytes( + bls::Bytes((uint8_t*)data, bls::PrivateKey::PRIVATE_KEY_SIZE), + modOrder)); + } catch (const std::exception& ex) { + // set err + fErrMsg = ex.what(); + *didErr = true; + return nullptr; + } + *didErr = false; + return skPtr; +} + +CPrivateKey CPrivateKeyAggregate(void** sks, const size_t len) +{ + return new bls::PrivateKey( + bls::PrivateKey::Aggregate(toBLSVector(sks, len))); +} + +void* CPrivateKeySerialize(const CPrivateKey sk) +{ + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + uint8_t* buffer = + bls::Util::SecAlloc(bls::PrivateKey::PRIVATE_KEY_SIZE); + skPtr->Serialize(buffer); + return (void*)buffer; +} + +size_t CPrivateKeySizeBytes() { return bls::PrivateKey::PRIVATE_KEY_SIZE; } + +bool CPrivateKeyIsEqual(const CPrivateKey sk1, const CPrivateKey sk2) +{ + const bls::PrivateKey* sk1Ptr = (bls::PrivateKey*)sk1; + const bls::PrivateKey* sk2Ptr = (bls::PrivateKey*)sk2; + return *sk1Ptr == *sk2Ptr; +} + +CG1Element CPrivateKeyGetG1Element(const CPrivateKey sk, bool* didErr) +{ + bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + bls::G1Element* el = nullptr; + try { + el = new bls::G1Element(skPtr->GetG1Element()); + *didErr = false; + } catch (const std::exception& ex) { + // set err + fErrMsg = ex.what(); + *didErr = true; + return nullptr; + } + return el; +} + +CG2Element CPrivateKeyGetG2Element(const CPrivateKey sk, bool* didErr) +{ + bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + bls::G2Element* el = nullptr; + try { + el = new bls::G2Element(skPtr->GetG2Element()); + *didErr = false; + } catch (const std::exception& ex) { + // set err + fErrMsg = ex.what(); + *didErr = true; + return nullptr; + } + return el; +} + +CG2Element CPrivateKeyGetG2Power(const CPrivateKey sk, const CG2Element el) +{ + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + const bls::G2Element* elPtr = (bls::G2Element*)el; + return new bls::G2Element(skPtr->GetG2Power(*elPtr)); +} + +CG2Element CPrivateKeySignG2( + const CPrivateKey sk, + uint8_t* msg, + const size_t len, + const uint8_t* dst, + const size_t dstLen) +{ + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G2Element(skPtr->SignG2(msg, len, dst, dstLen)); +} + +void CPrivateKeyFree(CPrivateKey sk) +{ + bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + delete skPtr; +} \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/privatekey.h b/flutter-bindings/bls_signatures_ffi/ios/bls/privatekey.h new file mode 100644 index 000000000..bc4a84487 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/privatekey.h @@ -0,0 +1,37 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FLUTTER_BINDINGS_PRIVATEKEY_H_ +#define FLUTTER_BINDINGS_PRIVATEKEY_H_ +#include +#include +#include "elements.h" +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* CPrivateKey; + +CPrivateKey CPrivateKeyFromBytes(const void* data, const bool modOrder, bool* didErr); +CPrivateKey CPrivateKeyAggregate(void** sks, const size_t len); +CG1Element CPrivateKeyGetG1Element(const CPrivateKey sk, bool* didErr); +CG2Element CPrivateKeyGetG2Element(const CPrivateKey sk, bool* didErr); +CG2Element CPrivateKeyGetG2Power(const CPrivateKey sk, const CG2Element el); +bool CPrivateKeyIsEqual(const CPrivateKey sk1, const CPrivateKey sk2); +void* CPrivateKeySerialize(const CPrivateKey sk); +void CPrivateKeyFree(const CPrivateKey sk); +size_t CPrivateKeySizeBytes(); + +#ifdef __cplusplus +} +#endif +#endif // FLUTTER_BINDINGS_PRIVATEKEY_H_ \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/schemes.cpp b/flutter-bindings/bls_signatures_ffi/ios/bls/schemes.cpp new file mode 100644 index 000000000..e15ff8526 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/schemes.cpp @@ -0,0 +1,295 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "schemes.h" + +#include + +#include "bls.hpp" +#include "blschia.h" +#include "elements.h" +#include "error.h" +#include "privatekey.h" +#include "utils.hpp" + +// Implementation of bindings for CoreMPL class + +CPrivateKey CCoreMPLKeyGen( + const CCoreMPL scheme, + const void* seed, + const size_t seedLen, + bool* didErr) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + bls::PrivateKey* sk = nullptr; + try { + sk = new bls::PrivateKey( + schemePtr->KeyGen(bls::Bytes((uint8_t*)seed, seedLen))); + } catch (const std::exception& ex) { + fErrMsg = ex.what(); + *didErr = true; + return nullptr; + } + *didErr = false; + return sk; +} + +CG1Element CCoreMPSkToG1(const CCoreMPL scheme, const CPrivateKey sk) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G1Element(schemePtr->SkToG1(*skPtr)); +} + +CG2Element CCoreMPLSign( + CCoreMPL scheme, + const CPrivateKey sk, + const void* msg, + const size_t msgLen) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G2Element( + schemePtr->Sign(*skPtr, bls::Bytes((uint8_t*)msg, msgLen))); +} + +bool CCoreMPLVerify( + const CCoreMPL scheme, + const CG1Element pk, + const void* msg, + const size_t msgLen, + const CG2Element sig) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + const bls::G1Element* pkPtr = (bls::G1Element*)pk; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + return schemePtr->Verify( + *pkPtr, bls::Bytes((uint8_t*)msg, msgLen), *sigPtr); +} + +CG1Element CCoreMPLAggregatePubKeys( + const CCoreMPL scheme, + void** pks, + const size_t pksLen) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + return new bls::G1Element( + schemePtr->Aggregate(toBLSVector(pks, pksLen))); +} + +CG2Element CCoreMPLAggregateSigs( + const CCoreMPL scheme, + void** sigs, + const size_t sigsLen) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + return new bls::G2Element( + schemePtr->Aggregate(toBLSVector(sigs, sigsLen))); +} + +CPrivateKey CCoreMPLDeriveChildSk( + const CCoreMPL scheme, + const CPrivateKey sk, + const uint32_t index) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::PrivateKey(schemePtr->DeriveChildSk(*skPtr, index)); +} + +CPrivateKey CCoreMPLDeriveChildSkUnhardened( + CCoreMPL scheme, + CPrivateKey sk, + uint32_t index) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::PrivateKey( + schemePtr->DeriveChildSkUnhardened(*skPtr, index)); +} + +CG1Element CCoreMPLDeriveChildPkUnhardened( + CCoreMPL scheme, + CG1Element el, + uint32_t index) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + bls::G1Element* elPtr = (bls::G1Element*)el; + return new bls::G1Element( + schemePtr->DeriveChildPkUnhardened(*elPtr, index)); +} + +bool CCoreMPLAggregateVerify( + const CCoreMPL scheme, + void** pks, + const size_t pksLen, + void** msgs, + const void* msgsLens, + const size_t msgsLen, + const CG2Element sig) +{ + bls::CoreMPL* schemePtr = (bls::CoreMPL*)scheme; + const size_t* msgLensPtr = (size_t*)msgsLens; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + const std::vector vecPubKeys = + toBLSVector(pks, pksLen); + const std::vector vecMsgsLens = + std::vector(msgLensPtr, msgLensPtr + msgsLen); + const std::vector vecMsgs = + toVectorBytes(msgs, msgsLen, vecMsgsLens); + return schemePtr->AggregateVerify(vecPubKeys, vecMsgs, *sigPtr); +} + +// BasicSchemeMPL +CBasicSchemeMPL NewCBasicSchemeMPL() { return new bls::BasicSchemeMPL(); } + +bool CBasicSchemeMPLAggregateVerify( + CBasicSchemeMPL scheme, + void** pks, + const size_t pksLen, + void** msgs, + const void* msgsLens, + const size_t msgsLen, + const CG2Element sig) +{ + bls::BasicSchemeMPL* schemePtr = (bls::BasicSchemeMPL*)scheme; + const size_t* msgLensPtr = (size_t*)msgsLens; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + const std::vector vecPubKeys = + toBLSVector(pks, pksLen); + const std::vector vecMsgsLens = + std::vector(msgLensPtr, msgLensPtr + msgsLen); + const std::vector vecMsgs = + toVectorBytes(msgs, msgsLen, vecMsgsLens); + return schemePtr->AggregateVerify(vecPubKeys, vecMsgs, *sigPtr); +} + +void CBasicSchemeMPLFree(CBasicSchemeMPL scheme) +{ + bls::BasicSchemeMPL* schemePtr = (bls::BasicSchemeMPL*)scheme; + delete schemePtr; +} + +// AugSchemeMPL +CAugSchemeMPL NewCAugSchemeMPL() { return new bls::AugSchemeMPL(); } + +CG2Element CAugSchemeMPLSign( + const CAugSchemeMPL scheme, + const CPrivateKey sk, + const void* msg, + const size_t msgLen) +{ + bls::AugSchemeMPL* schemePtr = (bls::AugSchemeMPL*)scheme; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G2Element( + schemePtr->Sign(*skPtr, bls::Bytes((uint8_t*)msg, msgLen))); +} + +CG2Element CAugSchemeMPLSignPrepend( + const CAugSchemeMPL scheme, + const CPrivateKey sk, + const void* msg, + const size_t msgLen, + const CG1Element prepPk) +{ + bls::AugSchemeMPL* schemePtr = (bls::AugSchemeMPL*)scheme; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + const bls::G1Element* prepPkPtr = (bls::G1Element*)prepPk; + return new bls::G2Element( + schemePtr->Sign(*skPtr, bls::Bytes((uint8_t*)msg, msgLen), *prepPkPtr)); +} + +bool CAugSchemeMPLVerify( + const CAugSchemeMPL scheme, + const CG1Element pk, + const void* msg, + const size_t msgLen, + const CG2Element sig) +{ + bls::AugSchemeMPL* schemePtr = (bls::AugSchemeMPL*)scheme; + const bls::G1Element* pkPtr = (bls::G1Element*)pk; + const uint8_t* msgPtr = (uint8_t*)msg; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + return schemePtr->Verify(*pkPtr, bls::Bytes(msgPtr, msgLen), *sigPtr); +} + +bool CAugSchemeMPLAggregateVerify( + const CAugSchemeMPL scheme, + void** pks, + const size_t pksLen, + void** msgs, + const void* msgsLens, + const size_t msgsLen, + const CG2Element sig) +{ + bls::AugSchemeMPL* schemePtr = (bls::AugSchemeMPL*)scheme; + const size_t* msgLensPtr = (size_t*)msgsLens; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + const std::vector vecPubKeys = + toBLSVector(pks, pksLen); + const std::vector vecMsgsLens = + std::vector(msgLensPtr, msgLensPtr + msgsLen); + const std::vector vecMsgs = + toVectorBytes(msgs, msgsLen, vecMsgsLens); + return schemePtr->AggregateVerify(vecPubKeys, vecMsgs, *sigPtr); +} + +void CAugSchemeMPLFree(CAugSchemeMPL scheme) +{ + bls::AugSchemeMPL* schemePtr = (bls::AugSchemeMPL*)scheme; + delete schemePtr; +} + +// PopSchemeMPL +CPopSchemeMPL NewCPopSchemeMPL() { return new bls::PopSchemeMPL(); } + +CG2Element CPopSchemeMPLPopProve( + const CPopSchemeMPL scheme, + const CPrivateKey sk) +{ + bls::PopSchemeMPL* schemePtr = (bls::PopSchemeMPL*)scheme; + const bls::PrivateKey* skPtr = (bls::PrivateKey*)sk; + return new bls::G2Element(schemePtr->PopProve(*skPtr)); +} + +bool CPopSchemeMPLPopVerify( + const CPopSchemeMPL scheme, + const CG1Element pk, + const CG2Element sig) +{ + bls::PopSchemeMPL* schemePtr = (bls::PopSchemeMPL*)scheme; + const bls::G1Element* pkPtr = (bls::G1Element*)pk; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + return schemePtr->PopVerify(*pkPtr, *sigPtr); +} + +bool CPopSchemeMPLFastAggregateVerify( + const CPopSchemeMPL scheme, + void** pks, + const size_t pksLen, + const void* msg, + const size_t msgLen, + const CG2Element sig) +{ + bls::PopSchemeMPL* schemePtr = (bls::PopSchemeMPL*)scheme; + const bls::G2Element* sigPtr = (bls::G2Element*)sig; + const std::vector vecPubKeys = + toBLSVector(pks, pksLen); + return schemePtr->FastAggregateVerify( + vecPubKeys, bls::Bytes((uint8_t*)msg, msgLen), *sigPtr); +} + +void CPopSchemeMPLFree(CPopSchemeMPL scheme) +{ + bls::PopSchemeMPL* schemePtr = (bls::PopSchemeMPL*)scheme; + delete schemePtr; +} \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/schemes.h b/flutter-bindings/bls_signatures_ffi/ios/bls/schemes.h new file mode 100644 index 000000000..7821255ba --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/schemes.h @@ -0,0 +1,98 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FLUTTER_BINDINGS_SCHEMES_H_ +#define FLUTTER_BINDINGS_SCHEMES_H_ +#include +#include +#include "privatekey.h" +#include "elements.h" +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* CCoreMPL; +typedef CCoreMPL CBasicSchemeMPL; +typedef CCoreMPL CAugSchemeMPL; +typedef CCoreMPL CPopSchemeMPL; + +// CoreMPL +CPrivateKey CCoreMPLKeyGen(const CCoreMPL scheme, const void* seed, const size_t seedLen, bool* didErr); +CG1Element CCoreMPSkToG1(const CCoreMPL scheme, const CPrivateKey sk); +CG2Element CCoreMPLSign(const CCoreMPL scheme, const CPrivateKey sk, const void* msg, const size_t msgLen); +bool CCoreMPLVerify(const CBasicSchemeMPL scheme, + const CG1Element pk, + const void* msg, + const size_t msgLen, + const CG2Element sig); +CG1Element CCoreMPLAggregatePubKeys(const CCoreMPL scheme, void** pubKeys, const size_t pkLen); +CG2Element CCoreMPLAggregateSigs(const CCoreMPL scheme, void** sigs, const size_t sigLen); +CPrivateKey CCoreMPLDeriveChildSk(const CCoreMPL scheme, const CPrivateKey sk, const uint32_t index); +CPrivateKey CCoreMPLDeriveChildSkUnhardened(const CCoreMPL scheme, const CPrivateKey sk, const uint32_t index); +CG1Element CCoreMPLDeriveChildPkUnhardened(const CCoreMPL scheme, const CG1Element sk, const uint32_t index); +bool CCoreMPLAggregateVerify(const CCoreMPL scheme, + void** pks, + const size_t pkLen, + void** msgs, + const void* msgLens, + const size_t msgLen, + const CG2Element sig); + +// BasicSchemeMPL +CBasicSchemeMPL NewCBasicSchemeMPL(); +bool CBasicSchemeMPLAggregateVerify(CBasicSchemeMPL scheme, + void** pks, + const size_t pksLen, + void** msgs, + const void* msgsLens, + const size_t msgsLen, + const CG2Element sig); +void CBasicSchemeMPLFree(CBasicSchemeMPL scheme); + +// AugSchemeMPL +CAugSchemeMPL NewCAugSchemeMPL(); +CG2Element CAugSchemeMPLSign(const CAugSchemeMPL scheme, const CPrivateKey sk, const void* msg, const size_t msgLen); +CG2Element CAugSchemeMPLSignPrepend(const CAugSchemeMPL scheme, + const CPrivateKey sk, + const void* msg, + const size_t msgLen, + const CG1Element prepPk); +bool CAugSchemeMPLVerify(const CAugSchemeMPL scheme, + const CG1Element pk, + const void* msg, + const size_t msgLen, + const CG2Element sig); +bool CAugSchemeMPLAggregateVerify(const CAugSchemeMPL scheme, + void** pks, + const size_t pksLen, + void** msgs, + const void* msgsLens, + const size_t msgsLen, + const CG2Element sig); +void CAugSchemeMPLFree(CAugSchemeMPL scheme); + +// PopSchemeMPL +CPopSchemeMPL NewCPopSchemeMPL(); +CG2Element CPopSchemeMPLPopProve(const CPopSchemeMPL scheme, const CPrivateKey sk); +bool CPopSchemeMPLPopVerify(const CPopSchemeMPL scheme, const CG1Element pk, const CG2Element sig); +bool CPopSchemeMPLFastAggregateVerify(const CPopSchemeMPL scheme, + void** pks, + const size_t pksLen, + const void* msgs, + const size_t msgsLen, + const CG2Element sig); +void CPopSchemeMPLFree(CPopSchemeMPL scheme); + +#ifdef __cplusplus +} +#endif +#endif // FLUTTER_BINDINGS_SCHEMES_H_ \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/utils.cpp b/flutter-bindings/bls_signatures_ffi/ios/bls/utils.cpp new file mode 100644 index 000000000..f126e707d --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/utils.cpp @@ -0,0 +1,42 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "bls.hpp" +#include "elements.h" +#include "privatekey.h" + +// helper functions +template +std::vector toBLSVector(void** elems, const size_t len) +{ + std::vector vec; + for (int i = 0; i < len; ++i) { + T* el = (T*)elems[i]; + vec.push_back(*el); + } + return vec; +} + +std::vector toVectorBytes( + void** elems, + const size_t len, + const std::vector vecElemsLens) +{ + std::vector vec; + for (int i = 0; i < len; ++i) { + uint8_t* elPtr = (uint8_t*)elems[i]; + vec.push_back(bls::Bytes(elPtr, vecElemsLens[i])); + } + return vec; +} \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls/utils.hpp b/flutter-bindings/bls_signatures_ffi/ios/bls/utils.hpp new file mode 100644 index 000000000..98469d909 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls/utils.hpp @@ -0,0 +1,36 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include "bls.hpp" +#include "elements.h" +#include "privatekey.h" + +// helper functions +template +std::vector toBLSVector(void** elems, const size_t len) +{ + std::vector vec; + for (int i = 0; i < len; ++i) { + const T* el = (T*)elems[i]; + vec.push_back(*el); + } + return vec; +} + +std::vector toVectorBytes( + void** elems, + const size_t len, + const std::vector vecElemsLens); \ No newline at end of file diff --git a/flutter-bindings/bls_signatures_ffi/ios/bls_signatures_ffi.podspec b/flutter-bindings/bls_signatures_ffi/ios/bls_signatures_ffi.podspec new file mode 100644 index 000000000..29b309d5d --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/ios/bls_signatures_ffi.podspec @@ -0,0 +1,64 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint bls_signatures_ffi.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'bls_signatures_ffi' + s.version = '0.0.1' + s.summary = 'A new flutter plugin project.' + s.description = <<-DESC +A new flutter plugin project. + DESC + s.homepage = 'http://example.com' + s.license = { :file => '../LICENSE' } + s.author = { 'Your Company' => 'email@example.com' } + s.source = { :path => '.' } + s.public_header_files = 'Classes/**/*.h' + s.source_files = [ + 'Classes/**/*', + 'bls/**/*.{cpp,hpp,c,h}', + ] + s.dependency 'Flutter' + s.platform = :ios, '11.0' + + # Flutter.framework does not contain a i386 slice. + s.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES', + 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', + 'EXCLUDED_ARCHS[sdk=iphoneos*]' => 'armv7 i386', + 'LIBRARY_SEARCH_PATH' => '$(inherited)', + 'HEADER_SEARCH_PATHS' => '$(SRCROOT)/bls/install/include/chiabls', + 'OTHER_LDFLAGS' => '-L$(SRCROOT)/bls/install/lib -lbls -lrelic_s -lsodium' + } + s.swift_version = '5.0' + s.script_phase = { + :name => 'Run cmake', + :script => ' + git clone https://github.com/leetal/ios-cmake.git + mkdir bls + cd bls + cat << EOF > CMakeLists.txt +CMAKE_MINIMUM_REQUIRED(VERSION 3.14.0 FATAL_ERROR) +include(FetchContent) +FetchContent_Declare( + bls + GIT_REPOSITORY https://github.com/MegaGrindStone/bls-signatures.git + GIT_TAG origin/flutter-bindings +) +FetchContent_MakeAvailable(bls) +install(FILES $ DESTINATION lib) +EOF + cmake -G Xcode -B build \ + -DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake \ + -DPLATFORM=OS64COMBINED \ + -DCMAKE_INSTALL_PREFIX=`pwd`/install \ + -DENABLE_BITCODE=True \ + -DBUILD_BLS_FLUTTER_BINDINGS=1 \ + -DBUILD_BLS_TESTS=0 \ + -DBUILD_BLS_BENCHMARKS=0 + cmake --build build --config Release + cmake --install build --config Release + ', + :execution_position => :before_compile + } +end diff --git a/flutter-bindings/bls_signatures_ffi/lib/bls_signatures_ffi.dart b/flutter-bindings/bls_signatures_ffi/lib/bls_signatures_ffi.dart new file mode 100644 index 000000000..8ba5a4ec5 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/bls_signatures_ffi.dart @@ -0,0 +1,6 @@ +library bls_signature_ffi; + +export 'src/elements.dart'; +export 'src/exception.dart'; +export 'src/privatekey.dart'; +export 'src/schemes.dart'; diff --git a/flutter-bindings/bls_signatures_ffi/lib/src/blschia.dart b/flutter-bindings/bls_signatures_ffi/lib/src/blschia.dart new file mode 100644 index 000000000..897c9973d --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/src/blschia.dart @@ -0,0 +1,11 @@ +import 'dart:ffi'; +import 'dart:io'; + +import 'package:bls_signatures_ffi/src/blschia.h.dart'; + +/// @nodoc +final bindings = BLSSignatureBindings( + Platform.isAndroid + ? DynamicLibrary.open('libblsflutter.so') + : DynamicLibrary.process(), +); diff --git a/flutter-bindings/bls_signatures_ffi/lib/src/blschia.h.dart b/flutter-bindings/bls_signatures_ffi/lib/src/blschia.h.dart new file mode 100644 index 000000000..ae7aa9d5c --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/src/blschia.h.dart @@ -0,0 +1,3306 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +class BLSSignatureBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + BLSSignatureBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + BLSSignatureBindings.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + int __ctype_get_mb_cur_max() { + return ___ctype_get_mb_cur_max(); + } + + late final ___ctype_get_mb_cur_maxPtr = + _lookup>('__ctype_get_mb_cur_max'); + late final ___ctype_get_mb_cur_max = + ___ctype_get_mb_cur_maxPtr.asFunction(); + + double atof( + ffi.Pointer __nptr, + ) { + return _atof( + __nptr, + ); + } + + late final _atofPtr = + _lookup)>>( + 'atof'); + late final _atof = + _atofPtr.asFunction)>(); + + int atoi( + ffi.Pointer __nptr, + ) { + return _atoi( + __nptr, + ); + } + + late final _atoiPtr = + _lookup)>>( + 'atoi'); + late final _atoi = _atoiPtr.asFunction)>(); + + int atol( + ffi.Pointer __nptr, + ) { + return _atol( + __nptr, + ); + } + + late final _atolPtr = + _lookup)>>( + 'atol'); + late final _atol = _atolPtr.asFunction)>(); + + int atoll( + ffi.Pointer __nptr, + ) { + return _atoll( + __nptr, + ); + } + + late final _atollPtr = + _lookup)>>( + 'atoll'); + late final _atoll = + _atollPtr.asFunction)>(); + + double strtod( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + ) { + return _strtod( + __nptr, + __endptr, + ); + } + + late final _strtodPtr = _lookup< + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer, + ffi.Pointer>)>>('strtod'); + late final _strtod = _strtodPtr.asFunction< + double Function( + ffi.Pointer, ffi.Pointer>)>(); + + double strtof( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + ) { + return _strtof( + __nptr, + __endptr, + ); + } + + late final _strtofPtr = _lookup< + ffi.NativeFunction< + ffi.Float Function(ffi.Pointer, + ffi.Pointer>)>>('strtof'); + late final _strtof = _strtofPtr.asFunction< + double Function( + ffi.Pointer, ffi.Pointer>)>(); + + int strtol( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + int __base, + ) { + return _strtol( + __nptr, + __endptr, + __base, + ); + } + + late final _strtolPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer>, ffi.Int32)>>('strtol'); + late final _strtol = _strtolPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer>, int)>(); + + int strtoul( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + int __base, + ) { + return _strtoul( + __nptr, + __endptr, + __base, + ); + } + + late final _strtoulPtr = _lookup< + ffi.NativeFunction< + ffi.Uint64 Function(ffi.Pointer, + ffi.Pointer>, ffi.Int32)>>('strtoul'); + late final _strtoul = _strtoulPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer>, int)>(); + + int strtoq( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + int __base, + ) { + return _strtoq( + __nptr, + __endptr, + __base, + ); + } + + late final _strtoqPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer>, ffi.Int32)>>('strtoq'); + late final _strtoq = _strtoqPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer>, int)>(); + + int strtouq( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + int __base, + ) { + return _strtouq( + __nptr, + __endptr, + __base, + ); + } + + late final _strtouqPtr = _lookup< + ffi.NativeFunction< + ffi.Uint64 Function(ffi.Pointer, + ffi.Pointer>, ffi.Int32)>>('strtouq'); + late final _strtouq = _strtouqPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer>, int)>(); + + int strtoll( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + int __base, + ) { + return _strtoll( + __nptr, + __endptr, + __base, + ); + } + + late final _strtollPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer>, ffi.Int32)>>('strtoll'); + late final _strtoll = _strtollPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer>, int)>(); + + int strtoull( + ffi.Pointer __nptr, + ffi.Pointer> __endptr, + int __base, + ) { + return _strtoull( + __nptr, + __endptr, + __base, + ); + } + + late final _strtoullPtr = _lookup< + ffi.NativeFunction< + ffi.Uint64 Function(ffi.Pointer, + ffi.Pointer>, ffi.Int32)>>('strtoull'); + late final _strtoull = _strtoullPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer>, int)>(); + + ffi.Pointer l64a( + int __n, + ) { + return _l64a( + __n, + ); + } + + late final _l64aPtr = + _lookup Function(ffi.Int64)>>( + 'l64a'); + late final _l64a = _l64aPtr.asFunction Function(int)>(); + + int a64l( + ffi.Pointer __s, + ) { + return _a64l( + __s, + ); + } + + late final _a64lPtr = + _lookup)>>( + 'a64l'); + late final _a64l = _a64lPtr.asFunction)>(); + + int select( + int __nfds, + ffi.Pointer __readfds, + ffi.Pointer __writefds, + ffi.Pointer __exceptfds, + ffi.Pointer __timeout, + ) { + return _select( + __nfds, + __readfds, + __writefds, + __exceptfds, + __timeout, + ); + } + + late final _selectPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Int32, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('select'); + late final _select = _selectPtr.asFunction< + int Function(int, ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + int pselect( + int __nfds, + ffi.Pointer __readfds, + ffi.Pointer __writefds, + ffi.Pointer __exceptfds, + ffi.Pointer __timeout, + ffi.Pointer<__sigset_t> __sigmask, + ) { + return _pselect( + __nfds, + __readfds, + __writefds, + __exceptfds, + __timeout, + __sigmask, + ); + } + + late final _pselectPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Int32, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<__sigset_t>)>>('pselect'); + late final _pselect = _pselectPtr.asFunction< + int Function( + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<__sigset_t>)>(); + + int random() { + return _random(); + } + + late final _randomPtr = + _lookup>('random'); + late final _random = _randomPtr.asFunction(); + + void srandom( + int __seed, + ) { + return _srandom( + __seed, + ); + } + + late final _srandomPtr = + _lookup>('srandom'); + late final _srandom = _srandomPtr.asFunction(); + + ffi.Pointer initstate( + int __seed, + ffi.Pointer __statebuf, + int __statelen, + ) { + return _initstate( + __seed, + __statebuf, + __statelen, + ); + } + + late final _initstatePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Uint32, ffi.Pointer, size_t)>>('initstate'); + late final _initstate = _initstatePtr.asFunction< + ffi.Pointer Function(int, ffi.Pointer, int)>(); + + ffi.Pointer setstate( + ffi.Pointer __statebuf, + ) { + return _setstate( + __statebuf, + ); + } + + late final _setstatePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>('setstate'); + late final _setstate = _setstatePtr + .asFunction Function(ffi.Pointer)>(); + + int random_r( + ffi.Pointer __buf, + ffi.Pointer __result, + ) { + return _random_r( + __buf, + __result, + ); + } + + late final _random_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('random_r'); + late final _random_r = _random_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int srandom_r( + int __seed, + ffi.Pointer __buf, + ) { + return _srandom_r( + __seed, + __buf, + ); + } + + late final _srandom_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Uint32, ffi.Pointer)>>('srandom_r'); + late final _srandom_r = + _srandom_rPtr.asFunction)>(); + + int initstate_r( + int __seed, + ffi.Pointer __statebuf, + int __statelen, + ffi.Pointer __buf, + ) { + return _initstate_r( + __seed, + __statebuf, + __statelen, + __buf, + ); + } + + late final _initstate_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Uint32, ffi.Pointer, size_t, + ffi.Pointer)>>('initstate_r'); + late final _initstate_r = _initstate_rPtr.asFunction< + int Function( + int, ffi.Pointer, int, ffi.Pointer)>(); + + int setstate_r( + ffi.Pointer __statebuf, + ffi.Pointer __buf, + ) { + return _setstate_r( + __statebuf, + __buf, + ); + } + + late final _setstate_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('setstate_r'); + late final _setstate_r = _setstate_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int rand() { + return _rand(); + } + + late final _randPtr = + _lookup>('rand'); + late final _rand = _randPtr.asFunction(); + + void srand( + int __seed, + ) { + return _srand( + __seed, + ); + } + + late final _srandPtr = + _lookup>('srand'); + late final _srand = _srandPtr.asFunction(); + + int rand_r( + ffi.Pointer __seed, + ) { + return _rand_r( + __seed, + ); + } + + late final _rand_rPtr = + _lookup)>>( + 'rand_r'); + late final _rand_r = + _rand_rPtr.asFunction)>(); + + double drand48() { + return _drand48(); + } + + late final _drand48Ptr = + _lookup>('drand48'); + late final _drand48 = _drand48Ptr.asFunction(); + + double erand48( + ffi.Pointer __xsubi, + ) { + return _erand48( + __xsubi, + ); + } + + late final _erand48Ptr = + _lookup)>>( + 'erand48'); + late final _erand48 = + _erand48Ptr.asFunction)>(); + + int lrand48() { + return _lrand48(); + } + + late final _lrand48Ptr = + _lookup>('lrand48'); + late final _lrand48 = _lrand48Ptr.asFunction(); + + int nrand48( + ffi.Pointer __xsubi, + ) { + return _nrand48( + __xsubi, + ); + } + + late final _nrand48Ptr = + _lookup)>>( + 'nrand48'); + late final _nrand48 = + _nrand48Ptr.asFunction)>(); + + int mrand48() { + return _mrand48(); + } + + late final _mrand48Ptr = + _lookup>('mrand48'); + late final _mrand48 = _mrand48Ptr.asFunction(); + + int jrand48( + ffi.Pointer __xsubi, + ) { + return _jrand48( + __xsubi, + ); + } + + late final _jrand48Ptr = + _lookup)>>( + 'jrand48'); + late final _jrand48 = + _jrand48Ptr.asFunction)>(); + + void srand48( + int __seedval, + ) { + return _srand48( + __seedval, + ); + } + + late final _srand48Ptr = + _lookup>('srand48'); + late final _srand48 = _srand48Ptr.asFunction(); + + ffi.Pointer seed48( + ffi.Pointer __seed16v, + ) { + return _seed48( + __seed16v, + ); + } + + late final _seed48Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>('seed48'); + late final _seed48 = _seed48Ptr + .asFunction Function(ffi.Pointer)>(); + + void lcong48( + ffi.Pointer __param, + ) { + return _lcong48( + __param, + ); + } + + late final _lcong48Ptr = + _lookup)>>( + 'lcong48'); + late final _lcong48 = + _lcong48Ptr.asFunction)>(); + + int drand48_r( + ffi.Pointer __buffer, + ffi.Pointer __result, + ) { + return _drand48_r( + __buffer, + __result, + ); + } + + late final _drand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, + ffi.Pointer)>>('drand48_r'); + late final _drand48_r = _drand48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int erand48_r( + ffi.Pointer __xsubi, + ffi.Pointer __buffer, + ffi.Pointer __result, + ) { + return _erand48_r( + __xsubi, + __buffer, + __result, + ); + } + + late final _erand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('erand48_r'); + late final _erand48_r = _erand48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int lrand48_r( + ffi.Pointer __buffer, + ffi.Pointer __result, + ) { + return _lrand48_r( + __buffer, + __result, + ); + } + + late final _lrand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('lrand48_r'); + late final _lrand48_r = _lrand48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int nrand48_r( + ffi.Pointer __xsubi, + ffi.Pointer __buffer, + ffi.Pointer __result, + ) { + return _nrand48_r( + __xsubi, + __buffer, + __result, + ); + } + + late final _nrand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('nrand48_r'); + late final _nrand48_r = _nrand48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int mrand48_r( + ffi.Pointer __buffer, + ffi.Pointer __result, + ) { + return _mrand48_r( + __buffer, + __result, + ); + } + + late final _mrand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('mrand48_r'); + late final _mrand48_r = _mrand48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int jrand48_r( + ffi.Pointer __xsubi, + ffi.Pointer __buffer, + ffi.Pointer __result, + ) { + return _jrand48_r( + __xsubi, + __buffer, + __result, + ); + } + + late final _jrand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('jrand48_r'); + late final _jrand48_r = _jrand48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int srand48_r( + int __seedval, + ffi.Pointer __buffer, + ) { + return _srand48_r( + __seedval, + __buffer, + ); + } + + late final _srand48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Int64, ffi.Pointer)>>('srand48_r'); + late final _srand48_r = + _srand48_rPtr.asFunction)>(); + + int seed48_r( + ffi.Pointer __seed16v, + ffi.Pointer __buffer, + ) { + return _seed48_r( + __seed16v, + __buffer, + ); + } + + late final _seed48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer)>>('seed48_r'); + late final _seed48_r = _seed48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int lcong48_r( + ffi.Pointer __param, + ffi.Pointer __buffer, + ) { + return _lcong48_r( + __param, + __buffer, + ); + } + + late final _lcong48_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, + ffi.Pointer)>>('lcong48_r'); + late final _lcong48_r = _lcong48_rPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + ffi.Pointer malloc( + int __size, + ) { + return _malloc( + __size, + ); + } + + late final _mallocPtr = + _lookup Function(size_t)>>( + 'malloc'); + late final _malloc = + _mallocPtr.asFunction Function(int)>(); + + ffi.Pointer calloc( + int __nmemb, + int __size, + ) { + return _calloc( + __nmemb, + __size, + ); + } + + late final _callocPtr = _lookup< + ffi.NativeFunction Function(size_t, size_t)>>( + 'calloc'); + late final _calloc = + _callocPtr.asFunction Function(int, int)>(); + + ffi.Pointer realloc( + ffi.Pointer __ptr, + int __size, + ) { + return _realloc( + __ptr, + __size, + ); + } + + late final _reallocPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, size_t)>>('realloc'); + late final _realloc = _reallocPtr + .asFunction Function(ffi.Pointer, int)>(); + + ffi.Pointer reallocarray( + ffi.Pointer __ptr, + int __nmemb, + int __size, + ) { + return _reallocarray( + __ptr, + __nmemb, + __size, + ); + } + + late final _reallocarrayPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, size_t, size_t)>>('reallocarray'); + late final _reallocarray = _reallocarrayPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int, int)>(); + + void free( + ffi.Pointer __ptr, + ) { + return _free( + __ptr, + ); + } + + late final _freePtr = + _lookup)>>( + 'free'); + late final _free = + _freePtr.asFunction)>(); + + ffi.Pointer alloca( + int __size, + ) { + return _alloca( + __size, + ); + } + + late final _allocaPtr = + _lookup Function(size_t)>>( + 'alloca'); + late final _alloca = + _allocaPtr.asFunction Function(int)>(); + + ffi.Pointer valloc( + int __size, + ) { + return _valloc( + __size, + ); + } + + late final _vallocPtr = + _lookup Function(size_t)>>( + 'valloc'); + late final _valloc = + _vallocPtr.asFunction Function(int)>(); + + int posix_memalign( + ffi.Pointer> __memptr, + int __alignment, + int __size, + ) { + return _posix_memalign( + __memptr, + __alignment, + __size, + ); + } + + late final _posix_memalignPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer>, size_t, + size_t)>>('posix_memalign'); + late final _posix_memalign = _posix_memalignPtr + .asFunction>, int, int)>(); + + ffi.Pointer aligned_alloc( + int __alignment, + int __size, + ) { + return _aligned_alloc( + __alignment, + __size, + ); + } + + late final _aligned_allocPtr = _lookup< + ffi.NativeFunction Function(size_t, size_t)>>( + 'aligned_alloc'); + late final _aligned_alloc = + _aligned_allocPtr.asFunction Function(int, int)>(); + + void abort() { + return _abort(); + } + + late final _abortPtr = + _lookup>('abort'); + late final _abort = _abortPtr.asFunction(); + + int atexit( + ffi.Pointer> __func, + ) { + return _atexit( + __func, + ); + } + + late final _atexitPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer>)>>('atexit'); + late final _atexit = _atexitPtr.asFunction< + int Function(ffi.Pointer>)>(); + + int at_quick_exit( + ffi.Pointer> __func, + ) { + return _at_quick_exit( + __func, + ); + } + + late final _at_quick_exitPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer>)>>( + 'at_quick_exit'); + late final _at_quick_exit = _at_quick_exitPtr.asFunction< + int Function(ffi.Pointer>)>(); + + int on_exit( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int32, ffi.Pointer)>> + __func, + ffi.Pointer __arg, + ) { + return _on_exit( + __func, + __arg, + ); + } + + late final _on_exitPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int32, ffi.Pointer)>>, + ffi.Pointer)>>('on_exit'); + late final _on_exit = _on_exitPtr.asFunction< + int Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int32, ffi.Pointer)>>, + ffi.Pointer)>(); + + void exit( + int __status, + ) { + return _exit( + __status, + ); + } + + late final _exitPtr = + _lookup>('exit'); + late final _exit = _exitPtr.asFunction(); + + void quick_exit( + int __status, + ) { + return _quick_exit( + __status, + ); + } + + late final _quick_exitPtr = + _lookup>('quick_exit'); + late final _quick_exit = _quick_exitPtr.asFunction(); + + void _Exit( + int __status, + ) { + return __Exit( + __status, + ); + } + + late final __ExitPtr = + _lookup>('_Exit'); + late final __Exit = __ExitPtr.asFunction(); + + ffi.Pointer getenv( + ffi.Pointer __name, + ) { + return _getenv( + __name, + ); + } + + late final _getenvPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>('getenv'); + late final _getenv = _getenvPtr + .asFunction Function(ffi.Pointer)>(); + + int putenv( + ffi.Pointer __string, + ) { + return _putenv( + __string, + ); + } + + late final _putenvPtr = + _lookup)>>( + 'putenv'); + late final _putenv = + _putenvPtr.asFunction)>(); + + int setenv( + ffi.Pointer __name, + ffi.Pointer __value, + int __replace, + ) { + return _setenv( + __name, + __value, + __replace, + ); + } + + late final _setenvPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, + ffi.Int32)>>('setenv'); + late final _setenv = _setenvPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int)>(); + + int unsetenv( + ffi.Pointer __name, + ) { + return _unsetenv( + __name, + ); + } + + late final _unsetenvPtr = + _lookup)>>( + 'unsetenv'); + late final _unsetenv = + _unsetenvPtr.asFunction)>(); + + int clearenv() { + return _clearenv(); + } + + late final _clearenvPtr = + _lookup>('clearenv'); + late final _clearenv = _clearenvPtr.asFunction(); + + ffi.Pointer mktemp( + ffi.Pointer __template, + ) { + return _mktemp( + __template, + ); + } + + late final _mktempPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>('mktemp'); + late final _mktemp = _mktempPtr + .asFunction Function(ffi.Pointer)>(); + + int mkstemp( + ffi.Pointer __template, + ) { + return _mkstemp( + __template, + ); + } + + late final _mkstempPtr = + _lookup)>>( + 'mkstemp'); + late final _mkstemp = + _mkstempPtr.asFunction)>(); + + int mkstemps( + ffi.Pointer __template, + int __suffixlen, + ) { + return _mkstemps( + __template, + __suffixlen, + ); + } + + late final _mkstempsPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('mkstemps'); + late final _mkstemps = + _mkstempsPtr.asFunction, int)>(); + + ffi.Pointer mkdtemp( + ffi.Pointer __template, + ) { + return _mkdtemp( + __template, + ); + } + + late final _mkdtempPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>('mkdtemp'); + late final _mkdtemp = _mkdtempPtr + .asFunction Function(ffi.Pointer)>(); + + int system( + ffi.Pointer __command, + ) { + return _system( + __command, + ); + } + + late final _systemPtr = + _lookup)>>( + 'system'); + late final _system = + _systemPtr.asFunction)>(); + + ffi.Pointer realpath( + ffi.Pointer __name, + ffi.Pointer __resolved, + ) { + return _realpath( + __name, + __resolved, + ); + } + + late final _realpathPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('realpath'); + late final _realpath = _realpathPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + + ffi.Pointer bsearch( + ffi.Pointer __key, + ffi.Pointer __base, + int __nmemb, + int __size, + __compar_fn_t __compar, + ) { + return _bsearch( + __key, + __base, + __nmemb, + __size, + __compar, + ); + } + + late final _bsearchPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + size_t, + size_t, + __compar_fn_t)>>('bsearch'); + late final _bsearch = _bsearchPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, int, __compar_fn_t)>(); + + void qsort( + ffi.Pointer __base, + int __nmemb, + int __size, + __compar_fn_t __compar, + ) { + return _qsort( + __base, + __nmemb, + __size, + __compar, + ); + } + + late final _qsortPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, size_t, size_t, __compar_fn_t)>>('qsort'); + late final _qsort = _qsortPtr.asFunction< + void Function(ffi.Pointer, int, int, __compar_fn_t)>(); + + int abs( + int __x, + ) { + return _abs( + __x, + ); + } + + late final _absPtr = + _lookup>('abs'); + late final _abs = _absPtr.asFunction(); + + int labs( + int __x, + ) { + return _labs( + __x, + ); + } + + late final _labsPtr = + _lookup>('labs'); + late final _labs = _labsPtr.asFunction(); + + int llabs( + int __x, + ) { + return _llabs( + __x, + ); + } + + late final _llabsPtr = + _lookup>('llabs'); + late final _llabs = _llabsPtr.asFunction(); + + div_t div( + int __numer, + int __denom, + ) { + return _div( + __numer, + __denom, + ); + } + + late final _divPtr = + _lookup>('div'); + late final _div = _divPtr.asFunction(); + + ldiv_t ldiv( + int __numer, + int __denom, + ) { + return _ldiv( + __numer, + __denom, + ); + } + + late final _ldivPtr = + _lookup>( + 'ldiv'); + late final _ldiv = _ldivPtr.asFunction(); + + lldiv_t lldiv( + int __numer, + int __denom, + ) { + return _lldiv( + __numer, + __denom, + ); + } + + late final _lldivPtr = + _lookup>( + 'lldiv'); + late final _lldiv = _lldivPtr.asFunction(); + + ffi.Pointer ecvt( + double __value, + int __ndigit, + ffi.Pointer __decpt, + ffi.Pointer __sign, + ) { + return _ecvt( + __value, + __ndigit, + __decpt, + __sign, + ); + } + + late final _ecvtPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Double, ffi.Int32, + ffi.Pointer, ffi.Pointer)>>('ecvt'); + late final _ecvt = _ecvtPtr.asFunction< + ffi.Pointer Function( + double, int, ffi.Pointer, ffi.Pointer)>(); + + ffi.Pointer fcvt( + double __value, + int __ndigit, + ffi.Pointer __decpt, + ffi.Pointer __sign, + ) { + return _fcvt( + __value, + __ndigit, + __decpt, + __sign, + ); + } + + late final _fcvtPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Double, ffi.Int32, + ffi.Pointer, ffi.Pointer)>>('fcvt'); + late final _fcvt = _fcvtPtr.asFunction< + ffi.Pointer Function( + double, int, ffi.Pointer, ffi.Pointer)>(); + + ffi.Pointer gcvt( + double __value, + int __ndigit, + ffi.Pointer __buf, + ) { + return _gcvt( + __value, + __ndigit, + __buf, + ); + } + + late final _gcvtPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Double, ffi.Int32, ffi.Pointer)>>('gcvt'); + late final _gcvt = _gcvtPtr.asFunction< + ffi.Pointer Function(double, int, ffi.Pointer)>(); + + int ecvt_r( + double __value, + int __ndigit, + ffi.Pointer __decpt, + ffi.Pointer __sign, + ffi.Pointer __buf, + int __len, + ) { + return _ecvt_r( + __value, + __ndigit, + __decpt, + __sign, + __buf, + __len, + ); + } + + late final _ecvt_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Double, + ffi.Int32, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + size_t)>>('ecvt_r'); + late final _ecvt_r = _ecvt_rPtr.asFunction< + int Function(double, int, ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + int fcvt_r( + double __value, + int __ndigit, + ffi.Pointer __decpt, + ffi.Pointer __sign, + ffi.Pointer __buf, + int __len, + ) { + return _fcvt_r( + __value, + __ndigit, + __decpt, + __sign, + __buf, + __len, + ); + } + + late final _fcvt_rPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Double, + ffi.Int32, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + size_t)>>('fcvt_r'); + late final _fcvt_r = _fcvt_rPtr.asFunction< + int Function(double, int, ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + int mblen( + ffi.Pointer __s, + int __n, + ) { + return _mblen( + __s, + __n, + ); + } + + late final _mblenPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, size_t)>>('mblen'); + late final _mblen = + _mblenPtr.asFunction, int)>(); + + int mbtowc( + ffi.Pointer __pwc, + ffi.Pointer __s, + int __n, + ) { + return _mbtowc( + __pwc, + __s, + __n, + ); + } + + late final _mbtowcPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Pointer, size_t)>>('mbtowc'); + late final _mbtowc = _mbtowcPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int)>(); + + int wctomb( + ffi.Pointer __s, + int __wchar, + ) { + return _wctomb( + __s, + __wchar, + ); + } + + late final _wctombPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, wchar_t)>>('wctomb'); + late final _wctomb = + _wctombPtr.asFunction, int)>(); + + int mbstowcs( + ffi.Pointer __pwcs, + ffi.Pointer __s, + int __n, + ) { + return _mbstowcs( + __pwcs, + __s, + __n, + ); + } + + late final _mbstowcsPtr = _lookup< + ffi.NativeFunction< + size_t Function(ffi.Pointer, ffi.Pointer, + size_t)>>('mbstowcs'); + late final _mbstowcs = _mbstowcsPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int)>(); + + int wcstombs( + ffi.Pointer __s, + ffi.Pointer __pwcs, + int __n, + ) { + return _wcstombs( + __s, + __pwcs, + __n, + ); + } + + late final _wcstombsPtr = _lookup< + ffi.NativeFunction< + size_t Function(ffi.Pointer, ffi.Pointer, + size_t)>>('wcstombs'); + late final _wcstombs = _wcstombsPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int)>(); + + int rpmatch( + ffi.Pointer __response, + ) { + return _rpmatch( + __response, + ); + } + + late final _rpmatchPtr = + _lookup)>>( + 'rpmatch'); + late final _rpmatch = + _rpmatchPtr.asFunction)>(); + + int getsubopt( + ffi.Pointer> __optionp, + ffi.Pointer> __tokens, + ffi.Pointer> __valuep, + ) { + return _getsubopt( + __optionp, + __tokens, + __valuep, + ); + } + + late final _getsuboptPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>)>>('getsubopt'); + late final _getsubopt = _getsuboptPtr.asFunction< + int Function( + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>)>(); + + int getloadavg( + ffi.Pointer __loadavg, + int __nelem, + ) { + return _getloadavg( + __loadavg, + __nelem, + ); + } + + late final _getloadavgPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, ffi.Int32)>>('getloadavg'); + late final _getloadavg = + _getloadavgPtr.asFunction, int)>(); + + int CG1ElementSize() { + return _CG1ElementSize(); + } + + late final _CG1ElementSizePtr = + _lookup>('CG1ElementSize'); + late final _CG1ElementSize = _CG1ElementSizePtr.asFunction(); + + CG1Element CG1ElementFromBytes( + ffi.Pointer data, + ffi.Pointer didErr, + ) { + return _CG1ElementFromBytes( + data, + didErr, + ); + } + + late final _CG1ElementFromBytesPtr = _lookup< + ffi.NativeFunction< + CG1Element Function(ffi.Pointer, + ffi.Pointer)>>('CG1ElementFromBytes'); + late final _CG1ElementFromBytes = _CG1ElementFromBytesPtr.asFunction< + CG1Element Function(ffi.Pointer, ffi.Pointer)>(); + + CG1Element CG1ElementGenerator() { + return _CG1ElementGenerator(); + } + + late final _CG1ElementGeneratorPtr = + _lookup>('CG1ElementGenerator'); + late final _CG1ElementGenerator = + _CG1ElementGeneratorPtr.asFunction(); + + bool CG1ElementIsValid( + CG1Element el, + ) { + return _CG1ElementIsValid( + el, + ) != + 0; + } + + late final _CG1ElementIsValidPtr = + _lookup>( + 'CG1ElementIsValid'); + late final _CG1ElementIsValid = + _CG1ElementIsValidPtr.asFunction(); + + int CG1ElementGetFingerprint( + CG1Element el, + ) { + return _CG1ElementGetFingerprint( + el, + ); + } + + late final _CG1ElementGetFingerprintPtr = + _lookup>( + 'CG1ElementGetFingerprint'); + late final _CG1ElementGetFingerprint = + _CG1ElementGetFingerprintPtr.asFunction(); + + bool CG1ElementIsEqual( + CG1Element el1, + CG1Element el2, + ) { + return _CG1ElementIsEqual( + el1, + el2, + ) != + 0; + } + + late final _CG1ElementIsEqualPtr = + _lookup>( + 'CG1ElementIsEqual'); + late final _CG1ElementIsEqual = + _CG1ElementIsEqualPtr.asFunction(); + + CG1Element CG1ElementAdd( + CG1Element el1, + CG1Element el2, + ) { + return _CG1ElementAdd( + el1, + el2, + ); + } + + late final _CG1ElementAddPtr = + _lookup>( + 'CG1ElementAdd'); + late final _CG1ElementAdd = _CG1ElementAddPtr.asFunction< + CG1Element Function(CG1Element, CG1Element)>(); + + CG1Element CG1ElementMul( + CG1Element el, + CPrivateKey sk, + ) { + return _CG1ElementMul( + el, + sk, + ); + } + + late final _CG1ElementMulPtr = + _lookup>( + 'CG1ElementMul'); + late final _CG1ElementMul = _CG1ElementMulPtr.asFunction< + CG1Element Function(CG1Element, CPrivateKey)>(); + + CG1Element CG1ElementNegate( + CG1Element el, + ) { + return _CG1ElementNegate( + el, + ); + } + + late final _CG1ElementNegatePtr = + _lookup>( + 'CG1ElementNegate'); + late final _CG1ElementNegate = + _CG1ElementNegatePtr.asFunction(); + + ffi.Pointer CG1ElementSerialize( + CG1Element el, + ) { + return _CG1ElementSerialize( + el, + ); + } + + late final _CG1ElementSerializePtr = + _lookup Function(CG1Element)>>( + 'CG1ElementSerialize'); + late final _CG1ElementSerialize = _CG1ElementSerializePtr.asFunction< + ffi.Pointer Function(CG1Element)>(); + + void CG1ElementFree( + CG1Element el, + ) { + return _CG1ElementFree( + el, + ); + } + + late final _CG1ElementFreePtr = + _lookup>( + 'CG1ElementFree'); + late final _CG1ElementFree = + _CG1ElementFreePtr.asFunction(); + + int CG2ElementSize() { + return _CG2ElementSize(); + } + + late final _CG2ElementSizePtr = + _lookup>('CG2ElementSize'); + late final _CG2ElementSize = _CG2ElementSizePtr.asFunction(); + + CG2Element CG2ElementFromBytes( + ffi.Pointer data, + ffi.Pointer didErr, + ) { + return _CG2ElementFromBytes( + data, + didErr, + ); + } + + late final _CG2ElementFromBytesPtr = _lookup< + ffi.NativeFunction< + CG2Element Function(ffi.Pointer, + ffi.Pointer)>>('CG2ElementFromBytes'); + late final _CG2ElementFromBytes = _CG2ElementFromBytesPtr.asFunction< + CG2Element Function(ffi.Pointer, ffi.Pointer)>(); + + CG2Element CG2ElementGenerator() { + return _CG2ElementGenerator(); + } + + late final _CG2ElementGeneratorPtr = + _lookup>('CG2ElementGenerator'); + late final _CG2ElementGenerator = + _CG2ElementGeneratorPtr.asFunction(); + + bool CG2ElementIsValid( + CG2Element el, + ) { + return _CG2ElementIsValid( + el, + ) != + 0; + } + + late final _CG2ElementIsValidPtr = + _lookup>( + 'CG2ElementIsValid'); + late final _CG2ElementIsValid = + _CG2ElementIsValidPtr.asFunction(); + + bool CG2ElementIsEqual( + CG2Element el1, + CG2Element el2, + ) { + return _CG2ElementIsEqual( + el1, + el2, + ) != + 0; + } + + late final _CG2ElementIsEqualPtr = + _lookup>( + 'CG2ElementIsEqual'); + late final _CG2ElementIsEqual = + _CG2ElementIsEqualPtr.asFunction(); + + CG2Element CG2ElementAdd( + CG2Element el1, + CG2Element el2, + ) { + return _CG2ElementAdd( + el1, + el2, + ); + } + + late final _CG2ElementAddPtr = + _lookup>( + 'CG2ElementAdd'); + late final _CG2ElementAdd = _CG2ElementAddPtr.asFunction< + CG2Element Function(CG2Element, CG2Element)>(); + + CG2Element CG2ElementMul( + CG2Element el, + CPrivateKey sk, + ) { + return _CG2ElementMul( + el, + sk, + ); + } + + late final _CG2ElementMulPtr = + _lookup>( + 'CG2ElementMul'); + late final _CG2ElementMul = _CG2ElementMulPtr.asFunction< + CG2Element Function(CG2Element, CPrivateKey)>(); + + CG2Element CG2ElementNegate( + CG2Element el, + ) { + return _CG2ElementNegate( + el, + ); + } + + late final _CG2ElementNegatePtr = + _lookup>( + 'CG2ElementNegate'); + late final _CG2ElementNegate = + _CG2ElementNegatePtr.asFunction(); + + ffi.Pointer CG2ElementSerialize( + CG2Element el, + ) { + return _CG2ElementSerialize( + el, + ); + } + + late final _CG2ElementSerializePtr = + _lookup Function(CG2Element)>>( + 'CG2ElementSerialize'); + late final _CG2ElementSerialize = _CG2ElementSerializePtr.asFunction< + ffi.Pointer Function(CG2Element)>(); + + void CG2ElementFree( + CG2Element el, + ) { + return _CG2ElementFree( + el, + ); + } + + late final _CG2ElementFreePtr = + _lookup>( + 'CG2ElementFree'); + late final _CG2ElementFree = + _CG2ElementFreePtr.asFunction(); + + CPrivateKey CPrivateKeyFromBytes( + ffi.Pointer data, + bool modOrder, + ffi.Pointer didErr, + ) { + return _CPrivateKeyFromBytes( + data, + modOrder ? 1 : 0, + didErr, + ); + } + + late final _CPrivateKeyFromBytesPtr = _lookup< + ffi.NativeFunction< + CPrivateKey Function(ffi.Pointer, ffi.Uint8, + ffi.Pointer)>>('CPrivateKeyFromBytes'); + late final _CPrivateKeyFromBytes = _CPrivateKeyFromBytesPtr.asFunction< + CPrivateKey Function( + ffi.Pointer, int, ffi.Pointer)>(); + + CPrivateKey CPrivateKeyAggregate( + ffi.Pointer> sks, + int len, + ) { + return _CPrivateKeyAggregate( + sks, + len, + ); + } + + late final _CPrivateKeyAggregatePtr = _lookup< + ffi.NativeFunction< + CPrivateKey Function(ffi.Pointer>, + size_t)>>('CPrivateKeyAggregate'); + late final _CPrivateKeyAggregate = _CPrivateKeyAggregatePtr.asFunction< + CPrivateKey Function(ffi.Pointer>, int)>(); + + CG1Element CPrivateKeyGetG1Element( + CPrivateKey sk, + ffi.Pointer didErr, + ) { + return _CPrivateKeyGetG1Element( + sk, + didErr, + ); + } + + late final _CPrivateKeyGetG1ElementPtr = _lookup< + ffi.NativeFunction< + CG1Element Function( + CPrivateKey, ffi.Pointer)>>('CPrivateKeyGetG1Element'); + late final _CPrivateKeyGetG1Element = _CPrivateKeyGetG1ElementPtr.asFunction< + CG1Element Function(CPrivateKey, ffi.Pointer)>(); + + CG2Element CPrivateKeyGetG2Element( + CPrivateKey sk, + ffi.Pointer didErr, + ) { + return _CPrivateKeyGetG2Element( + sk, + didErr, + ); + } + + late final _CPrivateKeyGetG2ElementPtr = _lookup< + ffi.NativeFunction< + CG2Element Function( + CPrivateKey, ffi.Pointer)>>('CPrivateKeyGetG2Element'); + late final _CPrivateKeyGetG2Element = _CPrivateKeyGetG2ElementPtr.asFunction< + CG2Element Function(CPrivateKey, ffi.Pointer)>(); + + CG2Element CPrivateKeyGetG2Power( + CPrivateKey sk, + CG2Element el, + ) { + return _CPrivateKeyGetG2Power( + sk, + el, + ); + } + + late final _CPrivateKeyGetG2PowerPtr = + _lookup>( + 'CPrivateKeyGetG2Power'); + late final _CPrivateKeyGetG2Power = _CPrivateKeyGetG2PowerPtr.asFunction< + CG2Element Function(CPrivateKey, CG2Element)>(); + + bool CPrivateKeyIsEqual( + CPrivateKey sk1, + CPrivateKey sk2, + ) { + return _CPrivateKeyIsEqual( + sk1, + sk2, + ) != + 0; + } + + late final _CPrivateKeyIsEqualPtr = + _lookup>( + 'CPrivateKeyIsEqual'); + late final _CPrivateKeyIsEqual = _CPrivateKeyIsEqualPtr.asFunction< + int Function(CPrivateKey, CPrivateKey)>(); + + ffi.Pointer CPrivateKeySerialize( + CPrivateKey sk, + ) { + return _CPrivateKeySerialize( + sk, + ); + } + + late final _CPrivateKeySerializePtr = + _lookup Function(CPrivateKey)>>( + 'CPrivateKeySerialize'); + late final _CPrivateKeySerialize = _CPrivateKeySerializePtr.asFunction< + ffi.Pointer Function(CPrivateKey)>(); + + void CPrivateKeyFree( + CPrivateKey sk, + ) { + return _CPrivateKeyFree( + sk, + ); + } + + late final _CPrivateKeyFreePtr = + _lookup>( + 'CPrivateKeyFree'); + late final _CPrivateKeyFree = + _CPrivateKeyFreePtr.asFunction(); + + int CPrivateKeySizeBytes() { + return _CPrivateKeySizeBytes(); + } + + late final _CPrivateKeySizeBytesPtr = + _lookup>('CPrivateKeySizeBytes'); + late final _CPrivateKeySizeBytes = + _CPrivateKeySizeBytesPtr.asFunction(); + + void SecFree( + ffi.Pointer p, + ) { + return _SecFree( + p, + ); + } + + late final _SecFreePtr = + _lookup)>>( + 'SecFree'); + late final _SecFree = + _SecFreePtr.asFunction)>(); + + ffi.Pointer> AllocPtrArray( + int len, + ) { + return _AllocPtrArray( + len, + ); + } + + late final _AllocPtrArrayPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer> Function( + size_t)>>('AllocPtrArray'); + late final _AllocPtrArray = _AllocPtrArrayPtr.asFunction< + ffi.Pointer> Function(int)>(); + + void SetPtrArray( + ffi.Pointer> arrPtr, + ffi.Pointer elemPtr, + int index, + ) { + return _SetPtrArray( + arrPtr, + elemPtr, + index, + ); + } + + late final _SetPtrArrayPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer>, + ffi.Pointer, ffi.Int32)>>('SetPtrArray'); + late final _SetPtrArray = _SetPtrArrayPtr.asFunction< + void Function( + ffi.Pointer>, ffi.Pointer, int)>(); + + void FreePtrArray( + ffi.Pointer> inPtr, + ) { + return _FreePtrArray( + inPtr, + ); + } + + late final _FreePtrArrayPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer>)>>('FreePtrArray'); + late final _FreePtrArray = _FreePtrArrayPtr.asFunction< + void Function(ffi.Pointer>)>(); + + ffi.Pointer GetPtrAtIndex( + ffi.Pointer> arrPtr, + int index, + ) { + return _GetPtrAtIndex( + arrPtr, + index, + ); + } + + late final _GetPtrAtIndexPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer>, ffi.Int32)>>('GetPtrAtIndex'); + late final _GetPtrAtIndex = _GetPtrAtIndexPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer>, int)>(); + + ffi.Pointer SecAllocBytes( + int len, + ) { + return _SecAllocBytes( + len, + ); + } + + late final _SecAllocBytesPtr = + _lookup Function(size_t)>>( + 'SecAllocBytes'); + late final _SecAllocBytes = + _SecAllocBytesPtr.asFunction Function(int)>(); + + ffi.Pointer GetAddressAtIndex( + ffi.Pointer ptr, + int index, + ) { + return _GetAddressAtIndex( + ptr, + index, + ); + } + + late final _GetAddressAtIndexPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Int32)>>('GetAddressAtIndex'); + late final _GetAddressAtIndex = _GetAddressAtIndexPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); + + ffi.Pointer GetLastErrorMsg() { + return _GetLastErrorMsg(); + } + + late final _GetLastErrorMsgPtr = + _lookup Function()>>( + 'GetLastErrorMsg'); + late final _GetLastErrorMsg = + _GetLastErrorMsgPtr.asFunction Function()>(); + + CPrivateKey CCoreMPLKeyGen( + CCoreMPL scheme, + ffi.Pointer seed, + int seedLen, + ffi.Pointer didErr, + ) { + return _CCoreMPLKeyGen( + scheme, + seed, + seedLen, + didErr, + ); + } + + late final _CCoreMPLKeyGenPtr = _lookup< + ffi.NativeFunction< + CPrivateKey Function(CCoreMPL, ffi.Pointer, size_t, + ffi.Pointer)>>('CCoreMPLKeyGen'); + late final _CCoreMPLKeyGen = _CCoreMPLKeyGenPtr.asFunction< + CPrivateKey Function( + CCoreMPL, ffi.Pointer, int, ffi.Pointer)>(); + + CG1Element CCoreMPSkToG1( + CCoreMPL scheme, + CPrivateKey sk, + ) { + return _CCoreMPSkToG1( + scheme, + sk, + ); + } + + late final _CCoreMPSkToG1Ptr = + _lookup>( + 'CCoreMPSkToG1'); + late final _CCoreMPSkToG1 = _CCoreMPSkToG1Ptr.asFunction< + CG1Element Function(CCoreMPL, CPrivateKey)>(); + + CG2Element CCoreMPLSign( + CCoreMPL scheme, + CPrivateKey sk, + ffi.Pointer msg, + int msgLen, + ) { + return _CCoreMPLSign( + scheme, + sk, + msg, + msgLen, + ); + } + + late final _CCoreMPLSignPtr = _lookup< + ffi.NativeFunction< + CG2Element Function(CCoreMPL, CPrivateKey, ffi.Pointer, + size_t)>>('CCoreMPLSign'); + late final _CCoreMPLSign = _CCoreMPLSignPtr.asFunction< + CG2Element Function(CCoreMPL, CPrivateKey, ffi.Pointer, int)>(); + + bool CCoreMPLVerify( + CBasicSchemeMPL scheme, + CG1Element pk, + ffi.Pointer msg, + int msgLen, + CG2Element sig, + ) { + return _CCoreMPLVerify( + scheme, + pk, + msg, + msgLen, + sig, + ) != + 0; + } + + late final _CCoreMPLVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function(CBasicSchemeMPL, CG1Element, ffi.Pointer, + size_t, CG2Element)>>('CCoreMPLVerify'); + late final _CCoreMPLVerify = _CCoreMPLVerifyPtr.asFunction< + int Function(CBasicSchemeMPL, CG1Element, ffi.Pointer, int, + CG2Element)>(); + + CG1Element CCoreMPLAggregatePubKeys( + CCoreMPL scheme, + ffi.Pointer> pubKeys, + int pkLen, + ) { + return _CCoreMPLAggregatePubKeys( + scheme, + pubKeys, + pkLen, + ); + } + + late final _CCoreMPLAggregatePubKeysPtr = _lookup< + ffi.NativeFunction< + CG1Element Function(CCoreMPL, ffi.Pointer>, + size_t)>>('CCoreMPLAggregatePubKeys'); + late final _CCoreMPLAggregatePubKeys = + _CCoreMPLAggregatePubKeysPtr.asFunction< + CG1Element Function( + CCoreMPL, ffi.Pointer>, int)>(); + + CG2Element CCoreMPLAggregateSigs( + CCoreMPL scheme, + ffi.Pointer> sigs, + int sigLen, + ) { + return _CCoreMPLAggregateSigs( + scheme, + sigs, + sigLen, + ); + } + + late final _CCoreMPLAggregateSigsPtr = _lookup< + ffi.NativeFunction< + CG2Element Function(CCoreMPL, ffi.Pointer>, + size_t)>>('CCoreMPLAggregateSigs'); + late final _CCoreMPLAggregateSigs = _CCoreMPLAggregateSigsPtr.asFunction< + CG2Element Function(CCoreMPL, ffi.Pointer>, int)>(); + + CPrivateKey CCoreMPLDeriveChildSk( + CCoreMPL scheme, + CPrivateKey sk, + int index, + ) { + return _CCoreMPLDeriveChildSk( + scheme, + sk, + index, + ); + } + + late final _CCoreMPLDeriveChildSkPtr = _lookup< + ffi.NativeFunction< + CPrivateKey Function( + CCoreMPL, CPrivateKey, ffi.Uint32)>>('CCoreMPLDeriveChildSk'); + late final _CCoreMPLDeriveChildSk = _CCoreMPLDeriveChildSkPtr.asFunction< + CPrivateKey Function(CCoreMPL, CPrivateKey, int)>(); + + CPrivateKey CCoreMPLDeriveChildSkUnhardened( + CCoreMPL scheme, + CPrivateKey sk, + int index, + ) { + return _CCoreMPLDeriveChildSkUnhardened( + scheme, + sk, + index, + ); + } + + late final _CCoreMPLDeriveChildSkUnhardenedPtr = _lookup< + ffi.NativeFunction< + CPrivateKey Function(CCoreMPL, CPrivateKey, + ffi.Uint32)>>('CCoreMPLDeriveChildSkUnhardened'); + late final _CCoreMPLDeriveChildSkUnhardened = + _CCoreMPLDeriveChildSkUnhardenedPtr.asFunction< + CPrivateKey Function(CCoreMPL, CPrivateKey, int)>(); + + CG1Element CCoreMPLDeriveChildPkUnhardened( + CCoreMPL scheme, + CG1Element sk, + int index, + ) { + return _CCoreMPLDeriveChildPkUnhardened( + scheme, + sk, + index, + ); + } + + late final _CCoreMPLDeriveChildPkUnhardenedPtr = _lookup< + ffi.NativeFunction< + CG1Element Function(CCoreMPL, CG1Element, + ffi.Uint32)>>('CCoreMPLDeriveChildPkUnhardened'); + late final _CCoreMPLDeriveChildPkUnhardened = + _CCoreMPLDeriveChildPkUnhardenedPtr.asFunction< + CG1Element Function(CCoreMPL, CG1Element, int)>(); + + bool CCoreMPLAggregateVerify( + CCoreMPL scheme, + ffi.Pointer> pks, + int pkLen, + ffi.Pointer> msgs, + ffi.Pointer msgLens, + int msgLen, + CG2Element sig, + ) { + return _CCoreMPLAggregateVerify( + scheme, + pks, + pkLen, + msgs, + msgLens, + msgLen, + sig, + ) != + 0; + } + + late final _CCoreMPLAggregateVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function( + CCoreMPL, + ffi.Pointer>, + size_t, + ffi.Pointer>, + ffi.Pointer, + size_t, + CG2Element)>>('CCoreMPLAggregateVerify'); + late final _CCoreMPLAggregateVerify = _CCoreMPLAggregateVerifyPtr.asFunction< + int Function( + CCoreMPL, + ffi.Pointer>, + int, + ffi.Pointer>, + ffi.Pointer, + int, + CG2Element)>(); + + CBasicSchemeMPL NewCBasicSchemeMPL() { + return _NewCBasicSchemeMPL(); + } + + late final _NewCBasicSchemeMPLPtr = + _lookup>( + 'NewCBasicSchemeMPL'); + late final _NewCBasicSchemeMPL = + _NewCBasicSchemeMPLPtr.asFunction(); + + bool CBasicSchemeMPLAggregateVerify( + CBasicSchemeMPL scheme, + ffi.Pointer> pks, + int pksLen, + ffi.Pointer> msgs, + ffi.Pointer msgsLens, + int msgsLen, + CG2Element sig, + ) { + return _CBasicSchemeMPLAggregateVerify( + scheme, + pks, + pksLen, + msgs, + msgsLens, + msgsLen, + sig, + ) != + 0; + } + + late final _CBasicSchemeMPLAggregateVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function( + CBasicSchemeMPL, + ffi.Pointer>, + size_t, + ffi.Pointer>, + ffi.Pointer, + size_t, + CG2Element)>>('CBasicSchemeMPLAggregateVerify'); + late final _CBasicSchemeMPLAggregateVerify = + _CBasicSchemeMPLAggregateVerifyPtr.asFunction< + int Function( + CBasicSchemeMPL, + ffi.Pointer>, + int, + ffi.Pointer>, + ffi.Pointer, + int, + CG2Element)>(); + + void CBasicSchemeMPLFree( + CBasicSchemeMPL scheme, + ) { + return _CBasicSchemeMPLFree( + scheme, + ); + } + + late final _CBasicSchemeMPLFreePtr = + _lookup>( + 'CBasicSchemeMPLFree'); + late final _CBasicSchemeMPLFree = + _CBasicSchemeMPLFreePtr.asFunction(); + + CAugSchemeMPL NewCAugSchemeMPL() { + return _NewCAugSchemeMPL(); + } + + late final _NewCAugSchemeMPLPtr = + _lookup>('NewCAugSchemeMPL'); + late final _NewCAugSchemeMPL = + _NewCAugSchemeMPLPtr.asFunction(); + + CG2Element CAugSchemeMPLSign( + CAugSchemeMPL scheme, + CPrivateKey sk, + ffi.Pointer msg, + int msgLen, + ) { + return _CAugSchemeMPLSign( + scheme, + sk, + msg, + msgLen, + ); + } + + late final _CAugSchemeMPLSignPtr = _lookup< + ffi.NativeFunction< + CG2Element Function(CAugSchemeMPL, CPrivateKey, ffi.Pointer, + size_t)>>('CAugSchemeMPLSign'); + late final _CAugSchemeMPLSign = _CAugSchemeMPLSignPtr.asFunction< + CG2Element Function( + CAugSchemeMPL, CPrivateKey, ffi.Pointer, int)>(); + + CG2Element CAugSchemeMPLSignPrepend( + CAugSchemeMPL scheme, + CPrivateKey sk, + ffi.Pointer msg, + int msgLen, + CG1Element prepPk, + ) { + return _CAugSchemeMPLSignPrepend( + scheme, + sk, + msg, + msgLen, + prepPk, + ); + } + + late final _CAugSchemeMPLSignPrependPtr = _lookup< + ffi.NativeFunction< + CG2Element Function(CAugSchemeMPL, CPrivateKey, ffi.Pointer, + size_t, CG1Element)>>('CAugSchemeMPLSignPrepend'); + late final _CAugSchemeMPLSignPrepend = + _CAugSchemeMPLSignPrependPtr.asFunction< + CG2Element Function(CAugSchemeMPL, CPrivateKey, ffi.Pointer, + int, CG1Element)>(); + + bool CAugSchemeMPLVerify( + CAugSchemeMPL scheme, + CG1Element pk, + ffi.Pointer msg, + int msgLen, + CG2Element sig, + ) { + return _CAugSchemeMPLVerify( + scheme, + pk, + msg, + msgLen, + sig, + ) != + 0; + } + + late final _CAugSchemeMPLVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function(CAugSchemeMPL, CG1Element, ffi.Pointer, + size_t, CG2Element)>>('CAugSchemeMPLVerify'); + late final _CAugSchemeMPLVerify = _CAugSchemeMPLVerifyPtr.asFunction< + int Function( + CAugSchemeMPL, CG1Element, ffi.Pointer, int, CG2Element)>(); + + bool CAugSchemeMPLAggregateVerify( + CAugSchemeMPL scheme, + ffi.Pointer> pks, + int pksLen, + ffi.Pointer> msgs, + ffi.Pointer msgsLens, + int msgsLen, + CG2Element sig, + ) { + return _CAugSchemeMPLAggregateVerify( + scheme, + pks, + pksLen, + msgs, + msgsLens, + msgsLen, + sig, + ) != + 0; + } + + late final _CAugSchemeMPLAggregateVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function( + CAugSchemeMPL, + ffi.Pointer>, + size_t, + ffi.Pointer>, + ffi.Pointer, + size_t, + CG2Element)>>('CAugSchemeMPLAggregateVerify'); + late final _CAugSchemeMPLAggregateVerify = + _CAugSchemeMPLAggregateVerifyPtr.asFunction< + int Function( + CAugSchemeMPL, + ffi.Pointer>, + int, + ffi.Pointer>, + ffi.Pointer, + int, + CG2Element)>(); + + void CAugSchemeMPLFree( + CAugSchemeMPL scheme, + ) { + return _CAugSchemeMPLFree( + scheme, + ); + } + + late final _CAugSchemeMPLFreePtr = + _lookup>( + 'CAugSchemeMPLFree'); + late final _CAugSchemeMPLFree = + _CAugSchemeMPLFreePtr.asFunction(); + + CPopSchemeMPL NewCPopSchemeMPL() { + return _NewCPopSchemeMPL(); + } + + late final _NewCPopSchemeMPLPtr = + _lookup>('NewCPopSchemeMPL'); + late final _NewCPopSchemeMPL = + _NewCPopSchemeMPLPtr.asFunction(); + + CG2Element CPopSchemeMPLPopProve( + CPopSchemeMPL scheme, + CPrivateKey sk, + ) { + return _CPopSchemeMPLPopProve( + scheme, + sk, + ); + } + + late final _CPopSchemeMPLPopProvePtr = _lookup< + ffi.NativeFunction>( + 'CPopSchemeMPLPopProve'); + late final _CPopSchemeMPLPopProve = _CPopSchemeMPLPopProvePtr.asFunction< + CG2Element Function(CPopSchemeMPL, CPrivateKey)>(); + + bool CPopSchemeMPLPopVerify( + CPopSchemeMPL scheme, + CG1Element pk, + CG2Element sig, + ) { + return _CPopSchemeMPLPopVerify( + scheme, + pk, + sig, + ) != + 0; + } + + late final _CPopSchemeMPLPopVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function(CPopSchemeMPL, CG1Element, + CG2Element)>>('CPopSchemeMPLPopVerify'); + late final _CPopSchemeMPLPopVerify = _CPopSchemeMPLPopVerifyPtr.asFunction< + int Function(CPopSchemeMPL, CG1Element, CG2Element)>(); + + bool CPopSchemeMPLFastAggregateVerify( + CPopSchemeMPL scheme, + ffi.Pointer> pks, + int pksLen, + ffi.Pointer msgs, + int msgsLen, + CG2Element sig, + ) { + return _CPopSchemeMPLFastAggregateVerify( + scheme, + pks, + pksLen, + msgs, + msgsLen, + sig, + ) != + 0; + } + + late final _CPopSchemeMPLFastAggregateVerifyPtr = _lookup< + ffi.NativeFunction< + ffi.Uint8 Function( + CPopSchemeMPL, + ffi.Pointer>, + size_t, + ffi.Pointer, + size_t, + CG2Element)>>('CPopSchemeMPLFastAggregateVerify'); + late final _CPopSchemeMPLFastAggregateVerify = + _CPopSchemeMPLFastAggregateVerifyPtr.asFunction< + int Function(CPopSchemeMPL, ffi.Pointer>, int, + ffi.Pointer, int, CG2Element)>(); + + void CPopSchemeMPLFree( + CPopSchemeMPL scheme, + ) { + return _CPopSchemeMPLFree( + scheme, + ); + } + + late final _CPopSchemeMPLFreePtr = + _lookup>( + 'CPopSchemeMPLFree'); + late final _CPopSchemeMPLFree = + _CPopSchemeMPLFreePtr.asFunction(); +} + +class __fsid_t extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array __val; +} + +abstract class idtype_t { + static const int P_ALL = 0; + static const int P_PID = 1; + static const int P_PGID = 2; +} + +class div_t extends ffi.Struct { + @ffi.Int32() + external int quot; + + @ffi.Int32() + external int rem; +} + +class ldiv_t extends ffi.Struct { + @ffi.Int64() + external int quot; + + @ffi.Int64() + external int rem; +} + +class lldiv_t extends ffi.Struct { + @ffi.Int64() + external int quot; + + @ffi.Int64() + external int rem; +} + +typedef size_t = ffi.Uint64; + +class __sigset_t extends ffi.Struct { + @ffi.Array.multi([16]) + external ffi.Array __val; +} + +class timeval extends ffi.Struct { + @__time_t() + external int tv_sec; + + @__suseconds_t() + external int tv_usec; +} + +typedef __time_t = ffi.Int64; +typedef __suseconds_t = ffi.Int64; + +class timespec extends ffi.Struct { + @__time_t() + external int tv_sec; + + @__syscall_slong_t() + external int tv_nsec; +} + +typedef __syscall_slong_t = ffi.Int64; + +class fd_set extends ffi.Struct { + @ffi.Array.multi([16]) + external ffi.Array<__fd_mask> __fds_bits; +} + +typedef __fd_mask = ffi.Int64; + +class __pthread_internal_list extends ffi.Struct { + external ffi.Pointer<__pthread_internal_list> __prev; + + external ffi.Pointer<__pthread_internal_list> __next; +} + +class __pthread_internal_slist extends ffi.Struct { + external ffi.Pointer<__pthread_internal_slist> __next; +} + +class __pthread_mutex_s extends ffi.Struct { + @ffi.Int32() + external int __lock; + + @ffi.Uint32() + external int __count; + + @ffi.Int32() + external int __owner; + + @ffi.Uint32() + external int __nusers; + + @ffi.Int32() + external int __kind; + + @ffi.Int16() + external int __spins; + + @ffi.Int16() + external int __elision; + + external __pthread_list_t __list; +} + +typedef __pthread_list_t = __pthread_internal_list; + +class __pthread_rwlock_arch_t extends ffi.Struct { + @ffi.Uint32() + external int __readers; + + @ffi.Uint32() + external int __writers; + + @ffi.Uint32() + external int __wrphase_futex; + + @ffi.Uint32() + external int __writers_futex; + + @ffi.Uint32() + external int __pad3; + + @ffi.Uint32() + external int __pad4; + + @ffi.Int32() + external int __cur_writer; + + @ffi.Int32() + external int __shared; + + @ffi.Int8() + external int __rwelision; + + @ffi.Array.multi([7]) + external ffi.Array __pad1; + + @ffi.Uint64() + external int __pad2; + + @ffi.Uint32() + external int __flags; +} + +class __pthread_cond_s extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array __g_refs; + + @ffi.Array.multi([2]) + external ffi.Array __g_size; + + @ffi.Uint32() + external int __g1_orig_size; + + @ffi.Uint32() + external int __wrefs; + + @ffi.Array.multi([2]) + external ffi.Array __g_signals; +} + +class pthread_mutexattr_t extends ffi.Union { + @ffi.Array.multi([4]) + external ffi.Array __size; + + @ffi.Int32() + external int __align; +} + +class pthread_condattr_t extends ffi.Union { + @ffi.Array.multi([4]) + external ffi.Array __size; + + @ffi.Int32() + external int __align; +} + +class pthread_attr_t extends ffi.Union { + @ffi.Array.multi([56]) + external ffi.Array __size; + + @ffi.Int64() + external int __align; +} + +class pthread_mutex_t extends ffi.Union { + external __pthread_mutex_s __data; + + @ffi.Array.multi([40]) + external ffi.Array __size; + + @ffi.Int64() + external int __align; +} + +class pthread_cond_t extends ffi.Union { + external __pthread_cond_s __data; + + @ffi.Array.multi([48]) + external ffi.Array __size; + + @ffi.Int64() + external int __align; +} + +class pthread_rwlock_t extends ffi.Union { + external __pthread_rwlock_arch_t __data; + + @ffi.Array.multi([56]) + external ffi.Array __size; + + @ffi.Int64() + external int __align; +} + +class pthread_rwlockattr_t extends ffi.Union { + @ffi.Array.multi([8]) + external ffi.Array __size; + + @ffi.Int64() + external int __align; +} + +class pthread_barrier_t extends ffi.Union { + @ffi.Array.multi([32]) + external ffi.Array __size; + + @ffi.Int64() + external int __align; +} + +class pthread_barrierattr_t extends ffi.Union { + @ffi.Array.multi([4]) + external ffi.Array __size; + + @ffi.Int32() + external int __align; +} + +class random_data extends ffi.Struct { + external ffi.Pointer fptr; + + external ffi.Pointer rptr; + + external ffi.Pointer state; + + @ffi.Int32() + external int rand_type; + + @ffi.Int32() + external int rand_deg; + + @ffi.Int32() + external int rand_sep; + + external ffi.Pointer end_ptr; +} + +class drand48_data extends ffi.Struct { + @ffi.Array.multi([3]) + external ffi.Array __x; + + @ffi.Array.multi([3]) + external ffi.Array __old_x; + + @ffi.Uint16() + external int __c; + + @ffi.Uint16() + external int __init; + + @ffi.Uint64() + external int __a; +} + +typedef __compar_fn_t = ffi.Pointer< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>>; +typedef wchar_t = ffi.Int32; +typedef CG1Element = ffi.Pointer; +typedef CPrivateKey = ffi.Pointer; +typedef CG2Element = ffi.Pointer; +typedef CCoreMPL = ffi.Pointer; +typedef CBasicSchemeMPL = CCoreMPL; +typedef CAugSchemeMPL = CCoreMPL; +typedef CPopSchemeMPL = CCoreMPL; + +const int true1 = 1; + +const int false1 = 0; + +const int __bool_true_false_are_defined = 1; + +const int _STDINT_H = 1; + +const int _FEATURES_H = 1; + +const int _DEFAULT_SOURCE = 1; + +const int __GLIBC_USE_ISOC2X = 1; + +const int __USE_ISOC11 = 1; + +const int __USE_ISOC99 = 1; + +const int __USE_ISOC95 = 1; + +const int _POSIX_SOURCE = 1; + +const int _POSIX_C_SOURCE = 200809; + +const int __USE_POSIX = 1; + +const int __USE_POSIX2 = 1; + +const int __USE_POSIX199309 = 1; + +const int __USE_POSIX199506 = 1; + +const int __USE_XOPEN2K = 1; + +const int __USE_XOPEN2K8 = 1; + +const int _ATFILE_SOURCE = 1; + +const int __USE_MISC = 1; + +const int __USE_ATFILE = 1; + +const int __USE_FORTIFY_LEVEL = 0; + +const int __GLIBC_USE_DEPRECATED_GETS = 0; + +const int __GLIBC_USE_DEPRECATED_SCANF = 0; + +const int _STDC_PREDEF_H = 1; + +const int __STDC_IEC_559__ = 1; + +const int __STDC_IEC_559_COMPLEX__ = 1; + +const int __STDC_ISO_10646__ = 201706; + +const int __GNU_LIBRARY__ = 6; + +const int __GLIBC__ = 2; + +const int __GLIBC_MINOR__ = 31; + +const int _SYS_CDEFS_H = 1; + +const int __glibc_c99_flexarr_available = 1; + +const int __WORDSIZE = 64; + +const int __WORDSIZE_TIME64_COMPAT32 = 1; + +const int __SYSCALL_WORDSIZE = 64; + +const int __LONG_DOUBLE_USES_FLOAT128 = 0; + +const int __HAVE_GENERIC_SELECTION = 0; + +const int __GLIBC_USE_LIB_EXT2 = 1; + +const int __GLIBC_USE_IEC_60559_BFP_EXT = 1; + +const int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = 1; + +const int __GLIBC_USE_IEC_60559_FUNCS_EXT = 1; + +const int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = 1; + +const int __GLIBC_USE_IEC_60559_TYPES_EXT = 1; + +const int _BITS_TYPES_H = 1; + +const int __TIMESIZE = 64; + +const int _BITS_TYPESIZES_H = 1; + +const int __OFF_T_MATCHES_OFF64_T = 1; + +const int __INO_T_MATCHES_INO64_T = 1; + +const int __RLIM_T_MATCHES_RLIM64_T = 1; + +const int __STATFS_MATCHES_STATFS64 = 1; + +const int __FD_SETSIZE = 1024; + +const int _BITS_TIME64_H = 1; + +const int _BITS_WCHAR_H = 1; + +const int __WCHAR_MAX = 2147483647; + +const int __WCHAR_MIN = -2147483648; + +const int _BITS_STDINT_INTN_H = 1; + +const int _BITS_STDINT_UINTN_H = 1; + +const int INT8_MIN = -128; + +const int INT16_MIN = -32768; + +const int INT32_MIN = -2147483648; + +const int INT64_MIN = -9223372036854775808; + +const int INT8_MAX = 127; + +const int INT16_MAX = 32767; + +const int INT32_MAX = 2147483647; + +const int INT64_MAX = 9223372036854775807; + +const int UINT8_MAX = 255; + +const int UINT16_MAX = 65535; + +const int UINT32_MAX = 4294967295; + +const int UINT64_MAX = -1; + +const int INT_LEAST8_MIN = -128; + +const int INT_LEAST16_MIN = -32768; + +const int INT_LEAST32_MIN = -2147483648; + +const int INT_LEAST64_MIN = -9223372036854775808; + +const int INT_LEAST8_MAX = 127; + +const int INT_LEAST16_MAX = 32767; + +const int INT_LEAST32_MAX = 2147483647; + +const int INT_LEAST64_MAX = 9223372036854775807; + +const int UINT_LEAST8_MAX = 255; + +const int UINT_LEAST16_MAX = 65535; + +const int UINT_LEAST32_MAX = 4294967295; + +const int UINT_LEAST64_MAX = -1; + +const int INT_FAST8_MIN = -128; + +const int INT_FAST16_MIN = -9223372036854775808; + +const int INT_FAST32_MIN = -9223372036854775808; + +const int INT_FAST64_MIN = -9223372036854775808; + +const int INT_FAST8_MAX = 127; + +const int INT_FAST16_MAX = 9223372036854775807; + +const int INT_FAST32_MAX = 9223372036854775807; + +const int INT_FAST64_MAX = 9223372036854775807; + +const int UINT_FAST8_MAX = 255; + +const int UINT_FAST16_MAX = -1; + +const int UINT_FAST32_MAX = -1; + +const int UINT_FAST64_MAX = -1; + +const int INTPTR_MIN = -9223372036854775808; + +const int INTPTR_MAX = 9223372036854775807; + +const int UINTPTR_MAX = -1; + +const int INTMAX_MIN = -9223372036854775808; + +const int INTMAX_MAX = 9223372036854775807; + +const int UINTMAX_MAX = -1; + +const int PTRDIFF_MIN = -9223372036854775808; + +const int PTRDIFF_MAX = 9223372036854775807; + +const int SIG_ATOMIC_MIN = -2147483648; + +const int SIG_ATOMIC_MAX = 2147483647; + +const int SIZE_MAX = -1; + +const int WCHAR_MIN = -2147483648; + +const int WCHAR_MAX = 2147483647; + +const int WINT_MIN = 0; + +const int WINT_MAX = 4294967295; + +const int NULL = 0; + +const int _STDLIB_H = 1; + +const int WNOHANG = 1; + +const int WUNTRACED = 2; + +const int WSTOPPED = 2; + +const int WEXITED = 4; + +const int WCONTINUED = 8; + +const int WNOWAIT = 16777216; + +const int __WNOTHREAD = 536870912; + +const int __WALL = 1073741824; + +const int __WCLONE = 2147483648; + +const int __ENUM_IDTYPE_T = 1; + +const int __W_CONTINUED = 65535; + +const int __WCOREFLAG = 128; + +const int __HAVE_FLOAT128 = 0; + +const int __HAVE_DISTINCT_FLOAT128 = 0; + +const int __HAVE_FLOAT64X = 1; + +const int __HAVE_FLOAT64X_LONG_DOUBLE = 1; + +const int __HAVE_FLOAT16 = 0; + +const int __HAVE_FLOAT32 = 1; + +const int __HAVE_FLOAT64 = 1; + +const int __HAVE_FLOAT32X = 1; + +const int __HAVE_FLOAT128X = 0; + +const int __HAVE_DISTINCT_FLOAT16 = 0; + +const int __HAVE_DISTINCT_FLOAT32 = 0; + +const int __HAVE_DISTINCT_FLOAT64 = 0; + +const int __HAVE_DISTINCT_FLOAT32X = 0; + +const int __HAVE_DISTINCT_FLOAT64X = 0; + +const int __HAVE_DISTINCT_FLOAT128X = 0; + +const int __HAVE_FLOAT128_UNLIKE_LDBL = 0; + +const int __HAVE_FLOATN_NOT_TYPEDEF = 0; + +const int __ldiv_t_defined = 1; + +const int __lldiv_t_defined = 1; + +const int RAND_MAX = 2147483647; + +const int EXIT_FAILURE = 1; + +const int EXIT_SUCCESS = 0; + +const int _SYS_TYPES_H = 1; + +const int __clock_t_defined = 1; + +const int __clockid_t_defined = 1; + +const int __time_t_defined = 1; + +const int __timer_t_defined = 1; + +const int __BIT_TYPES_DEFINED__ = 1; + +const int _ENDIAN_H = 1; + +const int _BITS_ENDIAN_H = 1; + +const int __LITTLE_ENDIAN = 1234; + +const int __BIG_ENDIAN = 4321; + +const int __PDP_ENDIAN = 3412; + +const int _BITS_ENDIANNESS_H = 1; + +const int __BYTE_ORDER = 1234; + +const int __FLOAT_WORD_ORDER = 1234; + +const int LITTLE_ENDIAN = 1234; + +const int BIG_ENDIAN = 4321; + +const int PDP_ENDIAN = 3412; + +const int BYTE_ORDER = 1234; + +const int _BITS_BYTESWAP_H = 1; + +const int _BITS_UINTN_IDENTITY_H = 1; + +const int _SYS_SELECT_H = 1; + +const String __FD_ZERO_STOS = 'stosq'; + +const int __sigset_t_defined = 1; + +const int _SIGSET_NWORDS = 16; + +const int __timeval_defined = 1; + +const int _STRUCT_TIMESPEC = 1; + +const int __NFDBITS = 64; + +const int FD_SETSIZE = 1024; + +const int NFDBITS = 64; + +const int _BITS_PTHREADTYPES_COMMON_H = 1; + +const int _THREAD_SHARED_TYPES_H = 1; + +const int _BITS_PTHREADTYPES_ARCH_H = 1; + +const int __SIZEOF_PTHREAD_MUTEX_T = 40; + +const int __SIZEOF_PTHREAD_ATTR_T = 56; + +const int __SIZEOF_PTHREAD_RWLOCK_T = 56; + +const int __SIZEOF_PTHREAD_BARRIER_T = 32; + +const int __SIZEOF_PTHREAD_MUTEXATTR_T = 4; + +const int __SIZEOF_PTHREAD_COND_T = 48; + +const int __SIZEOF_PTHREAD_CONDATTR_T = 4; + +const int __SIZEOF_PTHREAD_RWLOCKATTR_T = 8; + +const int __SIZEOF_PTHREAD_BARRIERATTR_T = 4; + +const int _THREAD_MUTEX_INTERNAL_H = 1; + +const int __PTHREAD_MUTEX_HAVE_PREV = 1; + +const int __PTHREAD_RWLOCK_ELISION_EXTRA = 0; + +const int __have_pthread_attr_t = 1; + +const int _ALLOCA_H = 1; diff --git a/flutter-bindings/bls_signatures_ffi/lib/src/elements.dart b/flutter-bindings/bls_signatures_ffi/lib/src/elements.dart new file mode 100644 index 000000000..ae971945b --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/src/elements.dart @@ -0,0 +1,186 @@ +import 'dart:ffi'; +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:bls_signatures_ffi/src/blschia.dart'; +import 'package:bls_signatures_ffi/src/blschia.h.dart'; +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; + +/// An instance of [G1Element]. +@immutable +class G1Element { + /// @nodoc + @protected + const G1Element(CG1Element g1Element) : _g1Element = g1Element; + + /// Create a [G1Element] instance from [data]. + factory G1Element.fromBytes({required Uint8List data}) { + final dataBuf = malloc.allocate(data.length) + ..asTypedList(data.length).setAll(0, data); + + final didErr = calloc.allocate(1); + final g1 = G1Element( + bindings.CG1ElementFromBytes(dataBuf.cast(), didErr.cast()), + ); + malloc.free(dataBuf); + if (didErr.value) { + malloc.free(didErr); + throw BLSException.errFromC(); + } + malloc.free(didErr); + return g1; + } + + final CG1Element _g1Element; + + /// @nodoc + @protected + CG1Element get ptr => _g1Element; + + /// Multiply an instance with [PrivateKey]. + G1Element operator *(PrivateKey pk) { + // ignore: invalid_use_of_protected_member + return G1Element(bindings.CG1ElementMul(_g1Element, pk.ptr)); + } + + @override + bool operator ==(Object other) { + return other is G1Element && + bindings.CG1ElementIsEqual( + _g1Element, + other._g1Element, + ); + } + + @override + int get hashCode => serialize().hashCode; + + /// Check if instance is valid [G1Element] or not. + bool isValid() { + return bindings.CG1ElementIsValid(_g1Element); + } + + /// Add an instance to another [G1Element]. + G1Element operator +(G1Element g1) { + return G1Element(bindings.CG1ElementAdd(_g1Element, g1._g1Element)); + } + + /// Get a fingerprint for a [G1Element] instance. + int fingerprint() { + return bindings.CG1ElementGetFingerprint(_g1Element); + } + + /// Serialize a [G1Element] instance into list of bytes. + Uint8List serialize() { + final ptr = bindings.CG1ElementSerialize(_g1Element); + final bytes = Uint8List.fromList( + ptr.cast().asTypedList(bindings.CG1ElementSize()), + ); + bindings.SecFree(ptr); + return bytes; + } + + /// Hex representation of [G1Element] instance. + String hexString() { + final bytes = serialize(); + final sb = StringBuffer(); + for (final b in bytes) { + var h = b.toRadixString(16); + if (h.length == 1) { + h = '0$h'; + } + sb.write(h); + } + return '0x${sb.toString()}'; + } + + /// Release a [G1Element] instance from memory. + void free() { + bindings.CG1ElementFree(_g1Element); + } +} + +/// An instance of [G2Element]. +@immutable +class G2Element { + /// @nodoc + @protected + const G2Element(CG2Element g2Element) : _g2Element = g2Element; + + /// Create a [G2Element] instance from [data]. + factory G2Element.fromBytes({required Uint8List data}) { + final dataBuf = malloc.allocate(data.length) + ..asTypedList(data.length).setAll(0, data); + + final didErr = calloc.allocate(1); + final g2 = G2Element( + bindings.CG2ElementFromBytes(dataBuf.cast(), didErr.cast()), + ); + malloc.free(dataBuf); + if (didErr.value) { + malloc.free(didErr); + throw BLSException.errFromC(); + } + malloc.free(didErr); + return g2; + } + + final CG2Element _g2Element; + + /// @nodoc + @protected + CG2Element get ptr => _g2Element; + + /// Multiply an instance with [PrivateKey]. + G2Element operator *(PrivateKey pk) { + // ignore: invalid_use_of_protected_member + return G2Element(bindings.CG2ElementMul(_g2Element, pk.ptr)); + } + + @override + bool operator ==(Object other) { + return other is G2Element && + bindings.CG2ElementIsEqual( + _g2Element, + other._g2Element, + ); + } + + @override + int get hashCode => serialize().hashCode; + + /// Add an instance to another [G2Element]. + G2Element operator +(G2Element g2) { + return G2Element(bindings.CG2ElementAdd(_g2Element, g2._g2Element)); + } + + /// Serialize a [G2Element] instance into list of bytes. + Uint8List serialize() { + final ptr = bindings.CG2ElementSerialize(_g2Element); + final bytes = Uint8List.fromList( + ptr.cast().asTypedList(bindings.CG2ElementSize()), + ); + bindings.SecFree(ptr); + return bytes; + } + + /// Hex representation of [G2Element] instance. + String hexString() { + final bytes = serialize(); + final sb = StringBuffer(); + for (final b in bytes) { + var h = b.toRadixString(16); + if (h.length == 1) { + h = '0$h'; + } + sb.write(h); + } + return '0x${sb.toString()}'; + } + + /// Release a [G2Element] instance from memory. + void free() { + bindings.CG2ElementFree(_g2Element); + } +} diff --git a/flutter-bindings/bls_signatures_ffi/lib/src/exception.dart b/flutter-bindings/bls_signatures_ffi/lib/src/exception.dart new file mode 100644 index 000000000..7f1b5bac4 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/src/exception.dart @@ -0,0 +1,21 @@ +import 'package:bls_signatures_ffi/src/blschia.dart'; +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; + +/// Represent any exception happen in BLS operation. +class BLSException implements Exception { + /// Create [BLSException] with message. + const BLSException(String message) : _message = message; + + /// @nodoc + @protected + factory BLSException.errFromC() { + final err = bindings.GetLastErrorMsg().cast().toDartString(); + return BLSException(err); + } + + final String _message; + + @override + String toString() => 'BLS Exception: $_message'; +} diff --git a/flutter-bindings/bls_signatures_ffi/lib/src/privatekey.dart b/flutter-bindings/bls_signatures_ffi/lib/src/privatekey.dart new file mode 100644 index 000000000..f06fc095a --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/src/privatekey.dart @@ -0,0 +1,128 @@ +import 'dart:ffi'; +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:bls_signatures_ffi/src/blschia.dart'; +import 'package:bls_signatures_ffi/src/blschia.h.dart'; +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; + +/// An instance of [PrivateKey]. +@immutable +class PrivateKey { + /// @nodoc + @protected + const PrivateKey(CPrivateKey privateKey) : _privateKey = privateKey; + + /// Create a [PrivateKey] instance from [data]. + factory PrivateKey.fromBytes({ + required Uint8List data, + bool modOrder = false, + }) { + final dataBuf = malloc.allocate(data.length) + ..asTypedList(data.length).setAll(0, data); + + final didErr = malloc.allocate(1); + final pk = PrivateKey( + bindings.CPrivateKeyFromBytes(dataBuf.cast(), modOrder, didErr.cast()), + ); + malloc.free(dataBuf); + if (didErr.value) { + malloc.free(didErr); + throw BLSException.errFromC(); + } + malloc.free(didErr); + return pk; + } + + /// Aggregate list of [PrivateKey] to create new [PrivateKey] instance. + factory PrivateKey.aggregate(List pks) { + final arrBuf = malloc.allocate(pks.length); + pks.asMap().forEach((index, pk) { + bindings.SetPtrArray(arrBuf.cast(), pk._privateKey, index); + }); + final pk = + PrivateKey(bindings.CPrivateKeyAggregate(arrBuf.cast(), pks.length)); + malloc.free(arrBuf); + return pk; + } + + final CPrivateKey _privateKey; + + /// @nodoc + @protected + CPrivateKey get ptr => _privateKey; + + /// Get a [G1Element] from this instance. + G1Element g1Element() { + final didErr = malloc.allocate(1); + final g1 = G1Element( + bindings.CPrivateKeyGetG1Element(_privateKey, didErr.cast()), + ); + if (didErr.value) { + malloc.free(didErr); + throw BLSException.errFromC(); + } + return g1; + } + + /// Get a [G2Element] from this instance. + G2Element g2Element() { + final didErr = malloc.allocate(1); + final g2 = G2Element( + bindings.CPrivateKeyGetG2Element(_privateKey, didErr.cast()), + ); + if (didErr.value) { + malloc.free(didErr); + throw BLSException.errFromC(); + } + return g2; + } + + /// Calculate power of [g2]. + G2Element operator ^(G2Element g2) { + // ignore: invalid_use_of_protected_member + return G2Element(bindings.CPrivateKeyGetG2Power(_privateKey, g2.ptr)); + } + + @override + bool operator ==(Object other) { + return other is PrivateKey && + bindings.CPrivateKeyIsEqual( + _privateKey, + other._privateKey, + ); + } + + @override + int get hashCode => serialize().hashCode; + + /// Serialize a [PrivateKey] instance into list of bytes. + Uint8List serialize() { + final ptr = bindings.CPrivateKeySerialize(_privateKey); + final bytes = Uint8List.fromList( + ptr.cast().asTypedList(bindings.CPrivateKeySizeBytes()), + ); + bindings.SecFree(ptr); + return bytes; + } + + /// Hex representation of [PrivateKey] instance. + String hexString() { + final bytes = serialize(); + final sb = StringBuffer(); + for (final b in bytes) { + var h = b.toRadixString(16); + if (h.length == 1) { + h = '0$h'; + } + sb.write(h); + } + return '0x${sb.toString()}'; + } + + /// Release a [PrivateKey] instance from memory. + void free() { + bindings.CPrivateKeyFree(_privateKey); + } +} diff --git a/flutter-bindings/bls_signatures_ffi/lib/src/schemes.dart b/flutter-bindings/bls_signatures_ffi/lib/src/schemes.dart new file mode 100644 index 000000000..f0ac5866f --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/lib/src/schemes.dart @@ -0,0 +1,406 @@ +import 'dart:ffi'; +import 'dart:typed_data'; + +import 'package:bls_signatures_ffi/bls_signatures_ffi.dart'; +import 'package:bls_signatures_ffi/src/blschia.dart'; +import 'package:bls_signatures_ffi/src/blschia.h.dart'; +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; + +/// An instance of [CoreMPL]. +abstract class CoreMPL { + /// @nodoc + @protected + const CoreMPL(CCoreMPL coreMPL) : _coreMPL = coreMPL; + + final CCoreMPL _coreMPL; + + /// Create a [PrivateKey] instance from [seed]. + PrivateKey keyGen(Uint8List seed) { + final seedBuf = malloc.allocate(seed.length) + ..asTypedList(seed.length).setAll(0, seed); + + final didErr = malloc.allocate(1); + final pk = PrivateKey( + bindings.CCoreMPLKeyGen( + _coreMPL, + seedBuf.cast(), + seed.length, + didErr.cast(), + ), + ); + malloc.free(seedBuf); + if (didErr.value) { + malloc.free(didErr); + throw BLSException.errFromC(); + } + malloc.free(didErr); + return pk; + } + + /// Convert [PrivateKey] into [G1Element]. + G1Element skToG1(PrivateKey privateKey) { + // ignore: invalid_use_of_protected_member + return G1Element(bindings.CCoreMPSkToG1(_coreMPL, privateKey.ptr)); + } + + /// Sign a [msg] using a [privateKey]. + G2Element sign(PrivateKey privateKey, Uint8List msg) { + final msgBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + final sig = G2Element( + bindings.CCoreMPLSign( + _coreMPL, + // ignore: invalid_use_of_protected_member + privateKey.ptr, + msgBuf.cast(), + msg.length, + ), + ); + malloc.free(msgBuf); + return sig; + } + + /// Verify a [sig] for a [msg] using [g1Element] as public key. + bool verify(G1Element g1Element, Uint8List msg, G2Element sig) { + final msgBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + final isVerified = bindings.CCoreMPLVerify( + _coreMPL, + // ignore: invalid_use_of_protected_member + g1Element.ptr, + msgBuf.cast(), + msg.length, + // ignore: invalid_use_of_protected_member + sig.ptr, + ); + malloc.free(msgBuf); + return isVerified; + } + + /// Aggregate list of [G1Element]. + G1Element aggregatePubKeys(List pks) { + final arrBuf = bindings.AllocPtrArray(pks.length); + pks.asMap().forEach((index, pk) { + // ignore: invalid_use_of_protected_member + bindings.SetPtrArray(arrBuf.cast(), pk.ptr, index); + }); + final aggSig = G1Element( + bindings.CCoreMPLAggregatePubKeys( + _coreMPL, + arrBuf.cast(), + pks.length, + ), + ); + malloc.free(arrBuf); + return aggSig; + } + + /// Aggregate list of [G2Element]. + G2Element aggregateSigs(List sigs) { + final arrBuf = malloc.allocate(sigs.length); + sigs.asMap().forEach((index, sig) { + // ignore: invalid_use_of_protected_member + bindings.SetPtrArray(arrBuf.cast(), sig.ptr, index); + }); + final aggSig = G2Element( + bindings.CCoreMPLAggregateSigs( + _coreMPL, + arrBuf.cast(), + sigs.length, + ), + ); + malloc.free(arrBuf); + return aggSig; + } + + /// Get a [privateKey]'s child. + PrivateKey deriveChildSk(PrivateKey privateKey, int index) { + return PrivateKey( + // ignore: invalid_use_of_protected_member + bindings.CCoreMPLDeriveChildSk(_coreMPL, privateKey.ptr, index), + ); + } + + /// Get a [privateKey]'s child. + PrivateKey deriveChildSkUnhardened(PrivateKey privateKey, int index) { + return PrivateKey( + // ignore: invalid_use_of_protected_member + bindings.CCoreMPLDeriveChildSkUnhardened(_coreMPL, privateKey.ptr, index), + ); + } + + /// Get a [g1]'s child. + G1Element deriveChildPkUnhardened(G1Element g1, int index) { + return G1Element( + // ignore: invalid_use_of_protected_member + bindings.CCoreMPLDeriveChildPkUnhardened(_coreMPL, g1.ptr, index), + ); + } + + /// Verify the aggregated signature [sig] for a list of messages [msgs] + /// with list of public keys [pks]. + bool aggregateVerify( + List pks, + List msgs, + G2Element sig, + ) { + final pkBuf = bindings.AllocPtrArray(pks.length); + pks.asMap().forEach((index, pk) { + // ignore: invalid_use_of_protected_member + bindings.SetPtrArray(pkBuf.cast(), pk.ptr, index); + }); + final msgBuf = bindings.AllocPtrArray(msgs.length); + final msgLens = []; + final msgPtrBuf = >[]; + msgs.asMap().forEach((index, msg) { + final mBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + msgPtrBuf.add(mBuf); + msgLens.add(msg.length); + bindings.SetPtrArray(msgBuf.cast(), mBuf.cast(), index); + }); + final msgLenBuf = malloc.allocate(msgLens.length) + ..asTypedList(msgLens.length).setAll(0, msgLens); + final res = bindings.CCoreMPLAggregateVerify( + _coreMPL, + pkBuf.cast(), + pks.length, + msgBuf.cast(), + msgLenBuf.cast(), + msgs.length, + // ignore: invalid_use_of_protected_member + sig.ptr, + ); + + malloc.free(pkBuf); + // ignore: cascade_invocations + malloc.free(msgBuf); + for (final buf in msgPtrBuf) { + malloc.free(buf); + } + malloc.free(msgLenBuf); + return res; + } +} + +/// An instance of [BasicSchemeMPL]. +class BasicSchemeMPL extends CoreMPL { + /// Create an instance of [BasicSchemeMPL]. + BasicSchemeMPL() : super(bindings.NewCBasicSchemeMPL()); + + @override + bool aggregateVerify( + List pks, + List msgs, + G2Element sig, + ) { + final pkBuf = bindings.AllocPtrArray(pks.length); + pks.asMap().forEach((index, pk) { + // ignore: invalid_use_of_protected_member + bindings.SetPtrArray(pkBuf.cast(), pk.ptr, index); + }); + final msgBuf = bindings.AllocPtrArray(msgs.length); + final msgLens = []; + final msgPtrBuf = >[]; + msgs.asMap().forEach((index, msg) { + final mBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + msgPtrBuf.add(mBuf); + msgLens.add(msg.length); + bindings.SetPtrArray(msgBuf.cast(), mBuf.cast(), index); + }); + final msgLenBuf = malloc.allocate(msgLens.length) + ..asTypedList(msgLens.length).setAll(0, msgLens); + final res = bindings.CBasicSchemeMPLAggregateVerify( + _coreMPL, + pkBuf.cast(), + pks.length, + msgBuf.cast(), + msgLenBuf.cast(), + msgs.length, + // ignore: invalid_use_of_protected_member + sig.ptr, + ); + + malloc.free(pkBuf); + // ignore: cascade_invocations + malloc.free(msgBuf); + for (final buf in msgPtrBuf) { + malloc.free(buf); + } + malloc.free(msgLenBuf); + return res; + } + + /// Release a [BasicSchemeMPL] instance from memory. + void free() { + bindings.CBasicSchemeMPLFree(_coreMPL); + } +} + +/// An instance of [AugSchemeMPL]. +class AugSchemeMPL extends CoreMPL { + /// Create an instance of [AugSchemeMPL]. + AugSchemeMPL() : super(bindings.NewCAugSchemeMPL()); + + @override + G2Element sign(PrivateKey privateKey, Uint8List msg) { + final msgBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + final sig = G2Element( + bindings.CAugSchemeMPLSign( + _coreMPL, + // ignore: invalid_use_of_protected_member + privateKey.ptr, + msgBuf.cast(), + msg.length, + ), + ); + malloc.free(msgBuf); + return sig; + } + + /// Prepending different message. + G2Element signPrepend( + PrivateKey privateKey, + Uint8List msg, + G1Element prepPK, + ) { + final msgBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + final sig = G2Element( + bindings.CAugSchemeMPLSignPrepend( + _coreMPL, + // ignore: invalid_use_of_protected_member + privateKey.ptr, + msgBuf.cast(), + msg.length, + // ignore: invalid_use_of_protected_member + prepPK.ptr, + ), + ); + malloc.free(msgBuf); + return sig; + } + + @override + bool verify(G1Element g1Element, Uint8List msg, G2Element sig) { + final msgBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + final isVerified = bindings.CAugSchemeMPLVerify( + _coreMPL, + // ignore: invalid_use_of_protected_member + g1Element.ptr, + msgBuf.cast(), + msg.length, + // ignore: invalid_use_of_protected_member + sig.ptr, + ); + malloc.free(msgBuf); + return isVerified; + } + + @override + bool aggregateVerify( + List pks, + List msgs, + G2Element sig, + ) { + final pkBuf = bindings.AllocPtrArray(pks.length); + pks.asMap().forEach((index, pk) { + // ignore: invalid_use_of_protected_member + bindings.SetPtrArray(pkBuf.cast(), pk.ptr, index); + }); + final msgBuf = bindings.AllocPtrArray(msgs.length); + final msgLens = []; + final msgPtrBuf = >[]; + msgs.asMap().forEach((index, msg) { + final mBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + msgPtrBuf.add(mBuf); + msgLens.add(msg.length); + bindings.SetPtrArray(msgBuf.cast(), mBuf.cast(), index); + }); + final msgLenBuf = malloc.allocate(msgLens.length) + ..asTypedList(msgLens.length).setAll(0, msgLens); + final res = bindings.CAugSchemeMPLAggregateVerify( + _coreMPL, + pkBuf.cast(), + pks.length, + msgBuf.cast(), + msgLenBuf.cast(), + msgs.length, + // ignore: invalid_use_of_protected_member + sig.ptr, + ); + + malloc.free(pkBuf); + // ignore: cascade_invocations + malloc.free(msgBuf); + for (final buf in msgPtrBuf) { + malloc.free(buf); + } + malloc.free(msgLenBuf); + return res; + } + + /// Release a [AugSchemeMPL] instance from memory. + void free() { + bindings.CAugSchemeMPLFree(_coreMPL); + } +} + +/// An instance of [PopSchemeMPL]. +class PopSchemeMPL extends CoreMPL { + /// Create an instance of [PopSchemeMPL]. + PopSchemeMPL() : super(bindings.NewCPopSchemeMPL()); + + /// Prove using [privateKey]. + G2Element popProve(PrivateKey privateKey) { + return G2Element( + // ignore: invalid_use_of_protected_member + bindings.CPopSchemeMPLPopProve(_coreMPL, privateKey.ptr), + ); + } + + /// Verifies [sig] using proof of possesion. + bool popVerify(G1Element g1Element, G2Element sig) { + // ignore: invalid_use_of_protected_member + return bindings.CPopSchemeMPLPopVerify(_coreMPL, g1Element.ptr, sig.ptr); + } + + /// Fast verification. + bool fastAggregateVerify( + List pks, + Uint8List msg, + G2Element sig, + ) { + final pkBuf = bindings.AllocPtrArray(pks.length); + pks.asMap().forEach((index, pk) { + // ignore: invalid_use_of_protected_member + bindings.SetPtrArray(pkBuf.cast(), pk.ptr, index); + }); + final msgBuf = malloc.allocate(msg.length) + ..asTypedList(msg.length).setAll(0, msg); + final res = bindings.CPopSchemeMPLFastAggregateVerify( + _coreMPL, + pkBuf.cast(), + pks.length, + msgBuf.cast(), + msg.length, + // ignore: invalid_use_of_protected_member + sig.ptr, + ); + + malloc.free(pkBuf); + // ignore: cascade_invocations + malloc.free(msgBuf); + return res; + } + + /// Release a [PopSchemeMPL] instance from memory. + void free() { + bindings.CPopSchemeMPLFree(_coreMPL); + } +} diff --git a/flutter-bindings/bls_signatures_ffi/pubspec.yaml b/flutter-bindings/bls_signatures_ffi/pubspec.yaml new file mode 100644 index 000000000..01e234dc7 --- /dev/null +++ b/flutter-bindings/bls_signatures_ffi/pubspec.yaml @@ -0,0 +1,41 @@ +name: bls_signatures_ffi +description: Flutter plugin for Chia's BLS-Signatures. +version: 0.1.0 +homepage: https://github.com/Chia-Network/bls-signatures + +environment: + sdk: ">=2.16.2 <3.0.0" + flutter: ">=2.5.0" + +dependencies: + ffi: ^1.1.2 + flutter: + sdk: flutter + +dev_dependencies: + build_runner: ^2.1.9 + ffigen: ^4.1.3 + flutter_lints: ^1.0.0 + flutter_test: + sdk: flutter + test: ^1.19.5 + very_good_analysis: ^2.4.0 + +ffigen: + name: BLSSignatureBindings + output: "lib/src/blschia.h.dart" + headers: + entry-points: + - "ios/bls/blschia.h" + - "ios/bls/elements.h" + - "ios/bls/privatekey.h" + - "ios/bls/schemes.h" + +flutter: + plugin: + platforms: + android: + package: net.chia.bls_signatures_ffi + pluginClass: BlsSignaturesFfiPlugin + ios: + pluginClass: BlsSignaturesFfiPlugin