-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,235 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var BLS = { | ||
VerifySignature: function (publicKey, messageHash, signature) { | ||
return blsVerify(publicKey, messageHash, signature); | ||
}, | ||
}; | ||
mergeInto(LibraryManager.library, BLS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
The following files should be added to the `Plugins/ICP.NET/` directory in Unity | ||
- UnityHttp.cs - An alternative HttpClient that uses UnityWebRequest (needed for WebGL) | ||
To use, create a `UnityHttpClient` instance and when creating an `HttpAgent` pass it as a parameter instead of the default | ||
- WebGlBlsCrytography.cs - The WebGL version of the bls signature verify library, run in the browswer vs in C#/WASM | ||
To use, create a `WebGlBlsCrytography` instance and when creating an `HttpAgent` pass it as a parameter instead of the default | ||
- Bls.jslib - The bridge between the C# code and JS to allow C# to invoke the JS bls signature verification | ||
|
||
Other files: | ||
- bls.js - Add to unity project and reference from an HTML file with a script tag. Loads in the JS bls signature verification that will be used with `WebGlBlsCrytography.cs`. | ||
To generate the bls.js file, run `npx esbuild --bundle src/index.ts --outfile=dist/index.js` on github.com/dfinity/agent-js project in the directory `packages/bls-verify/` | ||
Also modify the bls.js file to change `var blsVerify = ...` to `window.blsVerify = ...`. // TODO find a better way to export function |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Cysharp.Threading.Tasks; | ||
using EdjCase.ICP.Agent.Agents.Http; | ||
using EdjCase.ICP.BLS; | ||
using System; | ||
using System.Net; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
using UnityEngine.Networking; | ||
|
||
#if UNITY_WEBGL | ||
public class WebGlBlsCryptography : IBlsCryptography | ||
{ | ||
public bool VerifySignature(byte[] publicKey, byte[] messageHash, byte[] signature) | ||
{ | ||
return BrowserBlsLib.VerifySignature(publicKey, messageHash, signature); | ||
} | ||
} | ||
|
||
internal static class BrowserBlsLib | ||
{ | ||
[DllImport("__Internal")] | ||
public static extern bool VerifySignature(byte[] publicKey, byte[] messageHash, byte[] signature); | ||
} | ||
#endif | ||
|
Oops, something went wrong.