Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
**/.dart_tool
**/build
**/target
17 changes: 11 additions & 6 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,30 @@ permissions:

jobs:
build:
name: Build with Java ${{ matrix.java }}
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
java: [21, 25]

steps:
- uses: actions/checkout@v7.0.1

- name: Set up Java 21
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v6.0.1
with:
distribution: temurin
java-version: 21
java-version: ${{ matrix.java }}

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -39,9 +44,9 @@ jobs:
cache: true

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Build Flutter Android release APK
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter build apk --release --no-pub
8 changes: 4 additions & 4 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: actions/checkout@v7.0.1

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -33,9 +33,9 @@ jobs:
cache: true

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Build unsigned Flutter iOS release
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter build ios --release --no-codesign --no-pub
8 changes: 4 additions & 4 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: actions/checkout@v7.0.1

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -46,9 +46,9 @@ jobs:
run: dart build cli --target example/tweak_example.dart

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Build Flutter Linux release
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter build linux --release --no-pub
8 changes: 4 additions & 4 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: actions/checkout@v7.0.1

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -41,9 +41,9 @@ jobs:
run: dart build cli --target example/tweak_example.dart

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Build Flutter macOS release
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter build macos --release --no-pub
10 changes: 5 additions & 5 deletions .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
- uses: actions/checkout@v7.0.1

- name: Set up Rust with WebAssembly target
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0
with:
targets: wasm32-unknown-unknown

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -35,12 +35,12 @@ jobs:
cache: true

- name: Check Rust WebAssembly build
run: cargo check --locked --target wasm32-unknown-unknown --manifest-path frosty_flutter/rust/Cargo.toml
run: cargo check --locked --target wasm32-unknown-unknown --manifest-path frosty/rust/Cargo.toml

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Build Flutter web release
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter build web --release --no-pub
12 changes: 4 additions & 8 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: actions/checkout@v7.0.1

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -41,13 +41,9 @@ jobs:
run: dart build cli --target example/tweak_example.dart

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Build secp256k1 for Windows
working-directory: frosty_flutter/example
run: dart run coinlib:build_windows

- name: Build Flutter Windows release
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter build windows --release --no-pub
28 changes: 6 additions & 22 deletions .github/workflows/test-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
- uses: actions/checkout@v7.0.1

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@1.98.0
with:
components: rustfmt

- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: frosty_flutter/rust -> target
workspaces: frosty/rust -> target

- name: Set up Flutter
uses: subosito/flutter-action@v2.23.0
Expand All @@ -38,12 +38,8 @@ jobs:
working-directory: frosty
run: dart pub get

- name: Resolve Flutter plugin dependencies
working-directory: frosty_flutter
run: flutter pub get

- name: Resolve Flutter example dependencies
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter pub get

- name: Verify Dart formatting
Expand All @@ -53,27 +49,15 @@ jobs:
working-directory: frosty
run: dart analyze --fatal-infos

- name: Analyze Flutter plugin
working-directory: frosty_flutter
run: flutter analyze --fatal-infos

- name: Analyze Flutter example
working-directory: frosty_flutter/example
working-directory: frosty/example
run: flutter analyze --fatal-infos

- name: Verify Rust formatting
run: cargo fmt --check --manifest-path frosty_flutter/rust/Cargo.toml
run: cargo fmt --check --manifest-path frosty/rust/Cargo.toml

- name: Check Rust library
run: cargo check --locked --manifest-path frosty_flutter/rust/Cargo.toml

- name: Build native library for Dart tests
run: cargo build --locked --manifest-path frosty_flutter/rust/Cargo.toml

- name: Install native library for Dart tests
run: |
mkdir -p frosty/build
cp frosty_flutter/rust/target/debug/libfrosty_rust.so frosty/build/
run: cargo check --locked --manifest-path frosty/rust/Cargo.toml

- name: Run Dart tests
working-directory: frosty
Expand Down
76 changes: 28 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,39 @@
# Frosty

Frosty is a Dart library for generating FROST threshold Schnorr Signatures for
secp256k1.
Frosty is a Dart and Flutter library for generating FROST threshold Schnorr
signatures for secp256k1 and Taproot.

The Dart package is found under `frosty` and a flutter package is found under
`frosty_flutter` which includes a flutter build of the underlying Rust library.
The native Rust code is found under `frosty_flutter/rust`. Scripts for
building the native libraries for Linux and Android are found in `scripts`,
however `frosty_flutter` provides automatic builds for Linux, Android, macOS and
iOS.
The published package lives in `frosty/`. Its Rust crate is in `frosty/rust`
and is compiled and bundled automatically on Android, iOS, Linux, macOS, and
Windows by the Dart build hook using `code_assets` and
`native_toolchain_rust`. Consumers therefore depend on `frosty` directly;
there is no separate Flutter plugin package.

Please see below for build instructions.
Rust and rustup must be available on the development machine. The toolchain
and supported targets are pinned in `frosty/rust/rust-toolchain.toml`.

## Building and Installation

If you are using Flutter, the `frosty_flutter` package contains support for
automatic builds for different platforms. It requires Rust but otherwise should
not require anything else.

For pure Dart use, it is possible to build a Linux library. Library binaries
must be built for the native Rust code.

Podman or Docker can be used to build the binaries. This helps to provide a
consistent and reliable build across machines.

### Linux Builds

The `scripts/build-linux.sh` script can be executed. An archive of the Linux
library will be produced in `platform-build` and a copy will be placed in
`frosty/build` so that the tests can be run in the `frosty` directory.

During runtime, the shared library is expected to exist within a `$PWD/build/`
directory or within the library paths.

### Android Builds

If you do not wish to use the automatic Android build with `frosty_flutter`, the
`scripts/build-android.sh` script can be executed. An archive of the libraries
for the armeabi-v7a and arm64-v8a architectures will be produced in
`platform-build` as `jniLibs.tar.gz`. This can be extracted into the
`android/app/src/main` directory of an Android flutter app.
## Development

### Apple Builds
From the package directory:

The `scripts/build-apple.sh` script will produce a universal framework for macOS
and iOS into `platform-build` and a dylib will be created in the `frosty/build`
directory for local testing. This script does not use Podman or Docker and
requires the host machine to have Rust.
```sh
cd frosty
dart pub get
dart test
dart analyze
```

## Development
The package uses Coinlib 6 from pub.dev. Both native libraries are built and
bundled through Dart code assets.

Tests require the Linux Rust library in the `$PWD/build` directory.
The build hook compiles the native library before tests or application builds.
The Flutter app under `frosty/example/` exercises the same package and hook on
all supported Flutter platforms. The Dart CLI examples live in that directory
as well.

If the Rust bindings need to be regenerated, `flutter_rust_bridge_codegen
generate` should be run in the `frosty_flutter` directory.
Web continues to use the checked-in wasm-bindgen output in `frosty/web/pkg`.
Run `scripts/build-wasm.sh` to refresh those files.

The `scripts/build-wasm.sh` script can be run to update the WASM output and web
bindings for flutter use.
To regenerate the bridge after changing the Rust API, run
`flutter_rust_bridge_codegen generate` from `frosty/`. The WASM generator is
the only remaining script because Dart code assets handle every native target.
9 changes: 9 additions & 0 deletions frosty/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Next

- Replace the separate `frosty_flutter` plugin and Cargokit integration with a
`code_assets` build hook powered by `native_toolchain_rust`.
- Require Dart 3.13 and Coinlib 6 with its native code-assets build hook.
- Consolidate the Dart and Flutter examples under `frosty/example`.
- Remove obsolete native build scripts; retain only the reproducible WASM
generator.

## 4.0.0

- Update to flutter_rust_bridge 2.11.0 and fix to this version
Expand Down
10 changes: 8 additions & 2 deletions frosty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ The library uses the
[frost-secp256k1-tr](https://crates.io/crates/frost-secp256k1-tr) Rust crate
that implements that FROST scheme for Taproot.

It requires a native Rust library to be loaded. A README.md for building this
library can be found in the root of the repository.
Call `await loadFrosty()` before using the API. On Android, iOS, Linux, macOS,
and Windows, the package build hook compiles and bundles the Rust library
automatically through Dart code assets. Rust and rustup must be installed on
the development machine.

Flutter applications depend on this package directly; a separate
`frosty_flutter` plugin is not required. Web builds use the bundled
wasm-bindgen files under `web/pkg`.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions frosty/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Frosty Flutter example

Demonstrates using the `frosty` package directly from Flutter. The package's
build hook compiles and bundles the Rust library for native targets.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
exclude:
- build/**
- android/**
- ios/**
- web/**
- windows/**
- macos/**
- linux/**
include: package:flutter_lints/flutter.yaml

linter:
Expand Down
Loading
Loading