2024-12-05 17:53:43 +08:00
|
|
|
import { describe, it, before } from 'node:test'
|
|
|
|
import assert from 'node:assert'
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2021-11-23 13:22:47 +01:00
|
|
|
import buildPedersenHash from "../src/pedersen_hash.js";
|
2021-10-30 13:57:29 +02:00
|
|
|
|
|
|
|
function buff2hex(buff) {
|
|
|
|
function i2hex(i) {
|
|
|
|
return ('0' + i.toString(16)).slice(-2);
|
|
|
|
}
|
|
|
|
return Array.from(buff).map(i2hex).join('');
|
|
|
|
}
|
|
|
|
|
|
|
|
describe("Pedersen Hash test", function () {
|
|
|
|
let pedersen;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
pedersen = await buildPedersenHash();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should check multihash reference 2", async () => {
|
|
|
|
const msg = (new TextEncoder()).encode("Hello");
|
|
|
|
|
|
|
|
const res2 = pedersen.hash(msg);
|
|
|
|
// console.log(buff2hex(res2));
|
|
|
|
assert.equal(buff2hex(res2), "0e90d7d613ab8b5ea7f4f8bc537db6bb0fa2e5e97bbac1c1f609ef9e6a35fd8b");
|
|
|
|
});
|
|
|
|
});
|