@reclaimprotocol/attestor-core 5.0.1 → 5.0.2-beta.1

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.
@@ -7362,6 +7362,45 @@ function getZkResourcesBaseUrl() {
7362
7362
  // src/utils/claims.ts
7363
7363
  import canonicalize from "canonicalize";
7364
7364
  import { keccak256 } from "ethers";
7365
+
7366
+ // src/utils/signatures/eth.ts
7367
+ import { computeAddress, getBytes as getBytes2, hexlify, SigningKey, verifyMessage, Wallet as Wallet2 } from "ethers";
7368
+ var ETH_SIGNATURE_PROVIDER = {
7369
+ getPublicKey(privateKey) {
7370
+ const pub = SigningKey.computePublicKey(privateKey, true);
7371
+ return getBytes2(pub);
7372
+ },
7373
+ getAddress(publicKey) {
7374
+ const pubKeyHex = typeof publicKey === "string" ? publicKey : hexlify(publicKey);
7375
+ return computeAddress(pubKeyHex).toLowerCase();
7376
+ },
7377
+ async sign(data, privateKey) {
7378
+ const wallet = getEthWallet(privateKey);
7379
+ const signature = await wallet.signMessage(data);
7380
+ return getBytes2(signature);
7381
+ },
7382
+ async verify(data, signature, addressBytes) {
7383
+ const address = typeof addressBytes === "string" ? addressBytes : hexlify(addressBytes);
7384
+ const signatureHex = typeof signature === "string" ? signature : hexlify(signature);
7385
+ const signerAddress = verifyMessage(data, signatureHex);
7386
+ return signerAddress.toLowerCase() === address.toLowerCase();
7387
+ }
7388
+ };
7389
+ function getEthWallet(privateKey) {
7390
+ if (!privateKey) {
7391
+ throw new Error("Private key missing");
7392
+ }
7393
+ return new Wallet2(privateKey);
7394
+ }
7395
+
7396
+ // src/utils/signatures/index.ts
7397
+ var SIGNATURES = {
7398
+ [ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH]: ETH_SIGNATURE_PROVIDER
7399
+ };
7400
+ var SelectedServiceSignatureType = ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH;
7401
+ var SelectedServiceSignature = SIGNATURES[SelectedServiceSignatureType];
7402
+
7403
+ // src/utils/claims.ts
7365
7404
  function getIdentifierFromClaimInfo(info) {
7366
7405
  if (info.context?.length > 0) {
7367
7406
  try {
@@ -7447,43 +7486,6 @@ async function preparePacketsForReveal(tlsTranscript, reveals, { onZkProgress, .
7447
7486
  return transcript;
7448
7487
  }
7449
7488
 
7450
- // src/utils/signatures/eth.ts
7451
- import { computeAddress, getBytes as getBytes2, hexlify, SigningKey, verifyMessage, Wallet as Wallet2 } from "ethers";
7452
- var ETH_SIGNATURE_PROVIDER = {
7453
- getPublicKey(privateKey) {
7454
- const pub = SigningKey.computePublicKey(privateKey, true);
7455
- return getBytes2(pub);
7456
- },
7457
- getAddress(publicKey) {
7458
- const pubKeyHex = typeof publicKey === "string" ? publicKey : hexlify(publicKey);
7459
- return computeAddress(pubKeyHex).toLowerCase();
7460
- },
7461
- async sign(data, privateKey) {
7462
- const wallet = getEthWallet(privateKey);
7463
- const signature = await wallet.signMessage(data);
7464
- return getBytes2(signature);
7465
- },
7466
- async verify(data, signature, addressBytes) {
7467
- const address = typeof addressBytes === "string" ? addressBytes : hexlify(addressBytes);
7468
- const signatureHex = typeof signature === "string" ? signature : hexlify(signature);
7469
- const signerAddress = verifyMessage(data, signatureHex);
7470
- return signerAddress.toLowerCase() === address.toLowerCase();
7471
- }
7472
- };
7473
- function getEthWallet(privateKey) {
7474
- if (!privateKey) {
7475
- throw new Error("Private key missing");
7476
- }
7477
- return new Wallet2(privateKey);
7478
- }
7479
-
7480
- // src/utils/signatures/index.ts
7481
- var SIGNATURES = {
7482
- [ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH]: ETH_SIGNATURE_PROVIDER
7483
- };
7484
- var SelectedServiceSignatureType = ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH;
7485
- var SelectedServiceSignature = SIGNATURES[SelectedServiceSignatureType];
7486
-
7487
7489
  // src/utils/auth.ts
7488
7490
  import { getBytes as getBytes3 } from "ethers";
7489
7491
 
@@ -9893,11 +9895,7 @@ function getClaimRequestDifference(a, b) {
9893
9895
  }
9894
9896
 
9895
9897
  // src/external-rpc/benchmark.ts
9896
- import {
9897
- crypto as crypto4,
9898
- encryptWrappedRecord,
9899
- SUPPORTED_CIPHER_SUITE_MAP as SUPPORTED_CIPHER_SUITE_MAP2
9900
- } from "@reclaimprotocol/tls";
9898
+ import { crypto as crypto4, encryptWrappedRecord, SUPPORTED_CIPHER_SUITE_MAP as SUPPORTED_CIPHER_SUITE_MAP2 } from "@reclaimprotocol/tls";
9901
9899
  var ZK_CIPHER_SUITES2 = [
9902
9900
  "TLS_CHACHA20_POLY1305_SHA256",
9903
9901
  "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
package/lib/index.js CHANGED
@@ -5623,6 +5623,45 @@ function getZkResourcesBaseUrl() {
5623
5623
  // src/utils/claims.ts
5624
5624
  import canonicalize from "canonicalize";
5625
5625
  import { keccak256 } from "ethers";
5626
+
5627
+ // src/utils/signatures/eth.ts
5628
+ import { computeAddress, getBytes, hexlify, SigningKey, verifyMessage, Wallet } from "ethers";
5629
+ var ETH_SIGNATURE_PROVIDER = {
5630
+ getPublicKey(privateKey) {
5631
+ const pub = SigningKey.computePublicKey(privateKey, true);
5632
+ return getBytes(pub);
5633
+ },
5634
+ getAddress(publicKey) {
5635
+ const pubKeyHex = typeof publicKey === "string" ? publicKey : hexlify(publicKey);
5636
+ return computeAddress(pubKeyHex).toLowerCase();
5637
+ },
5638
+ async sign(data, privateKey) {
5639
+ const wallet = getEthWallet(privateKey);
5640
+ const signature = await wallet.signMessage(data);
5641
+ return getBytes(signature);
5642
+ },
5643
+ async verify(data, signature, addressBytes) {
5644
+ const address = typeof addressBytes === "string" ? addressBytes : hexlify(addressBytes);
5645
+ const signatureHex = typeof signature === "string" ? signature : hexlify(signature);
5646
+ const signerAddress = verifyMessage(data, signatureHex);
5647
+ return signerAddress.toLowerCase() === address.toLowerCase();
5648
+ }
5649
+ };
5650
+ function getEthWallet(privateKey) {
5651
+ if (!privateKey) {
5652
+ throw new Error("Private key missing");
5653
+ }
5654
+ return new Wallet(privateKey);
5655
+ }
5656
+
5657
+ // src/utils/signatures/index.ts
5658
+ var SIGNATURES = {
5659
+ [ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH]: ETH_SIGNATURE_PROVIDER
5660
+ };
5661
+ var SelectedServiceSignatureType = ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH;
5662
+ var SelectedServiceSignature = SIGNATURES[SelectedServiceSignatureType];
5663
+
5664
+ // src/utils/claims.ts
5626
5665
  function createSignDataForClaim(data) {
5627
5666
  const lines = [
5628
5667
  getIdentifierFromClaimInfo(data),
@@ -5765,43 +5804,6 @@ async function preparePacketsForReveal(tlsTranscript, reveals, { onZkProgress, .
5765
5804
  return transcript;
5766
5805
  }
5767
5806
 
5768
- // src/utils/signatures/eth.ts
5769
- import { computeAddress, getBytes, hexlify, SigningKey, verifyMessage, Wallet } from "ethers";
5770
- var ETH_SIGNATURE_PROVIDER = {
5771
- getPublicKey(privateKey) {
5772
- const pub = SigningKey.computePublicKey(privateKey, true);
5773
- return getBytes(pub);
5774
- },
5775
- getAddress(publicKey) {
5776
- const pubKeyHex = typeof publicKey === "string" ? publicKey : hexlify(publicKey);
5777
- return computeAddress(pubKeyHex).toLowerCase();
5778
- },
5779
- async sign(data, privateKey) {
5780
- const wallet = getEthWallet(privateKey);
5781
- const signature = await wallet.signMessage(data);
5782
- return getBytes(signature);
5783
- },
5784
- async verify(data, signature, addressBytes) {
5785
- const address = typeof addressBytes === "string" ? addressBytes : hexlify(addressBytes);
5786
- const signatureHex = typeof signature === "string" ? signature : hexlify(signature);
5787
- const signerAddress = verifyMessage(data, signatureHex);
5788
- return signerAddress.toLowerCase() === address.toLowerCase();
5789
- }
5790
- };
5791
- function getEthWallet(privateKey) {
5792
- if (!privateKey) {
5793
- throw new Error("Private key missing");
5794
- }
5795
- return new Wallet(privateKey);
5796
- }
5797
-
5798
- // src/utils/signatures/index.ts
5799
- var SIGNATURES = {
5800
- [ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH]: ETH_SIGNATURE_PROVIDER
5801
- };
5802
- var SelectedServiceSignatureType = ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH;
5803
- var SelectedServiceSignature = SIGNATURES[SelectedServiceSignatureType];
5804
-
5805
5807
  // src/utils/auth.ts
5806
5808
  import { getBytes as getBytes2 } from "ethers";
5807
5809
  async function assertValidAuthRequest(request, signatureType) {
@@ -3,7 +3,7 @@ import type { ServiceSignatureType } from '#src/proto/api.ts';
3
3
  /**
4
4
  * Sign message using the PRIVATE_KEY env var.
5
5
  */
6
- export declare function signAsAttestor(data: Uint8Array | string, scheme: ServiceSignatureType): Uint8Array<ArrayBufferLike> | Promise<Uint8Array<ArrayBufferLike>>;
6
+ export declare function signAsAttestor(data: Uint8Array | string, scheme: ServiceSignatureType): import("../../index.ts").Awaitable<Uint8Array<ArrayBufferLike>>;
7
7
  /**
8
8
  * Obtain the address on chain, from the PRIVATE_KEY env var.
9
9
  */
@@ -2,6 +2,7 @@ import type { TLSConnectionOptions } from '@reclaimprotocol/tls';
2
2
  import type { AttestorVersion, ProviderClaimData } from '#src/proto/api.ts';
3
3
  import type { ArraySlice, Logger, RedactedOrHashedArraySlice } from '#src/types/general.ts';
4
4
  import type { ProvidersConfig } from '#src/types/providers.gen.ts';
5
+ import type { Awaitable } from '#src/types/signatures.ts';
5
6
  import type { Transcript } from '#src/types/tunnel.ts';
6
7
  export type AttestorData = {
7
8
  id: string;
@@ -114,11 +115,11 @@ export interface Provider<N extends ProviderName, Params = ProviderParams<N>, Se
114
115
  * Optionally return parameters extracted from the receipt
115
116
  * that will then be included in the claim context
116
117
  * */
117
- assertValidProviderReceipt(opts: AssertValidProviderReceipt<Params>): void | Promise<void> | {
118
+ assertValidProviderReceipt(opts: AssertValidProviderReceipt<Params>): Awaitable<{
118
119
  extractedParameters: {
119
120
  [key: string]: string;
120
121
  };
121
- };
122
+ } | undefined>;
122
123
  }
123
124
  export type ProofGenerationStep = {
124
125
  name: 'connecting';
@@ -1,5 +1,5 @@
1
1
  export type PrivateKey = string;
2
- type Awaitable<T> = T | Promise<T>;
2
+ export type Awaitable<T> = T | Promise<T>;
3
3
  export type ServiceSignatureProvider = {
4
4
  /**
5
5
  * Returns public key in compressed (compact) format used in Reclaim RPC calls
@@ -25,4 +25,3 @@ export type ServiceSignatureProvider = {
25
25
  */
26
26
  verify(data: Uint8Array, signature: Uint8Array | string, addressBytes: Uint8Array | string): Awaitable<boolean>;
27
27
  };
28
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reclaimprotocol/attestor-core",
3
- "version": "5.0.1",
3
+ "version": "5.0.2-beta.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "imports": {
@@ -86,7 +86,7 @@
86
86
  "@peculiar/webcrypto": "^1.5.0",
87
87
  "@peculiar/x509": "^1.14.3",
88
88
  "@reclaimprotocol/tls": "github:reclaimprotocol/tls",
89
- "@reclaimprotocol/zk-symmetric-crypto": "^5.0.9",
89
+ "@reclaimprotocol/zk-symmetric-crypto": "^5.1.0",
90
90
  "ajv": "^8.18.0",
91
91
  "bs58": "^6.0.0",
92
92
  "canonicalize": "^2.1.0",