Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spell-checking settings, bump versions #354

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"rollForward": false
},
"dotnet-reportgenerator-globaltool": {
"version": "5.3.6",
"version": "5.3.7",
"commands": [
"reportgenerator"
],
Expand Down
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ root = true
# C# files
[*.cs]

# Spell checker
[*]
spelling_languages = en-US
spelling_checkable_types = strings,identifiers,comments
spelling_error_severity = information
spelling_exclusion_path = ./spellcheckerexclusion.dic
spelling_use_default_exclusion_dictionary = true


#### Core EditorConfig Options ####

# Indentation and spacing
Expand Down
1 change: 1 addition & 0 deletions Verifiable.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
LICENSE = LICENSE
NuGet.config = NuGet.config
README.md = README.md
spellcheckerexclusion.dic = spellcheckerexclusion.dic
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Verifiable.Core", "src\Verifiable.Core\Verifiable.Core.csproj", "{C22DC77B-093B-4B64-858E-02A3142DDFF9}"
Expand Down
1 change: 1 addition & 0 deletions spellcheckerexclusion.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Multicodec
4 changes: 2 additions & 2 deletions test/Verifiable.Tests/ExtendedDidDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class ExtendedService: Service
/// The core library provide a type for W3C defined DID type. It may
/// be possible in production extra data needs to serialized or
/// deserialized. This data can be unknown or the system not updated
/// to the latest expected data. Serializing or deserealizing unknown
/// to the latest expected data. Serializing or deserializing unknown
/// data is a potential security or information disclosure risk so
/// is not provided in the model by default.
/// </summary>
public class TestExtendedDidDocument: DidDocument
{
new public ExtendedService[]? Service { get; set; }
public new ExtendedService[]? Service { get; set; }

[JsonExtensionData]
public IDictionary<string, object>? AdditionalData { get; set; }
Expand Down
30 changes: 15 additions & 15 deletions test/Verifiable.Tests/TestDataProviders/EllipticCurveTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public record EllipticCurveTestData(
/// </summary>
public class EllipticCurveTheoryData: TheoryData<EllipticCurveTestData>
{
private static readonly IList<EllipticCurveTestData> ellipticCurveTestData = new List<EllipticCurveTestData>();
private static List<EllipticCurveTestData> EllipticCurveTestData { get; } = [];

public const string EllipticP256 = "P-256";
public const string EllipticP384 = "P-384";
Expand Down Expand Up @@ -95,9 +95,9 @@ public class EllipticCurveTheoryData: TheoryData<EllipticCurveTestData>
/// <exception cref="NotSupportedException"></exception>
public static (byte[] PublicKeyHeader, byte[] PrivateKeyHeader) FromCurveNameToMultiCodecHeader(string humanReadable) => humanReadable switch
{
EllipticP256 => (MulticodecHeaders.P256PublicKey.ToArray(), Array.Empty<byte>()),
EllipticP384 => (MulticodecHeaders.P384PublicKey.ToArray(), Array.Empty<byte>()),
EllipticP521 => (MulticodecHeaders.P521PublicKey.ToArray(), Array.Empty<byte>()),
EllipticP256 => (MulticodecHeaders.P256PublicKey.ToArray(), []),
EllipticP384 => (MulticodecHeaders.P384PublicKey.ToArray(), []),
EllipticP521 => (MulticodecHeaders.P521PublicKey.ToArray(), []),
EllipticSecP256k1 => (MulticodecHeaders.Secp256k1PublicKey.ToArray(), MulticodecHeaders.Secp256k1PrivateKey.ToArray()),
_ => throw new NotSupportedException()
};
Expand All @@ -108,14 +108,14 @@ static EllipticCurveTheoryData()
foreach(string humanReadableEllipticCurveConstant in HumanReadableEllipticCurveConstants)
{
(EllipticCurveTestData EvenKey, EllipticCurveTestData OddKey) = GenerateEllipticTestKeyMaterial(humanReadableEllipticCurveConstant);
ellipticCurveTestData.Add(EvenKey);
ellipticCurveTestData.Add(OddKey);
EllipticCurveTestData.Add(EvenKey);
EllipticCurveTestData.Add(OddKey);
}
}

public EllipticCurveTheoryData()
{
foreach(var td in ellipticCurveTestData)
foreach(EllipticCurveTestData td in EllipticCurveTestData)
{
Add(td);
}
Expand All @@ -128,8 +128,8 @@ private static (EllipticCurveTestData EvenKey, EllipticCurveTestData OddKey) Gen
while(evenKey == null || oddKey == null)
{
var loopKey = ECDsa.Create(FromHumanReadableEllipticPrimeCurve(humanReadableCurveName));
var loopParams = loopKey.ExportParameters(includePrivateParameters: false);
var loopSignByte = EllipticCurveUtilities.CompressionSignByte(loopParams.Q.Y);
ECParameters loopParams = loopKey.ExportParameters(includePrivateParameters: false);
byte loopSignByte = EllipticCurveUtilities.CompressionSignByte(loopParams.Q.Y);
if(loopSignByte == EllipticCurveUtilities.EvenYCoordinate)
{
evenKey = loopKey;
Expand All @@ -149,17 +149,17 @@ private static (EllipticCurveTestData EvenKey, EllipticCurveTestData OddKey) Gen
_ => throw new NotSupportedException()
};

var btc58Headers = FromCurveNameToBtc58EncodedHeader(humanReadableCurveName);
var multiCodecHeaders = FromCurveNameToMultiCodecHeader(humanReadableCurveName);
(string PublicKey, string PrivateKey) btc58Headers = FromCurveNameToBtc58EncodedHeader(humanReadableCurveName);
(byte[] PublicKeyHeader, byte[] PrivateKeyHeader) = FromCurveNameToMultiCodecHeader(humanReadableCurveName);

ECParameters evenKeyParameters = evenKey.ExportParameters(includePrivateParameters: true);
byte[] evenPublicKeyX = evenKeyParameters.Q.X!;
byte[] evenPublicKeyY = evenKeyParameters.Q.Y!;
byte[] evenPrivateKey = evenKeyParameters.D!;
var evenTestKeyMaterial = new EllipticCurveTestData(
true,
multiCodecHeaders.PublicKeyHeader,
multiCodecHeaders.PrivateKeyHeader,
PublicKeyHeader,
PrivateKeyHeader,
btc58Headers.PublicKey,
btc58Headers.PrivateKey,
humanReadableCurveName,
Expand All @@ -174,8 +174,8 @@ private static (EllipticCurveTestData EvenKey, EllipticCurveTestData OddKey) Gen
byte[] oddPrivateKey = oddKeyParameters.D!;
var oddTestKeyMaterial = new EllipticCurveTestData(
true,
multiCodecHeaders.PublicKeyHeader,
multiCodecHeaders.PrivateKeyHeader,
PublicKeyHeader,
PrivateKeyHeader,
btc58Headers.PublicKey,
btc58Headers.PrivateKey,
humanReadableCurveName,
Expand Down
Loading