Skip to content

Commit

Permalink
flutter: add SecretKey
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 5, 2024
1 parent 7fee141 commit da97244
Show file tree
Hide file tree
Showing 13 changed files with 1,345 additions and 37 deletions.
332 changes: 326 additions & 6 deletions Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import '../../frb_generated.dart';
import 'key/public_key.dart';
import 'key/secret_key.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Keys>>
Expand All @@ -15,11 +16,14 @@ abstract class Keys implements RustOpaqueInterface {
static Keys generate() =>
RustLib.instance.api.crateApiProtocolKeyKeysGenerate();

factory Keys({required SecretKey secretKey}) =>
RustLib.instance.api.crateApiProtocolKeyKeysNew(secretKey: secretKey);

/// Parse secret key from `hex` or `bech32`
static Keys parse({required String secretKey}) =>
RustLib.instance.api.crateApiProtocolKeyKeysParse(secretKey: secretKey);

Future<PublicKey> publicKey();

Future<String> secretKey();
Future<SecretKey> secretKey();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.5.1.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../../../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`, `from`
// These functions have error during generation (see debug logs or enable `stop_on_error: true` for more details): `to_secret_bytes`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_SecretKey>>
abstract class SecretKey implements RustOpaqueInterface {
static SecretKey fromHex({required String secretKey}) => RustLib.instance.api
.crateApiProtocolKeySecretKeySecretKeyFromHex(secretKey: secretKey);

static SecretKey fromSlice({required List<int> secretKey}) =>
RustLib.instance.api
.crateApiProtocolKeySecretKeySecretKeyFromSlice(secretKey: secretKey);

/// Generate random secret key
///
/// This constructor use a random number generator that retrieves randomness from the operating system.
static SecretKey generate() =>
RustLib.instance.api.crateApiProtocolKeySecretKeySecretKeyGenerate();

/// Parse from `hex` or `bech32`
static SecretKey parse({required String secretKey}) => RustLib.instance.api
.crateApiProtocolKeySecretKeySecretKeyParse(secretKey: secretKey);

Future<String> toBech32();

Future<String> toSecretHex();
}
Loading

0 comments on commit da97244

Please sign in to comment.