├── .gitattributes ├── .github └── workflows │ └── dotnetCI.yml ├── .gitignore ├── CHANGELOG.md ├── Doc └── Images │ └── MainPreview.jpg ├── License ├── README.md └── Src ├── FinderOuter.sln ├── FinderOuter ├── App.xaml ├── App.xaml.cs ├── Assets │ ├── Attention.png │ ├── Avalonia.jpg │ ├── Donate.png │ ├── Icon.ico │ ├── StatFail.png │ ├── StatPause.png │ ├── StatReady.png │ ├── StatStop.png │ ├── StatSuccess.png │ └── StatWorking.png ├── Backend │ ├── ConstantsFO.cs │ ├── DerInt.cs │ ├── ECC │ │ ├── Calc2.cs │ │ ├── Point2.cs │ │ ├── PointJacobian2.cs │ │ ├── PointStorage2.cs │ │ ├── Scalar2.cs │ │ ├── UInt128.cs │ │ ├── UInt256_4x64.cs │ │ └── UInt256_5x52.cs │ ├── ExtentionsAndHelpers.cs │ ├── Hashing │ │ ├── Hash160Fo.cs │ │ ├── Ripemd160Fo.cs │ │ ├── Sha256Fo.cs │ │ └── Sha512Fo.cs │ └── Mvvm │ │ └── Converters │ │ ├── PossibilityToColorConverter.cs │ │ ├── PossibilityToStringConverter.cs │ │ └── StateToBitmapConverter.cs ├── FinderOuter.csproj ├── ListHelper.cs ├── Models │ ├── AllEnums.cs │ ├── DescriptiveItem.cs │ ├── EncodingState.cs │ ├── ExampleData.cs │ ├── IReport.cs │ ├── Permutation.cs │ ├── PermutationVar.cs │ ├── Report.cs │ └── Settings.cs ├── Program.cs ├── Services │ ├── AddressService.cs │ ├── ArmoryService.cs │ ├── Base16Sevice.cs │ ├── Base58Service.cs │ ├── Bip32PathService.cs │ ├── Bip38Service.cs │ ├── CartesianProduct.cs │ ├── Comparers │ │ ├── DefaultComparer.cs │ │ ├── ICompareService.cs │ │ ├── PrvToAddrBase.cs │ │ ├── PrvToAddrBothComparer.cs │ │ ├── PrvToAddrCompComparer.cs │ │ ├── PrvToAddrNestedComparer.cs │ │ ├── PrvToAddrUncompComparer.cs │ │ ├── PrvToPrvComparer.cs │ │ └── PrvToPubComparer.cs │ ├── CorePassService.cs │ ├── FileManager.cs │ ├── IPasswordService.cs │ ├── InputService.cs │ ├── MiniKeyService.cs │ ├── MnemonicExtensionService.cs │ ├── MnemonicSevice.cs │ ├── PasswordService.cs │ ├── SearchSpaces │ │ ├── B16SearchSpace.cs │ │ ├── B58SearchSpace.cs │ │ ├── CorePassSearchSpace.cs │ │ ├── MiniKeySearchSpace.cs │ │ ├── MnemonicSearchSpace.cs │ │ ├── PasswordSearchSpace.cs │ │ └── SearchSpaceBase.cs │ └── WindowManager.cs ├── ViewLocator.cs ├── ViewModels │ ├── AboutViewModel.cs │ ├── CorePassViewModel.cs │ ├── HelpViewModel.cs │ ├── KnowledgeBaseViewModel.cs │ ├── MainWindowViewModel.cs │ ├── MessageBoxViewModel.cs │ ├── MissingArmoryViewModel.cs │ ├── MissingBase16ViewModel.cs │ ├── MissingBase58ViewModel.cs │ ├── MissingBip32PathViewModel.cs │ ├── MissingBip38PassViewModel.cs │ ├── MissingEncodingViewModel.cs │ ├── MissingMiniPrivateKeyViewModel.cs │ ├── MissingMnemonicPassViewModel.cs │ ├── MissingMnemonicViewModel.cs │ ├── OptionVmBase.cs │ ├── ViewModelBase.cs │ └── VmWithSizeBase.cs ├── Views │ ├── AboutView.axaml │ ├── AboutView.axaml.cs │ ├── CorePassView.axaml │ ├── CorePassView.axaml.cs │ ├── HelpView.axaml │ ├── HelpView.axaml.cs │ ├── KnowledgeBaseView.axaml │ ├── KnowledgeBaseView.axaml.cs │ ├── MainWindow.axaml │ ├── MainWindow.axaml.cs │ ├── MessageBoxView.axaml │ ├── MessageBoxView.axaml.cs │ ├── MissingArmoryView.axaml │ ├── MissingArmoryView.axaml.cs │ ├── MissingBase16View.axaml │ ├── MissingBase16View.axaml.cs │ ├── MissingBase58View.axaml │ ├── MissingBase58View.axaml.cs │ ├── MissingBip32PathView.axaml │ ├── MissingBip32PathView.axaml.cs │ ├── MissingBip38PassView.axaml │ ├── MissingBip38PassView.axaml.cs │ ├── MissingEncodingView.axaml │ ├── MissingEncodingView.axaml.cs │ ├── MissingMiniPrivateKeyView.axaml │ ├── MissingMiniPrivateKeyView.axaml.cs │ ├── MissingMnemonicPassView.axaml │ ├── MissingMnemonicPassView.axaml.cs │ ├── MissingMnemonicView.axaml │ └── MissingMnemonicView.axaml.cs └── nuget.config └── Tests ├── Backend ├── ConstantsFOTests.cs ├── ECC │ ├── ScalarTests.cs │ └── UInt128Tests.cs ├── Hashing │ ├── Hash160FoTests.cs │ ├── HashTestCaseHelper.cs │ ├── Ripemd160FoTests.cs │ ├── Sha256FoTests.cs │ └── Sha512FoTests.cs └── Mvvm │ └── Converters │ ├── PossibilityToColorConverterTests.cs │ └── PossibilityToStringConverterTests.cs ├── GlobalUsings.cs ├── Helper.cs ├── JsonConverterHelpers.cs ├── KeyHelper.cs ├── ListHelperTests.cs ├── MockDispatcher.cs ├── MockWindowManager.cs ├── Models ├── DescriptiveItemTests.cs ├── EncodingStateTests.cs ├── PermutationTests.cs ├── PermutationVarTests.cs ├── ReportTests.cs └── SettingsTests.cs ├── Services ├── AddressServiceTests.cs ├── Comparers │ ├── DefaultComparerTests.cs │ ├── PrvToAddrBothComparerTests.cs │ ├── PrvToAddrCompComparerTests.cs │ ├── PrvToAddrNestedComparerTests.cs │ ├── PrvToAddrUncompComparerTests.cs │ ├── PrvToPrvComparerTests.cs │ └── PrvToPubComparerTests.cs ├── InputServiceTests.cs ├── MnemonicSeviceTests.cs ├── PasswordServiceTests.cs └── SearchSpaces │ ├── B16SearchSpaceTests.cs │ ├── B58SearchSpaceTests.cs │ ├── CorePassSearchSpaceTests.cs │ ├── MiniKeySearchSpaceTests.cs │ ├── MnemonicSearchSpaceTests.cs │ └── SearchSpaceBaseTests.cs ├── TestData ├── HashTestData.json ├── Ripemd160ProgressiveTestData.json ├── Sha256NistTestData.json └── Sha512NistTestData.json ├── Tests.csproj └── ViewModels ├── MissingEncodingViewModelTests.cs ├── MissingMnemonicViewModelTests.cs ├── OptionVmBaseTests.cs └── ViewModelBaseTests.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/dotnetCI.yml: -------------------------------------------------------------------------------- 1 | name: .NET-CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | Windows: 11 | runs-on: windows-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Setup .NET 15 | uses: actions/setup-dotnet@v3 16 | with: 17 | dotnet-version: 8.0.x 18 | - name: Build 19 | run: dotnet build ./Src/FinderOuter.sln -c Release 20 | - name: Test 21 | run: dotnet test ./Src/Tests/Tests.csproj --verbosity normal -c Release 22 | 23 | Linux: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - uses: actions/checkout@v3 27 | - name: Setup .NET 28 | uses: actions/setup-dotnet@v3 29 | with: 30 | dotnet-version: 8.0.x 31 | - name: Build 32 | run: dotnet build ./Src/FinderOuter.sln -c Release 33 | - name: Test 34 | run: dotnet test ./Src/Tests/Tests.csproj --verbosity normal -c Release 35 | 36 | Mac: 37 | runs-on: macos-latest 38 | steps: 39 | - uses: actions/checkout@v3 40 | - name: Setup .NET 41 | uses: actions/setup-dotnet@v3 42 | with: 43 | dotnet-version: 8.0.x 44 | - name: Build 45 | run: dotnet build ./Src/FinderOuter.sln -c Release 46 | - name: Test 47 | run: dotnet test ./Src/Tests/Tests.csproj --verbosity normal -c Release 48 | -------------------------------------------------------------------------------- /Doc/Images/MainPreview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Doc/Images/MainPreview.jpg -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Coding Enthusiast 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Src/FinderOuter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.181 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinderOuter", "FinderOuter\FinderOuter.csproj", "{5D4D8B5B-B186-46EA-AAA8-56DBFBBF0102}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{CDF19237-9509-4FEB-9470-202F9864D8A6}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {5D4D8B5B-B186-46EA-AAA8-56DBFBBF0102}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {5D4D8B5B-B186-46EA-AAA8-56DBFBBF0102}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {5D4D8B5B-B186-46EA-AAA8-56DBFBBF0102}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {5D4D8B5B-B186-46EA-AAA8-56DBFBBF0102}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {CDF19237-9509-4FEB-9470-202F9864D8A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {CDF19237-9509-4FEB-9470-202F9864D8A6}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {CDF19237-9509-4FEB-9470-202F9864D8A6}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {CDF19237-9509-4FEB-9470-202F9864D8A6}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {BDB15806-2924-42EB-A0EB-3EBAEDF71E43} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Src/FinderOuter/App.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 44 | 47 | 48 | 49 | 52 | 53 | 54 | 63 | 64 | 65 | 75 | 76 | 77 | 85 | 86 | 87 | 91 | 92 | 93 | 107 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /Src/FinderOuter/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia; 7 | using Avalonia.Controls.ApplicationLifetimes; 8 | using Avalonia.Markup.Xaml; 9 | using FinderOuter.ViewModels; 10 | using FinderOuter.Views; 11 | 12 | namespace FinderOuter 13 | { 14 | public class App : Application 15 | { 16 | public override void Initialize() 17 | { 18 | AvaloniaXamlLoader.Load(this); 19 | } 20 | 21 | public override void OnFrameworkInitializationCompleted() 22 | { 23 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) 24 | { 25 | MainWindowViewModel vm = new(); 26 | desktop.MainWindow = new MainWindow 27 | { 28 | DataContext = vm 29 | }; 30 | vm.Clipboard = desktop.MainWindow.Clipboard; 31 | vm.StorageProvider = desktop.MainWindow.StorageProvider; 32 | } 33 | 34 | base.OnFrameworkInitializationCompleted(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/Attention.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/Attention.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/Avalonia.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/Avalonia.jpg -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/Donate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/Donate.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/Icon.ico -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/StatFail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/StatFail.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/StatPause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/StatPause.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/StatReady.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/StatReady.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/StatStop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/StatStop.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/StatSuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/StatSuccess.png -------------------------------------------------------------------------------- /Src/FinderOuter/Assets/StatWorking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-Enthusiast/FinderOuter/d8c4fc09de91b6cad6030abe0746bb21a9a38d40/Src/FinderOuter/Assets/StatWorking.png -------------------------------------------------------------------------------- /Src/FinderOuter/Backend/ConstantsFO.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System; 7 | 8 | namespace FinderOuter.Backend 9 | { 10 | public struct ConstantsFO 11 | { 12 | public const string LowerCase = "abcdefghijklmnopqrstuvwxyz"; 13 | public const string UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 14 | public const string Numbers = "0123456789"; 15 | // 0x2122232425262728292a2b2c2d2e2f3a3b3c3d3e3f405b5c5d5e5f607b7c7d7e 16 | public const string AllSymbols = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; 17 | 18 | public const string Base58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; 19 | public const string Base16Chars = "0123456789abcdef"; 20 | public const string ArmoryChars = "asdfghjkwertuion"; 21 | public const string MissingSymbols = "*?-_!@#$%^&+="; 22 | public const string MissingToolTip = "Replace missing item(s) with the selected symbol."; 23 | 24 | public const char PrivKeyCompChar1 = 'K'; 25 | public const char PrivKeyCompChar2 = 'L'; 26 | public const char PrivKeyUncompChar = '5'; 27 | public const int PrivKeyCompWifLen = 52; 28 | public const int PrivKeyUncompWifLen = 51; 29 | public const byte PrivKeyFirstByte = 0x80; 30 | public const byte PrivKeyCompLastByte = 1; 31 | 32 | public const int PrivKeyHexLen = 64; 33 | 34 | public const int B58AddressMinLen = 26; 35 | public const int B58AddressMaxLen = 35; 36 | public const char B58AddressChar1 = '1'; 37 | public const char B58AddressChar2 = '3'; 38 | public const byte P2pkhAddrFirstByte = 0; 39 | public const byte P2shAddrFirstByte = 5; 40 | 41 | public const char MiniKeyStart = 'S'; 42 | public const int MiniKeyLen1 = 22; 43 | public const int MiniKeyLen2 = 26; 44 | public const int MiniKeyLen3 = 30; 45 | 46 | public const int Bip38ByteLen = 39; 47 | public const int Bip38Base58Len = 58; 48 | public const string Bip38Start = "6P"; 49 | public static readonly byte[] Bip38Prefix = [0x01, 0x42]; 50 | public static readonly byte[] Bip38PrefixECMult = [0x01, 0x43]; 51 | 52 | public static readonly string ChangedMessage = "Input is changed and the search-space needs to be re-evaluated." + 53 | $"{Environment.NewLine}" + 54 | $"Click Yes to reset search-space to use default values or click No to manually set search-space."; 55 | 56 | // 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz 57 | public static readonly char[][] SimilarBase58Chars = 58 | [ 59 | ['0', 'o', 'C', 'G', 'c'], 60 | ['1', 'L', 'l'], 61 | ['5', 'S', 's'], 62 | ['7', 'J', 'T', 'j', 't', 'I', 'i'], 63 | ['8', 'B'], 64 | ['9', 'g', 'q', 'P', 'p', 'D', 'd', 'b'], 65 | ['E', 'F', 'f'], 66 | ['K', 'k'], 67 | ['M', 'm'], 68 | ['N', 'n'], 69 | ['U', 'u', 'V', 'v', 'Y', 'y'], 70 | ['W', 'w'], 71 | ['X', 'x'], 72 | ['Z', 'z'], 73 | ]; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Src/FinderOuter/Backend/ECC/PointStorage2.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System.Runtime.CompilerServices; 7 | 8 | namespace FinderOuter.Backend.ECC 9 | { 10 | public readonly struct PointStorage2 11 | { 12 | public PointStorage2(in UInt256_5x52 x52, in UInt256_5x52 y52) 13 | { 14 | x = x52.Normalize().ToUInt256_4x64(); 15 | y = y52.Normalize().ToUInt256_4x64(); 16 | } 17 | 18 | public PointStorage2(in UInt256_4x64 x32, in UInt256_4x64 y32) 19 | { 20 | x = x32; 21 | y = y32; 22 | } 23 | 24 | 25 | public readonly UInt256_4x64 x, y; 26 | 27 | 28 | public readonly Point2 ToPoint() => new(x.ToUInt256_5x52(), y.ToUInt256_5x52()); 29 | 30 | 31 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 32 | public static void CMov(ref PointStorage2 r, in PointStorage2 a, int flag) 33 | { 34 | UInt256_4x64 rx = r.x; 35 | UInt256_4x64 ry = r.y; 36 | UInt256_4x64.CMov(ref rx, a.x, flag); 37 | UInt256_4x64.CMov(ref ry, a.y, flag); 38 | r = new PointStorage2(rx, ry); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/FinderOuter/Backend/ECC/UInt256_4x64.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System.Runtime.CompilerServices; 7 | 8 | namespace FinderOuter.Backend.ECC 9 | { 10 | /// 11 | /// 256-bit unsigned integer using radix-2^64 representation 12 | /// 13 | public readonly struct UInt256_4x64 14 | { 15 | public UInt256_4x64(ulong u0, ulong u1, ulong u2, ulong u3) 16 | { 17 | b0 = u0; 18 | b1 = u1; 19 | b2 = u2; 20 | b3 = u3; 21 | } 22 | 23 | 24 | private readonly ulong b0, b1, b2, b3; 25 | 26 | 27 | public readonly UInt256_5x52 ToUInt256_5x52() => new(b0, b1, b2, b3); 28 | 29 | 30 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 31 | public static void CMov(ref UInt256_4x64 r, in UInt256_4x64 a, int flag) 32 | { 33 | ulong mask0, mask1; 34 | mask0 = (ulong)flag + ~(ulong)0; 35 | mask1 = ~mask0; 36 | r = new UInt256_4x64( 37 | (r.b0 & mask0) | (a.b0 & mask1), 38 | (r.b1 & mask0) | (a.b1 & mask1), 39 | (r.b2 & mask0) | (a.b2 & mask1), 40 | (r.b3 & mask0) | (a.b3 & mask1)); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Src/FinderOuter/Backend/Mvvm/Converters/PossibilityToColorConverter.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Data.Converters; 7 | using Avalonia.Media; 8 | using FinderOuter.Models; 9 | using System; 10 | using System.Globalization; 11 | 12 | namespace FinderOuter.Backend.Mvvm.Converters 13 | { 14 | public class PossibilityToColorConverter : IValueConverter 15 | { 16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | if (value is Possibility p) 19 | { 20 | return p switch 21 | { 22 | Possibility.Maybe => Brushes.Blue, 23 | Possibility.Possible => Brushes.Green, 24 | Possibility.Impossible => Brushes.Red, 25 | _ => throw new NotImplementedException(), 26 | }; 27 | } 28 | 29 | throw new NotSupportedException(); 30 | } 31 | 32 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/FinderOuter/Backend/Mvvm/Converters/PossibilityToStringConverter.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Data.Converters; 7 | using FinderOuter.Models; 8 | using System; 9 | using System.Globalization; 10 | 11 | namespace FinderOuter.Backend.Mvvm.Converters 12 | { 13 | public class PossibilityToStringConverter : IValueConverter 14 | { 15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | if (value is Possibility p) 18 | { 19 | return p switch 20 | { 21 | Possibility.Possible => "✔", 22 | Possibility.Impossible => "X", 23 | Possibility.Maybe => "?", 24 | _ => throw new NotImplementedException(), 25 | }; 26 | } 27 | 28 | throw new NotSupportedException(); 29 | } 30 | 31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 32 | { 33 | throw new NotSupportedException(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/FinderOuter/Backend/Mvvm/Converters/StateToBitmapConverter.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Data.Converters; 7 | using Avalonia.Media.Imaging; 8 | using Avalonia.Platform; 9 | using FinderOuter.Models; 10 | using System; 11 | using System.Globalization; 12 | using System.IO; 13 | 14 | namespace FinderOuter.Backend.Mvvm.Converters 15 | { 16 | public class StateToBitmapConverter : IValueConverter 17 | { 18 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | if (value is State state) 21 | { 22 | Uri uri = state switch 23 | { 24 | State.Ready => new Uri($"avares://FinderOuter/Assets/StatReady.png"), 25 | State.Working => new Uri($"avares://FinderOuter/Assets/StatWorking.png"), 26 | State.Paused => new Uri($"avares://FinderOuter/Assets/StatPause.png"), 27 | State.Stopped => new Uri($"avares://FinderOuter/Assets/StatStop.png"), 28 | State.FinishedSuccess => new Uri($"avares://FinderOuter/Assets/StatSuccess.png"), 29 | State.FinishedFail => new Uri($"avares://FinderOuter/Assets/StatFail.png"), 30 | _ => throw new NotImplementedException() 31 | }; 32 | 33 | using Stream asset = AssetLoader.Open(uri); 34 | return new Bitmap(asset); 35 | } 36 | 37 | throw new NotSupportedException(); 38 | } 39 | 40 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 41 | { 42 | throw new NotSupportedException(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Src/FinderOuter/FinderOuter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | WinExe 4 | net8.0 5 | 0.20.0.0 6 | 0.20.0.0 7 | 0.20.0.0 8 | https://github.com/Coding-Enthusiast/FinderOuter 9 | https://github.com/Coding-Enthusiast/FinderOuter 10 | git 11 | Copyright (c) 2020 Coding Enthusiast 12 | Autarkysoft 13 | Coding-Enthusiast 14 | bitcoin 15 | 16 | 17 | 18 | true 19 | Assets\Icon.ico 20 | false 21 | 22 | 23 | 24 | 25 | true 26 | 27 | 28 | true 29 | 30 | 31 | 32 | 33 | %(Filename) 34 | 35 | 36 | Designer 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Src/FinderOuter/ListHelper.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.Models; 7 | using FinderOuter.ViewModels; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | 12 | namespace FinderOuter 13 | { 14 | public static class ListHelper 15 | { 16 | public static IEnumerable GetAllEnumValues() where T : Enum 17 | { 18 | return Enum.GetValues(typeof(T)).Cast(); 19 | } 20 | 21 | public static IEnumerable> GetEnumDescItems(params T[] exclude) where T : Enum 22 | { 23 | foreach (T item in Enum.GetValues(typeof(T))) 24 | { 25 | if (exclude != null && !exclude.Contains(item)) 26 | { 27 | yield return new DescriptiveItem(item); 28 | } 29 | } 30 | } 31 | 32 | public static IEnumerable GetEnumDescHelpInput() 33 | { 34 | foreach (HelpInputTypes item in Enum.GetValues(typeof(HelpInputTypes))) 35 | { 36 | yield return new DescriptiveHelpInput(item); 37 | } 38 | } 39 | 40 | public static IEnumerable GetEnumDescKB() 41 | { 42 | foreach (KB item in Enum.GetValues(typeof(KB))) 43 | { 44 | yield return new DescriptiveKB(item); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/AllEnums.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System; 7 | using System.ComponentModel; 8 | 9 | namespace FinderOuter.Models 10 | { 11 | public enum Base58Type 12 | { 13 | PrivateKey, 14 | Address, 15 | Bip38 16 | } 17 | 18 | 19 | public enum CompareInputType 20 | { 21 | [Description("Address created using compressed public key")] 22 | AddrComp, 23 | [Description("Address created using uncompressed public key")] 24 | AddrUnComp, 25 | [Description("Address created using either compressed or uncompressed public key")] 26 | AddrBoth, 27 | [Description("P2SH-P2WPKH or nested SegWit starting with 3")] 28 | AddrNested, 29 | [Description("Public key in hexadecimal format")] 30 | Pubkey, 31 | [Description("Private key in WIF (Base-58) format")] 32 | PrivateKey, 33 | } 34 | 35 | 36 | public enum EncodingName 37 | { 38 | Base16, 39 | Base43, 40 | Base58, 41 | Base58Check, 42 | Base64, 43 | } 44 | 45 | 46 | public enum KB 47 | { 48 | Bitcoin, 49 | [Description("Private key")] 50 | PrivateKey, 51 | //[Description("Public key")] 52 | //Pubkey, 53 | 54 | //Address, 55 | //[Description("Mnemonic or seed phrase")] 56 | //Mnemonic, 57 | //[Description("Extended private/public key")] 58 | //ExtendedKey, 59 | [Description("BIP-32 derivation path")] 60 | Bip32Path, 61 | [Description("Damaged input")] 62 | DamagedInput, 63 | [Description("Extra input for comparison")] 64 | ExtraInput, 65 | [Description("Types of extra inputs for comparison")] 66 | ExtraInputTypes, 67 | [Description("Password recovery mode (alphanumeric)")] 68 | AlphanumericPass, 69 | [Description("Password recovery mode (custom characters)")] 70 | CustomCharPass, 71 | [Description("Number of threads used in settings")] 72 | ThreadCount, 73 | } 74 | 75 | 76 | public enum MessageBoxType 77 | { 78 | Ok, 79 | OkCancel, 80 | YesNo, 81 | } 82 | 83 | 84 | public enum MessageBoxResult 85 | { 86 | Ok, 87 | Cancel, 88 | Yes, 89 | No 90 | } 91 | 92 | 93 | public enum MnemonicTypes 94 | { 95 | BIP39, 96 | Electrum, 97 | } 98 | 99 | 100 | public enum PassRecoveryMode 101 | { 102 | [Description("A password consisting of random characters")] 103 | Alphanumeric, 104 | [Description("Custom password characters")] 105 | CustomChars 106 | } 107 | 108 | 109 | [Flags] 110 | public enum PasswordType : ulong 111 | { 112 | None = 0, 113 | UpperCase = 1 << 0, 114 | LowerCase = 1 << 1, 115 | Numbers = 1 << 2, 116 | Symbols = 1 << 3, 117 | Space = 1 << 4 118 | } 119 | 120 | 121 | public enum Possibility 122 | { 123 | Maybe, 124 | Possible, 125 | Impossible 126 | } 127 | 128 | 129 | public enum State 130 | { 131 | Ready, 132 | Working, 133 | Paused, 134 | Stopped, 135 | FinishedSuccess, 136 | FinishedFail 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/DescriptiveItem.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.ViewModels; 7 | using System; 8 | using System.ComponentModel; 9 | using System.Reflection; 10 | 11 | namespace FinderOuter.Models 12 | { 13 | public class DescriptiveItem where T : Enum 14 | { 15 | public DescriptiveItem(T value) 16 | { 17 | Value = value; 18 | 19 | FieldInfo fi = value.GetType().GetField(value.ToString()); 20 | object[] attributes = fi?.GetCustomAttributes(typeof(DescriptionAttribute), false); 21 | Description = (attributes != null && attributes.Length != 0) ? 22 | ((DescriptionAttribute)attributes[0]).Description : 23 | value.ToString(); 24 | } 25 | 26 | public string Description { get; set; } 27 | public T Value { get; set; } 28 | } 29 | 30 | public class DescriptiveHelpInput(HelpInputTypes value) : DescriptiveItem(value) 31 | { 32 | } 33 | 34 | public class DescriptiveHelpInput2(HelpSecondInputTypes value) : DescriptiveItem(value) 35 | { 36 | } 37 | 38 | public class DescriptiveKB(KB value): DescriptiveItem(value) 39 | { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/EncodingState.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Encoders; 7 | using ReactiveUI; 8 | using System; 9 | 10 | namespace FinderOuter.Models 11 | { 12 | public class EncodingState : ReactiveObject 13 | { 14 | public EncodingState(EncodingName name) 15 | { 16 | Name = name; 17 | } 18 | 19 | public EncodingName Name { get; } 20 | 21 | private Possibility _possible; 22 | public Possibility Possible 23 | { 24 | get => _possible; 25 | set => this.RaiseAndSetIfChanged(ref _possible, value); 26 | } 27 | 28 | 29 | public void SetPossibility(string input) 30 | { 31 | bool validity = Name switch 32 | { 33 | EncodingName.Base16 => Base16.IsValid(input), 34 | EncodingName.Base43 => Base43.IsValid(input), 35 | EncodingName.Base58 => Base58.IsValid(input), 36 | EncodingName.Base58Check => Base58.IsValidWithChecksum(input), 37 | EncodingName.Base64 => CheckBase64(input), 38 | _ => throw new NotImplementedException(), 39 | }; 40 | 41 | Possible = validity ? Possibility.Possible : Possibility.Impossible; 42 | } 43 | 44 | private static bool CheckBase64(string input) 45 | { 46 | try 47 | { 48 | Convert.FromBase64String(input); 49 | return true; 50 | } 51 | catch 52 | { 53 | return false; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/IReport.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System; 7 | using System.ComponentModel; 8 | using System.Diagnostics; 9 | using System.Numerics; 10 | using System.Threading.Tasks; 11 | 12 | namespace FinderOuter.Models 13 | { 14 | public interface IReport : INotifyPropertyChanged 15 | { 16 | Settings Settings { get; set; } 17 | State CurrentState { get; set; } 18 | string Message { get; set; } 19 | bool IsProgressVisible { get; set; } 20 | double Progress { get; set; } 21 | bool FoundAnyResult { get; set; } 22 | double Speed { get; set; } 23 | double TotalChecked { get; set; } 24 | TimeSpan Remaining { get; set; } 25 | Stopwatch Timer { get; } 26 | BigInteger Total { get; } 27 | 28 | ParallelOptions BuildParallelOptions(); 29 | 30 | void SetTotal(BigInteger value); 31 | void SetTotal(int value, int exponent); 32 | 33 | void Init(); 34 | bool Finalize(bool success); 35 | bool Finalize(); 36 | 37 | void AddMessage(string msg); 38 | void AddMessageSafe(string msg); 39 | 40 | bool Fail(string msg); 41 | bool Pass(string msg); 42 | 43 | void SetKeyPerSec(BigInteger totalKeys, double totalSecond); 44 | void SetKeyPerSecSafe(BigInteger totalKeys, double totalSecond); 45 | 46 | /// Number of keys checked in each round that completes 47 | void SetProgressStep(int splitSize); 48 | void IncrementProgress(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/Permutation.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | namespace FinderOuter.Models 7 | { 8 | public unsafe struct Permutation 9 | { 10 | public Permutation(int size, uint* values) 11 | { 12 | max = size; 13 | pt = values; 14 | index = 0; 15 | } 16 | 17 | 18 | public readonly int max; 19 | private int index; 20 | private readonly uint* pt; 21 | 22 | 23 | public uint GetValue() => pt[index]; 24 | 25 | 26 | public bool Increment() 27 | { 28 | index++; 29 | if (index == max) 30 | { 31 | index = 0; 32 | return false; 33 | } 34 | else 35 | { 36 | return true; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/PermutationVar.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System; 7 | 8 | namespace FinderOuter.Models 9 | { 10 | public unsafe struct PermutationVar 11 | { 12 | public PermutationVar(int size, byte* values, int* lengths) 13 | { 14 | max = size; 15 | src = values; 16 | lens = lengths; 17 | index = 0; 18 | pos = 0; 19 | } 20 | 21 | 22 | public readonly int max; 23 | private int index, pos; 24 | private readonly byte* src; 25 | private readonly int* lens; 26 | 27 | 28 | public bool Increment() 29 | { 30 | index++; 31 | if (index == max) 32 | { 33 | index = 0; 34 | pos = 0; 35 | return false; 36 | } 37 | else 38 | { 39 | pos += lens[index - 1]; 40 | return true; 41 | } 42 | } 43 | 44 | /// 45 | /// Writes the next value to the given pointer 46 | /// 47 | /// Pointer to the stream to write to 48 | /// Total size of the stream to write to 49 | /// Number of bytes written (should be used to move forward) 50 | public int WriteValue(byte* res, int dstSizeInBytes) 51 | { 52 | int len = lens[index]; 53 | Buffer.MemoryCopy(src + pos, res, dstSizeInBytes, len); 54 | return len; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Src/FinderOuter/Models/Settings.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using ReactiveUI; 7 | using System; 8 | 9 | namespace FinderOuter.Models 10 | { 11 | public class Settings : ReactiveObject 12 | { 13 | public Settings() 14 | { 15 | MaxCoreCount = Environment.ProcessorCount; 16 | _coreCount = MaxCoreCount; 17 | } 18 | 19 | public int MaxCoreCount { get; } 20 | 21 | private int _coreCount; 22 | public int CoreCount 23 | { 24 | get => _coreCount; 25 | set 26 | { 27 | if (value < 1) 28 | { 29 | value = 1; 30 | } 31 | this.RaiseAndSetIfChanged(ref _coreCount, value); 32 | } 33 | } 34 | 35 | public bool IsMax => CoreCount >= MaxCoreCount; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/FinderOuter/Program.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia; 7 | using Avalonia.ReactiveUI; 8 | 9 | namespace FinderOuter 10 | { 11 | class Program 12 | { 13 | // Initialization code. Don't use any Avalonia, third-party APIs or any 14 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized 15 | // yet and stuff might break. 16 | public static void Main(string[] args) => BuildAvaloniaApp() 17 | .StartWithClassicDesktopLifetime(args); 18 | 19 | // Avalonia configuration, don't remove; also used by visual designer. 20 | public static AppBuilder BuildAvaloniaApp() 21 | => AppBuilder.Configure() 22 | .UsePlatformDetect() 23 | .LogToTrace() 24 | .UseReactiveUI(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/AddressService.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Blockchain.Scripts; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using Autarkysoft.Bitcoin.Encoders; 9 | using System.Text; 10 | 11 | namespace FinderOuter.Services 12 | { 13 | public static class AddressService 14 | { 15 | /// 16 | /// Checks the given address and returns its decoded hash. 17 | /// Works only for P2PKH and P2WPKH addresses 18 | /// 19 | public static bool CheckAndGetHash(string address, out byte[] hash) 20 | { 21 | hash = null; 22 | if (string.IsNullOrWhiteSpace(address)) 23 | { 24 | return false; 25 | } 26 | else if (address[0] == '1') 27 | { 28 | return Address.VerifyType(address, PubkeyScriptType.P2PKH, out hash); 29 | } 30 | else if (address[0] == 'b') 31 | { 32 | return Address.VerifyType(address, PubkeyScriptType.P2WPKH, out hash); 33 | } 34 | else 35 | { 36 | return false; 37 | } 38 | } 39 | 40 | /// 41 | /// Checks the given address and returns its decoded hash. 42 | /// Works only for P2SH addresses 43 | /// 44 | public static bool CheckAndGetHash_P2sh(string address, out byte[] hash) 45 | { 46 | if (string.IsNullOrWhiteSpace(address) || address[0] != '3') 47 | { 48 | hash = null; 49 | return false; 50 | } 51 | else 52 | { 53 | return Address.VerifyType(address, PubkeyScriptType.P2SH, out hash); 54 | } 55 | } 56 | 57 | 58 | public static string GetAllAddresses(in Point pub) 59 | { 60 | StringBuilder sb = new(4 * 64); 61 | 62 | sb.AppendLine($"Compressed P2PKH: {Address.GetP2pkh(pub)}"); 63 | sb.AppendLine($"Uncompressed P2PKH: {Address.GetP2pkh(pub, false)}"); 64 | sb.AppendLine($"P2WPKH: {Address.GetP2wpkh(pub)}"); 65 | sb.AppendLine($"P2SH-P2WPKH: {Address.GetP2sh_P2wpkh(pub)}"); 66 | 67 | return sb.ToString(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/CartesianProduct.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | 10 | namespace FinderOuter.Services 11 | { 12 | [Obsolete("This class is very slow to use")] 13 | public class CartesianProduct 14 | { 15 | public static IEnumerable> Create(IEnumerable> inputs) 16 | { 17 | return inputs.Aggregate( 18 | EnumerableFrom(Enumerable.Empty()), 19 | (soFar, input) => 20 | from prevProductItem in soFar 21 | from item in input 22 | select prevProductItem.Append(item)); 23 | } 24 | private static IEnumerable EnumerableFrom(T item) 25 | { 26 | return new T[] { item }; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/DefaultComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 7 | 8 | namespace FinderOuter.Services.Comparers 9 | { 10 | public class DefaultComparer : ICompareService 11 | { 12 | public string CompareType => "None"; 13 | public bool IsInitialized => true; 14 | public bool Init(string data) => true; 15 | public ICompareService Clone() => this; 16 | 17 | private readonly Calc _calc = new(); 18 | public Calc Calc => _calc; 19 | 20 | public unsafe bool Compare(uint* hPt) => true; 21 | public unsafe bool Compare(ulong* hPt) => true; 22 | public bool Compare(in PointJacobian point) => true; 23 | public bool Compare(byte[] key) => true; 24 | public bool Compare(in Scalar8x32 key) => true; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/ICompareService.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 7 | 8 | namespace FinderOuter.Services.Comparers 9 | { 10 | public interface ICompareService 11 | { 12 | public string CompareType { get; } 13 | public bool IsInitialized { get; } 14 | public Calc Calc { get; } 15 | 16 | /// 17 | /// Builds the private key using the pointer 18 | /// 19 | /// pointer 20 | /// 21 | unsafe bool Compare(uint* hPt); 22 | /// 23 | /// Builds the private key using the pointer 24 | /// using its first 32 bytes as the key (similar to what BIP-32 works) 25 | /// 26 | /// pointer 27 | /// 28 | unsafe bool Compare(ulong* hPt); 29 | 30 | bool Compare(in PointJacobian point); 31 | 32 | bool Init(string data); 33 | ICompareService Clone(); 34 | bool Compare(byte[] key); 35 | bool Compare(in Scalar8x32 key); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToAddrBase.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 7 | 8 | namespace FinderOuter.Services.Comparers 9 | { 10 | public abstract class PrvToAddrBase : ICompareService 11 | { 12 | protected byte[] hash; 13 | 14 | public virtual bool Init(string address) 15 | { 16 | IsInitialized = AddressService.CheckAndGetHash(address, out hash); 17 | return IsInitialized; 18 | } 19 | 20 | public abstract ICompareService Clone(); 21 | 22 | public string CompareType => "Address"; 23 | public bool IsInitialized { get; protected set; } 24 | protected readonly Calc _calc = new(); 25 | public Calc Calc => _calc; 26 | 27 | public abstract unsafe bool Compare(uint* hPt); 28 | public abstract unsafe bool Compare(ulong* hPt); 29 | public abstract bool Compare(in PointJacobian point); 30 | 31 | public bool Compare(byte[] key) 32 | { 33 | Scalar8x32 k = new(key, out bool overflow); 34 | if (overflow) 35 | { 36 | return false; 37 | } 38 | PointJacobian pt = _calc.MultiplyByG(k); 39 | return Compare(pt); 40 | } 41 | 42 | public bool Compare(in Scalar8x32 key) => Compare(Calc.MultiplyByG(key)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToAddrBothComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using FinderOuter.Backend.Hashing; 9 | using System; 10 | 11 | namespace FinderOuter.Services.Comparers 12 | { 13 | /// 14 | /// Converts private key to address using both compressed and uncompressed public keys 15 | /// 16 | public class PrvToAddrBothComparer : PrvToAddrBase 17 | { 18 | public override ICompareService Clone() 19 | { 20 | return new PrvToAddrBothComparer() 21 | { 22 | hash = this.hash.CloneByteArray() 23 | }; 24 | } 25 | 26 | public override unsafe bool Compare(uint* hPt) 27 | { 28 | Scalar8x32 key = new(hPt, out bool overflow); 29 | if (overflow) 30 | { 31 | return false; 32 | } 33 | 34 | _calc.GetPubkey(in key, out Span comp, out Span uncomp); 35 | 36 | ReadOnlySpan compHash = Hash160Fo.Compress33(comp); 37 | if (compHash.SequenceEqual(hash)) 38 | { 39 | return true; 40 | } 41 | 42 | ReadOnlySpan uncompHash = Hash160Fo.Compress65(uncomp); 43 | return uncompHash.SequenceEqual(hash); 44 | } 45 | 46 | public override unsafe bool Compare(ulong* hPt) 47 | { 48 | Scalar8x32 key = new(hPt, out bool overflow); 49 | if (overflow) 50 | { 51 | return false; 52 | } 53 | 54 | _calc.GetPubkey(in key, out Span comp, out Span uncomp); 55 | 56 | ReadOnlySpan compHash = Hash160Fo.Compress33(comp); 57 | if (compHash.SequenceEqual(hash)) 58 | { 59 | return true; 60 | } 61 | 62 | ReadOnlySpan uncompHash = Hash160Fo.Compress65(uncomp); 63 | return uncompHash.SequenceEqual(hash); 64 | } 65 | 66 | public override bool Compare(in PointJacobian point) 67 | { 68 | Point pub = point.ToPoint(); 69 | 70 | UInt256_10x26 xNorm = pub.x.NormalizeVar(); 71 | UInt256_10x26 yNorm = pub.y.NormalizeVar(); 72 | 73 | byte firstByte = yNorm.IsOdd ? (byte)3 : (byte)2; 74 | 75 | Span uncomp = new byte[65]; 76 | uncomp[0] = 4; 77 | xNorm.WriteToSpan(uncomp[1..]); 78 | yNorm.WriteToSpan(uncomp[33..]); 79 | 80 | ReadOnlySpan uncompHash = Hash160Fo.Compress65(uncomp); 81 | if (uncompHash.SequenceEqual(hash)) 82 | { 83 | return true; 84 | } 85 | 86 | Span comp = new byte[33]; 87 | comp[0] = firstByte; 88 | uncomp.Slice(1, 32).CopyTo(comp[1..]); 89 | ReadOnlySpan compHash = Hash160Fo.Compress33(comp.ToArray()); 90 | return compHash.SequenceEqual(hash); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToAddrCompComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using FinderOuter.Backend.Hashing; 9 | using System; 10 | 11 | namespace FinderOuter.Services.Comparers 12 | { 13 | /// 14 | /// Converts private key to address using only compressed public key 15 | /// 16 | public class PrvToAddrCompComparer : PrvToAddrBase 17 | { 18 | public override ICompareService Clone() 19 | { 20 | return new PrvToAddrCompComparer() 21 | { 22 | hash = this.hash.CloneByteArray() 23 | }; 24 | } 25 | 26 | public override unsafe bool Compare(uint* hPt) 27 | { 28 | Scalar8x32 key = new(hPt, out bool overflow); 29 | if (overflow) 30 | { 31 | return false; 32 | } 33 | 34 | Span toHash = _calc.GetPubkey(in key, true); 35 | 36 | ReadOnlySpan actual = Hash160Fo.Compress33(toHash); 37 | return actual.SequenceEqual(hash); 38 | } 39 | 40 | public override unsafe bool Compare(ulong* hPt) 41 | { 42 | Scalar8x32 key = new(hPt, out bool overflow); 43 | if (overflow) 44 | { 45 | return false; 46 | } 47 | 48 | Span toHash = _calc.GetPubkey(in key, true); 49 | 50 | ReadOnlySpan actual = Hash160Fo.Compress33(toHash); 51 | return actual.SequenceEqual(hash); 52 | } 53 | 54 | public override bool Compare(in PointJacobian point) 55 | { 56 | Span toHash = point.ToPoint().ToByteArray(true); 57 | ReadOnlySpan compHash = Hash160Fo.Compress33(toHash); 58 | return compHash.SequenceEqual(hash); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToAddrNestedComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using FinderOuter.Backend.Hashing; 9 | using System; 10 | 11 | namespace FinderOuter.Services.Comparers 12 | { 13 | public class PrvToAddrNestedComparer : PrvToAddrBase 14 | { 15 | public override bool Init(string address) 16 | { 17 | IsInitialized = AddressService.CheckAndGetHash_P2sh(address, out hash); 18 | return IsInitialized; 19 | } 20 | 21 | public override ICompareService Clone() 22 | { 23 | return new PrvToAddrNestedComparer() 24 | { 25 | hash = this.hash.CloneByteArray() 26 | }; 27 | } 28 | 29 | public override unsafe bool Compare(uint* hPt) 30 | { 31 | Scalar8x32 key = new(hPt, out bool overflow); 32 | if (overflow) 33 | { 34 | return false; 35 | } 36 | 37 | Span toHash = _calc.GetPubkey(in key, true); 38 | 39 | ReadOnlySpan actual = Hash160Fo.Compress33_P2sh(toHash); 40 | return actual.SequenceEqual(hash); 41 | } 42 | 43 | public override unsafe bool Compare(ulong* hPt) 44 | { 45 | Scalar8x32 key = new(hPt, out bool overflow); 46 | if (overflow) 47 | { 48 | return false; 49 | } 50 | 51 | Span toHash = _calc.GetPubkey(in key, true); 52 | 53 | ReadOnlySpan actual = Hash160Fo.Compress33_P2sh(toHash); 54 | return actual.SequenceEqual(hash); 55 | } 56 | 57 | public override bool Compare(in PointJacobian point) 58 | { 59 | Span toHash = point.ToPoint().ToByteArray(true); 60 | ReadOnlySpan compHash = Hash160Fo.Compress33_P2sh(toHash); 61 | return compHash.SequenceEqual(hash); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToAddrUncompComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using FinderOuter.Backend.Hashing; 9 | using System; 10 | 11 | namespace FinderOuter.Services.Comparers 12 | { 13 | /// 14 | /// Converts private key to address using only uncompressed public key 15 | /// 16 | public class PrvToAddrUncompComparer : PrvToAddrBase 17 | { 18 | public override ICompareService Clone() 19 | { 20 | return new PrvToAddrUncompComparer() 21 | { 22 | hash = this.hash.CloneByteArray() 23 | }; 24 | } 25 | 26 | public override unsafe bool Compare(uint* hPt) 27 | { 28 | Scalar8x32 key = new(hPt, out bool overflow); 29 | if (overflow) 30 | { 31 | return false; 32 | } 33 | 34 | Span toHash = _calc.GetPubkey(in key, false); 35 | 36 | ReadOnlySpan compHash = Hash160Fo.Compress65(toHash); 37 | return compHash.SequenceEqual(hash); 38 | } 39 | 40 | public override unsafe bool Compare(ulong* hPt) 41 | { 42 | Scalar8x32 key = new(hPt, out bool overflow); 43 | if (overflow) 44 | { 45 | return false; 46 | } 47 | 48 | Span toHash = _calc.GetPubkey(in key, false); 49 | 50 | ReadOnlySpan compHash = Hash160Fo.Compress65(toHash); 51 | return compHash.SequenceEqual(hash); 52 | } 53 | 54 | public override bool Compare(in PointJacobian point) 55 | { 56 | Span toHash = point.ToPoint().ToByteArray(false); 57 | ReadOnlySpan compHash = Hash160Fo.Compress65(toHash); 58 | return compHash.SequenceEqual(hash); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToPrvComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using FinderOuter.Backend.Hashing; 9 | using System; 10 | 11 | namespace FinderOuter.Services.Comparers 12 | { 13 | /// 14 | /// Compares 2 private key bytes. It is useful for HD keys where user has a single child private key. 15 | /// 16 | public class PrvToPrvComparer : ICompareService 17 | { 18 | public string CompareType => "Privatekey"; 19 | public bool IsInitialized { get; private set; } 20 | 21 | private byte[] expectedBytes; 22 | private Scalar8x32 expectedKey; 23 | 24 | public bool Init(string data) 25 | { 26 | try 27 | { 28 | using PrivateKey temp = new(data); 29 | expectedBytes = temp.ToBytes(); 30 | expectedKey = new(expectedBytes, out _); 31 | IsInitialized = true; 32 | } 33 | catch (Exception) 34 | { 35 | IsInitialized = false; 36 | } 37 | 38 | return IsInitialized; 39 | } 40 | 41 | public ICompareService Clone() 42 | { 43 | return new PrvToPrvComparer() 44 | { 45 | expectedBytes = this.expectedBytes.CloneByteArray(), 46 | expectedKey = this.expectedKey 47 | }; 48 | } 49 | 50 | private readonly Calc _calc = new(); 51 | public Calc Calc => _calc; 52 | public unsafe bool Compare(uint* hPt) => ((Span)expectedBytes).SequenceEqual(Sha256Fo.GetBytes(hPt)); 53 | public unsafe bool Compare(ulong* hPt) => ((Span)expectedBytes).SequenceEqual(Sha512Fo.GetFirst32Bytes(hPt)); 54 | 55 | public bool Compare(byte[] key) => ((ReadOnlySpan)expectedBytes).SequenceEqual(key); 56 | 57 | public bool Compare(in Scalar8x32 key) => key == expectedKey; 58 | 59 | public bool Compare(in PointJacobian point) => throw new NotImplementedException(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/Comparers/PrvToPubComparer.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Cryptography.Asymmetric.EllipticCurve; 7 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 8 | using Autarkysoft.Bitcoin.Encoders; 9 | using System; 10 | 11 | namespace FinderOuter.Services.Comparers 12 | { 13 | /// 14 | /// Converts private key to an and compares it with the pubkey (point). 15 | /// 16 | public class PrvToPubComparer : ICompareService 17 | { 18 | public string CompareType => "Public key"; 19 | public bool IsInitialized { get; private set; } 20 | 21 | private byte[] pubBa; 22 | 23 | public bool Init(string pubHex) 24 | { 25 | IsInitialized = Base16.TryDecode(pubHex, out pubBa) && Point.TryRead(pubBa, out _); 26 | return IsInitialized; 27 | } 28 | 29 | public ICompareService Clone() 30 | { 31 | return new PrvToPubComparer() 32 | { 33 | pubBa = this.pubBa 34 | }; 35 | } 36 | 37 | protected readonly Calc _calc = new(); 38 | public Calc Calc => _calc; 39 | public unsafe bool Compare(uint* hPt) 40 | { 41 | Scalar8x32 key = new(hPt, out bool overflow); 42 | if (overflow) 43 | { 44 | return false; 45 | } 46 | 47 | Span actual = _calc.GetPubkey(key, pubBa.Length == 33); 48 | return actual.SequenceEqual(pubBa); 49 | } 50 | 51 | public unsafe bool Compare(ulong* hPt) 52 | { 53 | Scalar8x32 key = new(hPt, out bool overflow); 54 | if (overflow) 55 | { 56 | return false; 57 | } 58 | 59 | Span actual = _calc.GetPubkey(key, pubBa.Length == 33); 60 | return actual.SequenceEqual(pubBa); 61 | } 62 | 63 | public bool Compare(in PointJacobian point) 64 | { 65 | ReadOnlySpan actual = point.ToPoint().ToByteArray(pubBa.Length == 33); 66 | return actual.SequenceEqual(pubBa); 67 | } 68 | 69 | 70 | public bool Compare(byte[] key) 71 | { 72 | Scalar8x32 sc = new(key, out bool overflow); 73 | if (overflow) 74 | { 75 | return false; 76 | } 77 | 78 | Span actual = _calc.GetPubkey(sc, pubBa.Length == 33); 79 | return actual.SequenceEqual(pubBa); 80 | } 81 | 82 | public bool Compare(in Scalar8x32 key) => Compare(Calc.MultiplyByG(key)); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/FileManager.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Platform.Storage; 7 | using FinderOuter.Models; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.IO; 11 | using System.Linq; 12 | using System.Threading.Tasks; 13 | 14 | namespace FinderOuter.Services 15 | { 16 | public interface IFileManager 17 | { 18 | public Task OpenAsync(); 19 | public IStorageProvider StorageProvider { get; set; } 20 | } 21 | 22 | 23 | 24 | public class FileManager : IFileManager 25 | { 26 | public IWindowManager WinMan { get; set; } = new WindowManager(); 27 | public IStorageProvider StorageProvider { get; set; } 28 | 29 | public async Task OpenAsync() 30 | { 31 | FilePickerFileType fileType = new("txt") 32 | { 33 | Patterns = new string[] { "*.txt" } 34 | }; 35 | 36 | FilePickerOpenOptions options = new() 37 | { 38 | AllowMultiple = false, 39 | FileTypeFilter = new FilePickerFileType[] { fileType }, 40 | Title = "Text files (.txt)" 41 | }; 42 | 43 | try 44 | { 45 | IReadOnlyList dir = await StorageProvider.OpenFilePickerAsync(options); 46 | if (dir != null && dir.Count > 0) 47 | { 48 | return File.ReadAllLines(dir.ElementAt(0).Path.LocalPath); 49 | } 50 | } 51 | catch (Exception ex) 52 | { 53 | await WinMan.ShowMessageBox(MessageBoxType.Ok, ex.Message); 54 | } 55 | return Array.Empty(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/IPasswordService.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.Models; 7 | 8 | namespace FinderOuter.Services 9 | { 10 | public interface IPasswordService 11 | { 12 | bool TryGetAllValues(PasswordType type, out byte[] allValues, out string error); 13 | bool TryGetAllValues(string possibleChars, out byte[] allValues, out string error); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/PasswordService.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.Backend; 7 | using FinderOuter.Models; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | namespace FinderOuter.Services 12 | { 13 | public class PasswordService : IPasswordService 14 | { 15 | public bool TryGetAllValues(PasswordType type, out byte[] allValues, out string error) 16 | { 17 | string temp = string.Empty; 18 | if (type.HasFlag(PasswordType.UpperCase)) 19 | { 20 | temp += ConstantsFO.UpperCase; 21 | } 22 | if (type.HasFlag(PasswordType.LowerCase)) 23 | { 24 | temp += ConstantsFO.LowerCase; 25 | } 26 | if (type.HasFlag(PasswordType.Numbers)) 27 | { 28 | temp += ConstantsFO.Numbers; 29 | } 30 | if (type.HasFlag(PasswordType.Symbols)) 31 | { 32 | temp += ConstantsFO.AllSymbols; 33 | } 34 | if (type.HasFlag(PasswordType.Space)) 35 | { 36 | temp += " "; 37 | } 38 | 39 | allValues = Encoding.UTF8.GetBytes(temp); 40 | 41 | if (allValues.Length == 0) 42 | { 43 | error = type == PasswordType.None ? "At least one password character type has to be selected." : 44 | "Password character type is not defined (this is a bug)."; 45 | return false; 46 | } 47 | else 48 | { 49 | error = null; 50 | return true; 51 | } 52 | } 53 | 54 | 55 | public bool TryGetAllValues(string possibleChars, out byte[] allValues, out string error) 56 | { 57 | if (string.IsNullOrEmpty(possibleChars)) 58 | { 59 | error = "Please enter at least 1 possible character."; 60 | allValues = null; 61 | return false; 62 | } 63 | 64 | allValues = Encoding.UTF8.GetBytes(possibleChars.Normalize(NormalizationForm.FormC)); 65 | if (allValues.Distinct().Count() == allValues.Length) 66 | { 67 | error = null; 68 | return true; 69 | } 70 | else 71 | { 72 | error = "Remove the duplicate character(s) from possible password characters."; 73 | allValues = null; 74 | return false; 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/SearchSpaces/B16SearchSpace.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin.Cryptography.EllipticCurve; 7 | using Autarkysoft.Bitcoin.Encoders; 8 | using FinderOuter.Backend; 9 | using FinderOuter.Services.Comparers; 10 | using System; 11 | using System.Linq; 12 | 13 | namespace FinderOuter.Services.SearchSpaces 14 | { 15 | public class B16SearchSpace : SearchSpaceBase 16 | { 17 | public static readonly char[] AllChars = ConstantsFO.Base16Chars.ToCharArray(); 18 | public byte[] preComputed; 19 | 20 | public bool Process(string input, char missChar, out string error) 21 | { 22 | Input = input; 23 | 24 | if (!InputService.IsValidBase16Key(input, missChar, out error)) 25 | { 26 | return false; 27 | } 28 | else 29 | { 30 | MissCount = input.Count(c => c == missChar); 31 | if (MissCount == 0) 32 | { 33 | error = null; 34 | return true; 35 | } 36 | 37 | MissingIndexes = new int[MissCount]; 38 | preComputed = new byte[32]; 39 | for (int i = 0, j = 0; i < preComputed.Length; i++) 40 | { 41 | int hi, lo; 42 | if (input[i * 2] == missChar) 43 | { 44 | hi = 0; 45 | MissingIndexes[j++] = i * 2; 46 | } 47 | else 48 | { 49 | hi = input[i * 2] - 65; 50 | hi = hi + 10 + ((hi >> 31) & 7); 51 | } 52 | if (input[i * 2 + 1] == missChar) 53 | { 54 | lo = 0; 55 | MissingIndexes[j++] = i * 2 + 1; 56 | } 57 | else 58 | { 59 | lo = input[i * 2 + 1] - 65; 60 | lo = lo + 10 + ((lo >> 31) & 7) & 0x0f; 61 | } 62 | 63 | preComputed[i] = (byte)(lo | hi << 4); 64 | } 65 | 66 | error = null; 67 | return true; 68 | } 69 | } 70 | 71 | public bool ProcessNoMissing(ICompareService comparer, out string message) 72 | { 73 | if (!comparer.IsInitialized) 74 | { 75 | message = "Comparer is not initializd."; 76 | return false; 77 | } 78 | 79 | if (MissCount != 0) 80 | { 81 | message = "This method should not be called with missing characters."; 82 | return false; 83 | } 84 | // A quick check to make sure no exceptions are thrown later (this should always pass since 85 | // Input is already processed) 86 | if (!Base16.TryDecode(Input, out byte[] ba) || ba.Length != 32) 87 | { 88 | message = "Invalid Base-16 key."; 89 | return false; 90 | } 91 | 92 | Scalar8x32 key = new(ba, out bool overflow); 93 | if (key.IsZero || overflow) 94 | { 95 | message = "The given key is out of range."; 96 | return false; 97 | } 98 | 99 | if (comparer.Compare(key)) 100 | { 101 | message = $"The given key is valid and the given {comparer.CompareType} is correctly derived from it."; 102 | return true; 103 | } 104 | else 105 | { 106 | PrivateKey prv = new(ba); 107 | message = $"The given key is valid but the given {comparer.CompareType} can not be derived from it." + 108 | $"{Environment.NewLine}" + 109 | $"List of addresses that can be derived from this key:{Environment.NewLine}" + 110 | $"{AddressService.GetAllAddresses(prv.ToPublicKey(comparer.Calc))}"; 111 | 112 | return false; 113 | } 114 | } 115 | 116 | public bool SetValues(string[][] array, out string error) 117 | { 118 | uint[] all = Enumerable.Range(0, AllChars.Length).Select(i => (uint)i).ToArray(); 119 | return ProcessValues(array, out error) && ProcessCharValues(array, AllChars, all, out error); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/SearchSpaces/MiniKeySearchSpace.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.Backend; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace FinderOuter.Services.SearchSpaces 11 | { 12 | public class MiniKeySearchSpace : SearchSpaceBase 13 | { 14 | public static readonly char[] AllChars = ConstantsFO.Base58Chars.ToCharArray(); 15 | public static readonly byte[] AllBytes = Encoding.UTF8.GetBytes(ConstantsFO.Base58Chars); 16 | public byte[] preComputed; 17 | 18 | private void PreCompute(char missingChar) 19 | { 20 | int mis = 0; 21 | for (int i = 0; i < Input.Length; i++) 22 | { 23 | if (Input[i] == missingChar) 24 | { 25 | MissingIndexes[mis++] = i; 26 | } 27 | else 28 | { 29 | preComputed[i] = (byte)Input[i]; 30 | } 31 | } 32 | } 33 | 34 | public bool Process(string input, char missingChar, out string error) 35 | { 36 | Input = input; 37 | 38 | if (!InputService.IsMissingCharValid(missingChar)) 39 | { 40 | error = $"Invalid missing character. Choose one from {ConstantsFO.MissingSymbols}"; 41 | return false; 42 | } 43 | else if (string.IsNullOrEmpty(input)) 44 | { 45 | error = "Input can not be null or empty."; 46 | return false; 47 | } 48 | else if (!Input.StartsWith(ConstantsFO.MiniKeyStart)) 49 | { 50 | error = $"Minikey must start with {ConstantsFO.MiniKeyStart}."; 51 | return false; 52 | } 53 | else if (!InputService.CheckChars(input, AllChars, missingChar, out error)) 54 | { 55 | return false; 56 | } 57 | else 58 | { 59 | MissCount = Input.Count(c => c == missingChar); 60 | if (MissCount == 0) 61 | { 62 | error = null; 63 | return true; 64 | } 65 | 66 | MissingIndexes = new int[MissCount]; 67 | switch (Input.Length) 68 | { 69 | case ConstantsFO.MiniKeyLen1: 70 | preComputed = new byte[ConstantsFO.MiniKeyLen1]; 71 | break; 72 | case ConstantsFO.MiniKeyLen2: 73 | preComputed = new byte[ConstantsFO.MiniKeyLen2]; 74 | break; 75 | case ConstantsFO.MiniKeyLen3: 76 | preComputed = new byte[ConstantsFO.MiniKeyLen3]; 77 | break; 78 | default: 79 | error = $"Minikey length must be {ConstantsFO.MiniKeyLen1} or {ConstantsFO.MiniKeyLen2} or " + 80 | $"{ConstantsFO.MiniKeyLen3}."; 81 | return false; 82 | } 83 | 84 | PreCompute(missingChar); 85 | error = null; 86 | return true; 87 | } 88 | } 89 | 90 | 91 | public bool ProcessNoMissing(out string message) 92 | { 93 | if (MissCount != 0) 94 | { 95 | message = "This method should not be called with missing characters."; 96 | return false; 97 | } 98 | 99 | return InputService.IsValidMinikey(Input, out message); 100 | } 101 | 102 | 103 | public bool SetValues(string[][] array, out string error) 104 | { 105 | uint[] all = AllBytes.Select(i => (uint)i).ToArray(); 106 | return ProcessValues(array, out error) && ProcessCharValues(array, AllChars, all, out error); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/SearchSpaces/PasswordSearchSpace.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using FinderOuter.Backend.Hashing; 8 | using System.Diagnostics; 9 | using System.Linq; 10 | using System.Text; 11 | 12 | namespace FinderOuter.Services.SearchSpaces 13 | { 14 | public class PasswordSearchSpace : SearchSpaceBase 15 | { 16 | /// 17 | /// Number of chars/words in the password 18 | /// 19 | public int PasswordLength { get; private set; } 20 | /// 21 | /// Maximum possible password size in bytes (will be padded to be divisible by 4) 22 | /// 23 | public int MaxPasswordSize { get; private set; } 24 | public byte[] AllValues { get; private set; } 25 | public int[] PermutationLengths { get; private set; } 26 | public int[] PermutationSizes { get; private set; } 27 | public string[] AllWords { get; set; } 28 | 29 | public bool isComp, isEc, hasLot; 30 | public byte[] encryptedBA; 31 | public uint salt; 32 | 33 | 34 | public bool Process(string bip38, int passLength, out string error) 35 | { 36 | // I don't think anyone has a 1 char password so we take the lazy route and reject it (at least for now) 37 | if (passLength <= 1) 38 | { 39 | error = "Passwords smaller than 1 byte are not supported."; 40 | return false; 41 | } 42 | // Passwords bigger than 64 bytes need to be hashed first inside HMACSHA256 so we need a different MainLoop code 43 | // Considering that 64 byte is too big to brute force, we simply reject it 44 | if (passLength > Sha256Fo.BlockByteSize) 45 | { 46 | error = "Password is too long (bigger than SHA256 block size)."; 47 | return false; 48 | } 49 | 50 | if (!InputService.IsValidBase58Bip38(bip38, out error)) 51 | { 52 | return false; 53 | } 54 | else if (!InputService.TryDecodeBip38(bip38, out encryptedBA, out byte[] saltBa, out isComp, out isEc, out hasLot, out error)) 55 | { 56 | return false; 57 | } 58 | else 59 | { 60 | salt = (uint)(saltBa[0] << 24 | saltBa[1] << 16 | saltBa[2] << 8 | saltBa[3]); 61 | } 62 | 63 | PasswordLength = passLength; 64 | 65 | error = string.Empty; 66 | return true; 67 | } 68 | 69 | 70 | public bool SetValues(string[][] result, out string error) 71 | { 72 | if (result.Length != PasswordLength || result.Any(x => x.Length < 1)) 73 | { 74 | error = "Invalid array length."; 75 | return false; 76 | } 77 | 78 | int totalLen = 0; 79 | for (int i = 0; i < result.Length; i++) 80 | { 81 | if (result[i].Length < 1) 82 | { 83 | error = "At least 2 possible items is needed."; 84 | return false; 85 | } 86 | totalLen += result[i].Length; 87 | } 88 | 89 | PermutationLengths = new int[totalLen]; 90 | PermutationCounts = new int[PasswordLength]; 91 | PermutationSizes = new int[PasswordLength]; 92 | 93 | FastStream stream = new(); 94 | int index1 = 0; 95 | int index2 = 0; 96 | MaxPasswordSize = 0; 97 | foreach (string[] item in result) 98 | { 99 | int max = 0; 100 | foreach (string s in item) 101 | { 102 | byte[] t = Encoding.UTF8.GetBytes(s); 103 | stream.Write(t); 104 | PermutationLengths[index1++] = t.Length; 105 | PermutationSizes[index2] += t.Length; 106 | 107 | if (s.Length > max) 108 | { 109 | max = s.Length; 110 | } 111 | } 112 | Debug.Assert(max > 0); 113 | MaxPasswordSize += max; 114 | 115 | PermutationCounts[index2++] = item.Length; 116 | } 117 | 118 | while (MaxPasswordSize % 4 != 0) 119 | { 120 | MaxPasswordSize++; 121 | } 122 | if (MaxPasswordSize > Sha256Fo.BlockByteSize) 123 | { 124 | error = "Password is too long (bigger than SHA256 block size)."; 125 | return false; 126 | } 127 | 128 | AllValues = stream.ToByteArray(); 129 | 130 | error = string.Empty; 131 | return true; 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/SearchSpaces/SearchSpaceBase.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Autarkysoft.Bitcoin; 7 | using System; 8 | using System.Diagnostics; 9 | using System.Numerics; 10 | 11 | namespace FinderOuter.Services.SearchSpaces 12 | { 13 | public abstract class SearchSpaceBase 14 | { 15 | public string Input { get; protected set; } 16 | public uint[] AllPermutationValues { get; protected set; } 17 | public int[] PermutationCounts { get; protected set; } = Array.Empty(); 18 | public int[] MissingIndexes { get; protected set; } 19 | public int MissCount { get; protected set; } 20 | 21 | 22 | public bool ProcessValues(string[][] array, out string error) 23 | { 24 | if (array is null) 25 | { 26 | // ViewModels should never send null array 27 | error = "Permutations list can not be null (this is a bug)."; 28 | return false; 29 | } 30 | 31 | if (array.Length != MissCount) 32 | { 33 | error = "Permutations list doesn't have the same number of arrays as missing characters count."; 34 | return false; 35 | } 36 | 37 | int totalLen = 0; 38 | int maxLen = 0; 39 | int maxIndex = 0; 40 | for (int i = 0; i < array.Length; i++) 41 | { 42 | if (array[i] is null || array[i].Length < 2) 43 | { 44 | error = $"Search space values are not correctly set. " + 45 | $"Add at least 2 possible values for the {(i + 1).ToOrdinal()} missing position."; 46 | return false; 47 | } 48 | totalLen += array[i].Length; 49 | 50 | if (array[i].Length > maxLen) 51 | { 52 | maxLen = array[i].Length; 53 | maxIndex = i; 54 | } 55 | } 56 | 57 | if (maxIndex != 0) 58 | { 59 | string[] t1 = array[maxIndex]; 60 | array[maxIndex] = array[0]; 61 | array[0] = t1; 62 | 63 | int t2 = MissingIndexes[maxIndex]; 64 | MissingIndexes[maxIndex] = MissingIndexes[0]; 65 | MissingIndexes[0] = t2; 66 | } 67 | 68 | AllPermutationValues = new uint[totalLen]; 69 | PermutationCounts = new int[MissCount]; 70 | 71 | error = string.Empty; 72 | return true; 73 | } 74 | 75 | 76 | public bool ProcessCharValues(string[][] array, char[] allChars, uint[] permutationVals, out string error) 77 | { 78 | Debug.Assert(array is not null); 79 | Debug.Assert(array.Length == MissCount); 80 | 81 | int index1 = 0; 82 | int index2 = 0; 83 | foreach (string[] item in array) 84 | { 85 | Debug.Assert(item is not null && item.Length >= 2); 86 | 87 | PermutationCounts[index2++] = item.Length; 88 | foreach (string s in item) 89 | { 90 | if (string.IsNullOrEmpty(s) || s.Length != 1) 91 | { 92 | error = $"Given value ({s}) is not a valid character."; 93 | return false; 94 | } 95 | int i = Array.IndexOf(allChars, s[0]); 96 | if (i < 0) 97 | { 98 | error = $"Given character ({s}) is not found in the valid characters list."; 99 | return false; 100 | } 101 | if (i > permutationVals.Length) 102 | { 103 | error = "Given permutation value list is not valid (this is a bug)."; 104 | return false; 105 | } 106 | AllPermutationValues[index1++] = permutationVals[i]; 107 | } 108 | } 109 | 110 | error = string.Empty; 111 | return true; 112 | } 113 | 114 | 115 | public BigInteger GetTotal() 116 | { 117 | BigInteger res = BigInteger.One; 118 | foreach (int item in PermutationCounts) 119 | { 120 | res *= item; 121 | } 122 | return res; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Src/FinderOuter/Services/WindowManager.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia; 7 | using Avalonia.Controls; 8 | using Avalonia.Controls.ApplicationLifetimes; 9 | using FinderOuter.Models; 10 | using FinderOuter.ViewModels; 11 | using System.Threading.Tasks; 12 | 13 | namespace FinderOuter.Services 14 | { 15 | public interface IWindowManager 16 | { 17 | void ShowDialog(VmWithSizeBase vm); 18 | 19 | Task ShowMessageBox(MessageBoxType mbType, string message); 20 | } 21 | 22 | 23 | public class WindowManager : IWindowManager 24 | { 25 | public void ShowDialog(VmWithSizeBase vm) 26 | { 27 | Window win = new() 28 | { 29 | Content = vm, 30 | WindowStartupLocation = WindowStartupLocation.CenterOwner, 31 | CanResize = false, 32 | Width = vm.Width, 33 | Height = vm.Height, 34 | Title = vm.GetType().Name.Replace("ViewModel", ""), 35 | }; 36 | 37 | var lf = (IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime; 38 | win.ShowDialog(lf.MainWindow); 39 | } 40 | 41 | 42 | public async Task ShowMessageBox(MessageBoxType mbType, string message) 43 | { 44 | MessageBoxViewModel vm = new(mbType, message); 45 | Window win = new() 46 | { 47 | Content = vm, 48 | WindowStartupLocation = WindowStartupLocation.CenterOwner, 49 | CanResize = false, 50 | SizeToContent = SizeToContent.WidthAndHeight, 51 | Title = "Warning!", 52 | }; 53 | vm.CLoseEvent += (s, e) => win.Close(); 54 | 55 | var lf = (IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime; 56 | await win.ShowDialog(lf.MainWindow); 57 | 58 | return vm.Result; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Src/FinderOuter/ViewLocator.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Controls; 7 | using Avalonia.Controls.Templates; 8 | using FinderOuter.ViewModels; 9 | using System; 10 | 11 | namespace FinderOuter 12 | { 13 | [Obsolete] 14 | public class ViewLocator : IDataTemplate 15 | { 16 | public bool SupportsRecycling => false; 17 | 18 | public Control Build(object data) 19 | { 20 | string name = data.GetType().FullName.Replace("ViewModel", "View"); 21 | Type type = Type.GetType(name); 22 | 23 | if (!(type is null)) 24 | { 25 | return (Control)Activator.CreateInstance(type); 26 | } 27 | else 28 | { 29 | return new TextBlock { Text = "Not Found: " + name }; 30 | } 31 | } 32 | 33 | public bool Match(object data) 34 | { 35 | return data is ViewModelBase; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Src/FinderOuter/ViewModels/AboutViewModel.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Input.Platform; 7 | using System.Diagnostics; 8 | using System.Reflection; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace FinderOuter.ViewModels 12 | { 13 | public class AboutViewModel : VmWithSizeBase 14 | { 15 | // Makes designer happy! 16 | public AboutViewModel() 17 | { 18 | } 19 | 20 | public AboutViewModel(IClipboard clipboard) 21 | { 22 | Clipboard = clipboard; 23 | // Window size has to be set or the new window that is build with WindowManager 24 | // is going to have the same size as MainWindow 25 | Width = 600; 26 | Height = 400; 27 | } 28 | 29 | 30 | public IClipboard Clipboard { get; set; } 31 | public string NameAndVersion => $"The FinderOuter {Assembly.GetExecutingAssembly().GetName().Version.ToString(4)}"; 32 | public string SourceLink => "https://github.com/Coding-Enthusiast/FinderOuter"; 33 | public string BitcointalkLink => ""; 34 | public string AvaloniaLink => "https://avaloniaui.net/"; 35 | public string DonationUri1 => $"bitcoin:{DonationAddr1}{Bip21Extras}"; 36 | public string DonationAddr1 => "1Q9swRQuwhTtjZZ2yguFWk7m7pszknkWyk"; 37 | public string DonationUri2 => $"bitcoin:{DonationAddr2}{Bip21Extras}"; 38 | public string DonationAddr2 => "bc1q3n5t9gv40ayq68nwf0yth49dt5c799wpld376s"; 39 | 40 | private const string Bip21Extras = "?label=Coding-Enthusiast&message=Donation%20for%20FinderOuter%20project"; 41 | 42 | public async void Copy(int i) 43 | { 44 | if (Clipboard is not null) 45 | { 46 | await Clipboard.SetTextAsync(i == 1 ? DonationAddr1 : DonationAddr2); 47 | } 48 | } 49 | public void Copy1() => Copy(1); 50 | public void Copy2() => Copy(2); 51 | 52 | // Taken from avalonia source code 53 | // https://github.com/AvaloniaUI/Avalonia/blob/4340831f29c2dda00cfc3993303921272fedfc61/src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml 54 | public void OpenBrowser(string url) 55 | { 56 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 57 | { 58 | // If no associated application/json MimeType is found xdg-open opens retrun error 59 | // but it tries to open it anyway using the console editor (nano, vim, other..) 60 | ShellExec($"xdg-open {url}", false); 61 | } 62 | else 63 | { 64 | using Process process = Process.Start( 65 | new ProcessStartInfo 66 | { 67 | FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open", 68 | Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e {url}" : "", 69 | CreateNoWindow = true, 70 | UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) 71 | }); 72 | } 73 | } 74 | 75 | private static void ShellExec(string cmd, bool waitForExit = true) 76 | { 77 | string escapedArgs = cmd.Replace("\"", "\\\""); 78 | 79 | using Process process = Process.Start( 80 | new ProcessStartInfo 81 | { 82 | FileName = "/bin/sh", 83 | Arguments = $"-c \"{escapedArgs}\"", 84 | RedirectStandardOutput = true, 85 | UseShellExecute = false, 86 | CreateNoWindow = true, 87 | WindowStyle = ProcessWindowStyle.Hidden 88 | } 89 | ); 90 | if (waitForExit) 91 | { 92 | process.WaitForExit(); 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Src/FinderOuter/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using Avalonia.Input.Platform; 7 | using Avalonia.Platform.Storage; 8 | using FinderOuter.Models; 9 | using ReactiveUI; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.ComponentModel; 13 | using System.Reflection; 14 | 15 | namespace FinderOuter.ViewModels 16 | { 17 | public class MainWindowViewModel : ViewModelBase 18 | { 19 | public MainWindowViewModel() 20 | { 21 | OptionList = new OptionVmBase[] 22 | { 23 | new MissingBase16ViewModel(Settings), 24 | new MissingBase58ViewModel(Settings), 25 | new MissingMiniPrivateKeyViewModel(Settings), 26 | new MissingBip38PassViewModel(Settings), 27 | new CorePassViewModel(Settings), 28 | new MissingMnemonicViewModel(Settings), 29 | new MissingMnemonicPassViewModel(Settings), 30 | new MissingBip32PathViewModel(), 31 | new MissingArmoryViewModel(), 32 | new MissingEncodingViewModel(), 33 | }; 34 | } 35 | 36 | private static Version Version => Assembly.GetExecutingAssembly().GetName().Version; 37 | 38 | public static string WindowTitle => $"The FinderOuter - Version {((Version.Major == 0) ? "Beta" : Version.ToString(2))}"; 39 | 40 | public static string VerString => Version.ToString(4); 41 | 42 | public static string DebugWarning => "Warning: Debug mode detected. Build and run in release mode for faster performance."; 43 | 44 | public static bool IsDebug => 45 | #if DEBUG 46 | true; 47 | #else 48 | false; 49 | #endif 50 | 51 | public static string UnstableWarning => "Warning: You are running an unstable version. Make sure you understand the changes " + 52 | "after the previous stable release."; 53 | 54 | public static bool IsUnstable => Version.Revision != 0; 55 | 56 | 57 | public bool IsOptionSelected => SelectedOption is not null; 58 | 59 | public bool IsWorking => SelectedOption is not null && SelectedOption.Result.CurrentState == State.Working; 60 | 61 | public IEnumerable OptionList { get; private set; } 62 | 63 | private OptionVmBase _selOpt; 64 | public OptionVmBase SelectedOption 65 | { 66 | get => _selOpt; 67 | set 68 | { 69 | if (value is not null) 70 | { 71 | value.Result.PropertyChanged += SelectedOption_PropertyChanged; 72 | } 73 | else 74 | { 75 | _selOpt.Result.PropertyChanged -= SelectedOption_PropertyChanged; 76 | } 77 | 78 | this.RaiseAndSetIfChanged(ref _selOpt, value); 79 | this.RaisePropertyChanged(nameof(IsOptionSelected)); 80 | this.RaisePropertyChanged(nameof(IsWorking)); 81 | } 82 | } 83 | 84 | private void SelectedOption_PropertyChanged(object sender, PropertyChangedEventArgs e) 85 | { 86 | if (e.PropertyName == nameof(OptionVmBase.Result.CurrentState)) 87 | { 88 | this.RaisePropertyChanged(nameof(IsWorking)); 89 | } 90 | } 91 | 92 | public HelpViewModel HelpVm => new(); 93 | 94 | public Settings Settings { get; set; } = new(); 95 | public IClipboard Clipboard { get; set; } 96 | 97 | private IStorageProvider _sp; 98 | public IStorageProvider StorageProvider 99 | { 100 | get => _sp; 101 | set 102 | { 103 | _sp = value; 104 | foreach (var item in OptionList) 105 | { 106 | if (item is MissingBip38PassViewModel b38) 107 | { 108 | b38.FileMan.StorageProvider = value; 109 | } 110 | else if (item is CorePassViewModel core) 111 | { 112 | core.FileMan.StorageProvider = value; 113 | } 114 | } 115 | } 116 | } 117 | 118 | private bool _isCap = true; 119 | public bool IsCappedSettings 120 | { 121 | get => _isCap; 122 | set => this.RaiseAndSetIfChanged(ref _isCap, value); 123 | } 124 | 125 | public void OverrideSettings() 126 | { 127 | IsCappedSettings = false; 128 | } 129 | 130 | public void OpenAbout() 131 | { 132 | WinMan.ShowDialog(new AboutViewModel(Clipboard)); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Src/FinderOuter/ViewModels/MessageBoxViewModel.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.Models; 7 | using System; 8 | 9 | namespace FinderOuter.ViewModels 10 | { 11 | public class MessageBoxViewModel : ViewModelBase 12 | { 13 | public MessageBoxViewModel() 14 | { 15 | Message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et " + 16 | $"dolore magna aliqua. {Environment.NewLine}Ut enim ad minim veniam, quis nostrud exercitation ullamco " + 17 | $"laboris nisi ut aliquip ex ea commodo consequat."; 18 | IsDualCommand = true; 19 | CommandName1 = "cmd1"; 20 | CommandName2 = "cmd2"; 21 | } 22 | 23 | public MessageBoxViewModel(MessageBoxType t, string message) 24 | { 25 | Message = message; 26 | msgType = t; 27 | switch (t) 28 | { 29 | case MessageBoxType.Ok: 30 | CommandName1 = "Ok"; 31 | IsDualCommand = false; 32 | break; 33 | case MessageBoxType.OkCancel: 34 | CommandName1 = "OK"; 35 | CommandName2 = "Cancel"; 36 | IsDualCommand = true; 37 | break; 38 | case MessageBoxType.YesNo: 39 | CommandName1 = "Yes"; 40 | CommandName2 = "No"; 41 | IsDualCommand = true; 42 | break; 43 | default: 44 | throw new NotImplementedException(); 45 | } 46 | } 47 | 48 | 49 | private readonly MessageBoxType msgType; 50 | public string Message { get; } 51 | public bool IsDualCommand { get; } 52 | public string CommandName1 { get; } 53 | public string CommandName2 { get; } 54 | 55 | public MessageBoxResult Result { get; private set; } 56 | 57 | public void Command1() 58 | { 59 | Result = msgType switch 60 | { 61 | MessageBoxType.Ok => MessageBoxResult.Ok, 62 | MessageBoxType.OkCancel => MessageBoxResult.Ok, 63 | MessageBoxType.YesNo => MessageBoxResult.Yes, 64 | _ => throw new NotImplementedException(), 65 | }; 66 | 67 | RaiseCloseEvent(); 68 | } 69 | 70 | public void Command2() 71 | { 72 | Result = msgType switch 73 | { 74 | MessageBoxType.Ok => throw new Exception("This should never happen."), 75 | MessageBoxType.OkCancel => MessageBoxResult.Cancel, 76 | MessageBoxType.YesNo => MessageBoxResult.No, 77 | _ => throw new NotImplementedException(), 78 | }; 79 | 80 | RaiseCloseEvent(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Src/FinderOuter/ViewModels/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using FinderOuter.Models; 7 | using FinderOuter.Services; 8 | using ReactiveUI; 9 | using System; 10 | 11 | namespace FinderOuter.ViewModels 12 | { 13 | public class ViewModelBase : ReactiveObject 14 | { 15 | public ViewModelBase(IWindowManager winMan = null) 16 | { 17 | WinMan = winMan ?? new WindowManager(); 18 | OpenKBCommand = ReactiveCommand.Create(OpenKB); 19 | } 20 | 21 | public event EventHandler CLoseEvent; 22 | 23 | public void RaiseCloseEvent() => CLoseEvent?.Invoke(this, null); 24 | 25 | // Don't change to static, it will break the OpenKB(KB) method 26 | #pragma warning disable CA1822 // Mark members as static 27 | public KB InputKb => KB.DamagedInput; 28 | public KB ExtraInputKb => KB.ExtraInput; 29 | public KB Bip32PathKb => KB.Bip32Path; 30 | public KB AlphanumericPassKb => KB.AlphanumericPass; 31 | public KB CustomCharPassKb => KB.CustomCharPass; 32 | public KB ThreadKb => KB.ThreadCount; 33 | #pragma warning restore CA1822 // Mark members as static 34 | 35 | public IWindowManager WinMan { get; } 36 | public IReactiveCommand OpenKBCommand { get; } 37 | public void OpenKB(KB kb) => WinMan.ShowDialog(new KnowledgeBaseViewModel(kb)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/FinderOuter/ViewModels/VmWithSizeBase.cs: -------------------------------------------------------------------------------- 1 | // The FinderOuter 2 | // Copyright (c) 2020 Coding Enthusiast 3 | // Distributed under the MIT software license, see the accompanying 4 | // file LICENCE or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | using ReactiveUI; 7 | 8 | namespace FinderOuter.ViewModels 9 | { 10 | /// 11 | /// Base (abstract) class for view models that have to be shown in a new window 12 | /// and need to set the window's height and width. 13 | /// 14 | public abstract class VmWithSizeBase : ViewModelBase 15 | { 16 | private double _height; 17 | public double Height 18 | { 19 | get => _height; 20 | set => this.RaiseAndSetIfChanged(ref _height, value); 21 | } 22 | 23 | private double _width; 24 | public double Width 25 | { 26 | get => _width; 27 | set => this.RaiseAndSetIfChanged(ref _width, value); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/FinderOuter/Views/AboutView.axaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 |