@corpus-core/colibri-stateless 0.6.1 → 0.6.2

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/index.js CHANGED
@@ -122,19 +122,6 @@ export async function handle_request(req, conf) {
122
122
  if (conf.debug)
123
123
  log(`::: ${path} (Error: ${last_error})`);
124
124
  }
125
- function check_trusted_blockhashes(trusted_block_hashes, c4w, chainId) {
126
- const blockhashes = new Uint8Array(32 * trusted_block_hashes.length);
127
- for (let i = 0; i < trusted_block_hashes.length; i++) {
128
- if (trusted_block_hashes[i].length != 66 || !trusted_block_hashes[i].startsWith("0x"))
129
- throw new Error("Invalid trustedblockhash : " + trusted_block_hashes[i]);
130
- for (let j = 0; j < 32; j++)
131
- blockhashes[i * 32 + j] = parseInt(trusted_block_hashes[i].slice(2 + j * 2, 4 + j * 2), 16);
132
- }
133
- const ptr = copy_to_c(blockhashes, c4w);
134
- c4w._c4w_set_trusted_blockhashes(BigInt(chainId), ptr, blockhashes.length);
135
- c4w._free(ptr);
136
- trusted_block_hashes.length = 0;
137
- }
138
125
  const default_config = {
139
126
  '1': {
140
127
  alias: ["mainnet", "eth", "0x1"],
@@ -213,7 +200,7 @@ export default class C4Client {
213
200
  // Schutz vor Config-Manipulation durch Deep-Freeze
214
201
  const baseConfig = {
215
202
  chains: {},
216
- trusted_block_hashes: [],
203
+ trusted_checkpoint: undefined,
217
204
  rpcs: chain_config.rpcs || [],
218
205
  beacon_apis: chain_config.beacon_apis || [],
219
206
  prover: chain_config.prover || [],
@@ -303,10 +290,11 @@ export default class C4Client {
303
290
  const free_buffers = [];
304
291
  let ctx = 0;
305
292
  try {
306
- if (this.config.trusted_block_hashes && this.config.trusted_block_hashes.length > 0)
307
- check_trusted_blockhashes(this.config.trusted_block_hashes, c4w, parseInt(this.config.chainId));
308
293
  // Call the C function
309
- ctx = c4w._c4w_create_verify_ctx(copy_to_c(proof, c4w, free_buffers), proof.length, as_char_ptr(method, c4w, free_buffers), as_char_ptr(JSON.stringify(args), c4w, free_buffers), BigInt(this.config.chainId));
294
+ const checkpoint_ptr = this.config.trusted_checkpoint
295
+ ? as_char_ptr(this.config.trusted_checkpoint, c4w, free_buffers)
296
+ : 0;
297
+ ctx = c4w._c4w_create_verify_ctx(copy_to_c(proof, c4w, free_buffers), proof.length, as_char_ptr(method, c4w, free_buffers), as_char_ptr(JSON.stringify(args), c4w, free_buffers), BigInt(this.config.chainId), checkpoint_ptr);
310
298
  while (true) {
311
299
  const state = as_json(c4w._c4w_verify_proof(ctx), c4w, true);
312
300
  switch (state.status) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corpus-core/colibri-stateless",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Colibri is a stateless and trustless ethereum client, which is optimized for the mobile apps or embedded devices, because it does not hols the state, but verifies on demand.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/types.d.ts CHANGED
@@ -54,7 +54,7 @@ export interface ChainConfig {
54
54
  rpcs: string[];
55
55
  prover?: string[];
56
56
  checkpointz?: string[];
57
- trusted_block_hashes: string[];
57
+ trusted_checkpoint?: string;
58
58
  verify?: (method: string, args: any[]) => boolean;
59
59
  pollingInterval?: number;
60
60
  proofStrategy?: ProofStrategy;
package/wasm.d.ts CHANGED
@@ -28,8 +28,7 @@ export interface C4W {
28
28
  _c4w_req_set_response: (reqPtr: number, data: number, len: number, node_index: number) => void;
29
29
  _c4w_req_set_error: (reqPtr: number, error: number, node_index: number) => void;
30
30
  _c4w_get_method_type: (chain_id: bigint, method: number) => number;
31
- _c4w_set_trusted_blockhashes: (chain_id: bigint, blockhashes: number, len: number) => void;
32
- _c4w_create_verify_ctx: (proof: number, proof_len: number, method: number, args: number, chain_id: bigint) => number;
31
+ _c4w_create_verify_ctx: (proof: number, proof_len: number, method: number, args: number, chain_id: bigint, trusted_checkpoint: number) => number;
33
32
  _c4w_free_verify_ctx: (verifyCtx: number) => void;
34
33
  _c4w_verify_proof: (verifyCtx: number) => number;
35
34
  _c4w_req_free: (reqPtr: number) => void;