Remove Characters class
MODIFY
WalletWasabi.Tests/UnitTests/IoTests.cs
WalletWasabi.Tests/UnitTests/IoTests.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.Tests.UnitTests
List<string> lines = new List<string>();
for (int i = 0; i < 1000; i++)
{
- string line = (new InsecureRandom() as IWasabiRandom).GetString(100, Characters.AlphaNumeric);
+ string line = (new InsecureRandom() as IWasabiRandom).GetString(100, Constants.AlphaNumericCharacters);
lines.Add(line);
}

MODIFY
WalletWasabi.Tests/UnitTests/KeyManagementTests.cs
WalletWasabi.Tests/UnitTests/KeyManagementTests.cs
@@ -124,7 +124,7 @@ namespace WalletWasabi.Tests.UnitTests
for (int i = 0; i < 1000; i++)
{
var isInternal = random.Next(2) == 0;
- var label = (new InsecureRandom() as IWasabiRandom).GetString(21, Characters.AlphaNumeric);
+ var label = (new InsecureRandom() as IWasabiRandom).GetString(21, Constants.AlphaNumericCharacters);
var keyState = (KeyState)random.Next(3);
manager.GenerateNewKey(label, keyState, isInternal, toFile: false);
}
@@ -157,7 +157,7 @@ namespace WalletWasabi.Tests.UnitTests
for (int i = 0; i < 1000; i++)
{
var isInternal = random.Next(2) == 0;
- var label = (new WalletWasabi.Crypto.Randomness.InsecureRandom() as IWasabiRandom).GetString(21, Characters.AlphaNumeric);
+ var label = (new InsecureRandom() as IWasabiRandom).GetString(21, Constants.AlphaNumericCharacters);
var keyState = (KeyState)random.Next(3);
var generatedKey = manager.GenerateNewKey(label, keyState, isInternal);

MODIFY
WalletWasabi.Tests/UnitTests/PasswordTests.cs
WalletWasabi.Tests/UnitTests/PasswordTests.cs
@@ -59,13 +59,13 @@ namespace WalletWasabi.Tests.UnitTests
PasswordHelper.GetMasterExtKey(keyManager, original, out _);
// This should not throw format exception but pw is not correct.
- Assert.Throws<SecurityException>(() => PasswordHelper.GetMasterExtKey(keyManager, (new InsecureRandom() as IWasabiRandom).GetString(PasswordHelper.MaxPasswordLength, Characters.AlphaNumeric), out _));
+ Assert.Throws<SecurityException>(() => PasswordHelper.GetMasterExtKey(keyManager, (new InsecureRandom() as IWasabiRandom).GetString(PasswordHelper.MaxPasswordLength, Constants.AlphaNumericCharacters), out _));
// Password should be formatted, before entering here.
- Assert.Throws<FormatException>(() => PasswordHelper.GetMasterExtKey(keyManager, (new InsecureRandom() as IWasabiRandom).GetString(PasswordHelper.MaxPasswordLength + 1, Characters.AlphaNumeric), out _));
+ Assert.Throws<FormatException>(() => PasswordHelper.GetMasterExtKey(keyManager, (new InsecureRandom() as IWasabiRandom).GetString(PasswordHelper.MaxPasswordLength + 1, Constants.AlphaNumericCharacters), out _));
// Too long password with extra spaces.
- var badPassword = $" {(new InsecureRandom() as IWasabiRandom).GetString(PasswordHelper.MaxPasswordLength + 1, Characters.AlphaNumeric)} ";
+ var badPassword = $" {(new InsecureRandom() as IWasabiRandom).GetString(PasswordHelper.MaxPasswordLength + 1, Constants.AlphaNumericCharacters)} ";
// Password should be formatted, before entering here.
Assert.Throws<FormatException>(() => PasswordHelper.GetMasterExtKey(keyManager, badPassword, out _));

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClientBase.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClientBase.cs
@@ -969,7 +969,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
ingredients ??= "";
using var rand = new SecureRandom();
- Salt = (rand as IWasabiRandom).GetString(21, Characters.AlphaNumeric);
+ Salt = (rand as IWasabiRandom).GetString(21, Constants.AlphaNumericCharacters);
Soup = StringCipher.Encrypt(ingredients, Salt);
}
}

DELETE
WalletWasabi/Crypto/Randomness/Characters.cs
-using System;
-using System.Collections.Generic;
-using System.Text;
-using WalletWasabi.Helpers;
-
-namespace WalletWasabi.Crypto.Randomness
-{
- public class Characters
- {
- public static readonly Characters AlphaNumeric = new Characters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
- public static readonly Characters CapitalAlphaNumeric = new Characters("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
-
- public Characters(string chars)
- {
- Guard.NotNullOrEmpty(nameof(chars), chars);
- Chars = chars;
- }
-
- public string Chars { get; }
- }
-}

MODIFY
WalletWasabi/Crypto/Randomness/IWasabiRandom.cs
WalletWasabi/Crypto/Randomness/IWasabiRandom.cs
@@ -32,8 +32,6 @@ namespace WalletWasabi.Crypto.Randomness
return random;
}
- public string GetString(int length, Characters chars) => GetString(length, chars.Chars);
-
public Scalar GetScalar()
{
Scalar randomScalar;

MODIFY
WalletWasabi/Helpers/Constants.cs
WalletWasabi/Helpers/Constants.cs
@@ -53,6 +53,9 @@ namespace WalletWasabi.Helpers
public const long MaxSatoshisSupply = 2_100_000_000_000_000L;
+ public const string AlphaNumericCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ public const string CapitalAlphaNumericCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
public static readonly Version ClientVersion = new Version(1, 1, 11, 1);
public static readonly Version HwiVersion = new Version("1.1.2");
public static readonly Version BitcoinCoreVersion = new Version("0.19.1");

MODIFY
WalletWasabi/TorSocks5/TorSocks5Client.cs
WalletWasabi/TorSocks5/TorSocks5Client.cs
@@ -121,7 +121,7 @@ namespace WalletWasabi.TorSocks5
/// </summary>
internal async Task HandshakeAsync(bool isolateStream = true)
{
- await HandshakeAsync(isolateStream ? (new InsecureRandom() as IWasabiRandom).GetString(21, Characters.CapitalAlphaNumeric) : "").ConfigureAwait(false);
+ await HandshakeAsync(isolateStream ? (new InsecureRandom() as IWasabiRandom).GetString(21, Constants.CapitalAlphaNumericCharacters) : "").ConfigureAwait(false);
}
/// <summary>

Remove Characters class