Skip to content

Commit

Permalink
Additional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Sep 25, 2024
1 parent 52a53e4 commit 4b78f0a
Showing 1 changed file with 51 additions and 5 deletions.
56 changes: 51 additions & 5 deletions src/blsCompatibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,67 @@ describe.only("test BLS compatibility (noble crypto and herumi)", () => {
),
"e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208",
);

assert.equal(
toHex(
getPublicKeyBytesForShortSignaturesLikeHerumi(
fromHex("caffb9cb3d24451500f26def03cc034ae61978aeef702688c17ad2fd023c2837"),
),
),
"f69e71a3f99a3c3ec5454183b33ea776a9e69cbecca81c13218d3f6becb2deeb258e6210e097c6c04d8ff7573a4bd102ca22fd1aee8dac6eba495f2d24849b28cfbafdf748ed33195abd34212bdbb5ca53e21cee30d966e5c11895fd31f51f16",
);

assert.equal(
toHex(
getPublicKeyBytesForShortSignaturesLikeHerumi(
fromHex("6a4451e61581d545b12390bd461bffe7ca3d28943e61647c96c5acfbe2d01721"),
),
),
"3471540b7930bf52639acf66f8b98f73b87de782f5881d36e4c4008fd6de4214ccf1be7cbe2d8a1d4452fff453bc2416b8c7ce7ba84d34af58d20570d53aa12f6407125401dd103ffbb8a2d7f90c73639543c4e617a2da20398ad9d3a63c0010",
);
});

it("test sign", async function () {
const secretKeyHex = "7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247";
const secretKey = Buffer.from(secretKeyHex, "hex");

assert.equal(
toHex(signMessage(Buffer.from("hello"), secretKey)),
toHex(
signMessage(
Buffer.from("hello"),
fromHex("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247"),
),
),
"84fd0a3a9d4f1ea2d4b40c6da67f9b786284a1c3895b7253fec7311597cda3f757862bb0690a92a13ce612c33889fd86",
);

assert.equal(
toHex(signMessage(Buffer.from("MultiversX"), secretKey)),
toHex(
signMessage(
Buffer.from("MultiversX"),
fromHex("7cff99bd671502db7d15bc8abc0c9a804fb925406fbdd50f1e4c17a4cd774247"),
),
),
"f6e6102fae2c88c26e1194dbc8dfe7731361db65e7f927a67b51fe28db75f2cab3cefec5def449faa26af12598b5a109",
);

assert.equal(
toHex(
signMessage(
Buffer.from("message to be signed"),
fromHex("caffb9cb3d24451500f26def03cc034ae61978aeef702688c17ad2fd023c2837"),
),
),
"aace25fd4beb6626ff1772f12b61861434d02c4c5c6ae8090befc557765d5f46f319ff229acbfc6783363c496af3de06",
);

assert.equal(
toHex(
signMessage(
Buffer.from("message to be signed"),
fromHex("6a4451e61581d545b12390bd461bffe7ca3d28943e61647c96c5acfbe2d01721"),
),
),
"6847485e9cb0ce069825f492071188f616b32a65e2596f078b15a6c0a2d6033206ea42b621cad0559aea9797f1918691",
);
});
});

it("test hashAndMapToG1LikeHerumi", async function () {
Expand Down

0 comments on commit 4b78f0a

Please sign in to comment.