Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f0aa848
add serai submodule
julian-CStack Aug 1, 2023
734658e
WIP test build scripts
julian-CStack Aug 1, 2023
3a61bae
ffigen yaml
julian-CStack Aug 1, 2023
9996b17
update serai submodule to 1674b217 Various tweaks to bindings
sneurlax Aug 2, 2023
a71f125
somewhat "working" linux build
julian-CStack Aug 2, 2023
203332e
"fix" example cmakelist
julian-CStack Aug 2, 2023
6d7db53
fix types for quick example
julian-CStack Aug 2, 2023
8e2183e
flight param refactor and added custom exception
julian-CStack Aug 2, 2023
374f7d6
wrap all bound functions, converting non opaque types to dart native …
julian-CStack Aug 2, 2023
d41e354
example run ui
julian-CStack Aug 3, 2023
4f05a15
OwnedString toDartString extension
julian-CStack Aug 3, 2023
f236821
WIP sample testing run
julian-CStack Aug 3, 2023
2e801aa
update ref
julian-CStack Aug 3, 2023
9e78f56
full rebuild in build script
julian-CStack Aug 3, 2023
ad2a070
update ref
julian-CStack Aug 3, 2023
9e18598
update ref and affected bindings
julian-CStack Aug 4, 2023
2fd5ec3
basic working keygen example
julian-CStack Aug 4, 2023
47de721
remove unnecessary param and check lengths match
julian-CStack Aug 4, 2023
cbdcd11
array access fix
julian-CStack Aug 4, 2023
5e2d0ec
updated serai ref and bindings
julian-CStack Aug 4, 2023
8516ddd
Correct header
julian-CStack Aug 4, 2023
c149bb2
added new wrappers for new bindings
julian-CStack Aug 4, 2023
247db13
WIP signing example
julian-CStack Aug 4, 2023
a20d47d
fix double free
julian-CStack Aug 4, 2023
39f8100
simple signing example
julian-CStack Aug 4, 2023
835c1e4
update build script to use rust 1.71.0
julian-CStack Aug 8, 2023
7745395
android build
julian-CStack Aug 8, 2023
903da66
update gitignore
julian-CStack Aug 8, 2023
844c986
update serai ref
julian-CStack Aug 8, 2023
5ce4b3f
linux cmakelists fix
julian-CStack Aug 10, 2023
7e008d1
fix ffi wrapper call
julian-CStack Aug 15, 2023
65ca70e
fix func signature
julian-CStack Aug 16, 2023
819f402
add toString
julian-CStack Aug 17, 2023
e26c199
pass config in by string
julian-CStack Aug 17, 2023
468a724
ensure free called on owned string
julian-CStack Aug 17, 2023
1786222
bad free
julian-CStack Aug 17, 2023
41526eb
make frost API more dart friendly and call appropriate frees
julian-CStack Aug 18, 2023
0958db5
update serai ref
julian-CStack Aug 21, 2023
3994ed1
update bindings
julian-CStack Aug 21, 2023
dcb19e1
fix memory issues
julian-CStack Aug 21, 2023
d806b61
update serai ref
julian-CStack Aug 23, 2023
6efbe49
add wrapper calls for getting participant info from serialized keys
julian-CStack Aug 23, 2023
ffa6952
WIP resharing bindings
julian-CStack Aug 24, 2023
24da4fd
update resharing bindings
julian-CStack Aug 24, 2023
6eb209f
updates and fixes for resharing
julian-CStack Aug 25, 2023
a562fcb
update ref and bindings
julian-CStack Aug 26, 2023
43bf48e
added some comments
julian-CStack Aug 27, 2023
eabf42d
update ref and bindings
julian-CStack Aug 27, 2023
2c4041f
Update README.md
julian-CStack Aug 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ build/

.flutter-plugins
.flutter-plugins-dependencies

android/src/main/jniLibs/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/serai"]
path = src/serai
url = https://github.com/kayabaNerve/serai
93 changes: 7 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,13 @@
# frostdart

A new Flutter project.
Dart interface to the Serai FROST multisig implementation

## Getting Started
## Building

This project is a starting point for a Flutter
[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop),
a specialized package that includes native code directly invoked with Dart FFI.

## Project structure

This template uses the following structure:

* `src`: Contains the native source code, and a CmakeFile.txt file for building
that source code into a dynamic library.

* `lib`: Contains the Dart code that defines the API of the plugin, and which
calls into the native code using `dart:ffi`.

* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files
for building and bundling the native code library with the platform application.

## Building and bundling native code

The `pubspec.yaml` specifies FFI plugins as follows:

```yaml
plugin:
platforms:
some_platform:
ffiPlugin: true
```

This configuration invokes the native build for the various target platforms
and bundles the binaries in Flutter applications using these FFI plugins.

This can be combined with dartPluginClass, such as when FFI is used for the
implementation of one platform in a federated plugin:

```yaml
plugin:
implements: some_other_plugin
platforms:
some_platform:
dartPluginClass: SomeClass
ffiPlugin: true
```

A plugin can have both FFI and method channels:

```yaml
plugin:
platforms:
some_platform:
pluginClass: SomeName
ffiPlugin: true
git clone https://www.github.com/cypherstack/frostdart
cd frostdart
git submodule update --init --recursive
cd scripts/[platform]
./build_all.sh
```

The native build systems that are invoked by FFI (and method channel) plugins are:

* For Android: Gradle, which invokes the Android NDK for native builds.
* See the documentation in android/build.gradle.
* For iOS and MacOS: Xcode, via CocoaPods.
* See the documentation in ios/frostdart.podspec.
* See the documentation in macos/frostdart.podspec.
* For Linux and Windows: CMake.
* See the documentation in linux/CMakeLists.txt.
* See the documentation in windows/CMakeLists.txt.

## Binding to native code

To use the native code, bindings in Dart are needed.
To avoid writing these by hand, they are generated from the header file
(`src/frostdart.h`) by `package:ffigen`.
Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`.

## Invoking native code

Very short-running native functions can be directly invoked from any isolate.
For example, see `sum` in `lib/frostdart.dart`.

Longer-running functions should be invoked on a helper isolate to avoid
dropping frames in Flutter applications.
For example, see `sumAsync` in `lib/frostdart.dart`.

## Flutter help

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.

35 changes: 15 additions & 20 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ group 'com.example.frostdart'
version '1.0'

buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -23,37 +24,31 @@ rootProject.allprojects {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion 31

// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
ndkVersion "23.1.7779620"

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}

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
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
35 changes: 35 additions & 0 deletions android/src/main/kotlin/com/example/frostdart/FrostdartPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.flutter_libepiccash

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

/** FlutterLibepiccashPlugin */
class FrostdartPlugin: 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, "frostdart")
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)
}
}
3 changes: 2 additions & 1 deletion example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.frostdart_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.frostdart_example">
<application
android:label="frostdart_example"
android:name="${applicationName}"
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.frostdart_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
3 changes: 3 additions & 0 deletions example/ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading