Skip to content

Commit

Permalink
Adding a bypass to bls crytography
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekctek committed Dec 13, 2023
1 parent c897f5f commit 27f5914
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[*]
charset = utf-8
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


[*.{cs,razor}]
dotnet_style_qualification_for_property = true:error
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample.WebSockets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public static async Task Main(string[] args)
await host.WaitForShutdownAsync();
}

}
}
19 changes: 19 additions & 0 deletions src/BLS/BypassedBlsCryptography.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace EdjCase.ICP.BLS
{
/// <summary>
/// Bls cryptography class that AWLAYS returns TRUE. This is intended only for
/// development scenarios and is never recommended
/// </summary>
public class BypassedBlsCryptography : IBlsCryptography
{
/// <inheritdoc/>
public bool VerifySignature(byte[] publicKey, byte[] messageHash, byte[] signature)
{
return true;
}
}
}
10 changes: 9 additions & 1 deletion src/BLS/WasmBlsCrytography.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
Expand Down Expand Up @@ -50,8 +51,15 @@ private static bool VerifySignatureInternal(
byte[] signature
)
{
EnsureInitialized();
try
{

EnsureInitialized();
}
catch (DllNotFoundException ex)
{
throw new Exception("Unable to load the wasmtime bls library", ex);
}
byte[] blsPublicKey = instance!.PublicKeyDeserialize(publicKey);

byte[] blsSignature = instance.SignatureDeserialize(signature);
Expand Down

0 comments on commit 27f5914

Please sign in to comment.