|
| 1 | +// This file is automatically generated, so please do not edit it. |
| 2 | +// @generated by `flutter_rust_bridge`@ 2.5.1. |
| 3 | + |
| 4 | +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import |
| 5 | + |
| 6 | +import '../frb_generated.dart'; |
| 7 | +import 'package:collection/collection.dart'; |
| 8 | +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; |
| 9 | + |
| 10 | +// These functions are ignored because they are not marked as `pub`: `derive_xprv_helper`, `mnemonic_to_xprv_helper`, `sign_data_helper`, `verify_signature_xprv_helper`, `verify_signature_xpub_helper`, `xpublic_key_helper` |
| 11 | +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `clone`, `clone`, `clone`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `from`, `from` |
| 12 | + |
| 13 | +/// Generate a new extended private key (`XPrv`) from a mnemonic and passphrase. |
| 14 | +/// Note that this function only works with BIP-0039 mnemonics. |
| 15 | +/// For more information: Cardano Icarus master node derivation |
| 16 | +/// <https://github.com/satoshilabs/slips/blob/master/slip-0023.md> |
| 17 | +/// |
| 18 | +/// # Arguments |
| 19 | +/// |
| 20 | +/// - `mnemonic`: A string representing the mnemonic. |
| 21 | +/// - `passphrase`: An optional string representing the passphrase (aka. password). |
| 22 | +/// |
| 23 | +/// # Returns |
| 24 | +/// |
| 25 | +/// Returns a bytes of extended private key as a `Result`. |
| 26 | +/// |
| 27 | +/// # Errors |
| 28 | +/// |
| 29 | +/// Returns an error if the mnemonic is invalid. |
| 30 | +Future<XPrvBytes> mnemonicToXprv( |
| 31 | + {required String mnemonic, String? passphrase}) => |
| 32 | + RustLib.instance.api.crateApiKeyDerivationMnemonicToXprv( |
| 33 | + mnemonic: mnemonic, passphrase: passphrase); |
| 34 | + |
| 35 | +// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SignatureBytes>> |
| 36 | +abstract class SignatureBytes implements RustOpaqueInterface { |
| 37 | + /// Get the inner bytes. |
| 38 | + U8Array64 get inner; |
| 39 | + |
| 40 | + /// Create a new `SignatureBytes` from the given bytes. |
| 41 | + factory SignatureBytes({required U8Array64 sigBytes}) => RustLib.instance.api |
| 42 | + .crateApiKeyDerivationSignatureBytesNew(sigBytes: sigBytes); |
| 43 | +} |
| 44 | + |
| 45 | +// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<XPrvBytes>> |
| 46 | +abstract class XPrvBytes implements RustOpaqueInterface { |
| 47 | + /// Derive a new extended private key from the given extended private key. |
| 48 | + /// - V2 derivation scheme is used as it is mention in [SLIP-0023](https://github.com/satoshilabs/slips/blob/master/slip-0023.md). |
| 49 | + /// - More information about child key derivation can be found in [BIP32-Ed25519](https://input-output-hk.github.io/adrestia/static/Ed25519_BIP.pdf). |
| 50 | + /// |
| 51 | + /// # Arguments |
| 52 | + /// |
| 53 | + /// - `xprv_bytes`: An extended private key bytes of type `XPrvBytes`. |
| 54 | + /// - `path`: Derivation path. eg. m/0/2'/3 where ' represents hardened derivation. |
| 55 | + /// |
| 56 | + /// # Returns |
| 57 | + /// |
| 58 | + /// Returns a bytes of extended private key as a `Result`. |
| 59 | + /// |
| 60 | + /// # Errors |
| 61 | + /// |
| 62 | + /// Returns an error if the derivation path is invalid. |
| 63 | + Future<XPrvBytes> deriveXprv({required String path}); |
| 64 | + |
| 65 | + /// Drop the extended private key. |
| 66 | + void drop(); |
| 67 | + |
| 68 | + /// Extract the chain code from the extended private key. |
| 69 | + /// The chain code is the last 32 bytes of the extended private key. |
| 70 | + /// |
| 71 | + /// # Returns |
| 72 | + /// |
| 73 | + /// Returns a 32 length bytes representing the chain code. |
| 74 | + U8Array32 get chainCode; |
| 75 | + |
| 76 | + /// Extract the extended secret key from the extended private key. |
| 77 | + /// The extended secret key is the first 64 bytes of the extended private key. |
| 78 | + /// |
| 79 | + /// # Returns |
| 80 | + /// |
| 81 | + /// Returns a 64 length bytes representing the extended secret key. |
| 82 | + U8Array64 get extendedSecretKey; |
| 83 | + |
| 84 | + /// Get the inner bytes. |
| 85 | + U8Array96 get inner; |
| 86 | + |
| 87 | + /// Create a new `XPrvBytes` from the given bytes. |
| 88 | + factory XPrvBytes({required U8Array96 xprvBytes}) => RustLib.instance.api |
| 89 | + .crateApiKeyDerivationXPrvBytesNew(xprvBytes: xprvBytes); |
| 90 | + |
| 91 | + /// Sign the given data with the given extended private key. |
| 92 | + /// |
| 93 | + /// # Arguments |
| 94 | + /// |
| 95 | + /// - `data`: The data to sign. |
| 96 | + /// |
| 97 | + /// # Returns |
| 98 | + /// Returns a 64 length bytes `SignatureBytes` representing the signature. |
| 99 | + /// |
| 100 | + /// # Errors |
| 101 | + /// |
| 102 | + /// Returns an error if the extended private key is invalid. |
| 103 | + Future<SignatureBytes> signData({required List<int> data}); |
| 104 | + |
| 105 | + /// Verify the signature on the given data using extended private key. |
| 106 | + /// |
| 107 | + /// # Arguments |
| 108 | + /// |
| 109 | + /// - `data`: The data to sign. |
| 110 | + /// - `signature`: The signature to check. |
| 111 | + /// |
| 112 | + /// # Returns |
| 113 | + /// Returns a boolean value indicating if the signature match the sign data |
| 114 | + /// True if the signature is valid and match the sign data, false otherwise. |
| 115 | + /// |
| 116 | + /// # Errors |
| 117 | + /// |
| 118 | + /// Returns an error if the extended private key or signature is invalid. |
| 119 | + Future<bool> verifySignature( |
| 120 | + {required List<int> data, required SignatureBytes signature}); |
| 121 | + |
| 122 | + /// Get extended public key from the given extended private key. |
| 123 | + /// |
| 124 | + /// # Returns |
| 125 | + /// |
| 126 | + /// Returns a 64 length bytes `XPubBytes` representing the extended public key. |
| 127 | + /// |
| 128 | + /// # Errors |
| 129 | + /// |
| 130 | + /// Returns an error if the extended private key is invalid. |
| 131 | + Future<XPubBytes> xpublicKey(); |
| 132 | +} |
| 133 | + |
| 134 | +// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<XPubBytes>> |
| 135 | +abstract class XPubBytes implements RustOpaqueInterface { |
| 136 | + /// Extract the chain code from the extended public key. |
| 137 | + /// The chain code is the last 32 bytes of the extended public key. |
| 138 | + /// |
| 139 | + /// # Returns |
| 140 | + /// |
| 141 | + /// Returns a 32 length bytes representing the chain code. |
| 142 | + U8Array32 get chainCode; |
| 143 | + |
| 144 | + /// Get the inner bytes. |
| 145 | + U8Array64 get inner; |
| 146 | + |
| 147 | + /// Extract the public key from the extended public key. |
| 148 | + /// The public key is the first 32 bytes of the extended public key. |
| 149 | + /// |
| 150 | + /// # Returns |
| 151 | + /// |
| 152 | + /// Returns a 32 length bytes representing the public key. |
| 153 | + U8Array32 get publicKey; |
| 154 | + |
| 155 | + /// Create a new `XPubBytes` from the given bytes. |
| 156 | + factory XPubBytes({required U8Array64 xpubBytes}) => RustLib.instance.api |
| 157 | + .crateApiKeyDerivationXPubBytesNew(xpubBytes: xpubBytes); |
| 158 | + |
| 159 | + /// Verify the signature on the given data using extended public key. |
| 160 | + /// |
| 161 | + /// # Arguments |
| 162 | + /// |
| 163 | + /// - `data`: The data to sign. |
| 164 | + /// - `signature`: The signature to check. |
| 165 | + /// |
| 166 | + /// # Returns |
| 167 | + /// Returns a boolean value indicating if the signature match the sign data |
| 168 | + /// True if the signature is valid and match the sign data, false otherwise. |
| 169 | + /// |
| 170 | + /// # Errors |
| 171 | + /// |
| 172 | + /// Returns an error if the extended public key or signature is invalid. |
| 173 | + Future<bool> verifySignature( |
| 174 | + {required List<int> data, required SignatureBytes signature}); |
| 175 | +} |
| 176 | + |
| 177 | +class U8Array32 extends NonGrowableListView<int> { |
| 178 | + static const arraySize = 32; |
| 179 | + |
| 180 | + @internal |
| 181 | + Uint8List get inner => _inner; |
| 182 | + final Uint8List _inner; |
| 183 | + |
| 184 | + U8Array32(this._inner) |
| 185 | + : assert(_inner.length == arraySize), |
| 186 | + super(_inner); |
| 187 | + |
| 188 | + U8Array32.init() : this(Uint8List(arraySize)); |
| 189 | +} |
| 190 | + |
| 191 | +class U8Array64 extends NonGrowableListView<int> { |
| 192 | + static const arraySize = 64; |
| 193 | + |
| 194 | + @internal |
| 195 | + Uint8List get inner => _inner; |
| 196 | + final Uint8List _inner; |
| 197 | + |
| 198 | + U8Array64(this._inner) |
| 199 | + : assert(_inner.length == arraySize), |
| 200 | + super(_inner); |
| 201 | + |
| 202 | + U8Array64.init() : this(Uint8List(arraySize)); |
| 203 | +} |
| 204 | + |
| 205 | +class U8Array96 extends NonGrowableListView<int> { |
| 206 | + static const arraySize = 96; |
| 207 | + |
| 208 | + @internal |
| 209 | + Uint8List get inner => _inner; |
| 210 | + final Uint8List _inner; |
| 211 | + |
| 212 | + U8Array96(this._inner) |
| 213 | + : assert(_inner.length == arraySize), |
| 214 | + super(_inner); |
| 215 | + |
| 216 | + U8Array96.init() : this(Uint8List(arraySize)); |
| 217 | +} |
0 commit comments