├── .gitattributes ├── .github └── workflows │ └── dart.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ └── main.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ ├── main.cc │ ├── my_application.cc │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── lib ├── base32 │ └── base32.dart ├── base58 │ ├── base58.dart │ ├── base58_base.dart │ ├── base58_ex.dart │ └── base58_xmr.dart ├── bech32 │ ├── bch_bech32.dart │ ├── bech32.dart │ ├── bech32_base.dart │ ├── bech32_ex.dart │ ├── bech32_utils.dart │ └── segwit_bech32.dart ├── bip │ ├── address │ │ ├── ada │ │ │ ├── ada.dart │ │ │ ├── ada_addres_type.dart │ │ │ ├── ada_byron_addr.dart │ │ │ ├── ada_shelley_addr.dart │ │ │ ├── gneric_addr_decoder.dart │ │ │ └── network.dart │ │ ├── addr_dec_utils.dart │ │ ├── addr_key_validator.dart │ │ ├── algo_addr.dart │ │ ├── aptos_addr.dart │ │ ├── atom_addr.dart │ │ ├── avax_addr.dart │ │ ├── bch_addr_converter.dart │ │ ├── decoder.dart │ │ ├── decoders.dart │ │ ├── egld_addr.dart │ │ ├── encoder.dart │ │ ├── encoders.dart │ │ ├── eos_addr.dart │ │ ├── ergo.dart │ │ ├── eth_addr.dart │ │ ├── exception │ │ │ └── exception.dart │ │ ├── fil_addr.dart │ │ ├── icx_addr.dart │ │ ├── inj_addr.dart │ │ ├── nano_addr.dart │ │ ├── near_addr.dart │ │ ├── neo_addr.dart │ │ ├── okex_addr.dart │ │ ├── one_addr.dart │ │ ├── p2pkh_addr.dart │ │ ├── p2sh_addr.dart │ │ ├── p2tr_addr.dart │ │ ├── p2wpkh_addr.dart │ │ ├── sol_addr.dart │ │ ├── substrate_addr.dart │ │ ├── sui.dart │ │ ├── ton_addr.dart │ │ ├── trx_addr.dart │ │ ├── xlm_addr.dart │ │ ├── xmr_addr.dart │ │ ├── xrp_addr.dart │ │ ├── xtz_addr.dart │ │ └── zil_addr.dart │ ├── algorand │ │ ├── algorand.dart │ │ └── mnemonic │ │ │ ├── algorand_entropy_generator.dart │ │ │ ├── algorand_mnemonic.dart │ │ │ ├── algorand_mnemonic_decoder.dart │ │ │ ├── algorand_mnemonic_encoder.dart │ │ │ ├── algorand_mnemonic_generator.dart │ │ │ ├── algorand_mnemonic_utils.dart │ │ │ ├── algorand_mnemonic_validator.dart │ │ │ └── algorand_seed_generator.dart │ ├── bip.dart │ ├── bip │ │ ├── bip.dart │ │ ├── bip32 │ │ │ ├── base │ │ │ │ ├── bip32_base.dart │ │ │ │ ├── ibip32_key_derivator.dart │ │ │ │ └── ibip32_mst_key_generator.dart │ │ │ ├── bip32.dart │ │ │ ├── bip32_const.dart │ │ │ ├── bip32_ex.dart │ │ │ ├── bip32_key_data.dart │ │ │ ├── bip32_key_net_ver.dart │ │ │ ├── bip32_key_ser.dart │ │ │ ├── bip32_keys.dart │ │ │ ├── bip32_path.dart │ │ │ ├── khalow │ │ │ │ ├── bip32_kholaw_ed25519.dart │ │ │ │ ├── bip32_kholaw_ed25519_key_derivator.dart │ │ │ │ ├── bip32_kholaw_key_derivator_base.dart │ │ │ │ └── bip32_kholaw_mst_key_generator.dart │ │ │ └── slip10 │ │ │ │ ├── bip32_slip10_ed25519.dart │ │ │ │ ├── bip32_slip10_ed25519_blake2b.dart │ │ │ │ ├── bip32_slip10_key_derivator.dart │ │ │ │ ├── bip32_slip10_mst_key_generator.dart │ │ │ │ ├── bip32_slip10_nist256p1.dart │ │ │ │ ├── bip32_slip10_nist256p1_hybrid.dart │ │ │ │ └── bip32_slip10_secp256k1.dart │ │ ├── bip38 │ │ │ ├── bip38.dart │ │ │ ├── bip38_addr.dart │ │ │ ├── bip38_base.dart │ │ │ ├── bip38_ec.dart │ │ │ └── bip38_no_ec.dart │ │ ├── bip39 │ │ │ ├── bip39.dart │ │ │ ├── bip39_entropy_generator.dart │ │ │ ├── bip39_mnemonic.dart │ │ │ ├── bip39_mnemonic_decoder.dart │ │ │ ├── bip39_mnemonic_encoder.dart │ │ │ ├── bip39_mnemonic_generator.dart │ │ │ ├── bip39_mnemonic_utils.dart │ │ │ ├── bip39_mnemonic_validator.dart │ │ │ ├── bip39_seed_generator.dart │ │ │ └── word_list │ │ │ │ ├── chinese_simplified.dart │ │ │ │ ├── chinese_traditional.dart │ │ │ │ ├── czech.dart │ │ │ │ ├── english.dart │ │ │ │ ├── french.dart │ │ │ │ ├── italian.dart │ │ │ │ ├── japanese.dart │ │ │ │ ├── korean.dart │ │ │ │ ├── languages.dart │ │ │ │ ├── portuguese.dart │ │ │ │ └── spanish.dart │ │ ├── bip44 │ │ │ ├── base │ │ │ │ ├── bip44_base.dart │ │ │ │ ├── bip44_base_ex.dart │ │ │ │ └── bip44_keys.dart │ │ │ ├── bip44.dart │ │ │ └── bip44_base.dart │ │ ├── bip49 │ │ │ ├── bip49.dart │ │ │ └── bip49_base.dart │ │ ├── bip84 │ │ │ ├── bip84.dart │ │ │ └── bip84_base.dart │ │ ├── bip86 │ │ │ ├── bip86.dart │ │ │ └── bip86_base.dart │ │ ├── conf │ │ │ ├── bip │ │ │ │ └── bip_coins.dart │ │ │ ├── bip44 │ │ │ │ ├── bip44_coins.dart │ │ │ │ └── bip44_conf.dart │ │ │ ├── bip49 │ │ │ │ ├── bip49_coins.dart │ │ │ │ └── bip49_conf.dart │ │ │ ├── bip84 │ │ │ │ ├── bip84_coins.dart │ │ │ │ └── bip84_conf.dart │ │ │ ├── bip86 │ │ │ │ ├── bip86_coins.dart │ │ │ │ └── bip86_conf.dart │ │ │ ├── bip_config.dart │ │ │ ├── config │ │ │ │ ├── bip_bitcoin_cash_conf.dart │ │ │ │ ├── bip_coin_conf.dart │ │ │ │ └── bip_litecoin_conf.dart │ │ │ ├── const │ │ │ │ └── bip_conf_const.dart │ │ │ └── core │ │ │ │ ├── coin_conf.dart │ │ │ │ └── coins.dart │ │ └── types │ │ │ └── types.dart │ ├── cardano │ │ ├── bip32 │ │ │ ├── cardano_byron_legacy_bip32.dart │ │ │ ├── cardano_byron_legacy_key_derivator.dart │ │ │ ├── cardano_byron_legacy_mst_key_generator.dart │ │ │ ├── cardano_icarus_bip32.dart │ │ │ └── cardano_icarus_mst_key_generator.dart │ │ ├── byron │ │ │ └── cardano_byron_legacy.dart │ │ ├── cardano.dart │ │ ├── cip1852 │ │ │ ├── cip1852.dart │ │ │ └── conf │ │ │ │ ├── cip1852_coins.dart │ │ │ │ └── cip1852_conf.dart │ │ ├── mnemonic │ │ │ ├── cardano_byron_legacy_seed_generator.dart │ │ │ └── cardano_icarus_seed_generator.dart │ │ └── shelley │ │ │ ├── cardano_shelley.dart │ │ │ └── cardano_shelley_keys.dart │ ├── coin_conf │ │ ├── config.dart │ │ ├── constant │ │ │ └── coins_conf.dart │ │ └── models │ │ │ ├── coin_conf.dart │ │ │ └── coins_name.dart │ ├── ecc │ │ ├── bip_ecc.dart │ │ ├── curve │ │ │ ├── elliptic_curve_getter.dart │ │ │ └── elliptic_curve_types.dart │ │ └── keys │ │ │ ├── ecdsa_keys.dart │ │ │ ├── ed25519_blake2b_keys.dart │ │ │ ├── ed25519_keys.dart │ │ │ ├── ed25519_kholaw_keys.dart │ │ │ ├── ed25519_monero_keys.dart │ │ │ ├── i_keys.dart │ │ │ ├── nist256p1_keys.dart │ │ │ ├── nist256p1_keys_hybrid.dart │ │ │ ├── secp256k1_keys_ecdsa.dart │ │ │ └── sr25519_keys.dart │ ├── electrum │ │ ├── electrum.dart │ │ ├── electrum_v1.dart │ │ ├── electrum_v2.dart │ │ ├── mnemonic_v1 │ │ │ ├── electrum_v1_entropy_generator.dart │ │ │ ├── electrum_v1_mnemonic.dart │ │ │ ├── electrum_v1_mnemonic_decoder.dart │ │ │ ├── electrum_v1_mnemonic_encoder.dart │ │ │ ├── electrum_v1_mnemonic_generator.dart │ │ │ ├── electrum_v1_mnemonic_utils.dart │ │ │ ├── electrum_v1_mnemonic_validator.dart │ │ │ ├── electrum_v1_seed_generator.dart │ │ │ └── wrodlist │ │ │ │ ├── english.dart │ │ │ │ └── languages.dart │ │ └── mnemonic_v2 │ │ │ ├── electrum_v2_entropy_generator.dart │ │ │ ├── electrum_v2_mnemonic.dart │ │ │ ├── electrum_v2_mnemonic_decoder.dart │ │ │ ├── electrum_v2_mnemonic_encoder.dart │ │ │ ├── electrum_v2_mnemonic_generator.dart │ │ │ ├── electrum_v2_mnemonic_utils.dart │ │ │ ├── electrum_v2_mnemonic_validator.dart │ │ │ └── electrum_v2_seed_generator.dart │ ├── mnemonic │ │ ├── entropy_generator.dart │ │ ├── mnemonic.dart │ │ ├── mnemonic_decoder_base.dart │ │ ├── mnemonic_encoder_base.dart │ │ ├── mnemonic_ex.dart │ │ ├── mnemonic_utils.dart │ │ └── mnemonic_validator.dart │ ├── monero │ │ ├── conf │ │ │ ├── monero_coin_conf.dart │ │ │ ├── monero_coins.dart │ │ │ └── monero_conf.dart │ │ ├── mnemonic │ │ │ ├── monero_entropy_generator.dart │ │ │ ├── monero_mnemonic.dart │ │ │ ├── monero_mnemonic_decoder.dart │ │ │ ├── monero_mnemonic_encoder.dart │ │ │ ├── monero_mnemonic_generator.dart │ │ │ ├── monero_mnemonic_utils.dart │ │ │ ├── monero_mnemonic_validator.dart │ │ │ ├── monero_seed_generator.dart │ │ │ └── words_list │ │ │ │ ├── chinese_simplified.dart │ │ │ │ ├── dutch.dart │ │ │ │ ├── english.dart │ │ │ │ ├── french.dart │ │ │ │ ├── german.dart │ │ │ │ ├── italian.dart │ │ │ │ ├── japanese.dart │ │ │ │ ├── languages.dart │ │ │ │ ├── portuguese.dart │ │ │ │ ├── russian.dart │ │ │ │ └── spanish.dart │ │ ├── monero.dart │ │ ├── monero_base.dart │ │ ├── monero_exc.dart │ │ └── monero_subaddr.dart │ ├── slip │ │ ├── slip.dart │ │ ├── slip173 │ │ │ └── slip173.dart │ │ ├── slip32 │ │ │ ├── slip32.dart │ │ │ └── slip32_key_net_ver.dart │ │ └── slip44 │ │ │ └── slip44.dart │ ├── substrate │ │ ├── conf │ │ │ ├── substrate_coin_conf.dart │ │ │ ├── substrate_coins.dart │ │ │ └── substrate_conf.dart │ │ ├── core │ │ │ └── substrate_base.dart │ │ ├── exception │ │ │ └── substrate_ex.dart │ │ ├── keys │ │ │ └── substrate_keys.dart │ │ ├── path │ │ │ └── substrate_path.dart │ │ ├── scale │ │ │ ├── substrate_scale_enc_base.dart │ │ │ ├── substrate_scale_enc_bytes.dart │ │ │ ├── substrate_scale_enc_cuint.dart │ │ │ └── substrate_scale_enc_uint.dart │ │ └── substrate.dart │ ├── ton │ │ ├── mnemonic │ │ │ ├── ton_entropy_generator.dart │ │ │ ├── ton_mnemonic_encoder.dart │ │ │ ├── ton_mnemonic_generator.dart │ │ │ ├── ton_mnemonic_language.dart │ │ │ ├── ton_mnemonic_validator.dart │ │ │ └── ton_seed_generator.dart │ │ └── ton.dart │ └── wif │ │ └── wif.dart ├── blockchain_utils.dart ├── cbor │ ├── cbor.dart │ ├── core │ │ ├── cbor.dart │ │ └── tags.dart │ ├── exception │ │ └── exception.dart │ ├── extention │ │ └── extenton.dart │ ├── types │ │ ├── base.dart │ │ ├── bigfloat.dart │ │ ├── bigint.dart │ │ ├── boolean.dart │ │ ├── bytes.dart │ │ ├── cbor_tag.dart │ │ ├── datetime.dart │ │ ├── decimal.dart │ │ ├── double.dart │ │ ├── int.dart │ │ ├── int64.dart │ │ ├── list.dart │ │ ├── map.dart │ │ ├── mime.dart │ │ ├── null.dart │ │ ├── regex.dart │ │ ├── set.dart │ │ ├── string.dart │ │ ├── types.dart │ │ └── url.dart │ └── utils │ │ ├── cbor_utils.dart │ │ ├── dynamic_bytes.dart │ │ ├── extentions.dart │ │ └── float_utils.dart ├── crypto │ ├── crypto │ │ ├── aead │ │ │ └── aead.dart │ │ ├── aes │ │ │ ├── aes.dart │ │ │ ├── aes_lib.dart │ │ │ └── padding.dart │ │ ├── blockcipher │ │ │ └── blockcipher.dart │ │ ├── cdsa │ │ │ ├── cdsa.dart │ │ │ ├── crypto_ops │ │ │ │ ├── const │ │ │ │ │ └── const.dart │ │ │ │ ├── crypto_ops.dart │ │ │ │ ├── exception │ │ │ │ │ └── exception.dart │ │ │ │ ├── models │ │ │ │ │ └── models.dart │ │ │ │ └── operations │ │ │ │ │ └── ops.dart │ │ │ ├── curve │ │ │ │ ├── curve.dart │ │ │ │ └── curves.dart │ │ │ ├── ecdsa │ │ │ │ ├── private_key.dart │ │ │ │ ├── public_key.dart │ │ │ │ └── signature.dart │ │ │ ├── eddsa │ │ │ │ ├── keys.dart │ │ │ │ └── keys │ │ │ │ │ ├── privatekey.dart │ │ │ │ │ └── publickey.dart │ │ │ ├── musig2 │ │ │ │ ├── constants │ │ │ │ │ └── const.dart │ │ │ │ ├── exception │ │ │ │ │ └── exception.dart │ │ │ │ ├── musig2.dart │ │ │ │ ├── musig2 │ │ │ │ │ └── musig2.dart │ │ │ │ ├── types │ │ │ │ │ └── types.dart │ │ │ │ └── utils │ │ │ │ │ └── utils.dart │ │ │ ├── point │ │ │ │ ├── base.dart │ │ │ │ ├── ec_projective_point.dart │ │ │ │ ├── edwards.dart │ │ │ │ ├── point.dart │ │ │ │ └── ristretto_point.dart │ │ │ ├── rfc6979 │ │ │ │ └── rfc6979.dart │ │ │ ├── secp256k1 │ │ │ │ ├── constants │ │ │ │ │ ├── constants.dart │ │ │ │ │ └── tables.dart │ │ │ │ ├── impl │ │ │ │ │ └── secp256k1.dart │ │ │ │ ├── secp256k1.dart │ │ │ │ └── types │ │ │ │ │ └── types.dart │ │ │ └── utils │ │ │ │ ├── ed25519.dart │ │ │ │ ├── ristretto.dart │ │ │ │ ├── secp256k1.dart │ │ │ │ └── utils.dart │ │ ├── chacha │ │ │ └── chacha.dart │ │ ├── chacha20poly1305 │ │ │ └── chacha20poly1305.dart │ │ ├── crc16 │ │ │ └── crc16.dart │ │ ├── crc32 │ │ │ └── crc32.dart │ │ ├── crypto.dart │ │ ├── ctr │ │ │ └── ctr.dart │ │ ├── ecb │ │ │ └── ecb.dart │ │ ├── exception │ │ │ └── exception.dart │ │ ├── gcm │ │ │ └── gcm.dart │ │ ├── hash │ │ │ ├── black2b │ │ │ │ └── black2b.dart │ │ │ ├── hash.dart │ │ │ ├── keccack │ │ │ │ └── sha3.dart │ │ │ ├── md4 │ │ │ │ └── md4.dart │ │ │ ├── md5 │ │ │ │ └── md5.dart │ │ │ ├── ridemp │ │ │ │ └── ridemp.dart │ │ │ ├── sha1 │ │ │ │ └── sha1.dart │ │ │ ├── sha224 │ │ │ │ └── sha224.dart │ │ │ ├── sha256 │ │ │ │ └── sha256.dart │ │ │ ├── sha384 │ │ │ │ └── sha384.dart │ │ │ ├── sha512 │ │ │ │ └── sha512.dart │ │ │ ├── sha512_256 │ │ │ │ └── sh512256.dart │ │ │ └── xxhash64 │ │ │ │ └── xxhash64.dart │ │ ├── hmac │ │ │ └── hmac.dart │ │ ├── pbkdf2 │ │ │ └── pbkdf2.dart │ │ ├── poly1305 │ │ │ └── poly1305.dart │ │ ├── prng │ │ │ ├── fortuna.dart │ │ │ └── gamma.dart │ │ ├── schnorrkel │ │ │ ├── keys │ │ │ │ └── keys.dart │ │ │ ├── merlin │ │ │ │ └── transcript.dart │ │ │ ├── shnorrkel.dart │ │ │ └── strobe │ │ │ │ └── strobe.dart │ │ ├── scrypt │ │ │ └── scrypt.dart │ │ └── x_modem_crc │ │ │ └── x_modem_crc.dart │ └── quick_crypto.dart ├── double │ ├── codec │ │ ├── double_utils.dart │ │ └── float_utils.dart │ └── double_codec.dart ├── exception │ ├── const │ │ └── const.dart │ ├── exception │ │ ├── exception.dart │ │ └── rpc_error.dart │ └── exceptions.dart ├── helper │ ├── extensions │ │ └── extensions.dart │ └── helper.dart ├── hex │ └── hex.dart ├── layout │ ├── byte │ │ ├── byte_handler.dart │ │ ├── reader.dart │ │ └── writer.dart │ ├── constant │ │ └── constant.dart │ ├── core │ │ ├── core.dart │ │ ├── core │ │ │ └── core.dart │ │ └── types │ │ │ ├── array.dart │ │ │ ├── bit_sequence.dart │ │ │ ├── compact.dart │ │ │ ├── compact_bytes.dart │ │ │ ├── compact_layout.dart │ │ │ ├── constant.dart │ │ │ ├── coption_layout.dart │ │ │ ├── custom_layout.dart │ │ │ ├── lazy_struct.dart │ │ │ ├── lazy_union.dart │ │ │ ├── leb128.dart │ │ │ ├── leb128_offset.dart │ │ │ ├── map.dart │ │ │ ├── none.dart │ │ │ ├── numeric.dart │ │ │ ├── optional_layout.dart │ │ │ ├── padding_layout.dart │ │ │ ├── raw.dart │ │ │ ├── struct.dart │ │ │ ├── tuple_layout.dart │ │ │ ├── union.dart │ │ │ └── xdr_bytes.dart │ ├── exception │ │ └── exception.dart │ ├── layout.dart │ └── utils │ │ └── utils.dart ├── secret_wallet │ ├── exception.dart │ └── web3_storage_defination.dart ├── service │ ├── const │ │ └── constant.dart │ ├── models │ │ └── params.dart │ ├── service.dart │ └── utils │ │ └── utils.dart ├── signer │ ├── bitcoin │ │ ├── bitcoin_key_signer.dart │ │ └── bitcoin_signer.dart │ ├── cardano │ │ └── cardano_signer.dart │ ├── const │ │ └── constants.dart │ ├── ed25519 │ │ └── ed25519.dart │ ├── eth │ │ └── eth_signer.dart │ ├── exception │ │ └── signing_exception.dart │ ├── secp256k1 │ │ └── secp256k1_signer.dart │ ├── secp256r1 │ │ └── secp256r1_signer.dart │ ├── signer.dart │ ├── signing_key │ │ └── ecdsa_signing_key.dart │ ├── substrate │ │ ├── core │ │ │ ├── signer.dart │ │ │ └── verifier.dart │ │ ├── signers │ │ │ ├── substrate_ecdsa.dart │ │ │ ├── substrate_eddsa.dart │ │ │ └── substrate_sr25519.dart │ │ └── substrate.dart │ ├── tron │ │ └── tron_signer.dart │ ├── types │ │ ├── eth_signature.dart │ │ └── types.dart │ ├── utils │ │ └── utils.dart │ └── xrp │ │ └── xrp_signer.dart ├── ss58 │ ├── ss58.dart │ ├── ss58_base.dart │ └── ss58_ex.dart ├── utils │ ├── binary │ │ ├── binary_operation.dart │ │ ├── bit_utils.dart │ │ ├── bytes_tracker.dart │ │ └── utils.dart │ ├── compare │ │ ├── compare.dart │ │ └── hash_code.dart │ ├── equatable │ │ └── equatable.dart │ ├── numbers │ │ ├── numbers.dart │ │ ├── rational │ │ │ └── big_rational.dart │ │ └── utils │ │ │ ├── bigint_utils.dart │ │ │ └── int_utils.dart │ ├── string │ │ └── string.dart │ ├── tuple │ │ └── tuple.dart │ └── utils.dart └── uuid │ └── uuid.dart ├── pubspec.yaml └── test ├── address ├── ada_byron │ ├── byron_test.dart │ ├── byron_test_vector.dart │ └── lagacy_test_vector.dart ├── ada_shelly │ ├── ada_shelly_test.dart │ ├── stacking_test_vector.dart │ └── test_vector.dart ├── algo │ ├── algo_test.dart │ └── test_vector.dart ├── aptos │ ├── aptos_test.dart │ └── test_vector.dart ├── atom │ ├── atom_test.dart │ └── test_vector.dart ├── avax │ ├── avax_test.dart │ ├── test_p_vector.dart │ └── test_x_vector.dart ├── bch_p2pkh │ ├── bch_p2pkh_test.dart │ └── test_vector.dart ├── bch_p2sh │ ├── bch_p2sh_test.dart │ └── test_vector.dart ├── egld │ ├── egld_test.dart │ └── test_vector.dart ├── eos │ ├── eos_test.dart │ └── test_vector.dart ├── ergo │ ├── ergo_test.dart │ └── test_vector.dart ├── eth │ ├── eth_test.dart │ └── test_vector.dart ├── fil │ ├── fil_test.dart │ └── test_vector.dart ├── icx │ ├── icx_test.dart │ └── test_vector.dart ├── inj │ ├── inj_test.dart │ └── test_vector.dart ├── nano │ ├── nano_test.dart │ └── test_vector.dart ├── near │ ├── near_test.dart │ └── test_vector.dart ├── neo │ ├── neo_test.dart │ └── test_vector.dart ├── okex │ ├── okex_test.dart │ └── test_vector.dart ├── one │ ├── one_test.dart │ └── test_vector.dart ├── p2pkh │ ├── comperesed_test_vector.dart │ ├── p2pkh_test.dart │ └── uncompresed_test_vector.dart ├── p2sh │ ├── p2sh_test.dart │ └── test_vector.dart ├── p2tr │ ├── p2tr_test.dart │ └── test_vector.dart ├── p2wpkh │ ├── p2wpkh_test.dart │ └── test_vector.dart ├── sol │ ├── sol_test.dart │ └── test_vector.dart ├── substrate │ ├── substrate_test.dart │ └── test_vector.dart ├── sui │ ├── sui_test.dart │ └── test_vector.dart ├── ton │ ├── address_test.dart │ └── test_vector.dart ├── trx │ ├── test_vector.dart │ └── trx_test.dart ├── xlm │ ├── test_vector.dart │ └── xml_test.dart ├── xmr │ ├── test_vector.dart │ ├── test_vector_integrate.dart │ └── xmr_test.dart ├── xrp │ ├── test_vector.dart │ └── xrp_test.dart ├── xtz │ ├── test_vector.dart │ └── xtz_test.dart └── zil │ ├── test_vector.dart │ └── zil_test.dart ├── algorand ├── mnemonic_test.dart └── test_vector.dart ├── base58 ├── base58_test.dart └── base58_xmr_test.dart ├── bech32 ├── bch_bech32_test.dart ├── bech32_test.dart └── segwit_bech32_test.dart ├── bip ├── bip32 │ ├── ed25519 │ │ ├── ed25519_test.dart │ │ └── test_vector.dart │ ├── ed25519_blake2b │ │ ├── ed25519_blake2b_test.dart │ │ └── test_vector.dart │ ├── ed25519_khalow │ │ ├── ed25519_khalow_test.dart │ │ └── test_vector.dart │ ├── nist256p1 │ │ ├── nist256p1_test.dart │ │ └── test_vector.dart │ └── secp256k1 │ │ ├── secp256k1_test.dart │ │ └── test_vector.dart ├── bip38 │ ├── bip38_addr_test.dart │ ├── bip38_ec_test.dart │ └── bip38_no_ec_test.dart ├── bip39 │ ├── bip39_test.dart │ └── test_vector.dart ├── bip44 │ ├── bip44_test.dart │ └── test_vector.dart ├── bip49 │ ├── bip49_test.dart │ └── test_vector.dart ├── bip84 │ ├── bip84_test.dart │ └── test_vector.dart └── bip86 │ ├── bip86_test.dart │ └── test_vector.dart ├── cardano ├── bip32 │ ├── icarus_test.dart │ ├── icarus_test_vector.dart │ ├── legacy_test.dart │ └── test_vector.dart ├── byron │ ├── byron_lagacy_test.dart │ └── test_vector.dart ├── cip1852 │ ├── cip1852_test.dart │ └── test_vector.dart ├── mnemonic │ ├── mnemonic_test.dart │ └── test_vector.dart └── shelly │ ├── shelly_test.dart │ └── test_vector.dart ├── cbor_test.dart ├── crypto ├── aes │ ├── aes_ctr_test.dart │ └── test_vector.dart ├── blake2b │ ├── blake2b_test.dart │ └── test_vector.dart ├── chacha20_poly1305 │ ├── chacha20_poly1305_test.dart │ └── test_vector.dart ├── crc32 │ ├── crc32_test.dart │ └── test_vector.dart ├── hmac │ ├── hmac_test.dart │ └── test_vector.dart ├── keccack │ ├── keccack_test.dart │ └── test_vector.dart ├── md4 │ ├── md4_test.dart │ └── test_vector.dart ├── md5 │ ├── md5_test.dart │ └── test_vector.dart ├── pbkdf2 │ ├── pbkdf2_test.dart │ └── test_vector.dart ├── ripemd │ ├── ripemd_test.dart │ └── test_vector.dart ├── scrypt │ ├── scrypt_test.dart │ └── test_vector.dart ├── sha1 │ ├── sha1_test.dart │ └── test_vector.dart ├── sha256 │ ├── sha256_test.dart │ └── test_vector.dart ├── sha3 │ ├── sha3_test.dart │ └── test_vector.dart ├── sha512 │ ├── sha512_test.dart │ └── test_vector.dart ├── sha512_256 │ ├── sha512_256_test.dart │ └── test_vector.dart ├── shake │ ├── shake_test.dart │ ├── test_vector_128.dart │ └── test_vector_256.dart ├── x_modem_crc │ ├── test_vector.dart │ └── x_modem_crc_test.dart └── xxhash64 │ ├── test_vector.dart │ └── xxhash64_test.dart ├── ecdsa ├── ed_test.dart └── projective_test.dart ├── elctrum ├── mnemonic │ ├── mnemonic_test.dart │ ├── test_vector_v1.dart │ └── test_vector_v2.dart ├── v1 │ ├── test_vectors.dart │ └── v1_test.dart └── v2 │ ├── segwit_test_vector.dart │ ├── test_vector.dart │ └── v2_test.dart ├── monero ├── mnemonic │ ├── monero_mnemonic_test.dart │ └── test_vector.dart ├── monero_test.dart └── test_vector.dart ├── musig2 ├── det_sign_vector.dart ├── det_sign_verify_test.dart ├── geneare_nonce_test.dart ├── generate_key_agg_test.dart ├── nonce_agg_test.dart ├── nonce_agg_test_vector.dart ├── nonce_vector.dart ├── sig_agg_test.dart ├── sig_agg_vector.dart ├── sign_verify_test.dart ├── sign_verify_vector.dart └── test_vector.dart ├── quick_hex.dart ├── schnorrkel ├── derive_public_vector.dart ├── derive_test.dart ├── derive_test_vector.dart ├── key_test_vector.dart ├── schnorrkel_key_test.dart ├── sign_test.dart ├── sign_test_vector.dart ├── vrf2_test.dart └── vrf_test_vector.dart ├── secp256k1 ├── field_test.dart ├── group_test.dart ├── inv_test.dart ├── mult_test.dart ├── scalar_test.dart ├── test_constants.dart └── tools.dart ├── secure_storage_test.dart ├── signer ├── bitcoin_test.dart ├── ed25519_test.dart ├── ethereum_test.dart ├── tron_test.dart └── xrp_test.dart ├── ss58 └── ss58_test.dart ├── substrate ├── scale_test.dart ├── substrate_test.dart └── test_vector.dart ├── ton └── mnemonic_test.dart ├── uuid_test.dart └── wif └── wif_test.dart /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | lib.zip 32 | *.zip 33 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "2524052335ec76bb03e04ede244b071f1b86d190" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/tools/linter-rules. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/tools/analysis -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | plugins { 14 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 15 | } 16 | } 17 | 18 | include ":app" 19 | 20 | apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" 21 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | 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. -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrtnetwork/blockchain_utils/9b93cad983328a88b62824448e019d6f044696a2/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /lib/base58/base58.dart: -------------------------------------------------------------------------------- 1 | /// Library for working with Base58 encoding. 2 | library; 3 | 4 | /// Export statement for the core functionality of Base58 encoding. 5 | export 'base58_base.dart'; 6 | 7 | /// Export statement for Base58 encoding with Monero (XMR) support. 8 | export 'base58_xmr.dart'; 9 | -------------------------------------------------------------------------------- /lib/base58/base58_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// An exception class representing an error related to Base58 checksum validation. 4 | class Base58ChecksumError extends BlockchainUtilsException { 5 | /// Constructor for creating a Base58ChecksumError with an optional error message. 6 | const Base58ChecksumError(super.message, {super.details}); 7 | } 8 | -------------------------------------------------------------------------------- /lib/bech32/bech32.dart: -------------------------------------------------------------------------------- 1 | /// Library for working with Bech32 encoding. 2 | library; 3 | 4 | /// Export statement for the core Bech32 functionality. 5 | export 'bech32_base.dart'; 6 | 7 | /// Export statement for Bech32 utility functions. 8 | export 'bech32_utils.dart'; 9 | 10 | /// Export statement for Bech32 encoding specific to Bitcoin Cash (BCH). 11 | export 'bch_bech32.dart'; 12 | 13 | /// Export statement for Segregated Witness (SegWit) Bech32 encoding. 14 | export 'segwit_bech32.dart'; 15 | -------------------------------------------------------------------------------- /lib/bech32/bech32_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// An exception class representing errors related to Bech32 checksum validation. 4 | class Bech32ChecksumError extends BlockchainUtilsException { 5 | /// The error message associated with this checksum error. 6 | const Bech32ChecksumError(super.message, {super.details}); 7 | } 8 | -------------------------------------------------------------------------------- /lib/bip/address/ada/ada.dart: -------------------------------------------------------------------------------- 1 | export 'ada_addres_type.dart'; 2 | export 'ada_byron_addr.dart'; 3 | export 'ada_shelley_addr.dart'; 4 | export 'gneric_addr_decoder.dart'; 5 | export 'network.dart'; 6 | -------------------------------------------------------------------------------- /lib/bip/address/bch_addr_converter.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bech32/bch_bech32.dart'; 2 | 3 | /// Bitcoin Cash address converter class. 4 | /// It allows to convert a Bitcoin Cash address by changing its HRP and net version. 5 | class BchAddrConverter { 6 | /// Convert a Bitcoin Cash address by changing its HRP and net version. 7 | static String convert(String address, String hrp, List? netVer) { 8 | // Decode address 9 | final decode = BchBech32Decoder.decode( 10 | address.substring(0, address.indexOf(":")), address); 11 | final currNetVer = decode.item1; 12 | final data = decode.item2; 13 | // Encode again with new HRP and net version 14 | return BchBech32Encoder.encode(hrp, netVer ?? currNetVer, data); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/bip/address/decoder.dart: -------------------------------------------------------------------------------- 1 | /// An abstract class for decoding blockchain addresses. 2 | abstract class BlockchainAddressDecoder { 3 | /// Decodes a given blockchain address string. 4 | /// 5 | /// This method takes an address string and optional keyword arguments (kwargs) 6 | /// and decodes it into a List representing the decoded address. 7 | /// 8 | /// - [addr]: The blockchain address string to be decoded. 9 | /// - [kwargs]: Optional keyword arguments that can be used for configuration. 10 | /// 11 | /// Returns a List containing the decoded blockchain address. 12 | List decodeAddr(String addr, [Map kwargs = const {}]); 13 | } 14 | -------------------------------------------------------------------------------- /lib/bip/address/encoder.dart: -------------------------------------------------------------------------------- 1 | /// An abstract class for encoding blockchain addresses. 2 | /// 3 | /// This abstract class defines a common interface for encoding blockchain addresses. 4 | /// Subclasses of this class will implement specific encoding algorithms for different 5 | /// blockchain networks. 6 | abstract class BlockchainAddressEncoder { 7 | /// Encodes a public key into a blockchain address. 8 | /// 9 | /// This method takes a public key in the form of a List and optional keyword 10 | /// arguments (kwargs) for additional configuration if required. It encodes the 11 | /// public key into a blockchain-specific address. 12 | /// 13 | /// - [pubKey]: The public key to be encoded as a blockchain address. 14 | /// - [kwargs]: Optional keyword arguments for encoder-specific options. 15 | /// 16 | /// Returns the blockchain address string representing the encoded public key. 17 | String encodeKey(List pubKey, [Map kwargs = const {}]); 18 | } 19 | -------------------------------------------------------------------------------- /lib/bip/address/exception/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | class AddressConverterException extends BlockchainUtilsException { 4 | const AddressConverterException(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/bip/algorand/algorand.dart: -------------------------------------------------------------------------------- 1 | // This library, 'algorand_mnemonic', provides a comprehensive set of tools 2 | // for working with Algorand mnemonics, a critical component in the Algorand 3 | // blockchain ecosystem. 4 | 5 | library; 6 | 7 | // Export statement for the entropy generator module. 8 | export 'mnemonic/algorand_entropy_generator.dart'; 9 | 10 | // Export statement for the Algorand mnemonic class. 11 | export 'mnemonic/algorand_mnemonic.dart'; 12 | 13 | // Export statement for the mnemonic decoder module. 14 | export 'mnemonic/algorand_mnemonic_decoder.dart'; 15 | 16 | // Export statement for the mnemonic encoder module. 17 | export 'mnemonic/algorand_mnemonic_encoder.dart'; 18 | 19 | // Export statement for the mnemonic generator module. 20 | export 'mnemonic/algorand_mnemonic_generator.dart'; 21 | 22 | // Export statement for the mnemonic utility functions module. 23 | export 'mnemonic/algorand_mnemonic_utils.dart'; 24 | 25 | // Export statement for the seed generator module. 26 | export 'mnemonic/algorand_seed_generator.dart'; 27 | 28 | // Export statement for the mnemonic validator module. 29 | export 'mnemonic/algorand_mnemonic_validator.dart'; 30 | -------------------------------------------------------------------------------- /lib/bip/algorand/mnemonic/algorand_mnemonic_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/algorand/mnemonic/algorand_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/algorand/mnemonic/algorand_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_validator.dart'; 4 | 5 | /// A validator for Algorand mnemonic phrases. 6 | class AlgorandMnemonicValidator extends MnemonicValidator { 7 | /// The [AlgorandMnemonicValidator] class is used to validate Algorand 8 | /// mnemonic phrases. It utilizes the [AlgorandMnemonicDecoder] to decode the 9 | /// mnemonic and verify its integrity. 10 | /// 11 | /// Example usage: 12 | /// 13 | /// ```dart 14 | /// final validator = AlgorandMnemonicValidator(AlgorandLanguages.english); 15 | /// final isValid = validator.isValidMnemonic("your mnemonic phrase here"); 16 | /// ``` 17 | /// 18 | /// The [isValid] method can be used to check the validity of a given 19 | /// mnemonic phrase. 20 | AlgorandMnemonicValidator( 21 | [AlgorandLanguages? language = AlgorandLanguages.english]) 22 | : super(AlgorandMnemonicDecoder(language)); 23 | } 24 | -------------------------------------------------------------------------------- /lib/bip/bip.dart: -------------------------------------------------------------------------------- 1 | library; 2 | 3 | /// Export for cryptocurrency address encoding utilities. 4 | export 'address/encoders.dart'; 5 | 6 | /// Export for cryptocurrency address decoding utilities. 7 | export 'address/decoders.dart'; 8 | 9 | /// Export for Algorand blockchain-specific utilities. 10 | export 'algorand/algorand.dart'; 11 | 12 | /// Export for BIP (Bitcoin Improvement Proposals) utilities. 13 | export 'bip/bip.dart'; 14 | 15 | /// Export for Cardano blockchain-specific utilities. 16 | export 'cardano/cardano.dart'; 17 | 18 | /// Export for Electrum wallet and mnemonic utilities. 19 | export 'electrum/electrum.dart'; 20 | 21 | /// Export for Monero-specific utilities, including mnemonics. 22 | export 'monero/monero.dart'; 23 | 24 | /// Export for Substrate blockchain-specific utilities. 25 | export 'substrate/substrate.dart'; 26 | 27 | /// Export for Wallet Import Format (WIF) encoding and decoding utilities. 28 | export 'wif/wif.dart'; 29 | 30 | /// Exports modules related to ECC (Elliptic Curve Cryptography) in the context of BIP. 31 | export 'ecc/bip_ecc.dart'; 32 | 33 | /// Exports utility functions related to TON mnemonic. 34 | export 'ton/ton.dart'; 35 | 36 | /// Exports utility functions related to mnemonic. 37 | export 'mnemonic/mnemonic.dart'; 38 | 39 | /// config of every bip coin 40 | export 'coin_conf/config.dart'; 41 | 42 | export 'slip/slip.dart'; 43 | -------------------------------------------------------------------------------- /lib/bip/bip/bip32/base/ibip32_key_derivator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip32/bip32_key_data.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip32/bip32_keys.dart'; 3 | import 'package:blockchain_utils/bip/ecc/curve/elliptic_curve_types.dart'; 4 | import 'package:blockchain_utils/utils/utils.dart'; 5 | 6 | /// An abstract class that defines methods for BIP-32 key derivation. 7 | /// 8 | /// This class outlines key derivation methods for both public and private keys 9 | /// in the context of BIP-32 hierarchical deterministic keys. 10 | abstract class IBip32KeyDerivator { 11 | /// Checks if public key derivation is supported. 12 | bool isPublicDerivationSupported(); 13 | 14 | /// Derives a child private key from the given private and public keys. 15 | /// 16 | /// The [privKey] parameter represents the parent private key, [pubKey] is the 17 | /// parent public key, [index] specifies the child key index, and [type] is the 18 | /// elliptic curve type.Tuple 19 | Tuple, List> ckdPriv(Bip32PrivateKey privKey, 20 | Bip32PublicKey pubKey, Bip32KeyIndex index, EllipticCurveTypes type); 21 | 22 | /// Derives a child public key from the given public key. 23 | /// 24 | /// The [pubKey] parameter represents the parent public key, [index] specifies 25 | /// the child key index, and [type] is the elliptic curve type. 26 | Tuple, List> ckdPub( 27 | Bip32PublicKey pubKey, Bip32KeyIndex index, EllipticCurveTypes type); 28 | } 29 | -------------------------------------------------------------------------------- /lib/bip/bip/bip32/base/ibip32_mst_key_generator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | 3 | /// An abstract class that defines a method for generating master keys from a seed. 4 | /// 5 | /// This class outlines a method for generating BIP-32 master keys from seed bytes. 6 | abstract class IBip32MstKeyGenerator { 7 | /// Generates master keys from the given [seedBytes]. 8 | /// 9 | /// The [seedBytes] parameter represents the seed data from which master keys are derived. 10 | /// The method returns a pair of [List] objects containing the private and public keys. 11 | Tuple, List> generateFromSeed(List seedBytes); 12 | } 13 | -------------------------------------------------------------------------------- /lib/bip/bip/bip32/bip32_const.dart: -------------------------------------------------------------------------------- 1 | import 'bip32_key_net_ver.dart'; 2 | 3 | /// The `Bip32Const` class defines constants for different Bip32KeyNetVersions. 4 | class Bip32Const { 5 | /// mainnet key net version 6 | static final Bip32KeyNetVersions mainNetKeyNetVersions = Bip32KeyNetVersions( 7 | List.from([0x04, 0x88, 0xb2, 0x1e]), 8 | List.from([0x04, 0x88, 0xad, 0xe4])); 9 | 10 | /// testnet key network version 11 | static final Bip32KeyNetVersions testNetKeyNetVersions = Bip32KeyNetVersions( 12 | List.from([0x04, 0x35, 0x87, 0xcf]), 13 | List.from([0x04, 0x35, 0x83, 0x94])); 14 | 15 | /// kholaw key net version 16 | static Bip32KeyNetVersions kholawKeyNetVersions = Bip32KeyNetVersions( 17 | List.from([0x04, 0x88, 0xb2, 0x1e]), 18 | List.from([0x0f, 0x43, 0x31, 0xd4])); 19 | } 20 | -------------------------------------------------------------------------------- /lib/bip/bip/bip32/bip32_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// The `Bip32KeyError` class represents an exception that can be thrown in case 4 | /// of a key-related error during Bip32 key operations. It allows you to provide 5 | /// an optional error message to describe the specific issue. When caught, you 6 | /// can access the error message using the `toString()` method or the `message` 7 | /// property, if provided. 8 | class Bip32KeyError extends BlockchainUtilsException { 9 | const Bip32KeyError(super.message, {super.details}); 10 | } 11 | 12 | /// The `Bip32PathError` class represents an exception that can be thrown in case 13 | /// of a path-related error during Bip32 operations. It is designed to handle 14 | /// errors associated with hierarchical deterministic paths. You can include 15 | /// an optional error message to describe the specific issue. To access the error 16 | /// message, use the `toString()` method or the `message` property, if provided. 17 | class Bip32PathError extends BlockchainUtilsException { 18 | const Bip32PathError(super.message, {super.details}); 19 | } 20 | -------------------------------------------------------------------------------- /lib/bip/bip/bip32/bip32_key_net_ver.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | import 'package:blockchain_utils/helper/helper.dart'; 3 | 4 | /// Contains constants related to BIP32 key network versions. 5 | class Bip32KeyNetVersionsConst { 6 | /// The byte length of a BIP32 key network version. 7 | static const int keyNetVersionByteLen = 4; 8 | } 9 | 10 | class Bip32KeyNetVersions { 11 | late final List _pubNetVer; 12 | late final List _privNetVer; 13 | Bip32KeyNetVersions._(this._pubNetVer, this._privNetVer); 14 | 15 | /// constractur for Bip32KeyNetVersions 16 | factory Bip32KeyNetVersions(List pubNetVer, List privNetVer) { 17 | if (pubNetVer.length != length || privNetVer.length != length) { 18 | throw const ArgumentException("Invalid key net version length"); 19 | } 20 | return Bip32KeyNetVersions._( 21 | pubNetVer.asImmutableBytes, privNetVer.asImmutableBytes); 22 | } 23 | 24 | /// Get the key net version length. 25 | static int get length { 26 | return Bip32KeyNetVersionsConst.keyNetVersionByteLen; 27 | } 28 | 29 | /// Get public net version. 30 | List get public { 31 | return List.from(_pubNetVer); 32 | } 33 | 34 | /// Get private net version. 35 | List get private { 36 | return List.from(_privNetVer); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/bip/bip/bip38/bip38.dart: -------------------------------------------------------------------------------- 1 | /// The 'bip38' library provides tools for working with BIP-38, a standard for 2 | /// encrypting and decrypting private keys in a human-readable format. 3 | library; 4 | 5 | /// Export statement for BIP-38 address-related functions and utilities. 6 | export 'bip38_addr.dart'; 7 | 8 | /// Export statement for the BIP-38 base implementation. 9 | export 'bip38_base.dart'; 10 | 11 | /// Export statement for BIP-38 functions related to elliptic curve cryptography. 12 | export 'bip38_ec.dart'; 13 | 14 | /// Export statement for BIP-38 functions when no elliptic curve cryptography is used. 15 | export 'bip38_no_ec.dart'; 16 | -------------------------------------------------------------------------------- /lib/bip/bip/bip39/bip39_mnemonic_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic.dart'; 4 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_validator.dart'; 5 | 6 | /// Validates BIP39 mnemonics based on a specified language. 7 | /// 8 | /// The `Bip39MnemonicValidator` class is responsible for validating BIP39 mnemonics 9 | /// by using the `Bip39MnemonicDecoder` for decoding and checking the correctness of 10 | /// the mnemonic phrase. It ensures that the provided mnemonic follows the specified 11 | /// language's word list and can be successfully decoded. 12 | /// The [isValid] method can be used to check the validity of a given 13 | /// mnemonic phrase. 14 | class Bip39MnemonicValidator extends MnemonicValidator { 15 | /// Creates a new instance of the Bip39MnemonicValidator. 16 | /// 17 | /// The [language] parameter specifies the language used for the word list. 18 | Bip39MnemonicValidator([Bip39Languages? language]) 19 | : super(Bip39MnemonicDecoder(language)); 20 | 21 | bool validateWords(String mnemonic) { 22 | try { 23 | final mn = Mnemonic.fromString(mnemonic); 24 | final language = decoder.findLanguage(mn).item1; 25 | decoder.mnemonicToBinaryStr(mn, language); 26 | return true; 27 | } catch (e) { 28 | return false; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/bip/bip/bip44/base/bip44_base_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// Custom exception for errors related to BIP-44 depth. 4 | /// 5 | /// This class, `Bip44DepthError`, represents a custom exception for handling 6 | /// errors related to the BIP-44 hierarchical deterministic wallet structure's 7 | /// depth. It can be thrown to indicate issues with depth levels in BIP-44 paths. 8 | class Bip44DepthError extends BlockchainUtilsException { 9 | const Bip44DepthError(super.message, {super.details}); 10 | } 11 | -------------------------------------------------------------------------------- /lib/bip/bip/bip44/bip44.dart: -------------------------------------------------------------------------------- 1 | /// The 'bip44' library provides tools for working with BIP-44, a standard for 2 | /// hierarchical deterministic wallets and key derivation in cryptocurrencies. 3 | library; 4 | 5 | /// Export statement for the base BIP-44 implementation and key-related functions. 6 | export 'base/bip44_base.dart'; 7 | 8 | /// Export statement for BIP-44 key-related functions and structures. 9 | export 'base/bip44_keys.dart'; 10 | 11 | export 'base/bip44_base_ex.dart'; 12 | 13 | /// Export statement for the BIP-44 base implementation, which includes key 14 | /// derivation and wallet management functions. 15 | export 'bip44_base.dart'; 16 | -------------------------------------------------------------------------------- /lib/bip/bip/bip49/bip49.dart: -------------------------------------------------------------------------------- 1 | /// The 'bip49' library provides tools for working with BIP-49, a standard for 2 | /// hierarchical deterministic wallets and key derivation in cryptocurrencies. 3 | 4 | /// Export statement for the BIP-49 base implementation, which includes key 5 | /// derivation and wallet management functions. 6 | library; 7 | 8 | export 'bip49_base.dart'; 9 | -------------------------------------------------------------------------------- /lib/bip/bip/bip84/bip84.dart: -------------------------------------------------------------------------------- 1 | /// The 'bip84' library provides tools for working with BIP-84, a standard for 2 | /// hierarchical deterministic wallets and key derivation in cryptocurrencies. 3 | library; 4 | 5 | /// Export statement for the BIP-84 base implementation, which includes key 6 | /// derivation and wallet management functions. 7 | export 'bip84_base.dart'; 8 | -------------------------------------------------------------------------------- /lib/bip/bip/bip86/bip86.dart: -------------------------------------------------------------------------------- 1 | /// The 'bip86' library provides tools for working with BIP-86, a standard for 2 | /// hierarchical deterministic wallets and key derivation in cryptocurrencies. 3 | library; 4 | 5 | /// Export statement for the BIP-86 base implementation, which includes key 6 | /// derivation and wallet management functions. 7 | export 'bip86_base.dart'; 8 | -------------------------------------------------------------------------------- /lib/bip/bip/conf/bip_config.dart: -------------------------------------------------------------------------------- 1 | /// The 'bip_config' library provides configuration files and information related to 2 | /// various BIP (Bitcoin Improvement Proposal) standards, including BIP-44, BIP-49, BIP-84, 3 | /// and BIP-86. It defines coin names, parameters, and coin configuration data for 4 | /// hierarchical deterministic wallets in cryptocurrencies, facilitating wallet development 5 | /// and key derivation for a variety of blockchain networks. 6 | library; 7 | 8 | export 'bip/bip_coins.dart'; 9 | 10 | /// bip44 11 | export 'bip44/bip44_coins.dart'; 12 | export 'bip44/bip44_conf.dart'; 13 | 14 | /// bip49 15 | export 'bip49/bip49_coins.dart'; 16 | export 'bip49/bip49_conf.dart'; 17 | 18 | /// bip84 19 | export 'bip84/bip84_coins.dart'; 20 | export 'bip84/bip84_conf.dart'; 21 | 22 | /// bip86 23 | export 'bip86/bip86_coins.dart'; 24 | export 'bip86/bip86_conf.dart'; 25 | 26 | /// coin configs 27 | export 'config/bip_bitcoin_cash_conf.dart'; 28 | export 'config/bip_coin_conf.dart'; 29 | export 'config/bip_litecoin_conf.dart'; 30 | 31 | /// coin constants 32 | export 'const/bip_conf_const.dart'; 33 | 34 | /// crypto coin base class 35 | export 'core/coins.dart'; 36 | export 'core/coin_conf.dart'; 37 | -------------------------------------------------------------------------------- /lib/bip/bip/types/types.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/const/const.dart'; 2 | 3 | /// Enumeration representing different modes for public keys used in P2PKH addresses. 4 | /// 5 | /// This enum defines different modes for public keys that can be used in P2PKH (Pay-to-Public-Key-Hash) 6 | /// addresses. These modes may include compressed and uncompressed public keys, among others. 7 | enum PubKeyModes { 8 | compressed(0), 9 | uncompressed(1); 10 | 11 | const PubKeyModes(this.value); 12 | final int value; 13 | 14 | bool get isCompressed => this == compressed; 15 | 16 | static PubKeyModes fromValue(int? value, {PubKeyModes? defaultValue}) { 17 | return values.firstWhere((e) => e.value == value, orElse: () { 18 | if (defaultValue != null && value == null) return defaultValue; 19 | throw ExceptionConst.itemNotFound(item: 'public format'); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/bip/cardano/mnemonic/cardano_icarus_seed_generator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic_decoder.dart'; 3 | 4 | /// A class responsible for generating Cardano Icarus seeds from mnemonics. 5 | class CardanoIcarusSeedGenerator { 6 | final List _entropyBytes; 7 | 8 | /// Constructor to create a seed generator for Cardano Icarus wallets. 9 | /// 10 | /// It takes a mnemonic string as input, decodes it into entropy bytes. 11 | /// 12 | /// Parameters: 13 | /// - `mnemonic`: The mnemonic string used to generate the seed. 14 | /// - `language`: An optional parameter to specify the language used in the mnemonic. 15 | CardanoIcarusSeedGenerator( 16 | String mnemonic, { 17 | Bip39Languages? language, 18 | }) : _entropyBytes = Bip39MnemonicDecoder(language).decode(mnemonic); 19 | 20 | /// Generates and returns the Cardano Icarus seed as a `List`. 21 | List generate() { 22 | return List.from(_entropyBytes); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/bip/coin_conf/config.dart: -------------------------------------------------------------------------------- 1 | export 'constant/coins_conf.dart'; 2 | export 'models/coin_conf.dart'; 3 | export 'models/coins_name.dart'; 4 | -------------------------------------------------------------------------------- /lib/bip/coin_conf/models/coins_name.dart: -------------------------------------------------------------------------------- 1 | /// A class that represents the names and abbreviations of a cryptocurrency coin. 2 | /// 3 | /// It stores the full name and its abbreviation, making it easy to access and display. 4 | class CoinNames { 5 | /// The full name of the cryptocurrency. 6 | final String name; 7 | 8 | /// The abbreviation or ticker symbol of the cryptocurrency. 9 | final String abbreviation; 10 | 11 | const CoinNames(this.name, this.abbreviation); 12 | 13 | @override 14 | String toString() { 15 | return name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/bip/ecc/bip_ecc.dart: -------------------------------------------------------------------------------- 1 | export 'curve/elliptic_curve_types.dart'; 2 | export 'curve/elliptic_curve_getter.dart'; 3 | export 'keys/ecdsa_keys.dart'; 4 | export 'keys/ed25519_blake2b_keys.dart'; 5 | export 'keys/ed25519_keys.dart'; 6 | export 'keys/ed25519_kholaw_keys.dart'; 7 | export 'keys/ed25519_monero_keys.dart'; 8 | export 'keys/i_keys.dart'; 9 | export 'keys/nist256p1_keys.dart'; 10 | export 'keys/secp256k1_keys_ecdsa.dart'; 11 | export 'keys/sr25519_keys.dart'; 12 | export 'keys/nist256p1_keys_hybrid.dart'; 13 | -------------------------------------------------------------------------------- /lib/bip/ecc/curve/elliptic_curve_getter.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/ecc/curve/elliptic_curve_types.dart'; 2 | import 'package:blockchain_utils/crypto/crypto/cdsa/curve/curves.dart'; 3 | import 'package:blockchain_utils/crypto/crypto/cdsa/point/base.dart'; 4 | 5 | /// A utility class for obtaining elliptic curve generators based on curve types. 6 | class EllipticCurveGetter { 7 | /// Retrieves the elliptic curve generator based on the specified curve type. 8 | /// 9 | /// Parameters: 10 | /// - `type`: The type of elliptic curve. 11 | /// 12 | /// Returns an abstract elliptic curve point generator. 13 | static AbstractPoint generatorFromType(EllipticCurveTypes type) { 14 | switch (type) { 15 | case EllipticCurveTypes.secp256k1: 16 | return Curves.generatorSecp256k1; 17 | case EllipticCurveTypes.nist256p1: 18 | case EllipticCurveTypes.nist256p1Hybrid: 19 | return Curves.generator256; 20 | case EllipticCurveTypes.ed25519: 21 | case EllipticCurveTypes.ed25519Kholaw: 22 | return Curves.generatorED25519; 23 | default: 24 | throw UnimplementedError("generatorFromType does not provide curve."); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/bip/ecc/curve/elliptic_curve_types.dart: -------------------------------------------------------------------------------- 1 | /// An enumeration of common elliptic curve types used in cryptographic operations. 2 | enum EllipticCurveTypes { 3 | /// Edwards-curve Digital Signature Algorithm (EdDSA) using ed25519 curve 4 | ed25519, 5 | 6 | /// EdDSA with Blake2b hash 7 | ed25519Blake2b, 8 | 9 | /// EdDSA with Kholaw's 25519 curve 10 | ed25519Kholaw, 11 | 12 | /// EdDSA curve used in Monero 13 | ed25519Monero, 14 | 15 | /// NIST P-256 elliptic curve 16 | nist256p1, 17 | 18 | /// Hybrid derivation using NIST P-256 elliptic curve 19 | nist256p1Hybrid, 20 | 21 | /// SECG secp256k1 elliptic curve 22 | secp256k1, 23 | 24 | /// Schnorr over Ristretto255 curve 25 | sr25519; 26 | 27 | /// Retrieves the [EllipticCurveTypes] from its string [name] 28 | static EllipticCurveTypes fromName(String name) { 29 | return EllipticCurveTypes.values.firstWhere( 30 | (element) => element.name == name, 31 | orElse: () => throw ArgumentError('Invalid curve type name: $name'), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/bip/ecc/keys/ecdsa_keys.dart: -------------------------------------------------------------------------------- 1 | /// Constants related to ECDSA (Elliptic Curve Digital Signature Algorithm) keys. 2 | class EcdsaKeysConst { 3 | /// AffinePointt coordinate length in bytes 4 | static const int pointCoordByteLen = 32; 5 | 6 | /// Private key length in bytes 7 | static const int privKeyByteLen = 32; 8 | 9 | /// Uncompressed public key prefix 10 | static const List pubKeyUncompressedPrefix = [0x04]; 11 | 12 | /// Compressed public key length in bytes 13 | static const int pubKeyCompressedByteLen = 33; 14 | 15 | /// Uncompressed public key length in bytes 16 | static const int pubKeyUncompressedByteLen = 65; 17 | } 18 | -------------------------------------------------------------------------------- /lib/bip/electrum/electrum.dart: -------------------------------------------------------------------------------- 1 | /// The 'electrum' library provides tools for working with Electrum-style mnemonic phrases 2 | /// and address keys, including version 1 (v1) and version 2 (v2) of Electrum standards. 3 | library; 4 | 5 | /// Export statements for Electrum-style mnemonic version 1 (v1) components. 6 | export 'mnemonic_v1/electrum_v1_entropy_generator.dart'; 7 | export 'mnemonic_v1/electrum_v1_mnemonic.dart'; 8 | export 'mnemonic_v1/electrum_v1_mnemonic_decoder.dart'; 9 | export 'mnemonic_v1/electrum_v1_mnemonic_encoder.dart'; 10 | export 'mnemonic_v1/electrum_v1_mnemonic_generator.dart'; 11 | export 'mnemonic_v1/electrum_v1_mnemonic_utils.dart'; 12 | export 'mnemonic_v1/electrum_v1_mnemonic_validator.dart'; 13 | export 'mnemonic_v1/electrum_v1_seed_generator.dart'; 14 | 15 | /// Export statements for Electrum-style mnemonic version 2 (v2) components. 16 | export 'mnemonic_v2/electrum_v2_entropy_generator.dart'; 17 | export 'mnemonic_v2/electrum_v2_mnemonic.dart'; 18 | export 'mnemonic_v2/electrum_v2_mnemonic_decoder.dart'; 19 | export 'mnemonic_v2/electrum_v2_mnemonic_encoder.dart'; 20 | export 'mnemonic_v2/electrum_v2_mnemonic_generator.dart'; 21 | export 'mnemonic_v2/electrum_v2_mnemonic_utils.dart'; 22 | export 'mnemonic_v2/electrum_v2_mnemonic_validator.dart'; 23 | export 'mnemonic_v2/electrum_v2_seed_generator.dart'; 24 | 25 | /// Export statement for Electrum-style version 1 (v1) address keys and derivation. 26 | export 'electrum_v1.dart'; 27 | 28 | /// Export statement for Electrum-style version 2 (v2) address keys and derivation. 29 | export 'electrum_v2.dart'; 30 | -------------------------------------------------------------------------------- /lib/bip/electrum/mnemonic_v1/electrum_v1_mnemonic_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/electrum/mnemonic_v1/electrum_v1_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/electrum/mnemonic_v1/electrum_v1_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_validator.dart'; 4 | 5 | /// A class for validating Electrum V1 mnemonics, extending the MnemonicValidator class. 6 | class ElectrumV1MnemonicValidator extends MnemonicValidator { 7 | /// Constructs an ElectrumV1MnemonicValidator with an optional language specification. 8 | /// 9 | /// The validator is initialized with an `ElectrumV1MnemonicDecoder` that uses the specified language 10 | /// (default: English) for decoding Electrum V1 mnemonics. 11 | /// 12 | /// [language]: The language to use for mnemonic decoding (default: English). 13 | ElectrumV1MnemonicValidator( 14 | [ElectrumV1Languages? language = ElectrumV1Languages.english]) 15 | : super(ElectrumV1MnemonicDecoder(language)); 16 | } 17 | -------------------------------------------------------------------------------- /lib/bip/electrum/mnemonic_v1/wrodlist/languages.dart: -------------------------------------------------------------------------------- 1 | /// Library for Electrum V1 mnemonic language support. 2 | 3 | library; 4 | 5 | /// Part for the English Electrum V1 mnemonic language. 6 | part 'english.dart'; 7 | 8 | /// A list of Electrum V1 mnemonic words, specifically for the English language. 9 | List get elctrumMnemonicWordsList => _english; 10 | -------------------------------------------------------------------------------- /lib/bip/electrum/mnemonic_v2/electrum_v2_mnemonic_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/electrum/mnemonic_v2/electrum_v2_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/electrum/mnemonic_v2/electrum_v2_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_validator.dart'; 4 | 5 | /// Validator class for Electrum V2 mnemonics. 6 | class ElectrumV2MnemonicValidator extends MnemonicValidator { 7 | /// Creates a new instance of the Electrum V2 mnemonic validator. 8 | /// 9 | /// [v2mnemonicTypes] (Optional) The specific type of Electrum V2 mnemonic to validate. 10 | /// [language] (Optional) The language to use for validation. 11 | ElectrumV2MnemonicValidator( 12 | {ElectrumV2MnemonicTypes? v2mnemonicTypes, ElectrumV2Languages? language}) 13 | : super(ElectrumV2MnemonicDecoder( 14 | mnemonicType: v2mnemonicTypes, language: language)); 15 | } 16 | -------------------------------------------------------------------------------- /lib/bip/mnemonic/entropy_generator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/quick_crypto.dart'; 2 | 3 | /// A class for generating cryptographically secure random entropy. 4 | /// 5 | /// The [EntropyGenerator] class is designed to produce random entropy with a specified bit length. 6 | /// It uses a cryptographically secure random number generator to generate the entropy. 7 | class EntropyGenerator { 8 | final int bitlen; 9 | 10 | /// Creates an [EntropyGenerator] instance with the desired bit length. 11 | /// 12 | /// The [bitlen] parameter specifies the length of the entropy in bits. 13 | EntropyGenerator(this.bitlen); 14 | 15 | /// Generates and returns random entropy as a [List]. 16 | /// 17 | /// The length of the generated entropy is determined by the [bitlen] parameter, and it is converted 18 | /// to bytes (rounded up to the nearest byte). 19 | List generate() { 20 | return QuickCrypto.generateRandom(bitlen ~/ 8); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/bip/mnemonic/mnemonic_encoder_base.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/mnemonic/mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_utils.dart'; 3 | 4 | /// An abstract class for encoding binary entropy data into human-readable mnemonic phrases. 5 | /// 6 | /// Subclasses of this class implement specific encoding algorithms for different mnemonic standards. 7 | abstract class MnemonicEncoderBase { 8 | /// The list of words used for encoding. 9 | final MnemonicWordsList wordsList; 10 | 11 | /// Creates an instance of MnemonicEncoderBase. 12 | /// 13 | /// The [language] parameter specifies the language used for the mnemonic words. 14 | /// The [wordsListGetter] is a helper class to retrieve the appropriate words list. 15 | MnemonicEncoderBase( 16 | MnemonicLanguages language, MnemonicWordsListGetterBase wordsListGetter) 17 | : wordsList = wordsListGetter.getByLanguage(language); 18 | 19 | /// Encodes the provided binary entropy data into a human-readable mnemonic phrase. 20 | /// 21 | /// The [entropyBytes] parameter is the binary entropy data to be encoded. 22 | Mnemonic encode(List entropyBytes); 23 | } 24 | -------------------------------------------------------------------------------- /lib/bip/mnemonic/mnemonic_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// An exception representing an error related to mnemonic. 4 | class MnemonicException extends BlockchainUtilsException { 5 | const MnemonicException(super.message, {super.details}); 6 | } 7 | -------------------------------------------------------------------------------- /lib/bip/mnemonic/mnemonic_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_decoder_base.dart'; 2 | 3 | /// Utility class for validating and checking the validity of mnemonic phrases. 4 | /// 5 | /// The `MnemonicValidator` class provides methods to validate and determine the 6 | /// validity of mnemonic phrases using a specified `MnemonicDecoderBase`. It can 7 | /// check whether a given mnemonic phrase is valid and adheres to the expected format. 8 | class MnemonicValidator { 9 | final T decoder; 10 | 11 | /// Creates a new instance of the MnemonicValidator with the provided [decoder]. 12 | /// 13 | /// The [decoder] is responsible for decoding and verifying the correctness 14 | /// of the mnemonic phrase. 15 | MnemonicValidator(this.decoder); 16 | 17 | /// Validates a given [mnemonic] phrase using the associated decoder. 18 | /// 19 | /// Throws an exception if the mnemonic phrase is invalid or cannot be decoded. 20 | void validate(String mnemonic) { 21 | decoder.decode(mnemonic); 22 | } 23 | 24 | /// Checks if a given [mnemonic] phrase is valid. 25 | /// 26 | /// Returns `true` if the mnemonic is valid, `false` otherwise. 27 | bool isValid(String mnemonic) { 28 | try { 29 | validate(mnemonic); 30 | return true; 31 | } catch (e) { 32 | return false; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/bip/monero/conf/monero_conf.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/conf/core/coin_conf.dart'; 2 | import 'package:blockchain_utils/bip/coin_conf/constant/coins_conf.dart'; 3 | import 'package:blockchain_utils/bip/monero/conf/monero_coin_conf.dart'; 4 | 5 | /// A configuration class for Monero that defines the key network versions and 6 | /// maps each supported MoneroCoins to its corresponding BipCoinConfig. 7 | class MoneroConf { 8 | // Configuration for Monero main net 9 | static final MoneroCoinConf mainNet = MoneroCoinConf.fromCoinConf( 10 | coinConf: CoinsConf.moneroMainNet, chainType: ChainType.mainnet); 11 | 12 | // Configuration for Monero stage net 13 | static final MoneroCoinConf stageNet = MoneroCoinConf.fromCoinConf( 14 | coinConf: CoinsConf.moneroStageNet, chainType: ChainType.testnet); 15 | 16 | // Configuration for Monero test net 17 | static final MoneroCoinConf testNet = MoneroCoinConf.fromCoinConf( 18 | coinConf: CoinsConf.moneroTestNet, chainType: ChainType.testnet); 19 | } 20 | -------------------------------------------------------------------------------- /lib/bip/monero/mnemonic/monero_mnemonic_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_validator.dart'; 4 | 5 | /// A class for validating Monero mnemonics. 6 | /// 7 | /// This class extends `MnemonicValidator` and is specialized for validating Monero mnemonics. 8 | /// It uses a `MoneroMnemonicDecoder` for decoding and validating Monero mnemonics. 9 | /// 10 | /// [language]: The Monero language used for validation. Defaults to null, allowing the decoder 11 | /// to use the default language. 12 | class MoneroMnemonicValidator extends MnemonicValidator { 13 | /// Constructs a MoneroMnemonicValidator with an optional language parameter. 14 | /// 15 | /// [language]: The Monero language used for validation. Defaults to null. 16 | MoneroMnemonicValidator([MoneroLanguages? language]) 17 | : super(MoneroMnemonicDecoder(language)); 18 | } 19 | -------------------------------------------------------------------------------- /lib/bip/monero/mnemonic/monero_seed_generator.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic.dart'; 4 | 5 | /// A class responsible for generating a seed from Monero mnemonic entropy. 6 | /// 7 | /// This class takes a Monero mnemonic, decodes it to obtain the associated entropy bytes, 8 | /// and allows you to generate a seed from that entropy. The generated seed can be used 9 | /// as a cryptographic seed in Monero-related operations. 10 | class MoneroSeedGenerator { 11 | final List _entropyBytes; 12 | 13 | /// Constructs a MoneroSeedGenerator with a Monero mnemonic and an optional language. 14 | /// 15 | /// [mnemonic]: The Monero mnemonic from which to derive the seed. 16 | /// [language]: The Monero language used for decoding. Defaults to null, allowing the decoder 17 | /// to use the default language. 18 | MoneroSeedGenerator(Mnemonic mnemonic, [MoneroLanguages? language]) 19 | : _entropyBytes = 20 | MoneroMnemonicDecoder(language).decode(mnemonic.toStr()); 21 | 22 | /// Generates a seed from the decoded entropy bytes. 23 | /// 24 | /// This method generates a seed from the decoded entropy bytes obtained from the 25 | /// Monero mnemonic. The seed can be used for cryptographic purposes. 26 | /// 27 | /// Returns a `List` containing the generated seed. 28 | List generate() => List.from(_entropyBytes); 29 | } 30 | -------------------------------------------------------------------------------- /lib/bip/monero/monero.dart: -------------------------------------------------------------------------------- 1 | /// The 'monero' library provides tools for working with Monero cryptocurrency, including 2 | /// configuration data, mnemonic phrases, keys, and address generation. 3 | library; 4 | 5 | /// Export statement for Monero coin definitions and configuration. 6 | export 'conf/monero_coins.dart'; 7 | export 'conf/monero_conf.dart'; 8 | 9 | /// Export statements for Monero mnemonic-related components. 10 | export 'mnemonic/monero_entropy_generator.dart'; 11 | export 'mnemonic/monero_mnemonic.dart'; 12 | export 'mnemonic/monero_mnemonic_decoder.dart'; 13 | export 'mnemonic/monero_mnemonic_encoder.dart'; 14 | export 'mnemonic/monero_mnemonic_generator.dart'; 15 | export 'mnemonic/monero_mnemonic_utils.dart'; 16 | export 'mnemonic/monero_mnemonic_validator.dart'; 17 | export 'mnemonic/monero_seed_generator.dart'; 18 | export 'mnemonic/words_list/languages.dart'; 19 | 20 | /// Export statement for Monero base components, including address generation. 21 | export 'monero_base.dart'; 22 | 23 | /// Export statement for Monero subaddress components. 24 | export 'monero_subaddr.dart'; 25 | -------------------------------------------------------------------------------- /lib/bip/monero/monero_exc.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// An exception class representing an error related to Monero keys. 4 | /// 5 | /// This exception class is used to represent errors and exceptions related to Monero keys. 6 | class MoneroKeyError extends BlockchainUtilsException { 7 | const MoneroKeyError(super.message, {super.details}); 8 | } 9 | -------------------------------------------------------------------------------- /lib/bip/slip/slip.dart: -------------------------------------------------------------------------------- 1 | export 'slip173/slip173.dart'; 2 | export 'slip32/slip32.dart'; 3 | export 'slip32/slip32_key_net_ver.dart'; 4 | export 'slip44/slip44.dart'; 5 | -------------------------------------------------------------------------------- /lib/bip/slip/slip173/slip173.dart: -------------------------------------------------------------------------------- 1 | /// SLIP-0173 class. 2 | /// It defines the human-readable parts in accordance with SLIP-0173. 3 | class Slip173 { 4 | static const String akashNetwork = "akash"; 5 | static const String axelar = "axelar"; 6 | static const String bandProtocol = "band"; 7 | static const String binanceChain = "bnb"; 8 | static const String bitcoinMainnet = "bc"; 9 | static const String bitcoinTestnet = "tb"; 10 | static const String certik = "certik"; 11 | static const String chihuahua = "chihuahua"; 12 | static const String cosmos = "cosmos"; 13 | static const String elrond = "erd"; 14 | static const String harmonyOne = "one"; 15 | static const String injective = "inj"; 16 | static const String irisNetwork = "iaa"; 17 | static const String kava = "kava"; 18 | static const String litecoinMainnet = "ltc"; 19 | static const String litecoinTestnet = "tltc"; 20 | static const String okexChain = "ex"; 21 | static const String osmosis = "osmo"; 22 | static const String secretNetwork = "secret"; 23 | static const String terra = "terra"; 24 | static const String zilliqa = "zil"; 25 | static const String electraProtocol = "ep"; 26 | static const String electraProtocolTestnet = "te"; 27 | } 28 | -------------------------------------------------------------------------------- /lib/bip/substrate/exception/substrate_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// An exception class representing an error related to Substrate keys. 4 | class SubstrateKeyError extends BlockchainUtilsException { 5 | const SubstrateKeyError(super.message, {super.details}); 6 | } 7 | 8 | /// An exception class representing an error related to Substrate paths. 9 | class SubstratePathError extends BlockchainUtilsException { 10 | const SubstratePathError(super.message, {super.details}); 11 | } 12 | -------------------------------------------------------------------------------- /lib/bip/substrate/scale/substrate_scale_enc_base.dart: -------------------------------------------------------------------------------- 1 | /// An abstract base class for encoding values in Substrate SCALE format. 2 | abstract class SubstrateScaleEncoderBase { 3 | const SubstrateScaleEncoderBase(); 4 | 5 | /// Encode the provided [value] into a `List` in Substrate SCALE format. 6 | List encode(String value); 7 | } 8 | -------------------------------------------------------------------------------- /lib/bip/substrate/scale/substrate_scale_enc_bytes.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/substrate/scale/substrate_scale_enc_base.dart'; 2 | import 'package:blockchain_utils/bip/substrate/scale/substrate_scale_enc_cuint.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | 5 | /// A Substrate SCALE encoder for string values represented as bytes. 6 | class SubstrateScaleBytesEncoder extends SubstrateScaleEncoderBase { 7 | const SubstrateScaleBytesEncoder(); 8 | 9 | /// Encode the provided [value] as bytes and wrap it in Substrate SCALE format. 10 | @override 11 | List encode(String value) { 12 | final toBytes = StringUtils.encode(value); 13 | final List lengthBytes = 14 | const SubstrateScaleCUintEncoder().encode(toBytes.length.toString()); 15 | return List.from([...lengthBytes, ...toBytes]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/bip/substrate/substrate.dart: -------------------------------------------------------------------------------- 1 | /// The 'substrate' library provides tools for working with the Substrate blockchain 2 | /// ecosystem, including coin definitions, configuration data, and encoding utilities. 3 | library; 4 | 5 | /// Export statement for Substrate coin definitions and configuration. 6 | export 'conf/substrate_coins.dart'; 7 | export 'conf/substrate_conf.dart'; 8 | 9 | /// Export statements for Substrate SCALE encoding utilities. 10 | export 'scale/substrate_scale_enc_base.dart'; 11 | export 'scale/substrate_scale_enc_bytes.dart'; 12 | export 'scale/substrate_scale_enc_cuint.dart'; 13 | export 'scale/substrate_scale_enc_uint.dart'; 14 | 15 | /// Export statement for Substrate base components, including key, derivation, address. 16 | export 'core/substrate_base.dart'; 17 | 18 | /// Export statement for Substrate key management components. 19 | export 'keys/substrate_keys.dart'; 20 | 21 | /// Export statement for Substrate path components. 22 | export 'path/substrate_path.dart'; 23 | -------------------------------------------------------------------------------- /lib/bip/ton/mnemonic/ton_mnemonic_language.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip39/bip39.dart'; 2 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_ex.dart'; 3 | import 'package:blockchain_utils/bip/mnemonic/mnemonic_utils.dart'; 4 | import 'package:blockchain_utils/bip/bip/bip39/word_list/languages.dart' 5 | as languages; 6 | 7 | /// The TonMnemonicLanguages class implements the Bip39Languages interface to 8 | /// provide support for BIP-39 mnemonic languages, specifically tailored for TON (The Open Network). 9 | class TonMnemonicLanguages implements Bip39Languages { 10 | @override 11 | final String name; 12 | 13 | /// Predefined constant for the English language. 14 | static const TonMnemonicLanguages english = TonMnemonicLanguages._("English"); 15 | 16 | /// Private constructor for defining language instances. 17 | const TonMnemonicLanguages._(this.name); 18 | 19 | /// List of all supported TonMnemonicLanguages instances. 20 | static const List values = [english]; 21 | 22 | // Retrieves the word list associated with the language instance. 23 | @override 24 | List get wordList { 25 | switch (this) { 26 | case TonMnemonicLanguages.english: 27 | return languages.bip39WordList(Bip39Languages.english); 28 | default: 29 | throw const MnemonicException( 30 | "TonMnemonicLanguages only support english"); 31 | } 32 | } 33 | 34 | /// Provides a list of all mnemonic language values. 35 | @override 36 | List get languageValues => TonMnemonicLanguages.values; 37 | } 38 | -------------------------------------------------------------------------------- /lib/bip/ton/ton.dart: -------------------------------------------------------------------------------- 1 | export 'mnemonic/ton_entropy_generator.dart'; 2 | export 'mnemonic/ton_mnemonic_encoder.dart'; 3 | export 'mnemonic/ton_mnemonic_generator.dart'; 4 | export 'mnemonic/ton_mnemonic_language.dart'; 5 | export 'mnemonic/ton_mnemonic_validator.dart'; 6 | export 'mnemonic/ton_seed_generator.dart'; 7 | -------------------------------------------------------------------------------- /lib/cbor/cbor.dart: -------------------------------------------------------------------------------- 1 | /// Library for working with Concise Binary Object Representation (CBOR) data format. 2 | library; 3 | 4 | /// Export statement for the core CBOR data types and decode functionality. 5 | export 'core/cbor.dart'; 6 | 7 | export 'types/types.dart'; 8 | 9 | export 'exception/exception.dart'; 10 | -------------------------------------------------------------------------------- /lib/cbor/exception/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | class CborException extends BlockchainUtilsException { 4 | const CborException(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/cbor/extention/extenton.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | 3 | extension QuickCastingCbor on CborObject { 4 | T cast() { 5 | if (this is T) return this as T; 6 | throw CborException("cbor object casting faild", 7 | details: {"expected": "$T", "value": runtimeType.toString()}); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/cbor/types/boolean.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/cbor/utils/dynamic_bytes.dart'; 3 | import 'package:blockchain_utils/cbor/core/tags.dart'; 4 | import 'package:blockchain_utils/cbor/core/cbor.dart'; 5 | 6 | /// A class representing a CBOR (Concise Binary Object Representation) boolean value. 7 | class CborBoleanValue implements CborObject { 8 | /// Constructor for creating a CborBoleanValue instance with the provided parameters. 9 | /// It accepts the boolean value. 10 | const CborBoleanValue(this.value); 11 | 12 | /// The value as a boolean. 13 | @override 14 | final bool value; 15 | 16 | /// Encode the value into CBOR bytes 17 | @override 18 | List encode() { 19 | final bytes = CborBytesTracker(); 20 | bytes.pushInt(MajorTags.simpleOrFloat, 21 | value ? SimpleTags.simpleTrue : SimpleTags.simpleFalse); 22 | return bytes.toBytes(); 23 | } 24 | 25 | /// Encode the value into CBOR bytes an then to hex 26 | @override 27 | String toCborHex() { 28 | return BytesUtils.toHexString(encode()); 29 | } 30 | 31 | /// Returns the string representation of the value. 32 | @override 33 | String toString() { 34 | return value.toString(); 35 | } 36 | 37 | /// overide equal operation 38 | @override 39 | operator ==(other) { 40 | if (other is! CborBoleanValue) return false; 41 | 42 | return value == other.value; 43 | } 44 | 45 | /// ovveride hash code 46 | @override 47 | int get hashCode => value.hashCode; 48 | } 49 | -------------------------------------------------------------------------------- /lib/cbor/types/cbor_tag.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/helper/helper.dart'; 2 | import 'package:blockchain_utils/utils/utils.dart'; 3 | import 'package:blockchain_utils/cbor/utils/dynamic_bytes.dart'; 4 | import 'package:blockchain_utils/cbor/core/cbor.dart'; 5 | 6 | /// A class representing a CBOR (Concise Binary Object Representation) tag value. 7 | class CborTagValue implements CborObject { 8 | /// Constructor for creating a CborBoleanValue instance with the provided parameters. 9 | /// It accepts the all encodable cbor value. 10 | CborTagValue(T value, List tags) 11 | : _value = value, 12 | tags = tags.immutable; 13 | 14 | final List tags; 15 | 16 | final T _value; 17 | @override 18 | T get value => _value; 19 | 20 | /// Encode the value into CBOR bytes 21 | @override 22 | List encode() { 23 | final bytes = CborBytesTracker(); 24 | bytes.pushTags(tags); 25 | final obj = CborObject.fromDynamic(_value).encode(); 26 | bytes.pushBytes(obj); 27 | return bytes.buffer(); 28 | } 29 | 30 | /// Encode the value into CBOR bytes an then to hex 31 | @override 32 | String toCborHex() { 33 | return BytesUtils.toHexString(encode()); 34 | } 35 | 36 | /// Returns the string representation of the value. 37 | @override 38 | String toString() { 39 | return value.toString(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/cbor/types/mime.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/cbor/utils/dynamic_bytes.dart'; 3 | import 'package:blockchain_utils/cbor/core/tags.dart'; 4 | import 'package:blockchain_utils/cbor/core/cbor.dart'; 5 | import 'package:blockchain_utils/cbor/types/string.dart'; 6 | 7 | /// A class representing a CBOR (Concise Binary Object Representation) mime value. 8 | class CborMimeValue implements CborObject { 9 | /// Constructor for creating a CborMimeValue instance with the provided parameters. 10 | /// It accepts the string value. 11 | const CborMimeValue(this.value); 12 | 13 | /// value as string 14 | @override 15 | final String value; 16 | 17 | /// Encode the value into CBOR bytes 18 | @override 19 | List encode() { 20 | final bytes = CborBytesTracker(); 21 | bytes.pushTags(CborTags.mime); 22 | final toBytes = CborStringValue(value); 23 | bytes.pushBytes(toBytes.encode()); 24 | return bytes.toBytes(); 25 | } 26 | 27 | /// Encode the value into CBOR bytes an then to hex 28 | @override 29 | String toCborHex() { 30 | return BytesUtils.toHexString(encode()); 31 | } 32 | 33 | /// Returns the string representation of the value. 34 | @override 35 | String toString() { 36 | return value; 37 | } 38 | 39 | /// override equal operation 40 | @override 41 | operator ==(other) { 42 | if (other is! CborMimeValue) return false; 43 | return value == other.value; 44 | } 45 | 46 | /// override hashcode 47 | @override 48 | int get hashCode => value.hashCode; 49 | } 50 | -------------------------------------------------------------------------------- /lib/cbor/types/regex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/cbor/utils/dynamic_bytes.dart'; 3 | import 'package:blockchain_utils/cbor/core/tags.dart'; 4 | import 'package:blockchain_utils/cbor/types/string.dart'; 5 | 6 | /// A class representing a CBOR (Concise Binary Object Representation) Regex value. 7 | class CborRegxpValue implements CborString { 8 | /// Constructor for creating a CborRegxpValue instance with the provided parameters. 9 | /// It accepts string value of regex. 10 | const CborRegxpValue(this.value); 11 | 12 | /// value as string 13 | @override 14 | final String value; 15 | 16 | /// Encode the value into CBOR bytes 17 | @override 18 | List encode() { 19 | final bytes = CborBytesTracker(); 20 | bytes.pushTags(CborTags.regexp); 21 | final toBytes = CborStringValue(value); 22 | bytes.pushBytes(toBytes.encode()); 23 | return bytes.toBytes(); 24 | } 25 | 26 | /// Encode the value into CBOR bytes an then to hex 27 | @override 28 | String toCborHex() { 29 | return BytesUtils.toHexString(encode()); 30 | } 31 | 32 | /// Returns the string representation of the value. 33 | @override 34 | String toString() { 35 | return value; 36 | } 37 | 38 | /// override equal operation 39 | @override 40 | operator ==(other) { 41 | if (other is! CborRegxpValue) return false; 42 | return value == other.value; 43 | } 44 | 45 | /// override hashcode 46 | @override 47 | int get hashCode => value.hashCode; 48 | } 49 | -------------------------------------------------------------------------------- /lib/cbor/types/url.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/cbor/utils/dynamic_bytes.dart'; 3 | import 'package:blockchain_utils/cbor/core/tags.dart'; 4 | import 'package:blockchain_utils/cbor/types/string.dart'; 5 | 6 | /// A class representing a CBOR (Concise Binary Object Representation) uri value. 7 | class CborUriValue implements CborString { 8 | /// Constructor for creating a CborUriValue instance with the provided parameters. 9 | /// It accepts string value of uri. 10 | const CborUriValue(this.value); 11 | 12 | /// value as string 13 | @override 14 | final String value; 15 | 16 | /// Encode the value into CBOR bytes 17 | @override 18 | List encode() { 19 | final bytes = CborBytesTracker(); 20 | bytes.pushTags(CborTags.uri); 21 | final toBytes = CborStringValue(value); 22 | bytes.pushBytes(toBytes.encode()); 23 | return bytes.toBytes(); 24 | } 25 | 26 | /// Returns the string representation of the value. 27 | @override 28 | String toString() { 29 | return value; 30 | } 31 | 32 | /// Encode the value into CBOR bytes an then to hex 33 | @override 34 | String toCborHex() { 35 | return BytesUtils.toHexString(encode()); 36 | } 37 | 38 | /// override equal operation 39 | @override 40 | operator ==(other) { 41 | if (other is! CborUriValue) return false; 42 | return value == other.value; 43 | } 44 | 45 | /// override hashcode 46 | @override 47 | int get hashCode => value.hashCode; 48 | } 49 | -------------------------------------------------------------------------------- /lib/cbor/utils/extentions.dart: -------------------------------------------------------------------------------- 1 | /// Extension on the DateTime class to format a DateTime object as an RFC3339 string 2 | extension RFC3339 on DateTime { 3 | /// Convert the DateTime to an RFC3339 formatted string with time zone information. 4 | String toRFC3339WithTimeZone() { 5 | final String year = this.year.toString().padLeft(4, '0'); 6 | final String month = this.month.toString().padLeft(2, '0'); 7 | final String day = this.day.toString().padLeft(2, '0'); 8 | final String hour = this.hour.toString().padLeft(2, '0'); 9 | final String minute = this.minute.toString().padLeft(2, '0'); 10 | final String second = this.second.toString().padLeft(2, '0'); 11 | final String millisecond = this 12 | .millisecond 13 | .toString() 14 | .padLeft(3, '0') 15 | .replaceAll(RegExp(r'0*$'), ''); 16 | 17 | final Duration timeZoneOffset = isUtc ? Duration.zero : this.timeZoneOffset; 18 | 19 | final String timeZoneOffsetSign = timeZoneOffset.isNegative ? '-' : '+'; 20 | final int timeZoneOffsetHours = timeZoneOffset.inHours.abs(); 21 | final int timeZoneOffsetMinutes = timeZoneOffset.inMinutes.abs() % 60; 22 | 23 | final String timeZoneOffsetFormatted = isUtc 24 | ? "Z" 25 | : '$timeZoneOffsetSign${timeZoneOffsetHours.toString().padLeft(2, '0')}:${timeZoneOffsetMinutes.toString().padLeft(2, '0')}'; 26 | 27 | return '$year-$month-${day}T$hour:$minute:$second.$millisecond$timeZoneOffsetFormatted'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/cdsa.dart: -------------------------------------------------------------------------------- 1 | /// The 'cdsa' library provides tools and components for working with various cryptographic 2 | /// algorithms, including elliptic curve cryptography (ECDSA and EDDSA) and related functionality. 3 | library; 4 | 5 | /// Export statement for cryptographic curve definitions. 6 | export 'curve/curves.dart'; 7 | 8 | /// Export statement for ECDSA (Elliptic Curve Digital Signature Algorithm) private and 9 | /// public key components, as well as signature functionality. 10 | export 'ecdsa/private_key.dart'; 11 | export 'ecdsa/public_key.dart'; 12 | export 'ecdsa/signature.dart'; 13 | 14 | /// Export statement for EDDSA (Edwards-curve Digital Signature Algorithm) private and 15 | /// public key components. 16 | export 'eddsa/keys.dart'; 17 | 18 | /// Export statements for elliptic curve point representations, including Edwards 19 | /// and projective points. 20 | export 'point/edwards.dart'; 21 | export 'point/point.dart'; 22 | export 'point/ec_projective_point.dart'; 23 | 24 | /// Export statement for RFC 6979, which provides deterministic ECDSA signatures, 25 | /// allowing for secure signature generation. 26 | export 'rfc6979/rfc6979.dart'; 27 | export 'crypto_ops/crypto_ops.dart'; 28 | 29 | export 'musig2/musig2.dart'; 30 | 31 | export 'utils/ed25519.dart'; 32 | export 'utils/ristretto.dart'; 33 | export 'utils/secp256k1.dart'; 34 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/crypto_ops/crypto_ops.dart: -------------------------------------------------------------------------------- 1 | export 'const/const.dart'; 2 | export 'exception/exception.dart'; 3 | export 'models/models.dart'; 4 | export 'operations/ops.dart'; 5 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/crypto_ops/exception/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | class CryptoOpsException extends BlockchainUtilsException { 4 | const CryptoOpsException(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/eddsa/keys.dart: -------------------------------------------------------------------------------- 1 | export 'keys/privatekey.dart'; 2 | export 'keys/publickey.dart'; 3 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/musig2/constants/const.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:blockchain_utils/crypto/crypto/cdsa/curve/curve.dart'; 3 | 4 | class MuSig2Const { 5 | static const int xOnlyBytesLength = 32; 6 | static const int partialSignatureLength = 32; 7 | static const int minimumRequiredKey = 2; 8 | static const int pubnonceLength = 66; 9 | // static const int schnorrSignatureLength = 64; 10 | static const int secnoncelength = 11 | QuickCrypto.sha256DigestSize * 2 + EcdsaKeysConst.pubKeyCompressedByteLen; 12 | static final CurveFp curve = Curves.curveSecp256k1; 13 | static final BigInt order = Curves.generatorSecp256k1.order!; 14 | static final ProjectiveECCPoint generator = Curves.generatorSecp256k1; 15 | static final List zero = 16 | List.unmodifiable(List.filled(EcdsaKeysConst.pubKeyCompressedByteLen, 0)); 17 | static const String deterministicNonceDomain = "MuSig/deterministic/nonce"; 18 | static const String auxDomain = "MuSig/deterministic/nonce"; 19 | static const String noncecoefDomain = 'MuSig/noncecoef'; 20 | static const String challengeDomain = 'BIP0340/challenge'; 21 | static const String keyAggListDomain = 'KeyAgg list'; 22 | static const String keyAggCoeffDomain = 'KeyAgg coefficient'; 23 | static const String nonceDomain = 'MuSig/nonce'; 24 | static const String musigAuxDomain = "MuSig/aux"; 25 | } 26 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/musig2/exception/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/exception/exception.dart'; 2 | 3 | class MuSig2Exception extends CryptoException { 4 | const MuSig2Exception(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/musig2/musig2.dart: -------------------------------------------------------------------------------- 1 | export 'musig2/musig2.dart'; 2 | export 'exception/exception.dart'; 3 | export 'types/types.dart'; 4 | export 'utils/utils.dart'; 5 | -------------------------------------------------------------------------------- /lib/crypto/crypto/cdsa/secp256k1/secp256k1.dart: -------------------------------------------------------------------------------- 1 | export 'types/types.dart'; 2 | export 'impl/secp256k1.dart'; 3 | export 'constants/constants.dart'; 4 | -------------------------------------------------------------------------------- /lib/crypto/crypto/crc16/crc16.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | 3 | class Crc16 { 4 | static const int _poly = 0x1021; 5 | 6 | static List quickIntDigest(List data) { 7 | int reg = 0; 8 | final List message = List.filled(data.length + 2, 0); 9 | message.setAll(0, data); 10 | 11 | for (final byte in message) { 12 | int mask = 0x80; 13 | while (mask > 0) { 14 | reg <<= 1; 15 | if (byte & mask != 0) { 16 | reg += 1; 17 | } 18 | mask >>= 1; 19 | if (reg > mask16) { 20 | reg &= mask16; 21 | reg ^= _poly; 22 | } 23 | } 24 | } 25 | return List.from([reg >> 8, reg & mask8]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/crypto/crypto/exception/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exception/exception.dart'; 2 | 3 | class CryptoException extends BlockchainUtilsException { 4 | const CryptoException(super.message, {super.details}); 5 | 6 | @override 7 | String toString() { 8 | return message; 9 | } 10 | } 11 | 12 | /// An exception class for errors related to square root calculations. 13 | /// 14 | /// This exception is thrown when there is an issue with computing the square root 15 | /// of a BigInt value within the defined constraints. 16 | /// 17 | class SquareRootError extends CryptoException { 18 | const SquareRootError(super.message, {super.details}); 19 | } 20 | 21 | /// An exception class for errors related to Jacobi symbol calculations. 22 | /// 23 | /// This exception is thrown when there is an issue with computing the Jacobi symbol 24 | /// for a pair of BigInt values within the defined constraints. 25 | /// 26 | class JacobiError extends CryptoException { 27 | const JacobiError(super.message, {super.details}); 28 | } 29 | -------------------------------------------------------------------------------- /lib/crypto/crypto/hash/sha224/sha224.dart: -------------------------------------------------------------------------------- 1 | part of 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | 3 | /// The `SHA224` class represents the SHA-224 hash algorithm, which is a variant of SHA-256. 4 | /// 5 | /// SHA-224 is a cryptographic hash function that produces a 224-bit (28-byte) hash 6 | /// value from an input message. It's a variant of SHA-256 and follows a similar 7 | /// implementation with a different initial hash value and digest length. 8 | class SHA224 extends SHA256 { 9 | /// digest length 10 | static const int digestLength = 28; 11 | 12 | // block size 13 | static const int blockSize = 64; 14 | 15 | /// digest length 16 | @override 17 | int get getDigestLength => SHA224.digestLength; 18 | 19 | // block size 20 | @override 21 | int get getBlockSize => SHA224.blockSize; 22 | 23 | @override 24 | void _initState() { 25 | _state[0] = 0xc1059ed8; 26 | _state[1] = 0x367cd507; 27 | _state[2] = 0x3070dd17; 28 | _state[3] = 0xf70e5939; 29 | _state[4] = 0xffc00b31; 30 | _state[5] = 0x68581511; 31 | _state[6] = 0x64f98fa7; 32 | _state[7] = 0xbefa4fa4; 33 | } 34 | 35 | /// Computes the SHA224 hash of the provided data. 36 | static List hash(List data) { 37 | final h = SHA224(); 38 | h.update(data); 39 | final digest = h.digest(); 40 | h.clean(); 41 | return digest; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/crypto/crypto/schnorrkel/shnorrkel.dart: -------------------------------------------------------------------------------- 1 | /// The 'schnorrkel' library provides tools for working with the Schnorrkel 2 | /// digital signature scheme, including key management and cryptographic functions. 3 | library; 4 | 5 | /// Export statement for Schnorrkel key management components. 6 | export 'keys/keys.dart'; 7 | 8 | /// Export statement for the Schnorrkel Merlin transcript, which is used for 9 | /// creating transcripts to be used in the signature process. 10 | export 'merlin/transcript.dart'; 11 | 12 | /// Export statement for the Schnorrkel Strobe framework, which provides 13 | /// cryptographic primitives for building the Schnorrkel digital signature scheme. 14 | export 'strobe/strobe.dart'; 15 | -------------------------------------------------------------------------------- /lib/double/codec/double_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | /// Utility class for encoding and decoding double values. 4 | class DoubleCoder { 5 | /// Converts a double value to bytes. 6 | /// 7 | /// - [value] : The double value to encode. 8 | /// - [byteOrder] (optional): The byte order for encoding. Defaults to big endian. 9 | static List toBytes(double value, {Endian byteOrder = Endian.big}) { 10 | final ByteData byteData = ByteData(8); 11 | byteData.setFloat64(0, value, byteOrder); 12 | return byteData.buffer.asUint8List(); 13 | } 14 | 15 | /// Converts bytes to a double value. 16 | /// 17 | /// - [bytes] : The bytes to decode. 18 | /// - [byteOrder] (optional): The byte order for decoding. Defaults to big endian. 19 | static double fromBytes(List bytes, {Endian byteOrder = Endian.big}) { 20 | final ByteData byteData = ByteData.sublistView(Uint8List.fromList(bytes)); 21 | return byteData.getFloat64(0, byteOrder); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/double/codec/float_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | /// Utility class for encoding and decoding float values. 4 | class FloatCoder { 5 | /// Converts a double value to bytes. 6 | /// 7 | /// - [value] : The double value to encode. 8 | /// - [byteOrder] (optional): The byte order for encoding. Defaults to big endian. 9 | static List toBytes(double value, {Endian byteOrder = Endian.big}) { 10 | final ByteData byteData = ByteData(4); 11 | byteData.setFloat32(0, value, byteOrder); 12 | return byteData.buffer.asUint8List(); 13 | } 14 | 15 | /// Converts bytes to a double value. 16 | /// 17 | /// - [bytes] : The bytes to decode. 18 | /// - [byteOrder] (optional): The byte order for decoding. Defaults to big endian. 19 | static double fromBytes(List bytes, {Endian byteOrder = Endian.big}) { 20 | final ByteData byteData = ByteData.sublistView(Uint8List.fromList(bytes)); 21 | return byteData.getFloat32(0, byteOrder); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/double/double_codec.dart: -------------------------------------------------------------------------------- 1 | export 'codec/double_utils.dart'; 2 | export 'codec/float_utils.dart'; 3 | -------------------------------------------------------------------------------- /lib/exception/const/const.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exception/exception.dart'; 2 | 3 | class ExceptionConst { 4 | static GenericException itemNotFound({String? item}) => 5 | GenericException("${item ?? 'item'} not found."); 6 | } 7 | -------------------------------------------------------------------------------- /lib/exception/exceptions.dart: -------------------------------------------------------------------------------- 1 | export 'exception/exception.dart'; 2 | export 'exception/rpc_error.dart'; 3 | -------------------------------------------------------------------------------- /lib/helper/helper.dart: -------------------------------------------------------------------------------- 1 | export 'extensions/extensions.dart'; 2 | -------------------------------------------------------------------------------- /lib/layout/byte/byte_handler.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/layout/exception/exception.dart'; 3 | import 'package:blockchain_utils/layout/utils/utils.dart'; 4 | part 'reader.dart'; 5 | part 'writer.dart'; 6 | -------------------------------------------------------------------------------- /lib/layout/byte/writer.dart: -------------------------------------------------------------------------------- 1 | part of "package:blockchain_utils/layout/byte/byte_handler.dart"; 2 | 3 | /// A utility class for writing layout bytes dynamically. 4 | class LayoutByteWriter { 5 | // static const int _minimuBufferLength = 1024; 6 | final bool growable; 7 | LayoutByteWriter(int span) 8 | : _buffer = LayoutByteReader.write( 9 | span >= 0 ? List.filled(span, 0) : List.empty(growable: true)), 10 | growable = span < 0; 11 | final LayoutByteReader _buffer; 12 | 13 | /// Get the last byte in the tracked bytes. 14 | int get last => _buffer.last; 15 | 16 | LayoutByteReader get reader => _buffer; 17 | 18 | /// buffer bytes. 19 | List toBytes() { 20 | return _buffer._bytes; 21 | } 22 | 23 | List sublist(int start, int end) { 24 | return _buffer.sublist(start, end); 25 | } 26 | 27 | int get length => _buffer.length; 28 | 29 | void _filled(int end) { 30 | if (growable) { 31 | if (end > _buffer.length) { 32 | final filled = end - (_buffer.length); 33 | _buffer._bytes.addAll(List.filled(filled, 0, growable: true)); 34 | } 35 | } 36 | } 37 | 38 | void setAll(int index, List bytes) { 39 | _filled(index + bytes.length); 40 | _buffer._bytes.setAll(index, bytes); 41 | } 42 | 43 | void set(int offset, int value) { 44 | _filled(offset); 45 | _buffer._bytes[offset] = value & mask8; 46 | } 47 | 48 | int at(int pos) => _buffer._bytes[pos]; 49 | } 50 | -------------------------------------------------------------------------------- /lib/layout/core/core.dart: -------------------------------------------------------------------------------- 1 | export 'core/core.dart'; 2 | export 'types/custom_layout.dart'; 3 | export 'types/none.dart'; 4 | export 'types/numeric.dart'; 5 | export 'types/optional_layout.dart'; 6 | export 'types/tuple_layout.dart'; 7 | export 'types/coption_layout.dart'; 8 | export 'types/array.dart'; 9 | export 'types/compact.dart'; 10 | export 'types/compact_bytes.dart'; 11 | export 'types/struct.dart'; 12 | export 'types/union.dart'; 13 | export 'types/raw.dart'; 14 | export 'types/map.dart'; 15 | export 'types/constant.dart'; 16 | export 'types/compact_layout.dart'; 17 | export 'types/padding_layout.dart'; 18 | export 'types/bit_sequence.dart'; 19 | export 'types/xdr_bytes.dart'; 20 | export 'types/lazy_union.dart'; 21 | export 'types/lazy_struct.dart'; 22 | export 'types/leb128.dart'; 23 | export 'types/leb128_offset.dart'; 24 | -------------------------------------------------------------------------------- /lib/layout/core/types/bit_sequence.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/constant/constant.dart'; 3 | import 'package:blockchain_utils/layout/core/core/core.dart'; 4 | 5 | class BitSequenceLayout extends Layout> { 6 | const BitSequenceLayout({String? property}) : super(-1, property: property); 7 | static final _lengthCodec = LayoutConst.compactIntU48(); 8 | 9 | @override 10 | BitSequenceLayout clone({String? newProperty}) { 11 | return BitSequenceLayout(property: property); 12 | } 13 | 14 | @override 15 | int getSpan(LayoutByteReader? bytes, {int offset = 0, List? source}) { 16 | return bytes!.getCompactTotalLenght(offset).item2 ~/ 8; 17 | } 18 | 19 | @override 20 | LayoutDecodeResult> decode(LayoutByteReader bytes, 21 | {int offset = 0}) { 22 | final decode = bytes.getCompactLengthInfos(offset); 23 | final totalLength = decode.item1 + (decode.item2 ~/ 8); 24 | final result = bytes.sublist(offset + decode.item1, offset + totalLength); 25 | return LayoutDecodeResult(consumed: totalLength, value: result); 26 | } 27 | 28 | @override 29 | int encode(List source, LayoutByteWriter writer, {int offset = 0}) { 30 | final int length = 31 | _lengthCodec.encode(source.length * 8, writer, offset: offset); 32 | 33 | writer.setAll(offset + length, source); 34 | return source.length + length; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/layout/core/types/compact.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/core/core/core.dart'; 3 | import 'package:blockchain_utils/layout/utils/utils.dart'; 4 | import 'numeric.dart'; 5 | 6 | class CompactOffsetLayout extends ExternalLayout { 7 | const CompactOffsetLayout({String? property}) : super(-1, property: property); 8 | 9 | @override 10 | bool isCount() { 11 | return true; 12 | } 13 | 14 | @override 15 | LayoutDecodeResult decode(LayoutByteReader bytes, {int offset = 0}) { 16 | throw UnimplementedError(); 17 | } 18 | 19 | @override 20 | int encode(int source, LayoutByteWriter writer, {int offset = 0}) { 21 | final encodeLength = LayoutSerializationUtils.compactIntToBytes(source); 22 | writer.setAll(offset, encodeLength); 23 | return encodeLength.length; 24 | } 25 | 26 | @override 27 | CompactOffsetLayout clone({String? newProperty}) { 28 | return CompactOffsetLayout(property: newProperty); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/layout/core/types/compact_bytes.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/constant/constant.dart'; 3 | import 'package:blockchain_utils/layout/core/core/core.dart'; 4 | 5 | class CompactBytes extends Layout> { 6 | const CompactBytes({String? property}) : super(-1, property: property); 7 | static final _lengthCodec = LayoutConst.compactIntU48(); 8 | 9 | @override 10 | CompactBytes clone({String? newProperty}) { 11 | return CompactBytes(property: property); 12 | } 13 | 14 | @override 15 | int getSpan(LayoutByteReader? bytes, {int offset = 0, List? source}) { 16 | return bytes!.getCompactTotalLenght(offset).item2; 17 | } 18 | 19 | @override 20 | LayoutDecodeResult> decode(LayoutByteReader bytes, 21 | {int offset = 0}) { 22 | final decode = bytes.getCompactTotalLenght(offset); 23 | final result = bytes.sublist(offset + decode.item1, offset + decode.item2); 24 | return LayoutDecodeResult(consumed: decode.item2, value: result); 25 | } 26 | 27 | @override 28 | int encode(List source, LayoutByteWriter writer, {int offset = 0}) { 29 | final int length = 30 | _lengthCodec.encode(source.length, writer, offset: offset); 31 | writer.setAll(offset + length, source); 32 | return source.length + length; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/layout/core/types/compact_layout.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/core/core/core.dart'; 3 | import 'package:blockchain_utils/layout/utils/utils.dart'; 4 | 5 | class CompactLayout extends Layout { 6 | CompactLayout(this.layout, {String? property}) 7 | : super(-1, property: property); 8 | final Layout layout; 9 | 10 | @override 11 | LayoutDecodeResult decode(LayoutByteReader bytes, {int offset = 0}) { 12 | final decode = bytes.getCompactTotalLenght(offset); 13 | final result = layout 14 | .decode(bytes.getReader(offset + decode.item1, offset + decode.item2)); 15 | return LayoutDecodeResult(consumed: decode.item2, value: result.value); 16 | } 17 | 18 | @override 19 | int encode(T source, LayoutByteWriter writer, {int offset = 0}) { 20 | final encode = layout.serialize(source); 21 | final lengthBytes = LayoutSerializationUtils.encodeLength(encode); 22 | writer.setAll(offset, lengthBytes); 23 | writer.setAll(offset + lengthBytes.length, encode); 24 | return encode.length + lengthBytes.length; 25 | } 26 | 27 | @override 28 | int getSpan(LayoutByteReader? bytes, {int offset = 0, T? source}) { 29 | return bytes!.getCompactTotalLenght(offset).item2; 30 | } 31 | 32 | @override 33 | CompactLayout clone({String? newProperty}) { 34 | return CompactLayout(layout, property: newProperty); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/layout/core/types/constant.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/core/core/core.dart'; 3 | 4 | /// A class representing a constant layout within a buffer. 5 | class ConstantLayout extends Layout { 6 | /// The value produced by this constant when the layout is decoded. 7 | /// 8 | /// Any Dart value including `null` and `undefined` is permitted. 9 | /// 10 | /// **WARNING** If `value` passed in the constructor was not 11 | /// frozen, it is possible for users of decoded values to change 12 | /// the content of the value. 13 | final T value; 14 | 15 | /// Constructs a [ConstantLayout] layout with the given [value] and [property]. 16 | const ConstantLayout(this.value, {String? property}) 17 | : super(0, property: property); 18 | 19 | @override 20 | LayoutDecodeResult decode(LayoutByteReader bytes, {int offset = 0}) { 21 | return LayoutDecodeResult(consumed: 0, value: value); 22 | } 23 | 24 | @override 25 | int encode(T source, LayoutByteWriter writer, {int offset = 0}) { 26 | // Constants take no space 27 | return 0; 28 | } 29 | 30 | @override 31 | Layout clone({String? newProperty}) { 32 | return ConstantLayout(value, property: newProperty); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/layout/core/types/none.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/core/core/core.dart'; 3 | 4 | /// Represents a layout with no data. 5 | class NoneLayout extends Layout { 6 | const NoneLayout({String? property}) : super(0, property: property); 7 | 8 | /// Constructs a [NoneLayout] layout. 9 | /// 10 | /// - [property] (optional): The property identifier. 11 | @override 12 | Layout clone({String? newProperty}) { 13 | return NoneLayout(property: newProperty); 14 | } 15 | 16 | @override 17 | decode(LayoutByteReader bytes, {int offset = 0}) { 18 | return const LayoutDecodeResult(consumed: 0, value: null); 19 | } 20 | 21 | @override 22 | int encode(source, LayoutByteWriter writer, {int offset = 0}) { 23 | return 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/layout/core/types/padding_layout.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/layout/byte/byte_handler.dart'; 2 | import 'package:blockchain_utils/layout/core/core/core.dart'; 3 | import 'numeric.dart'; 4 | 5 | class PaddingLayout extends Layout { 6 | final BaseIntiger layout; 7 | PaddingLayout(this.layout, {String? property}) 8 | : super(layout.span, property: property); 9 | 10 | @override 11 | int getSpan(LayoutByteReader? bytes, {int offset = 0, T? source}) { 12 | return layout.getSpan(bytes, offset: offset, source: source); 13 | } 14 | 15 | @override 16 | PaddingLayout clone({String? newProperty}) { 17 | return PaddingLayout(layout, property: newProperty); 18 | } 19 | 20 | @override 21 | LayoutDecodeResult decode(LayoutByteReader bytes, {int offset = 0}) { 22 | return layout.decode(bytes, offset: offset); 23 | } 24 | 25 | @override 26 | int encode(T source, LayoutByteWriter writer, {int offset = 0}) { 27 | return layout.encode(source, writer, offset: offset); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/layout/exception/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | class LayoutException extends BlockchainUtilsException { 4 | const LayoutException(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/layout/layout.dart: -------------------------------------------------------------------------------- 1 | export 'core/core.dart'; 2 | export 'constant/constant.dart'; 3 | export 'utils/utils.dart'; 4 | export 'exception/exception.dart'; 5 | -------------------------------------------------------------------------------- /lib/secret_wallet/exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | 3 | class Web3SecretStorageDefinationV3Exception extends BlockchainUtilsException { 4 | const Web3SecretStorageDefinationV3Exception(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/service/service.dart: -------------------------------------------------------------------------------- 1 | export 'models/params.dart'; 2 | export 'const/constant.dart'; 3 | export 'utils/utils.dart'; 4 | -------------------------------------------------------------------------------- /lib/signer/exception/signing_exception.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/exception/exception.dart'; 2 | 3 | class CryptoSignException extends CryptoException { 4 | const CryptoSignException(super.message, {super.details}); 5 | } 6 | -------------------------------------------------------------------------------- /lib/signer/signer.dart: -------------------------------------------------------------------------------- 1 | export 'xrp/xrp_signer.dart'; 2 | export 'bitcoin/bitcoin_signer.dart'; 3 | export 'types/eth_signature.dart'; 4 | export 'eth/eth_signer.dart'; 5 | export 'tron/tron_signer.dart'; 6 | export 'cardano/cardano_signer.dart'; 7 | export 'substrate/substrate.dart'; 8 | export 'const/constants.dart'; 9 | export 'secp256k1/secp256k1_signer.dart'; 10 | export 'secp256r1/secp256r1_signer.dart'; 11 | export 'ed25519/ed25519.dart'; 12 | export 'signing_key/ecdsa_signing_key.dart'; 13 | export 'utils/utils.dart'; 14 | export 'bitcoin/bitcoin_key_signer.dart'; 15 | export 'exception/signing_exception.dart'; 16 | -------------------------------------------------------------------------------- /lib/ss58/ss58.dart: -------------------------------------------------------------------------------- 1 | /// Library for SS58 address encoding and decoding. 2 | library; 3 | 4 | /// Export statement for SS58 address encoding-decoding functionality. 5 | export 'ss58_base.dart'; 6 | -------------------------------------------------------------------------------- /lib/ss58/ss58_ex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/exception/exceptions.dart'; 2 | 3 | /// An exception class for errors related to SS58 address checksum validation. 4 | /// 5 | /// The [message] field can contain additional information about the error. 6 | class SS58ChecksumError extends BlockchainUtilsException { 7 | const SS58ChecksumError(super.message, {super.details}); 8 | } 9 | -------------------------------------------------------------------------------- /lib/utils/binary/bit_utils.dart: -------------------------------------------------------------------------------- 1 | /// Class container for bit utility functions. 2 | class BitUtils { 3 | /// Get if the specified bit is set. 4 | static bool intIsBitSet(int value, int bitNum) { 5 | return (value & (1 << bitNum)) != 0; 6 | } 7 | 8 | /// Get if the specified bits are set. 9 | static bool areBitsSet(int value, int bitMask) { 10 | return (value & bitMask) != 0; 11 | } 12 | 13 | /// Set the specified bit. 14 | static int setBit(int value, int bitNum) { 15 | return value | (1 << bitNum); 16 | } 17 | 18 | /// Set the specified bits. 19 | static int setBits(int value, int bitMask) { 20 | return value | bitMask; 21 | } 22 | 23 | /// Reset the specified bit. 24 | static int resetBit(int value, int bitNum) { 25 | return value & ~(1 << bitNum); 26 | } 27 | 28 | /// Reset the specified bits. 29 | static int resetBits(int value, int bitMask) { 30 | return value & ~bitMask; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/utils/binary/bytes_tracker.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/helper/helper.dart'; 2 | 3 | /// A utility class for tracking bytes dynamically. 4 | class DynamicByteTracker { 5 | final List _buffer = List.empty(growable: true); 6 | 7 | /// Get the last byte in the tracked bytes. 8 | int get last => _buffer.last; 9 | 10 | /// buffer bytes. 11 | List toBytes() { 12 | return List.from(_buffer); 13 | } 14 | 15 | void add(List chunk) { 16 | _buffer.addAll(chunk.asBytes); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/utils/compare/hash_code.dart: -------------------------------------------------------------------------------- 1 | import '../binary/binary_operation.dart'; 2 | 3 | /// A utility class for generating consistent and efficient hash codes 4 | /// for collections and objects. 5 | class HashCodeGenerator { 6 | /// Generates a hash code for a list of bytes, optionally including 7 | /// additional objects in the calculation. 8 | /// 9 | /// Returns: A 32-bit integer hash code. 10 | static int generateBytesHashCode(List bytes, 11 | [List optional = const []]) { 12 | int hash = 12; 13 | for (final element in bytes) { 14 | hash ^= element; 15 | hash = (hash * 31) & mask32; 16 | } 17 | if (optional.isNotEmpty) { 18 | hash = (hash ^ generateHashCode(optional)) & mask32; 19 | } 20 | return hash; 21 | } 22 | 23 | /// Generates a hash code for a collection of objects, recursively handling 24 | /// nested iterables. 25 | /// 26 | /// Returns: A 32-bit integer hash code. 27 | static int generateHashCode(Iterable objects) { 28 | int hash = 12; 29 | for (final element in objects) { 30 | if (element is Iterable) { 31 | hash = (hash ^ generateHashCode(element)) & mask32; 32 | } else { 33 | hash = (hash ^ element.hashCode) & mask32; 34 | } 35 | } 36 | return hash; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/utils/equatable/equatable.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | 3 | abstract mixin class Equality { 4 | List get variabels; 5 | 6 | @override 7 | bool operator ==(Object other) { 8 | if (identical(this, other)) { 9 | return true; 10 | } 11 | if (other is! Equality) { 12 | return false; 13 | } 14 | if (other.runtimeType != runtimeType) return false; 15 | return CompareUtils.iterableIsEqual(variabels, other.variabels); 16 | } 17 | 18 | @override 19 | int get hashCode { 20 | return HashCodeGenerator.generateHashCode(variabels); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/utils/numbers/numbers.dart: -------------------------------------------------------------------------------- 1 | export 'utils/bigint_utils.dart'; 2 | 3 | /// bigint utils 4 | export 'utils/int_utils.dart'; 5 | 6 | /// BigintUtils 7 | export 'rational/big_rational.dart'; 8 | -------------------------------------------------------------------------------- /lib/utils/tuple/tuple.dart: -------------------------------------------------------------------------------- 1 | /// A generic Tuple class with two typed elements, [T] and [R]. 2 | /// Tuples are immutable, and this class provides a simple way to store pairs of values. 3 | class Tuple { 4 | /// Field to store the first element of the tuple. 5 | final T item1; 6 | 7 | /// Field to store the second element of the tuple. 8 | final R item2; 9 | 10 | /// Constructor to initialize the tuple with the provided values. 11 | const Tuple(this.item1, this.item2); 12 | } 13 | -------------------------------------------------------------------------------- /lib/utils/utils.dart: -------------------------------------------------------------------------------- 1 | export 'binary/binary_operation.dart'; 2 | export 'binary/bit_utils.dart'; 3 | export 'binary/utils.dart'; 4 | export 'binary/bytes_tracker.dart'; 5 | 6 | export 'compare/compare.dart'; 7 | export 'compare/hash_code.dart'; 8 | export 'numbers/numbers.dart'; 9 | export 'string/string.dart'; 10 | export 'tuple/tuple.dart'; 11 | export 'equatable/equatable.dart'; 12 | -------------------------------------------------------------------------------- /test/address/ada_byron/byron_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/ada/ada_byron_addr.dart'; 2 | import 'package:blockchain_utils/utils/utils.dart'; 3 | import 'package:test/test.dart'; 4 | import 'byron_test_vector.dart' as byron; 5 | import 'lagacy_test_vector.dart' as lagacy; 6 | 7 | void main() { 8 | test("ada byron legacy test", () { 9 | for (final i in lagacy.testVector) { 10 | final params = Map.from(i["params"]); 11 | params["chain_code"] = BytesUtils.fromHexString(params["chain_code"]); 12 | params["hd_path_key"] = BytesUtils.fromHexString(params["hd_path_key"]); 13 | final l = AdaByronLegacyAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(l, i["address"]); 16 | final decode = AdaByronAddrDecoder().decodeAddr(l); 17 | expect( 18 | BytesUtils.bytesEqual(decode, BytesUtils.fromHexString(i["decode"])), 19 | true); 20 | } 21 | }); 22 | 23 | test("ada byron icarus test", () { 24 | for (final i in byron.testVector) { 25 | final params = Map.from(i["params"]); 26 | params["chain_code"] = BytesUtils.fromHexString(params["chain_code"]); 27 | final l = AdaByronIcarusAddrEncoder() 28 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 29 | expect(l, i["address"]); 30 | final decode = AdaByronAddrDecoder().decodeAddr(l); 31 | expect( 32 | BytesUtils.bytesEqual(decode, BytesUtils.fromHexString(i["decode"])), 33 | true); 34 | } 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /test/address/ada_shelly/ada_shelly_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/ada/ada_shelley_addr.dart'; 2 | 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:blockchain_utils/bip/address/encoders.dart'; 5 | import 'package:test/test.dart'; 6 | import '../../quick_hex.dart'; 7 | import 'test_vector.dart'; 8 | import 'stacking_test_vector.dart' as t; 9 | 10 | void main() { 11 | test("adda shelly address test", () { 12 | for (final i in testVector) { 13 | final params = Map.from(i["params"]); 14 | params["pub_skey"] = BytesUtils.fromHexString(params["pub_skey"]); 15 | final z = AdaShelleyAddrEncoder() 16 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 17 | expect(z, i["address"]); 18 | final decode = AdaShelleyAddrDecoder().decodeAddr(z, params); 19 | expect(decode.toHex(), i["decode"]); 20 | } 21 | }); 22 | test("ada shelly stacking address test", () { 23 | for (final i in t.testVector) { 24 | final params = Map.from(i["params"]); 25 | final netTag = ADANetwork.values.firstWhere((element) => 26 | element.name.toLowerCase() == 27 | (params["net_tag"] as String).toLowerCase()); 28 | 29 | params["net_tag"] = netTag; 30 | final z = AdaShelleyStakingAddrEncoder() 31 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 32 | expect(z, i["address"]); 33 | final decode = AdaShelleyStakingAddrDecoder().decodeAddr(z, params); 34 | expect(decode.toHex(), i["decode"]); 35 | } 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /test/address/algo/algo_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/algo_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("algo address tes", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = AlgoAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = AlgoAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/atom/atom_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/atom_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | import 'test_vector.dart'; 6 | 7 | void main() { 8 | test("atom address test", () { 9 | for (final i in testVector) { 10 | final params = Map.from(i["params"]); 11 | 12 | final z = AtomAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = AtomAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/avax/avax_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/avax_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_p_vector.dart' as p; 7 | import 'test_x_vector.dart' as x; 8 | 9 | void main() { 10 | test("avax P-address test", () { 11 | for (final i in p.testVector) { 12 | final params = Map.from(i["params"]); 13 | 14 | final z = AvaxPChainAddrEncoder() 15 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 16 | expect(z, i["address"]); 17 | final decode = AvaxPChainAddrDecoder().decodeAddr(z, params); 18 | expect(decode.toHex(), i["decode"]); 19 | } 20 | }); 21 | test("avax x-address test", () { 22 | for (final i in x.testVector) { 23 | final params = Map.from(i["params"]); 24 | 25 | final z = AvaxXChainAddrEncoder() 26 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 27 | expect(z, i["address"]); 28 | final decode = AvaxXChainAddrDecoder().decodeAddr(z, params); 29 | expect(decode.toHex(), i["decode"]); 30 | } 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/address/bch_p2pkh/bch_p2pkh_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/p2pkh_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("bch p2pkh test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | params["net_ver"] = BytesUtils.fromHexString(params["net_ver"]); 13 | 14 | final z = BchP2PKHAddrEncoder() 15 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 16 | expect(z, i["address"]); 17 | final decode = BchP2PKHAddrDecoder().decodeAddr(z, params); 18 | expect(decode.toHex(), i["decode"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/address/bch_p2sh/bch_p2sh_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/p2sh_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("bch address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | params["net_ver"] = BytesUtils.fromHexString(params["net_ver"]); 13 | 14 | final z = BchP2SHAddrEncoder() 15 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 16 | expect(z, i["address"]); 17 | final decode = BchP2SHAddrDecoder().decodeAddr(z, params); 18 | expect(decode.toHex(), i["decode"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/address/egld/egld_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/egld_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("egld address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = EgldAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = EgldAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/eos/eos_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/eos_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("eos address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = EosAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = EosAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/ergo/ergo_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/ergo.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("ergo address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | params["net_type"] = ErgoNetworkTypes.values.firstWhere((element) => 13 | element.name.toLowerCase() == 14 | (params["net_type"] as String).toLowerCase()); 15 | final z = ErgoP2PKHAddrEncoder() 16 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 17 | expect(z, i["address"]); 18 | final decode = ErgoP2PKHAddrDecoder().decodeAddr(z, params); 19 | expect(decode.toHex(), i["decode"]); 20 | } 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/address/eth/eth_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/eth_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("eth address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = EthAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = EthAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/fil/fil_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/fil_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("fil address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = FilSecp256k1AddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = FilSecp256k1AddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/icx/icx_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/icx_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVecotr; 7 | 8 | void main() { 9 | test("icx address test", () { 10 | for (final i in testVecotr) { 11 | final params = Map.from(i["params"]); 12 | final z = IcxAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = IcxAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/inj/inj_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/inj_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("inj address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = InjAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = InjAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/nano/nano_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/nano_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("neo address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = NanoAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | 15 | expect(z, i["address"]); 16 | final decode = NanoAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/near/near_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/near_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("near address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = NearAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = NearAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/neo/neo_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/neo_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVecotr; 7 | 8 | void main() { 9 | test("neo address test", () { 10 | for (final i in testVecotr) { 11 | final params = Map.from(i["params"]); 12 | params["ver"] = BytesUtils.fromHexString(params["ver"]); 13 | final z = NeoAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = NeoAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/okex/okex_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/okex_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("okex address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = OkexAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = OkexAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/one/one_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/one_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("one address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = OneAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = OneAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/p2pkh/p2pkh_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | import 'comperesed_test_vector.dart' show compresedTestVector; 6 | import 'uncompresed_test_vector.dart' show uncompressedTestVector; 7 | 8 | void main() { 9 | test("p2pkh address test", () { 10 | for (final i in compresedTestVector) { 11 | final params = Map.from(i["params"]); 12 | params["pub_key_mode"] = PubKeyModes.compressed; 13 | params["net_ver"] = BytesUtils.fromHexString(params["net_ver"]); 14 | final z = P2PKHAddrEncoder() 15 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 16 | expect(z, i["address"]); 17 | final decode = P2PKHAddrDecoder().decodeAddr(z, params); 18 | expect(decode.toHex(), i["decode"]); 19 | } 20 | }); 21 | test("p2pkh uncompressed publickey address test", () { 22 | for (final i in uncompressedTestVector) { 23 | final params = Map.from(i["params"]); 24 | params["pub_key_mode"] = PubKeyModes.uncompressed; 25 | params["net_ver"] = BytesUtils.fromHexString(params["net_ver"]); 26 | final z = P2PKHAddrEncoder() 27 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 28 | expect(z, i["address"]); 29 | final decode = P2PKHAddrDecoder().decodeAddr(z, params); 30 | expect(decode.toHex(), i["decode"]); 31 | } 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/address/p2sh/p2sh_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/p2sh_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("p2sh address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | params["net_ver"] = BytesUtils.fromHexString(params["net_ver"]); 13 | final z = P2SHAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = P2SHAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/p2tr/p2tr_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/p2tr_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("p2tr address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = P2TRAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = P2TRAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/p2wpkh/p2wpkh_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/p2wpkh_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("p2wpkh address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = P2WPKHAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = P2WPKHAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/sol/sol_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/sol_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("solana address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = SolAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = SolAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/substrate/substrate_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/bip/address/substrate_addr.dart'; 3 | import '../../quick_hex.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("substrate ED25519 test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = SubstrateEd25519AddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = SubstrateEd25519AddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | test("substrate sr25519 test", () { 21 | for (final i in testVector) { 22 | final params = Map.from(i["params"]); 23 | 24 | final z = SubstrateGenericAddrEncoder() 25 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 26 | expect(z, i["address"]); 27 | final decode = SubstrateGenericAddrDecoder().decodeAddr(z, params); 28 | expect(decode.toHex(), i["decode"]); 29 | } 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/address/ton/address_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | import 'test_vector.dart'; 5 | 6 | void main() { 7 | _test(); 8 | } 9 | 10 | void _test() { 11 | test("Ton encode, decode address", () { 12 | final encoder = TonAddrEncoder(); 13 | final decoder = TonAddrDecoder(); 14 | for (final i in tonTestVector) { 15 | final hash = BytesUtils.fromHexString(i["hash"]); 16 | final String bounceable = 17 | encoder.encodeKey(hash, {"workchain": i["workchain"]}); 18 | final String nonBounceable = encoder 19 | .encodeKey(hash, {"workchain": i["workchain"], "bounceable": false}); 20 | expect(bounceable, i["bounceable"]); 21 | expect(nonBounceable, i["nonBounceable"]); 22 | final decodeBounceable = decoder.decodeAddr(bounceable); 23 | final decodeNonBounceable = decoder.decodeAddr(bounceable); 24 | expect(decodeBounceable, hash); 25 | expect(decodeNonBounceable, hash); 26 | } 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/address/trx/trx_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/trx_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVecotr; 7 | 8 | void main() { 9 | test("trx address test", () { 10 | for (final i in testVecotr) { 11 | final params = Map.from(i["params"]); 12 | 13 | final z = TrxAddrEncoder() 14 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 15 | expect(z, i["address"]); 16 | final decode = TrxAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/xlm/xml_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/xlm_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("xml address test", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | params["addr_type"] = XlmAddrTypes.values 13 | .firstWhere((element) => element.value == params["addr_type"]); 14 | final z = XlmAddrEncoder() 15 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 16 | expect(z, i["address"]); 17 | final decode = XlmAddrDecoder().decodeAddr(z, params); 18 | expect(decode.toHex(), i["decode"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/address/xrp/xrp_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/xrp_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("xrp address", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = XrpAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = XrpAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/address/xtz/xtz_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/xtz_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("xtz address", () { 10 | for (final i in testVector) { 11 | final params = Map.from({"prefix": XtzAddrPrefixes.tz1}); 12 | final z = XtzAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | 15 | expect(z, i["address"]); 16 | final decode = XtzAddrDecoder().decodeAddr(z, params); 17 | expect(decode.toHex(), i["decode"]); 18 | } 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/address/zil/zil_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/address/zil_addr.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart' show testVector; 7 | 8 | void main() { 9 | test("zil address", () { 10 | for (final i in testVector) { 11 | final params = Map.from(i["params"]); 12 | final z = ZilAddrEncoder() 13 | .encodeKey(BytesUtils.fromHexString(i["public"]), params); 14 | expect(z, i["address"]); 15 | final decode = ZilAddrDecoder().decodeAddr(z, params); 16 | expect(decode.toHex(), i["decode"]); 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/algorand/mnemonic_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/algorand/mnemonic/algorand_mnemonic_decoder.dart'; 2 | import 'package:blockchain_utils/bip/algorand/mnemonic/algorand_mnemonic_generator.dart'; 3 | import 'package:blockchain_utils/bip/algorand/mnemonic/algorand_mnemonic_validator.dart'; 4 | import 'package:blockchain_utils/bip/algorand/mnemonic/algorand_seed_generator.dart'; 5 | import 'package:blockchain_utils/bip/bip/bip44/bip44_base.dart'; 6 | import 'package:blockchain_utils/bip/bip/conf/bip44/bip44_coins.dart'; 7 | import 'package:blockchain_utils/utils/utils.dart'; 8 | import 'package:test/test.dart'; 9 | import '../quick_hex.dart'; 10 | import 'test_vector.dart'; 11 | 12 | void main() { 13 | test("algorand", () { 14 | for (final i in testVector) { 15 | final mn = AlgorandMnemonicGenerator() 16 | .fromEntropy(BytesUtils.fromHexString(i["entropy"])); 17 | final valid = AlgorandMnemonicValidator().isValid(mn.toStr()); 18 | expect(valid, true); 19 | final entropy = AlgorandMnemonicDecoder().decode(mn.toStr()); 20 | expect(entropy.toHex(), i["entropy"]); 21 | final seed = AlgorandSeedGenerator(mn).generate(); 22 | expect(seed.toHex(), i["entropy"]); 23 | final bip44 = Bip44.fromPrivateKey(seed, Bip44Coins.algorand); 24 | final address = bip44.publicKey.toAddress; 25 | expect(address, i["address"]); 26 | } 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/bip/bip32/ed25519/ed25519_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip32/bip32_key_data.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip32/slip10/bip32_slip10_ed25519.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("bip32 ed25519", () { 10 | for (final i in testVector) { 11 | final seed = BytesUtils.fromHexString(i["seed"]); 12 | Bip32Slip10Ed25519 w = Bip32Slip10Ed25519.fromSeed(seed); 13 | expect(w.publicKey.toExtended, i["public"]); 14 | expect(w.privateKey.toExtended, i["private"]); 15 | expect(w.chainCode.toHex(), i["chaincode"]); 16 | expect(w.fingerPrint.toHex(), i["finger_print"]); 17 | for (final c in (i["child"] as List)) { 18 | final index = Bip32KeyIndex(c["index"]); 19 | w = w.childKey(index); 20 | expect(w.publicKey.toExtended, c["public"]); 21 | expect(w.privateKey.toExtended, c["private"]); 22 | expect(w.chainCode.toHex(), c["chaincode"]); 23 | expect(w.fingerPrint.toHex(), c["finger_print"]); 24 | expect(w.parentFingerPrint.toHex(), c["parent_finger_print"]); 25 | expect(w.depth.toInt(), c["depth"]); 26 | } 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/bip/bip32/ed25519_blake2b/ed25519_blake2b_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip32/bip32_key_data.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip32/slip10/bip32_slip10_ed25519_blake2b.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("bip32 ed25519 blake2b", () { 10 | for (final i in testVector) { 11 | final seed = BytesUtils.fromHexString(i["seed"]); 12 | var w = Bip32Slip10Ed25519Blake2b.fromSeed(seed); 13 | expect(w.publicKey.toExtended, i["public"]); 14 | expect(w.privateKey.toExtended, i["private"]); 15 | expect(w.chainCode.toHex(), i["chaincode"]); 16 | expect(w.fingerPrint.toHex(), i["finger_print"]); 17 | for (final c in (i["child"] as List)) { 18 | final index = Bip32KeyIndex(c["index"]); 19 | w = w.childKey(index); 20 | expect(w.publicKey.toExtended, c["public"]); 21 | expect(w.privateKey.toExtended, c["private"]); 22 | expect(w.chainCode.toHex(), c["chaincode"]); 23 | expect(w.fingerPrint.toHex(), c["finger_print"]); 24 | expect(w.parentFingerPrint.toHex(), c["parent_finger_print"]); 25 | expect(w.depth.toInt(), c["depth"]); 26 | } 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/bip/bip32/ed25519_khalow/ed25519_khalow_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip32/bip32_key_data.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip32/khalow/bip32_kholaw_ed25519.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("ed25519 khalow", () { 10 | for (final i in testVector) { 11 | final seed = BytesUtils.fromHexString(i["seed"]); 12 | var w = Bip32KholawEd25519.fromSeed(seed); 13 | expect(w.publicKey.toExtended, i["public"]); 14 | expect(w.privateKey.toExtended, i["private"]); 15 | expect(w.chainCode.toHex(), i["chaincode"]); 16 | expect(w.fingerPrint.toHex(), i["finger_print"]); 17 | for (final c in (i["child"] as List)) { 18 | final index = Bip32KeyIndex(c["index"]); 19 | w = w.childKey(index); 20 | expect(w.publicKey.toExtended, c["public"]); 21 | expect(w.privateKey.toExtended, c["private"]); 22 | expect(w.chainCode.toHex(), c["chaincode"]); 23 | expect(w.fingerPrint.toHex(), c["finger_print"]); 24 | expect(w.parentFingerPrint.toHex(), c["parent_finger_print"]); 25 | expect(w.depth.toInt(), c["depth"]); 26 | } 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/bip/bip32/nist256p1/nist256p1_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip32/bip32_key_data.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip32/slip10/bip32_slip10_nist256p1.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("nist256p1", () { 10 | for (final i in testVector) { 11 | final seed = BytesUtils.fromHexString(i["seed"]); 12 | var w = Bip32Slip10Nist256p1.fromSeed(seed); 13 | expect(w.publicKey.toExtended, i["public"]); 14 | expect(w.privateKey.toExtended, i["private"]); 15 | expect(w.chainCode.toHex(), i["chaincode"]); 16 | expect(w.fingerPrint.toHex(), i["finger_print"]); 17 | 18 | for (final c in (i["child"] as List)) { 19 | final index = Bip32KeyIndex(c["index"]); 20 | w = w.childKey(index); 21 | expect(w.publicKey.toExtended, c["public"]); 22 | expect(w.privateKey.toExtended, c["private"]); 23 | expect(w.chainCode.toHex(), c["chaincode"]); 24 | expect(w.fingerPrint.toHex(), c["finger_print"]); 25 | expect(w.parentFingerPrint.toHex(), c["parent_finger_print"]); 26 | expect(w.depth.toInt(), c["depth"]); 27 | } 28 | } 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/bip/bip32/secp256k1/secp256k1_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | import 'test_vector.dart'; 5 | 6 | void main() { 7 | test("bip32 secp256k1", () { 8 | for (final i in testVector) { 9 | final seed = BytesUtils.fromHexString(i["seed"]); 10 | Bip32Slip10Secp256k1 w = Bip32Slip10Secp256k1.fromSeed(seed); 11 | expect(w.publicKey.toExtended, i["public"]); 12 | expect(w.privateKey.toExtended, i["private"]); 13 | expect(w.chainCode.toHex(), i["chaincode"]); 14 | expect(w.fingerPrint.toHex(), i["finger_print"]); 15 | 16 | for (final c in (i["child"] as List)) { 17 | final index = Bip32KeyIndex(c["index"]); 18 | w = w.childKey(index); 19 | 20 | expect(w.publicKey.toExtended, c["public"]); 21 | 22 | expect(w.privateKey.toExtended, c["private"]); 23 | 24 | expect(w.chainCode.toHex(), c["chaincode"]); 25 | expect(w.fingerPrint.toHex(), c["finger_print"]); 26 | expect(w.parentFingerPrint.toHex(), c["parent_finger_print"]); 27 | expect(w.depth.toInt(), c["depth"]); 28 | } 29 | } 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/bip/bip38/bip38_addr_test.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: depend_on_referenced_packages 2 | 3 | import 'package:blockchain_utils/blockchain_utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | List> _testVector = [ 7 | { 8 | "pub_key_mode": PubKeyModes.compressed, 9 | "pub_key": 10 | "03aaeb52dd7494c361049de67cc680e83ebcbbbdbeb13637d92cd845f70308af5e", 11 | "address_hash": "a374deb6", 12 | }, 13 | { 14 | "pub_key_mode": PubKeyModes.uncompressed, 15 | "pub_key": 16 | "03aaeb52dd7494c361049de67cc680e83ebcbbbdbeb13637d92cd845f70308af5e", 17 | "address_hash": "6a531625", 18 | }, 19 | { 20 | "pub_key_mode": PubKeyModes.compressed, 21 | "pub_key": 22 | "02b5cbfe6ee73b7c5e968e1c515a964894f306a7c882dd18433ab4e16a66d36972", 23 | "address_hash": "97c1e671", 24 | }, 25 | { 26 | "pub_key_mode": PubKeyModes.uncompressed, 27 | "pub_key": 28 | "02b5cbfe6ee73b7c5e968e1c515a964894f306a7c882dd18433ab4e16a66d36972", 29 | "address_hash": "8805ef61", 30 | }, 31 | ]; 32 | void main() { 33 | test("address hash", () { 34 | for (final i in _testVector) { 35 | final result = Bip38Addr.addressHash( 36 | BytesUtils.fromHexString(i["pub_key"]), i["pub_key_mode"]); 37 | expect(BytesUtils.toHexString(result), i["address_hash"]); 38 | } 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /test/bip/bip39/bip39_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/bip/bip39/bip39_mnemonic_generator.dart'; 4 | import 'package:blockchain_utils/bip/bip/bip39/bip39_seed_generator.dart'; 5 | import 'package:blockchain_utils/utils/utils.dart'; 6 | import 'package:test/test.dart'; 7 | import '../../quick_hex.dart'; 8 | import 'test_vector.dart' show testVector; 9 | 10 | const String _passphrase = "MRT"; 11 | void main() { 12 | test("bip39", () { 13 | for (final i in testVector) { 14 | final lower = (i["lang"] as String).replaceAll("_", "").toLowerCase(); 15 | final lang = Bip39Languages.values 16 | .firstWhere((element) => element.name.toLowerCase() == lower); 17 | final mn = Bip39MnemonicGenerator(lang) 18 | .fromEntropy(BytesUtils.fromHexString(i["entropy"])); 19 | expect(mn.toStr(), i["mnemonic"]); 20 | final decode = Bip39MnemonicDecoder(lang).decode(mn.toStr()); 21 | expect(decode.toHex(), i["entropy"]); 22 | final decodeWithChecksum = 23 | Bip39MnemonicDecoder(lang).decodeWithChecksum(mn.toStr()); 24 | expect(decodeWithChecksum.toHex(), i["checksum"]); 25 | final seed = Bip39SeedGenerator(mn).generate(_passphrase); 26 | expect(seed.toHex(), i["seed"]); 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/bip/bip49/bip49_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip49/bip49_base.dart'; 2 | import 'package:blockchain_utils/bip/bip/conf/bip49/bip49_coins.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | import 'test_vector.dart'; 6 | 7 | void main() { 8 | test("bip49", () { 9 | for (final i in testVector) { 10 | final seed = BytesUtils.fromHexString(i["seed"]); 11 | final coin = Bip49Coins.values.firstWhere((element) => 12 | element.name.toLowerCase() == 13 | (i["coin"] as String).replaceAll("_", "").toLowerCase()); 14 | final b44 = Bip49.fromSeed(seed, coin); 15 | final coinInex = b44.purpose.coin; 16 | expect(b44.privateKey.toExtended, i["master"]); 17 | expect(b44.publicKey.toExtended, i["master_public"]); 18 | expect(coinInex.privateKey.toExtended, i["coin_private"]); 19 | expect(coinInex.publicKey.toExtended, i["coin_public"]); 20 | final accounts = (i["child"] as List); 21 | for (int i = 0; i < accounts.length; i++) { 22 | final accountInfo = accounts[i]; 23 | final account = coinInex.account(i); 24 | expect(account.privateKey.toExtended, accountInfo["account"]); 25 | expect(account.publicKey.toExtended, accountInfo["account_public"]); 26 | expect(account.publicKey.toAddress, accountInfo["address"]); 27 | } 28 | } 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/bip/bip84/bip84_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip84/bip84_base.dart'; 2 | import 'package:blockchain_utils/bip/bip/conf/bip84/bip84_coins.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | import 'test_vector.dart'; 6 | 7 | void main() { 8 | test("bip84", () { 9 | for (final i in testVector) { 10 | final seed = BytesUtils.fromHexString(i["seed"]); 11 | final coin = Bip84Coins.values.firstWhere((element) => 12 | element.name.toLowerCase() == 13 | (i["coin"] as String).replaceAll("_", "").toLowerCase()); 14 | final b44 = Bip84.fromSeed(seed, coin); 15 | final coinInex = b44.purpose.coin; 16 | expect(b44.privateKey.toExtended, i["master"]); 17 | expect(b44.publicKey.toExtended, i["master_public"]); 18 | expect(coinInex.privateKey.toExtended, i["coin_private"]); 19 | expect(coinInex.publicKey.toExtended, i["coin_public"]); 20 | final accounts = (i["child"] as List); 21 | for (int i = 0; i < accounts.length; i++) { 22 | final accountInfo = accounts[i]; 23 | final account = coinInex.account(i); 24 | expect(account.privateKey.toExtended, accountInfo["account"]); 25 | expect(account.publicKey.toExtended, accountInfo["account_public"]); 26 | expect(account.publicKey.toAddress, accountInfo["address"]); 27 | } 28 | } 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/bip/bip86/bip86_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/bip/bip86/bip86_base.dart'; 2 | import 'package:blockchain_utils/bip/bip/conf/bip86/bip86_coins.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | import 'test_vector.dart'; 6 | 7 | void main() { 8 | test("bip 86", () { 9 | for (final i in testVector) { 10 | final seed = BytesUtils.fromHexString(i["seed"]); 11 | final coin = Bip86Coins.values.firstWhere((element) => 12 | element.name.toLowerCase() == 13 | (i["coin"] as String).replaceAll("_", "").toLowerCase()); 14 | final b44 = Bip86.fromSeed(seed, coin); 15 | final coinInex = b44.purpose.coin; 16 | expect(b44.privateKey.toExtended, i["master"]); 17 | expect(b44.publicKey.toExtended, i["master_public"]); 18 | expect(coinInex.privateKey.toExtended, i["coin_private"]); 19 | expect(coinInex.publicKey.toExtended, i["coin_public"]); 20 | final accounts = (i["child"] as List); 21 | for (int i = 0; i < accounts.length; i++) { 22 | final accountInfo = accounts[i]; 23 | final account = coinInex.account(i); 24 | expect(account.privateKey.toExtended, accountInfo["account"]); 25 | expect(account.publicKey.toExtended, accountInfo["account_public"]); 26 | expect(account.publicKey.toAddress, accountInfo["address"]); 27 | } 28 | } 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/cardano/mnemonic/mnemonic_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/cardano/mnemonic/cardano_byron_legacy_seed_generator.dart'; 2 | import 'package:blockchain_utils/bip/cardano/mnemonic/cardano_icarus_seed_generator.dart'; 3 | import 'package:test/test.dart'; 4 | import '../../quick_hex.dart'; 5 | import 'test_vector.dart'; 6 | 7 | void main() { 8 | test("mnemonic", () { 9 | for (final i in testVector) { 10 | final String mnemonic = i["mnemonic"]; 11 | final legacy = CardanoByronLegacySeedGenerator(mnemonic).generate(); 12 | final icarus = CardanoIcarusSeedGenerator(mnemonic).generate(); 13 | expect(legacy.toHex(), i["legacy"]); 14 | expect(icarus.toHex(), i["icarus"]); 15 | } 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /test/crypto/aes/aes_ctr_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:blockchain_utils/crypto/crypto/aes/aes.dart'; 4 | import 'package:blockchain_utils/crypto/crypto/ctr/ctr.dart'; 5 | import '../../quick_hex.dart'; 6 | import 'package:blockchain_utils/utils/utils.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | import 'test_vector.dart'; 10 | 11 | void main() { 12 | test("test aes ctr", () { 13 | for (final i in testVector) { 14 | final key = BytesUtils.fromHexString(i["key"]); 15 | final iv = BytesUtils.fromHexString(i["iv"]); 16 | final plainText = BytesUtils.fromHexString(i["plain_text"]); 17 | final encrypt = BytesUtils.fromHexString(i["encrypt"]); 18 | final CTR ctr = CTR(AES(key), iv); 19 | final encryptOut = Uint8List(plainText.length); 20 | ctr.streamXOR(plainText, encryptOut); 21 | ctr.clean(); 22 | ctr.setCipher(AES(key), iv); 23 | final decryptOut = Uint8List(encrypt.length); 24 | ctr.streamXOR(encrypt, decryptOut); 25 | expect(encryptOut.toHex(), encrypt.toHex()); 26 | expect(decryptOut.toHex(), plainText.toHex()); 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/crypto/blake2b/blake2b_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | 3 | import '../../quick_hex.dart'; 4 | import 'package:blockchain_utils/utils/utils.dart'; 5 | import 'package:test/test.dart'; 6 | 7 | import 'test_vector.dart'; 8 | 9 | void main() { 10 | test("blake2b test", () { 11 | for (final i in testVector64) { 12 | final k = BLAKE2b(digestLength: 64); 13 | final message = BytesUtils.fromHexString(i["message"]); 14 | k.update(message.sublist(0, 10)); 15 | k.update(message.sublist(10)); 16 | expect(k.digest().toHex(), i["hash"]); 17 | k.reset(); 18 | k.update(message); 19 | expect(k.digest().toHex(), i["hash"]); 20 | } 21 | }); 22 | test("blake2b with key and nonce test", () { 23 | for (final i in testVectorWithKeyAndSalt) { 24 | final key = BytesUtils.fromHexString(i["key"]); 25 | final salt = BytesUtils.fromHexString(i["salt"]); 26 | final k = BLAKE2b( 27 | digestLength: 64, config: Blake2bConfig(key: key, salt: salt)); 28 | final message = BytesUtils.fromHexString(i["message"]); 29 | k.update(message.sublist(0, 10)); 30 | k.update(message.sublist(10)); 31 | expect(k.digest().toHex(), i["hash"]); 32 | } 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/crypto/crc32/crc32_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/crc32/crc32.dart'; 2 | import 'package:blockchain_utils/utils/utils.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | import 'test_vector.dart'; 6 | 7 | void main() { 8 | test("crc test", () { 9 | for (final i in testVector) { 10 | final result = 11 | Crc32.quickIntDigest(BytesUtils.fromHexString(i["message"])); 12 | expect(result, i["crc32"]); 13 | } 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /test/crypto/keccack/keccack_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | import '../../quick_hex.dart'; 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("kechack 256 bit", () { 10 | for (final i in testVector) { 11 | final k = Keccack(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | test("test keccack 512 bit", () { 22 | for (final i in keccack512TestVector) { 23 | final k = Keccack(64); 24 | final message = BytesUtils.fromHexString(i["message"]); 25 | k.update(message.sublist(0, 10)); 26 | k.update(message.sublist(10)); 27 | final result = k.digest(); 28 | expect(result.toHex(), i["hash"]); 29 | k.clean(); 30 | k.update(message); 31 | expect(k.digest().toHex(), i["hash"]); 32 | } 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/crypto/md4/md4_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("md4 test", () { 10 | for (final i in testVector) { 11 | final k = MD4(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/crypto/md5/md5_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("md5 test", () { 10 | for (final i in testVector) { 11 | final k = MD5(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/crypto/pbkdf2/pbkdf2_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import 'package:blockchain_utils/crypto/crypto/hmac/hmac.dart'; 3 | import 'package:blockchain_utils/crypto/crypto/pbkdf2/pbkdf2.dart'; 4 | import 'package:test/test.dart'; 5 | import '../../quick_hex.dart'; 6 | import 'package:blockchain_utils/utils/utils.dart'; 7 | 8 | import 'test_vector.dart'; 9 | 10 | void main() { 11 | test("pbkdf2", () { 12 | for (final i in testVector) { 13 | final password = BytesUtils.fromHexString(i["password"]); 14 | final salt = BytesUtils.fromHexString(i["salt"]); 15 | final h = PBKDF2.deriveKey( 16 | mac: () => HMAC(() => SHA512(), password), 17 | salt: salt, 18 | iterations: i["n"], 19 | length: 32); 20 | expect(h.toHex(), i["hash"]); 21 | } 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /test/crypto/scrypt/scrypt_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/scrypt/scrypt.dart'; 2 | import 'package:test/test.dart'; 3 | import '../../quick_hex.dart'; 4 | import 'package:blockchain_utils/utils/utils.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("scrypt", () { 10 | for (final i in testVector) { 11 | final s = Scrypt(i["n"], i["r"], i["p"]); 12 | final derive = s.derive(BytesUtils.fromHexString(i["password"]), 13 | BytesUtils.fromHexString(i["salt"]), 32); 14 | expect(derive.toHex(), i["hash"]); 15 | } 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /test/crypto/sha1/sha1_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("sh1", () { 10 | for (final i in testVector) { 11 | final k = SHA1(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/crypto/sha256/sha256_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("sha256", () { 10 | for (final i in testVector) { 11 | final k = SHA256(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/crypto/sha3/sha3_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | import '../../quick_hex.dart'; 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("sha3-512", () { 10 | for (final i in testVector) { 11 | final k = SHA3(64); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | 22 | test("sha3-256", () { 23 | for (final i in testVectorSha332) { 24 | final k = SHA3(32); 25 | final message = BytesUtils.fromHexString(i["message"]); 26 | k.update(message.sublist(0, 10)); 27 | k.update(message.sublist(10)); 28 | expect(k.digest().toHex(), i["hash"]); 29 | k.clean(); 30 | k.update(message); 31 | expect(k.digest().toHex(), i["hash"]); 32 | } 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/crypto/sha512/sha512_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("sha512", () { 10 | for (final i in testVector) { 11 | final k = SHA512(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/crypto/sha512_256/sha512_256_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("sha512-256", () { 10 | for (final i in testVector) { 11 | final k = SHA512256(); 12 | final message = BytesUtils.fromHexString(i["message"]); 13 | k.update(message.sublist(0, 10)); 14 | k.update(message.sublist(10)); 15 | expect(k.digest().toHex(), i["hash"]); 16 | k.clean(); 17 | k.update(message); 18 | expect(k.digest().toHex(), i["hash"]); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/crypto/shake/shake_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 2 | 3 | import '../../quick_hex.dart'; 4 | import 'package:blockchain_utils/utils/utils.dart'; 5 | import 'package:test/test.dart'; 6 | 7 | import 'test_vector_256.dart'; 8 | import 'test_vector_128.dart'; 9 | 10 | void main() { 11 | test("shake25", () { 12 | for (final i in testVecotr256) { 13 | final inp = BytesUtils.fromHexString(i["input"]); 14 | final int out = i["out_size"]; 15 | final h = SHAKE256(); 16 | h.update(inp.sublist(0, 1)); 17 | h.update(inp.sublist(1)); 18 | final digest = h.digest(out); 19 | expect(digest.toHex(), i["out"]); 20 | h.reset(); 21 | h.update(inp); 22 | expect(digest.toHex(), i["out"]); 23 | } 24 | }); 25 | test("shake128", () { 26 | for (final i in testVector128) { 27 | final inp = BytesUtils.fromHexString(i["input"]); 28 | final int out = i["out_size"]; 29 | final h = SHAKE128(); 30 | h.update(inp.sublist(0, 1)); 31 | h.update(inp.sublist(1)); 32 | final digest = h.digest(out); 33 | expect(digest.toHex(), i["out"]); 34 | h.reset(); 35 | h.update(inp); 36 | expect(digest.toHex(), i["out"]); 37 | } 38 | }); 39 | } 40 | -------------------------------------------------------------------------------- /test/crypto/x_modem_crc/x_modem_crc_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/crypto/crypto/x_modem_crc/x_modem_crc.dart'; 2 | import '../../quick_hex.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("x-Modem crc", () { 10 | for (final i in testVector) { 11 | final result = 12 | XModemCrc.quickDigest(BytesUtils.fromHexString(i["message"])); 13 | expect(result.toHex(), i["crc"]); 14 | } 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /test/crypto/xxhash64/xxhash64_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | import 'package:blockchain_utils/crypto/crypto/hash/hash.dart'; 3 | import 'package:test/test.dart'; 4 | import 'test_vector.dart'; 5 | 6 | void main() { 7 | test("xxhash64", () { 8 | for (final i in testVector) { 9 | final data = BytesUtils.fromHexString(i["hex"]); 10 | final int bitLength = i["bitlength"]; 11 | if (data.length.isEven) { 12 | final half = data.length ~/ 2; 13 | final first = data.sublist(0, half); 14 | final secound = data.sublist(half); 15 | final hasher = XXHash64(bitLength: bitLength); 16 | hasher.update(first); 17 | hasher.update(secound); 18 | expect( 19 | BytesUtils.toHexString(hasher.digest(), prefix: "0x"), i["hash"]); 20 | continue; 21 | } 22 | final hash = XXHash64.hash(data, bitlength: bitLength); 23 | expect(BytesUtils.toHexString(hash, prefix: "0x"), i["hash"]); 24 | } 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/elctrum/v1/v1_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:test/test.dart'; 2 | 3 | import '../../quick_hex.dart'; 4 | import 'test_vectors.dart'; 5 | import 'package:blockchain_utils/blockchain_utils.dart'; 6 | 7 | void main() { 8 | test("electrum v1", () { 9 | for (final i in testVector) { 10 | final seed = BytesUtils.fromHexString(i["seed"]); 11 | final elc = ElectrumV1.fromSeed(seed); 12 | final prv = WifEncoder.encode(elc.privateKey!.raw, 13 | netVer: CoinsConf.bitcoinMainNet.params.wifNetVer!, 14 | pubKeyMode: PubKeyModes.uncompressed); 15 | expect(prv, i["private"]); 16 | 17 | final public = elc.publicKey.uncompressed.toHex(); 18 | expect(public, i["public"]); 19 | for (final c in (i["child"] as List)) { 20 | final changeIndex = c["change_index"]; 21 | final addressIndex = c["address_index"]; 22 | final cPrv = WifEncoder.encode( 23 | elc.getPrivateKey(changeIndex, addressIndex).raw, 24 | netVer: CoinsConf.bitcoinMainNet.params.wifNetVer!, 25 | pubKeyMode: PubKeyModes.uncompressed); 26 | expect(cPrv, c["private"]); 27 | final cPub = 28 | elc.getPublicKey(changeIndex, addressIndex).uncompressed.toHex(); 29 | expect(cPub, c["public"]); 30 | final cAddress = elc.getAddress(changeIndex, addressIndex); 31 | expect(cAddress, c["address"]); 32 | } 33 | } 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /test/monero/mnemonic/monero_mnemonic_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic.dart'; 2 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic_decoder.dart'; 3 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_mnemonic_generator.dart'; 4 | import 'package:blockchain_utils/bip/monero/mnemonic/monero_seed_generator.dart'; 5 | import 'package:blockchain_utils/utils/utils.dart'; 6 | import 'package:test/test.dart'; 7 | import "test_vector.dart"; 8 | 9 | void main() { 10 | test("monero mnemonic", () { 11 | for (final i in testVector) { 12 | final lang = MoneroLanguages.values.firstWhere((element) => 13 | element.name.toLowerCase() == 14 | (i["lang"] as String).replaceAll("_", "").toLowerCase()); 15 | final entropy = BytesUtils.fromHexString(i["entropy"]); 16 | final mn = MoneroMnemonicGenerator(lang).fromEntropyWithChecksum(entropy); 17 | expect(mn.toStr(), i["mnemonic"]); 18 | final mnNc = MoneroMnemonicGenerator(lang).fromEntropyNoChecksum(entropy); 19 | expect(mnNc.toStr(), i["no_checksum"]); 20 | final entropyResult = MoneroMnemonicDecoder(lang).decode(mn.toStr()); 21 | expect(BytesUtils.bytesEqual(entropyResult, entropy), true); 22 | final seed = MoneroSeedGenerator(mn).generate(); 23 | expect(BytesUtils.bytesEqual(seed, entropy), true); 24 | } 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/monero/monero_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/bip/monero/conf/monero_coins.dart'; 2 | import 'package:blockchain_utils/bip/monero/monero_base.dart'; 3 | import 'package:blockchain_utils/utils/utils.dart'; 4 | import 'package:test/test.dart'; 5 | import '../quick_hex.dart'; 6 | import 'test_vector.dart'; 7 | 8 | void main() { 9 | test("monero account", () { 10 | for (final i in testVector) { 11 | final seed = BytesUtils.fromHexString(i["seed"]); 12 | final coin = MoneroCoins.values.firstWhere((element) => 13 | element.name.toLowerCase() == 14 | (i["coin"] as String).replaceAll("_", "").toLowerCase()); 15 | final w = MoneroAccount.fromSeed(seed, coinType: coin); 16 | expect(w.privateSpendKey.raw.toHex(), i["private_sky"]); 17 | expect(w.privateViewKey.raw.toHex(), i["private_vkey"]); 18 | expect(w.publicSpendKey.compressed.toHex(), i["public_sky"]); 19 | expect(w.publicViewKey.compressed.toHex(), i["public_vsky"]); 20 | expect(w.primaryAddress, i["primary_address"]); 21 | final paymentId = BytesUtils.fromHexString(i["payment_id"]); 22 | expect(w.integratedAddress(paymentId), i["integrated_address"]); 23 | final addresses = List.from(i["addresses"]); 24 | for (final a in addresses) { 25 | final minorIndex = a["minor_idx"]; 26 | final majorIndex = a["major_idx"]; 27 | final addr = w.subaddress(minorIndex, majorIndex: majorIndex); 28 | expect(a["address"], addr); 29 | } 30 | } 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/musig2/geneare_nonce_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:test/test.dart'; 3 | import 'nonce_vector.dart'; 4 | 5 | void main() { 6 | test("generate nonce", () { 7 | for (final i in nonceVector) { 8 | final rand = BytesUtils.fromHexString(i["rand_"]!); 9 | final sk = BytesUtils.tryFromHexString(i["sk"]); 10 | final publicKey = BytesUtils.fromHexString(i["pk"]!); 11 | final aggpk = BytesUtils.tryFromHexString(i["aggpk"]); 12 | final msg = BytesUtils.tryFromHexString(i["msg"]); 13 | final extraIn = BytesUtils.tryFromHexString(i["extra_in"]); 14 | final nonce = MuSig2.nonceGenerate( 15 | rand: rand, 16 | publicKey: publicKey, 17 | aggPubKey: aggpk ?? [], 18 | extra: extraIn, 19 | msg: msg, 20 | sk: sk); 21 | expect(BytesUtils.toHexString(nonce.pubnonce, lowerCase: false), 22 | i["expected_pubnonce"]); 23 | expect(BytesUtils.toHexString(nonce.secnonce, lowerCase: false), 24 | i["expected_secnonce"]); 25 | } 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/musig2/generate_key_agg_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:test/test.dart'; 3 | import 'test_vector.dart'; 4 | 5 | void main() { 6 | _test(); 7 | } 8 | 9 | void _test() { 10 | test("generate agg key", () { 11 | final List> pubKeys = (keyAggTestVector["pubkeys"] as List) 12 | .map((e) => BytesUtils.fromHexString(e)) 13 | .toList(); 14 | final validateTestCase = 15 | List>.from(keyAggTestVector["valid_test_cases"]!); 16 | for (final i in validateTestCase) { 17 | final indeces = List.from(i["key_indices"]); 18 | final keys = List.generate(indeces.length, (i) { 19 | return pubKeys.elementAt(indeces[i]); 20 | }); 21 | final key = MuSig2.aggPublicKeys(keys: keys); 22 | final keyHex = BytesUtils.toHexString(key.xOnly(), lowerCase: false); 23 | expect(keyHex, i["expected"]); 24 | } 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/musig2/nonce_agg_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:test/test.dart'; 3 | import 'nonce_agg_test_vector.dart'; 4 | 5 | void main() { 6 | _test(); 7 | } 8 | 9 | void _test() { 10 | test("nonce agg", () { 11 | final List> pubKeys = (nonceAggVectors["pnonces"] as List) 12 | .map((e) => BytesUtils.fromHexString(e)) 13 | .toList(); 14 | final validateTestCase = 15 | List>.from(nonceAggVectors["valid_test_cases"]!); 16 | for (final i in validateTestCase) { 17 | final indeces = List.from(i["pnonce_indices"]); 18 | final keys = List.generate(indeces.length, (i) { 19 | return pubKeys.elementAt(indeces[i]); 20 | }); 21 | final key = MuSig2.nonceAgg(keys); 22 | final keyHex = BytesUtils.toHexString(key, lowerCase: false); 23 | expect(keyHex, i["expected"]); 24 | } 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/quick_hex.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/utils/utils.dart'; 2 | 3 | extension HEX on List { 4 | String toHex() => BytesUtils.toHexString(this); 5 | } 6 | -------------------------------------------------------------------------------- /test/schnorrkel/schnorrkel_key_test.dart: -------------------------------------------------------------------------------- 1 | // all keys generated from https://github.com/noot/schnorrkel/blob/f7551a43845ba65e8782a2c7d80439111eeda687/src/keys.rs#L983 2 | 3 | import 'package:blockchain_utils/crypto/crypto/schnorrkel/keys/keys.dart'; 4 | import 'package:blockchain_utils/utils/utils.dart'; 5 | import 'package:test/test.dart'; 6 | 7 | import '../quick_hex.dart'; 8 | import 'key_test_vector.dart'; 9 | 10 | void main() { 11 | test("schnorrkel keys", () { 12 | for (final i in keyTestVector) { 13 | final seed = BytesUtils.fromHexString(i["mini_secret"]); 14 | final miniSecret = SchnorrkelMiniSecretKey.fromBytes(seed); 15 | final edSecret = miniSecret.toSecretKey(ExpansionMode.ed25519); 16 | expect(edSecret.toBytes().toHex().toUpperCase(), i["ed_secret"]); 17 | expect( 18 | edSecret.publicKey().toBytes().toHex().toUpperCase(), i["ed_public"]); 19 | final uniSecret = miniSecret.toSecretKey(ExpansionMode.uniform); 20 | expect(uniSecret.toBytes().toHex().toUpperCase(), i["uniform_secret"]); 21 | expect(uniSecret.publicKey().toBytes().toHex().toUpperCase(), 22 | i["uniform_public"]); 23 | } 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/signer/ed25519_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/signer/signer.dart'; 2 | import 'package:blockchain_utils/utils/binary/utils.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | _test(); 7 | } 8 | 9 | void _test() { 10 | group("ED25519", () { 11 | test("sign/verify", () { 12 | final digest = BytesUtils.fromHexString( 13 | "80010001030b513ad9b4924015ca0902ed079044d3ac5dbec2306f06948c10da8eb6e39f2d807e1b63e7c241c72448e8f9f05e65d421ea40ceae40f47ca347f7d79c38d0e60000000000000000000000000000000000000000000000000000000000000000be4325d9b7456f6393d0c1bbf8ef09c05d5c179fb830b7e16f1c3d1f21c8540b01020200010c0200000040420f000000000000"); 14 | final signer = Ed25519Signer.fromKeyBytes(BytesUtils.fromHexString( 15 | "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c")); 16 | final sig = BytesUtils.fromHexString( 17 | "47c2764edb810b97c7a883c292a74c9850af349473fcbd9f08b13fd772b215f4129d90b4eacae7112f04d2a9c3fb871cd2ae382772ff9da0528071b9f68d7300"); 18 | List signature = signer.sign(digest); 19 | expect(signature, sig); 20 | signature = signer.signConst(digest); 21 | expect(signature, sig); 22 | }); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/signer/ethereum_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:blockchain_utils/blockchain_utils.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | void main() { 5 | test("sign verify test", () { 6 | final signer = ETHSigner.fromKeyBytes(BytesUtils.fromHexString( 7 | "cd23c9f2e2c096ee3be3c4e0e58199800c0036ea27b7cd4e838bbde8b21788b3")); 8 | final message = 9 | BytesUtils.fromHexString("0x84df2267aa318f451199223385516162"); 10 | final sign = signer.signProsonalMessage(message); 11 | final signConst = signer.signProsonalMessageConst(message); 12 | final verify = signer.toVerifyKey().verifyPersonalMessage(message, sign); 13 | expect(BytesUtils.toHexString(sign), 14 | "4b57a6ca5e2f5da5ae9667d69bb61285808b54ed08dacc76d77b02a8e6f6be905bf4f6fce63ff4142af25458c3bb8ecbda4990b76783a35561382096e30082321b"); 15 | expect(BytesUtils.toHexString(signConst), 16 | "4b57a6ca5e2f5da5ae9667d69bb61285808b54ed08dacc76d77b02a8e6f6be905bf4f6fce63ff4142af25458c3bb8ecbda4990b76783a35561382096e30082321b"); 17 | 18 | expect(verify, true); 19 | final publicKey = ETHVerifier.getPublicKey(message, sign); 20 | expect( 21 | BytesUtils.bytesEqual(publicKey?.toBytes(), 22 | signer.toVerifyKey().edsaVerifyKey.publicKey.toBytes()), 23 | true); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/signer/tron_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:blockchain_utils/blockchain_utils.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | void main() { 7 | test("sign verify test", () { 8 | final signer = TronSigner.fromKeyBytes(BytesUtils.fromHexString( 9 | "43985273a3d94eb753fe6acfd7003e88254effce1eb53e2e97b8522558a98038")); 10 | final message = utf8.encode("message"); 11 | final sign = signer.signProsonalMessage(message); 12 | final signConst = signer.signProsonalMessageConst(message); 13 | final verify = signer.toVerifyKey().verifyPersonalMessage(message, sign); 14 | expect(BytesUtils.toHexString(sign), 15 | "fde00bc33d78109bc61de314c1c0526a047e22a2aaae473ca84b32d8aa35ed3e03720e05d614087e3d8c6fae63879755b32aa08818a2d4de66fee1a617a971671b"); 16 | expect(BytesUtils.toHexString(signConst), 17 | "fde00bc33d78109bc61de314c1c0526a047e22a2aaae473ca84b32d8aa35ed3e03720e05d614087e3d8c6fae63879755b32aa08818a2d4de66fee1a617a971671b"); 18 | 19 | expect(verify, true); 20 | final publicKey = TronVerifier.getPublicKey(message, sign); 21 | expect( 22 | BytesUtils.bytesEqual(publicKey.toBytes(), 23 | signer.toVerifyKey().edsaVerifyKey.publicKey.toBytes()), 24 | true); 25 | }); 26 | } 27 | --------------------------------------------------------------------------------