@typeberry/lib 0.8.1-27281aa → 0.8.1-57267fb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeberry/lib",
3
- "version": "0.8.1-27281aa",
3
+ "version": "0.8.1-57267fb",
4
4
  "description": "Typeberry Library",
5
5
  "main": "./bin/lib/index.js",
6
6
  "types": "./bin/lib/index.d.ts",
@@ -267,7 +267,7 @@
267
267
  "@fluffylabs/anan-as": "^1.4.0",
268
268
  "@noble/ed25519": "2.2.3",
269
269
  "hash-wasm": "4.12.0",
270
- "@typeberry/native": "0.2.0-74dd7d7",
270
+ "@typeberry/native": "0.3.0-462f2ab",
271
271
  "eventemitter3": "^5.0.1",
272
272
  "@opentelemetry/api": "1.9.0"
273
273
  },
@@ -1,4 +1,4 @@
1
- import assert, { deepEqual } from "node:assert";
1
+ import assert from "node:assert";
2
2
  import { before, describe, it } from "node:test";
3
3
  import { tryAsValidatorIndex } from "#@typeberry/block";
4
4
  import { tryAsTicketAttempt } from "#@typeberry/block/tickets.js";
@@ -8,7 +8,7 @@ import { BANDERSNATCH_KEY_BYTES, SEED_SIZE } from "#@typeberry/crypto";
8
8
  import { BANDERSNATCH_PROOF_BYTES, BANDERSNATCH_RING_ROOT_BYTES, BANDERSNATCH_VRF_SIGNATURE_BYTES, } from "#@typeberry/crypto/bandersnatch.js";
9
9
  import { deriveBandersnatchPublicKey } from "#@typeberry/crypto/key-derivation.js";
10
10
  import { HASH_SIZE } from "#@typeberry/hash";
11
- import { Result } from "#@typeberry/utils";
11
+ import { deepEqual, Result } from "#@typeberry/utils";
12
12
  import bandersnatchVrf from "./bandersnatch-vrf.js";
13
13
  import { BandernsatchWasm } from "./bandersnatch-wasm.js";
14
14
  const bandersnatchWasm = BandernsatchWasm.new();
@@ -123,7 +123,7 @@ describe("Bandersnatch verification", () => {
123
123
  const secretSeed = Bytes.fill(SEED_SIZE, 1).asOpaque();
124
124
  const input = BytesBlob.blobFromString("example input");
125
125
  const auxData = BytesBlob.blobFromString("example aux data");
126
- const expectedSeal = Bytes.parseBytes("0x0b6c772fe61e4e7252722633475c998be3bfcabcda2efff75edaa7c6c889f4df8b487dea89dfbdf086e74c7a3678fed15e5b39eceebf133711c7410ea99d420163f50a95249c087272604395fc694a522ac50a572ac66a4706366a69fda74500", BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque();
126
+ const expectedSeal = Bytes.parseBytes("0x0b6c772fe61e4e7252722633475c998be3bfcabcda2efff75edaa7c6c889f4df832618f0679ff329ca154a1e495a64939756928fbfb7d50587348584d0ad6e09a84014dab23c7493031bba1a2efe727cea82fe1f7c2f0d9777f0d40761083007", BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque();
127
127
  const result = await bandersnatchVrf.generateSeal(await bandersnatchWasm, secretSeed, input, auxData);
128
128
  deepEqual(result, Result.ok(expectedSeal));
129
129
  });
@@ -145,14 +145,15 @@ describe("Bandersnatch verification", () => {
145
145
  const pubKey = deriveBandersnatchPublicKey(secretSeed);
146
146
  const input = BytesBlob.blobFromString("example input");
147
147
  const auxData = BytesBlob.blobFromString("example aux data");
148
- const expectedSeal = Bytes.parseBytes("0x0b6c772fe61e4e7252722633475c998be3bfcabcda2efff75edaa7c6c889f4df8b487dea89dfbdf086e74c7a3678fed15e5b39eceebf133711c7410ea99d420163f50a95249c087272604395fc694a522ac50a572ac66a4706366a69fda74500", BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque();
148
+ const expectedSeal = Bytes.parseBytes("0x0b6c772fe61e4e7252722633475c998be3bfcabcda2efff75edaa7c6c889f4df832618f0679ff329ca154a1e495a64939756928fbfb7d50587348584d0ad6e09a84014dab23c7493031bba1a2efe727cea82fe1f7c2f0d9777f0d40761083007", BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque();
149
149
  const generationResult = await bandersnatchVrf.generateSeal(await bandersnatchWasm, secretSeed, input, auxData);
150
150
  deepEqual(generationResult, Result.ok(expectedSeal));
151
151
  if (generationResult.isError) {
152
152
  throw new Error("Seal generation failed");
153
153
  }
154
154
  const verificationResult = await bandersnatchVrf.verifySeal(await bandersnatchWasm, pubKey, generationResult.ok, input, auxData);
155
- deepEqual(verificationResult, Result.ok(BytesBlob.parseBlob("0x000b0e5c06e70a23d6cfed372763de718b0c21119ea51f7afe1e69b0000de620")));
155
+ const expected = Result.ok(Bytes.parseBytes("0x000b0e5c06e70a23d6cfed372763de718b0c21119ea51f7afe1e69b0000de620", HASH_SIZE).asOpaque());
156
+ deepEqual(verificationResult, expected);
156
157
  });
157
158
  });
158
159
  describe("generateTickets", () => {