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

chore(deps): export blake2b and ed25519 #16

Merged
merged 1 commit into from
Sep 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static String getHandshake() {

@JSBody(params = {"handshake", "protocolId"}, script = "window.fruzhin.libp.getConnections().forEach(async (peer) => {" +
" let stream = await ItPbStream.pbStream(await window.fruzhin.libp.dialProtocol(peer.remotePeer, protocolId));" +
" stream.writeLP(window.fruzhin.ED25519.h2b(handshake));" +
" stream.writeLP(Ed25519.h2b(handshake));" +
"});")
public static native void sendHandshakeToAll(String handshake, String protocolId);

Expand All @@ -61,9 +61,9 @@ public static String getHandshake() {
" let subarr = msg.subarray();" +
" if(subarr.length === 69) {" +
" let handshake = announceExport.getHandshake();" +
" (await ItPbStream.pbStream(stream)).writeLP(window.fruzhin.ED25519.h2b(handshake));" +
" (await ItPbStream.pbStream(stream)).writeLP(Ed25519.h2b(handshake));" +
" } else if (subarr.length > 1) {" +
" announceExport.blockAnnounce(window.fruzhin.ED25519.b2h(subarr.slice(2)), connection.remotePeer.toString());" +
" announceExport.blockAnnounce(Ed25519.b2h(subarr.slice(2)), connection.remotePeer.toString());" +
" }" +
" }" +
" });" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static String getNeighbourMessage() {

@JSBody(params = {"handshake", "protocolId"}, script = "window.fruzhin.libp.getConnections().forEach(async (peer) => {" +
" let stream = await ItPbStream.pbStream(await window.fruzhin.libp.dialProtocol(peer.remotePeer, protocolId));" +
" stream.write(window.fruzhin.ED25519.h2b(handshake));" + "});")
" stream.write(Ed25519.h2b(handshake));" + "});")
public static native void sendHandshakeToAll(String handshake, String protocolId);

@JSBody(params = {"grandpaExport", "protocolId"}, script =
Expand All @@ -116,13 +116,13 @@ public static String getNeighbourMessage() {
" for await (const msg of source) {" + " let subarr = msg.subarray();" +
" if(subarr.length === 1) {" +
" let handshake = grandpaExport.getHandshake();" +
" (await ItPbStream.pbStream(stream)).writeLP(window.fruzhin.ED25519.h2b(handshake));" +
" (await ItPbStream.pbStream(stream)).writeLP(Ed25519.h2b(handshake));" +
" } else if (subarr.length > 1) {" +
" if(subarr.slice(1)[0] === 2) {" +
" let niehgbourMessage = grandpaExport.getNeighbourMessage();" +
" (await ItPbStream.pbStream(stream)).writeLP(window.fruzhin.ED25519.h2b(niehgbourMessage));" +
" (await ItPbStream.pbStream(stream)).writeLP(Ed25519.h2b(niehgbourMessage));" +
" }" +
" grandpaExport.handleMessage(window.fruzhin.ED25519.b2h(subarr.slice(1)), connection.remotePeer.toString());" +
" grandpaExport.handleMessage(Ed25519.b2h(subarr.slice(1)), connection.remotePeer.toString());" +
" }" + " }" + " });" + " });")
public static native void registerHandler(JSObject grandpaExport, String protocolId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static byte[] getDataToVerify(Precommit precommit, BigInteger authoritie
}

@JSBody(params = {"publicKeyHex", "signatureHex",
"messageHex"}, script = "return window.fruzhin.ED25519.verifyAsync(signatureHex, messageHex, publicKeyHex);")
"messageHex"}, script = "return Ed25519.verifyAsync(signatureHex, messageHex, publicKeyHex);")
public static native JSPromise<JSBoolean> verifyAsync(String publicKeyHex, String signatureHex,
String messageHex);
}
2 changes: 1 addition & 1 deletion src/main/java/com/limechain/utils/HashUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class HashUtils {

@JSBody(params = {"inputHex"}, script = "{" +
"let bytes = new Uint8Array([...inputHex.matchAll(/../g)].map(m => parseInt(m[0], 16)));" +
"return window.fruzhin.Blake2b.hash(bytes,undefined,32);" + "}")
"return Blake2B.hash(bytes,undefined,32);" + "}")
public static native JSString hashWithBlake2b(String inputHex);
}
167 changes: 0 additions & 167 deletions src/main/webapp/js/blake2b.js

This file was deleted.

Loading
Loading