Skip to content

Commit

Permalink
Merge pull request #2151 from yahiheb/consts-name
Browse files Browse the repository at this point in the history
Edit consts names
  • Loading branch information
nopara73 committed Sep 1, 2019
2 parents 3528b5c + 7594763 commit 6065710
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions WalletWasabi/Crypto/StringCipher.cs
Expand Up @@ -11,7 +11,7 @@ public static class StringCipher
{
// This constant is used to determine the keysize of the encryption algorithm in bits.
// We divide this by 8 within the code below to get the equivalent number of bytes.
private const int Keysize = 128;
private const int KeySize = 128;

// This constant determines the number of iterations for the password bytes generation function.
private const int DerivationIterations = 1000;
Expand All @@ -28,7 +28,7 @@ public static string Encrypt(string plainText, string passPhrase)

using (var password = new Rfc2898DeriveBytes(passPhrase, salt, DerivationIterations))
{
key = password.GetBytes(Keysize / 8);
key = password.GetBytes(KeySize / 8);
using (var aes = CreateAES())
{
aes.GenerateIV();
Expand Down Expand Up @@ -81,15 +81,15 @@ public static string Decrypt(string cipherText, string passPhrase)
var cipherLength = 0;
using (var reader = new BinaryReader(memoryStream, Encoding.UTF8, true))
{
var salt = reader.ReadBytes(Keysize / 8);
iv = reader.ReadBytes(Keysize / 8);
var salt = reader.ReadBytes(KeySize / 8);
iv = reader.ReadBytes(KeySize / 8);
var authenticationCode = reader.ReadBytes(32);
cipherLength = (int)(memoryStream.Length - memoryStream.Position);
var cipher = reader.ReadBytes(cipherLength);

using (var password = new Rfc2898DeriveBytes(passPhrase, salt, DerivationIterations))
{
key = password.GetBytes(Keysize / 8);
key = password.GetBytes(KeySize / 8);
}

using (var hmac = new HMACSHA256(key))
Expand Down
Expand Up @@ -37,7 +37,7 @@ internal EightBitByteEncoder() : base()
/// <summary>
/// Bitcount, Chapter 8.4.4, P.24
/// </summary>
private const int EIGHT_BIT_BYTE_BITCOUNT = 8;
private const int EightBitByteBitcount = 8;

internal override BitList GetDataBits(string content)
{
Expand All @@ -64,13 +64,13 @@ internal BitList GetDataBitsByByteArray(byte[] encodeContent, string encodingNam
byte[] utf8BOM = QRCodeConstantVariable.UTF8ByteOrderMark;
for (int index = 0; index < utf8BOM.Length; index++)
{
dataBits.Add(utf8BOM[index], EIGHT_BIT_BYTE_BITCOUNT);
dataBits.Add(utf8BOM[index], EightBitByteBitcount);
}
}

for (int index = 0; index < encodeContent.Length; index++)
{
dataBits.Add(encodeContent[index], EIGHT_BIT_BYTE_BITCOUNT);
dataBits.Add(encodeContent[index], EightBitByteBitcount);
}
return dataBits;
}
Expand Down
Expand Up @@ -13,7 +13,7 @@ public static bool IsModeEncodeValid(string encoding, string content)
/// Encoding.GetEncoding.GetBytes will transform char to 0x3F if that char not belong to current encoding table.
/// 0x3F is '?'
/// </summary>
private const int QUESTION_MARK_CHAR = 0x3F;
private const int QuestionMarkChar = 0x3F;

private static bool EightBitByteCheck(string encodingName, string content)
{
Expand Down Expand Up @@ -54,7 +54,7 @@ internal static int TryEncodeEightBitByte(string content, string encodingName, i
currentChar[0] = content[index];
bytes = encoding.GetBytes(currentChar);
int length = bytes.Length;
if (currentChar[0] != '?' && length == 1 && bytes[0] == QUESTION_MARK_CHAR)
if (currentChar[0] != '?' && length == 1 && bytes[0] == QuestionMarkChar)
{
return index;
}
Expand All @@ -69,7 +69,7 @@ internal static int TryEncodeEightBitByte(string content, string encodingName, i
currentChar[0] = content[index];
bytes = encoding.GetBytes(currentChar);
int length = bytes.Length;
if (currentChar[0] != '?' && length == 1 && bytes[0] == QUESTION_MARK_CHAR)
if (currentChar[0] != '?' && length == 1 && bytes[0] == QuestionMarkChar)
{
return index;
}
Expand Down
12 changes: 6 additions & 6 deletions WalletWasabi/Gma/QrCodeNet/Encoding/Versions/VersionControl.cs
Expand Up @@ -5,8 +5,8 @@ namespace Gma.QrCodeNet.Encoding.Versions
{
internal static class VersionControl
{
private const int NUM_BITS_MODE_INDICATOR = 4;
private const string DEFAULT_ENCODING = QRCodeConstantVariable.DefaultEncoding;
private const int NumBitsModeIndicator = 4;
private const string DefaultEncoding = QRCodeConstantVariable.DefaultEncoding;

/// <summary>
/// Determine which version to use
Expand All @@ -22,7 +22,7 @@ internal static VersionControlStruct InitialSetup(int dataBitsLength, ErrorCorre

BitList eciHeader = new BitList();

if (encodingName != DEFAULT_ENCODING && encodingName != QRCodeConstantVariable.UTF8Encoding)
if (encodingName != DefaultEncoding && encodingName != QRCodeConstantVariable.UTF8Encoding)
{
ECISet eciSet = new ECISet(ECISet.AppendOption.NameToValue);
int eciValue = eciSet.GetECIValueByName(encodingName);
Expand All @@ -37,7 +37,7 @@ internal static VersionControlStruct InitialSetup(int dataBitsLength, ErrorCorre

int[] charCountIndicator = CharCountIndicatorTable.GetCharCountIndicatorSet();

totalDataBits += (NUM_BITS_MODE_INDICATOR + charCountIndicator[searchGroup]);
totalDataBits += (NumBitsModeIndicator + charCountIndicator[searchGroup]);

int lowerSearchBoundary = searchGroup == 0 ? 1 : (VERSION_GROUP[searchGroup - 1] + 1);
int higherSearchBoundary = VERSION_GROUP[searchGroup];
Expand Down Expand Up @@ -93,7 +93,7 @@ private static int DynamicSearchIndicator(int numBits, ErrorCorrectionLevel leve
int loopLength = VERSION_GROUP.Length;
for (int i = 0; i < loopLength; i++)
{
int totalBits = numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator[i];
int totalBits = numBits + NumBitsModeIndicator + charCountIndicator[i];

QRCodeVersion version = VersionTable.GetVersionByNum(VERSION_GROUP[i]);
int numECCodewords = version.GetECBlocksByLevel(level).NumErrorCorrectionCodewards;
Expand All @@ -106,7 +106,7 @@ private static int DynamicSearchIndicator(int numBits, ErrorCorrectionLevel leve
}
}

throw new InputOutOfBoundaryException($"QRCode do not have enough space for {(numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator[2])} bits");
throw new InputOutOfBoundaryException($"QRCode do not have enough space for {(numBits + NumBitsModeIndicator + charCountIndicator[2])} bits");
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions WalletWasabi/Helpers/Constants.cs
Expand Up @@ -11,26 +11,26 @@ public static class Constants
public const string BackendMajorVersion = "3";
public static readonly VersionsResponse VersionsResponse = new VersionsResponse { ClientVersion = ClientVersion.ToString(3), BackendMajorVersion = BackendMajorVersion };

public const uint ProtocolVersion_WITNESS_VERSION = 70012;
public const uint ProtocolVersionWitnessVersion = 70012;

public static readonly NodeRequirement NodeRequirements = new NodeRequirement
{
RequiredServices = NodeServices.NODE_WITNESS,
MinVersion = ProtocolVersion_WITNESS_VERSION,
MinVersion = ProtocolVersionWitnessVersion,
MinProtocolCapabilities = new ProtocolCapabilities { SupportGetBlock = true, SupportWitness = true, SupportMempoolQuery = true }
};

public static readonly NodeRequirement LocalNodeRequirements = new NodeRequirement
{
RequiredServices = NodeServices.NODE_WITNESS,
MinVersion = ProtocolVersion_WITNESS_VERSION,
MinVersion = ProtocolVersionWitnessVersion,
MinProtocolCapabilities = new ProtocolCapabilities { SupportGetBlock = true, SupportWitness = true }
};

public static readonly NodeRequirement LocalBackendNodeRequirements = new NodeRequirement
{
RequiredServices = NodeServices.NODE_WITNESS,
MinVersion = ProtocolVersion_WITNESS_VERSION,
MinVersion = ProtocolVersionWitnessVersion,
MinProtocolCapabilities = new ProtocolCapabilities
{
SupportGetBlock = true,
Expand Down
10 changes: 5 additions & 5 deletions WalletWasabi/Services/MempoolBehavior.cs
Expand Up @@ -12,7 +12,7 @@ namespace WalletWasabi.Services
{
public class MempoolBehavior : NodeBehavior
{
private const int MAX_INV_SIZE = 50000;
private const int MaxInvSize = 50000;

public MempoolService MempoolService { get; }

Expand Down Expand Up @@ -66,9 +66,9 @@ private async void AttachedNode_MessageReceivedAsync(Node node, IncomingMessage

private async Task ProcessGetDataAsync(Node node, GetDataPayload payload)
{
if (payload.Inventory.Count > MAX_INV_SIZE)
if (payload.Inventory.Count > MaxInvSize)
{
Logger.LogDebug<MempoolBehavior>($"Received inventory too big. {nameof(MAX_INV_SIZE)}: {MAX_INV_SIZE}, Node: {node.RemoteSocketEndpoint}");
Logger.LogDebug<MempoolBehavior>($"Received inventory too big. {nameof(MaxInvSize)}: {MaxInvSize}, Node: {node.RemoteSocketEndpoint}");
return;
}

Expand Down Expand Up @@ -105,9 +105,9 @@ private async Task ProcessGetDataAsync(Node node, GetDataPayload payload)

private async Task ProcessInvAsync(Node node, InvPayload payload)
{
if (payload.Inventory.Count > MAX_INV_SIZE)
if (payload.Inventory.Count > MaxInvSize)
{
Logger.LogDebug<MempoolBehavior>($"Received inventory too big. {nameof(MAX_INV_SIZE)}: {MAX_INV_SIZE}, Node: {node.RemoteSocketEndpoint}");
Logger.LogDebug<MempoolBehavior>($"Received inventory too big. {nameof(MaxInvSize)}: {MaxInvSize}, Node: {node.RemoteSocketEndpoint}");
return;
}

Expand Down

0 comments on commit 6065710

Please sign in to comment.