@sig-net/midnight 0.21.0-rc.9 → 0.21.0

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.
@@ -5,20 +5,23 @@
5
5
  // v2.0.0 (COLON-separated) is the only scheme the MPC answers: the Compact
6
6
  // contracts assert `keyVersion >= 1`, which selects v2.
7
7
  import { secp256k1 } from "@noble/curves/secp256k1.js";
8
- import { computeAddress, keccak256, SigningKey, toUtf8Bytes } from "ethers";
8
+ import { computeAddress, keccak256, toUtf8Bytes } from "ethers";
9
9
  import { bigintToBytes32BE, bytesToBigintBE, stripHexPrefix } from "./byte-codecs.js";
10
- import { SECP256K1_ORDER } from "./ecdsa-attestation.js";
10
+ import { parseSecp256k1PublicKeyToNoblePoint, SECP256K1_ORDER, } from "./ecdsa-attestation.js";
11
11
  /**
12
12
  * Domain prefix of the sig-net v2.0.0 epsilon derivation scheme. The full
13
- * derivation string is `<prefix>:<chainId>:<requester>:<path>` (colon-separated),
14
- * matching `caip2_derivation_path` in the MPC's `crypto/src/kdf.rs`.
13
+ * derivation string is `<prefix>:midnight:mainnet:<requester>:<path>`
14
+ * (colon-separated), matching `caip2_derivation_path` in the MPC's
15
+ * `signet-crypto/src/kdf.rs`.
15
16
  */
16
17
  export const EPSILON_DERIVATION_PREFIX = "sig.network v2.0.0 epsilon derivation";
17
18
  /**
18
- * CAIP-2 chain id under which the MPC derives keys for requests originating
19
- * from Midnight contracts.
19
+ * CAIP-2 chain id component of every Midnight derivation string. The MPC
20
+ * renders `Chain::Midnight` as this one literal for every Midnight network
21
+ * (sig-net/mpc signet-primitives/src/chain.rs), so it never varies with the
22
+ * network a contract is deployed on.
20
23
  */
21
- export const MIDNIGHT_TESTNET_CHAIN_ID = "midnight:testnet";
24
+ export const MIDNIGHT_CAIP2_ID = "midnight:mainnet";
22
25
  /**
23
26
  * The FIXED derivation path of the MPC's respond-bidirectional RESPONSE key
24
27
  * for Midnight client contracts. It enters the derivation string verbatim,
@@ -46,12 +49,13 @@ function normaliseRequesterAddress(contractAddress) {
46
49
  /**
47
50
  * Derive the EVM address the MPC network signs from for a given Midnight
48
51
  * contract and derivation path, using the sig-net v2.0.0 epsilon scheme:
49
- * `epsilon = keccak256("<prefix>:<chainId>:<requester>:<path>")` and
52
+ * `epsilon = keccak256("<prefix>:midnight:mainnet:<requester>:<path>")` and
50
53
  * `derivedPubKey = mpcRootPubKey + epsilon * G` on secp256k1. The MPC
51
54
  * treats `path` as an opaque string.
52
55
  *
53
- * @param mpcSecp256k1PubkeyHex - The MPC root secp256k1 public key as 0x-hex
54
- * (compressed or uncompressed, normalised internally).
56
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any
57
+ * spelling `parseSecp256k1PublicKey` accepts (SEC1 hex or NEAR
58
+ * `secp256k1:<base58>`).
55
59
  * @param contractAddress - The Midnight contract address the request
56
60
  * originates from (`0x` prefix optional, case-insensitive: it enters the
57
61
  * derivation string through {@link normaliseRequesterAddress}).
@@ -60,27 +64,26 @@ function normaliseRequesterAddress(contractAddress) {
60
64
  * `path: Bytes<32>`: the lowercase hex of the FULL 32 bytes, no `0x`
61
65
  * prefix and no trimming ({@link bytesToHex} of the raw bytes), so
62
66
  * `0xab..00` and `0xab..` derive different accounts.
63
- * @param chainId - CAIP-2 chain id component of the derivation string.
64
67
  * @returns The derived EVM address as a 0x-prefixed EIP-55 checksummed string.
65
68
  */
66
- export function deriveEvmAddress(mpcSecp256k1PubkeyHex, contractAddress, path, chainId = MIDNIGHT_TESTNET_CHAIN_ID) {
67
- const derivedPoint = deriveChildPoint(mpcSecp256k1PubkeyHex, normaliseRequesterAddress(contractAddress), path, chainId);
69
+ export function deriveEvmAddress(mpcSecp256k1PublicKey, contractAddress, path) {
70
+ const derivedPoint = deriveChildPoint(mpcSecp256k1PublicKey, normaliseRequesterAddress(contractAddress), path);
68
71
  return computeAddress(`0x${derivedPoint.toHex(false)}`);
69
72
  }
70
73
  /**
71
74
  * The epsilon scalar of the sig-net v2.0.0 derivation scheme:
72
- * `keccak256("<prefix>:<chainId>:<requester>:<path>")` reduced mod the
73
- * secp256k1 curve order. Child keys are `root + epsilon` (secret side) and
75
+ * `keccak256("<prefix>:midnight:mainnet:<requester>:<path>")` reduced mod
76
+ * the secp256k1 curve order, the chain id fixed to
77
+ * {@link MIDNIGHT_CAIP2_ID}. Child keys are `root + epsilon` (secret side) and
74
78
  * `rootPubKey + epsilon * G` (public side).
75
79
  *
76
80
  * @param requester - The requester component of the derivation string,
77
81
  * verbatim (no normalisation: callers must agree on the exact rendering).
78
82
  * @param path - The derivation path string.
79
- * @param chainId - CAIP-2 chain id component of the derivation string.
80
83
  * @returns The epsilon scalar, in `[0, n)`.
81
84
  */
82
- export function deriveEpsilon(requester, path, chainId = MIDNIGHT_TESTNET_CHAIN_ID) {
83
- const fullPath = `${EPSILON_DERIVATION_PREFIX}:${chainId}:${requester}:${path}`;
85
+ export function deriveEpsilon(requester, path) {
86
+ const fullPath = `${EPSILON_DERIVATION_PREFIX}:${MIDNIGHT_CAIP2_ID}:${requester}:${path}`;
84
87
  // Reduce mod n before using: noble throws on scalars >= n, whereas the
85
88
  // server's scalar arithmetic reduces implicitly.
86
89
  return BigInt(keccak256(toUtf8Bytes(fullPath))) % SECP256K1_ORDER;
@@ -88,16 +91,15 @@ export function deriveEpsilon(requester, path, chainId = MIDNIGHT_TESTNET_CHAIN_
88
91
  /**
89
92
  * Derive the child public key as a noble curve point (internal shape).
90
93
  *
91
- * @param mpcSecp256k1PubkeyHex - The MPC root public key in SEC1 hex.
94
+ * @param mpcSecp256k1PublicKey - The MPC root public key, any spelling
95
+ * `parseSecp256k1PublicKey` accepts.
92
96
  * @param requester - The normalised requester address.
93
97
  * @param path - The derivation path component.
94
- * @param chainId - The chain id component.
95
98
  * @returns The derived child point on secp256k1.
96
99
  */
97
- function deriveChildPoint(mpcSecp256k1PubkeyHex, requester, path, chainId) {
98
- const epsilon = deriveEpsilon(requester, path, chainId);
99
- const rootPubKeyHex = SigningKey.computePublicKey(mpcSecp256k1PubkeyHex, false);
100
- const rootPoint = secp256k1.Point.fromHex(rootPubKeyHex.slice(2));
100
+ function deriveChildPoint(mpcSecp256k1PublicKey, requester, path) {
101
+ const epsilon = deriveEpsilon(requester, path);
102
+ const rootPoint = parseSecp256k1PublicKeyToNoblePoint(mpcSecp256k1PublicKey);
101
103
  return epsilon === 0n ? rootPoint : rootPoint.add(secp256k1.Point.BASE.multiply(epsilon));
102
104
  }
103
105
  /**
@@ -106,14 +108,15 @@ function deriveChildPoint(mpcSecp256k1PubkeyHex, requester, path, chainId) {
106
108
  * and what response verification checks against. See
107
109
  * {@link MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH} for the scheme.
108
110
  *
109
- * @param mpcSecp256k1PubkeyHex - The MPC root secp256k1 public key as 0x-hex
110
- * (compressed or uncompressed).
111
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any
112
+ * spelling `parseSecp256k1PublicKey` accepts (SEC1 hex or NEAR
113
+ * `secp256k1:<base58>`).
111
114
  * @param clientContractAddress - The client contract's Midnight address
112
115
  * (`0x` prefix optional, case-insensitive).
113
116
  * @returns The response public key as a Compact-runtime `Secp256k1Point`.
114
117
  */
115
- export function deriveMidnightResponseKey(mpcSecp256k1PubkeyHex, clientContractAddress) {
116
- const point = deriveChildPoint(mpcSecp256k1PubkeyHex, normaliseRequesterAddress(clientContractAddress), MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, MIDNIGHT_TESTNET_CHAIN_ID);
118
+ export function deriveMidnightResponseKey(mpcSecp256k1PublicKey, clientContractAddress) {
119
+ const point = deriveChildPoint(mpcSecp256k1PublicKey, normaliseRequesterAddress(clientContractAddress), MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH);
117
120
  return { x: point.x, y: point.y, identity: false };
118
121
  }
119
122
  /**
@@ -133,7 +136,7 @@ export function deriveMidnightResponseSecretKey(mpcRootSecretKey, clientContract
133
136
  throw new Error(`MPC root secret key must be 32 bytes, got ${String(mpcRootSecretKey.length)}`);
134
137
  }
135
138
  const root = bytesToBigintBE(mpcRootSecretKey);
136
- const epsilon = deriveEpsilon(normaliseRequesterAddress(clientContractAddress), MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, MIDNIGHT_TESTNET_CHAIN_ID);
139
+ const epsilon = deriveEpsilon(normaliseRequesterAddress(clientContractAddress), MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH);
137
140
  const child = (root + epsilon) % SECP256K1_ORDER;
138
141
  if (child === 0n) {
139
142
  throw new Error("derived response secret key is zero (invalid scalar)");
@@ -1 +1 @@
1
- {"version":3,"file":"epsilon-derivation.js","sourceRoot":"","sources":["../src/epsilon-derivation.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,2EAA2E;AAC3E,wDAAwD;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,wBAAwB,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,uCAAuC,CAAC;AAEjF;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAE3E;;;;;;;;GAQG;AACH,SAAS,yBAAyB,CAAC,eAAuB;IACxD,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,qBAA6B,EAC7B,eAAuB,E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E, bytesToHex, hexToBytes, stripHexPrefix, } from "./byte-codecs.ts";
3
3
  export * from "./constants.ts";
4
- export { deriveEpsilon, deriveEvmAddress, deriveMidnightResponseKey, EPSILON_DERIVATION_PREFIX, MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, MIDNIGHT_TESTNET_CHAIN_ID, } from "./epsilon-derivation.ts";
4
+ export { deriveEpsilon, deriveEvmAddress, deriveMidnightResponseKey, EPSILON_DERIVATION_PREFIX, MIDNIGHT_CAIP2_ID, MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, } from "./epsilon-derivation.ts";
5
5
  export { type RawContractState, signetFieldNodeByPath } from "./raw-contract-state.ts";
6
6
  export * from "./signature-requests-state-reader.ts";
7
7
  export * from "./signature-response-verification.ts";
@@ -10,7 +10,7 @@ export { abiWordToBool, abiWordToUint128, assembleCalldata, boolAbiWord, type Ev
10
10
  export { calculateRequestId } from "./signet-request-id.ts";
11
11
  export * from "./signet-request-response-reader.ts";
12
12
  export { type ContractAddress, contractAddressFromHex, type Maybe, MPCDestination, MPCSignatureAlgorithm, parseRequestIdHex, PATH_BYTES, type RequestId, requestIdBytes, type RequestIdHex, requestIdHex, type SignBidirectionalEvent, type SignBidirectionalEventIndex, type SignBidirectionalEventLedgerMap, toSignBidirectionalEventIndex, TxParamType, } from "./signet-requests.ts";
13
- export { formatSecp256k1PublicKey, parseSecp256k1PublicKey, respondBidirectionalEventToCircuitInput, SECP256K1_ORDER, type Secp256k1Point, signatureRespondedEventToSignature, verifyRespondBidirectionalSignature, } from "./ecdsa-attestation.ts";
13
+ export { formatSecp256k1PublicKey, normaliseSecp256k1PublicKey, parseSecp256k1PublicKey, respondBidirectionalEventToCircuitInput, SECP256K1_ORDER, type Secp256k1Point, signatureRespondedEventToSignature, verifyRespondBidirectionalSignature, } from "./ecdsa-attestation.ts";
14
14
  /**
15
15
  * Compiled pure circuits of Signet.compact (run `yarn compile` first).
16
16
  * Off-chain code MUST use these instead of re-porting the algorithms:
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAI1B,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,cAAc,EACd,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,OAAO,EACL,KAAK,eAAe,EACpB,sBAAsB,EACtB,KAAK,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,KAAK,SAAS,EACd,cAAc,EACd,KAAK,YAAY,EACjB,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,6BAA6B,EAC7B,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EACf,KAAK,cAAc,EACnB,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wBAAw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3B,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EACf,KAAK,cAAc,EACnB,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { bigintToBytes32, bigintToBytes32BE, BLS_ORDER, bytesToBigint, bytesToBi
9
9
  export * from "./constants.js";
10
10
  // Selective: deriveMidnightResponseSecretKey takes the MPC root secret, so
11
11
  // it is exported through ./testing with the other secret-taking helpers.
12
- export { deriveEpsilon, deriveEvmAddress, deriveMidnightResponseKey, EPSILON_DERIVATION_PREFIX, MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, MIDNIGHT_TESTNET_CHAIN_ID, } from "./epsilon-derivation.js";
12
+ export { deriveEpsilon, deriveEvmAddress, deriveMidnightResponseKey, EPSILON_DERIVATION_PREFIX, MIDNIGHT_CAIP2_ID, MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, } from "./epsilon-derivation.js";
13
13
  export { signetFieldNodeByPath } from "./raw-contract-state.js";
14
14
  export * from "./signature-requests-state-reader.js";
15
15
  export * from "./signature-response-verification.js";
@@ -20,8 +20,9 @@ export * from "./signet-request-response-reader.js";
20
20
  export { contractAddressFromHex, MPCDestination, MPCSignatureAlgorithm, parseRequestIdHex, PATH_BYTES, requestIdBytes, requestIdHex, toSignBidirectionalEventIndex, TxParamType, } from "./signet-requests.js";
21
21
  // Explicit list: ecdsa-attestation.ts also backs the ./testing entry point
22
22
  // (the attestation-minting helpers that take a secret key live THERE), and
23
- // its record decoder (mpcSignatureToEcdsaSignature) is package-internal.
24
- export { formatSecp256k1PublicKey, parseSecp256k1PublicKey, respondBidirectionalEventToCircuitInput, SECP256K1_ORDER, signatureRespondedEventToSignature, verifyRespondBidirectionalSignature, } from "./ecdsa-attestation.js";
23
+ // its record decoder (mpcSignatureToEcdsaSignature) and noble-point parser
24
+ // (parseSecp256k1PublicKeyToNoblePoint) are package-internal.
25
+ export { formatSecp256k1PublicKey, normaliseSecp256k1PublicKey, parseSecp256k1PublicKey, respondBidirectionalEventToCircuitInput, SECP256K1_ORDER, signatureRespondedEventToSignature, verifyRespondBidirectionalSignature, } from "./ecdsa-attestation.js";
25
26
  /**
26
27
  * Compiled pure circuits of Signet.compact (run `yarn compile` first).
27
28
  * Off-chain code MUST use these instead of re-porting the algorithms:
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AAExE,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,uEAAuE;AACvE,4EAA4E;AAC5E,4EAA4E;AAC5E,cAAc,gBAAgB,CAAC;AAC/B,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAyB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EAEX,iBAAiB,EAGjB,cAAc,EACd,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAEL,sBAAsB,EAEtB,cAAc,EACd,qBAAqB,EACr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qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EAEV,cAAc,EAEd,YAAY,EAIZ,6BAA6B,EAC7B,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,8DAA8D;AAC9D,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EAEf,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EAAqB,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
@@ -64,6 +64,17 @@
64
64
  ]
65
65
  }
66
66
  },
67
+ {
68
+ "name": "ethereumCaip2Id",
69
+ "pure": true,
70
+ "proof": false,
71
+ "arguments": [
72
+ ],
73
+ "result-type": {
74
+ "type-name": "Bytes",
75
+ "length": 32
76
+ }
77
+ },
67
78
  {
68
79
  "name": "evmAddressAbiWord",
69
80
  "pure": true,
@@ -181,35 +192,6 @@
181
192
  "length": 32
182
193
  }
183
194
  },
184
- {
185
- "name": "calculateSignetAttestationDigest2",
186
- "pure": true,
187
- "proof": false,
188
- "arguments": [
189
- {
190
- "name": "requestId",
191
- "type": {
192
- "type-name": "Alias",
193
- "name": "RequestId",
194
- "type": {
195
- "type-name": "Bytes",
196
- "length": 32
197
- }
198
- }
199
- },
200
- {
201
- "name": "serializedOutput",
202
- "type": {
203
- "type-name": "Bytes",
204
- "length": 2
205
- }
206
- }
207
- ],
208
- "result-type": {
209
- "type-name": "Bytes",
210
- "length": 32
211
- }
212
- },
213
195
  {
214
196
  "name": "calculateSignetAttestationDigest32",
215
197
  "pure": true,
@@ -7,26 +7,26 @@
7
7
  "type": "directory",
8
8
  "contract-info.json": {
9
9
  "type": "file",
10
- "size": 8356,
11
- "hash": "15bb6a6ac0c2c0b34888269101edc5f506a5376bf7f6272eb5130c11af77758e"
10
+ "size": 7940,
11
+ "hash": "ddb43aa351cab8b4e6a93df7d97efc0a13c71995b3371f18d2f42ee153babe41"
12
12
  }
13
13
  },
14
14
  "contract": {
15
15
  "type": "directory",
16
16
  "index.d.ts": {
17
17
  "type": "file",
18
- "size": 6686,
19
- "hash": "3f18fa6a8e53cdf89d5e207d9a4da9e8d9efafae14245345a151640fb78129b8"
18
+ "size": 6430,
19
+ "hash": "defcd9964cb7d9cb1f4819717538eeca53c9c6bbca6706091ce5cf861d6c1a49"
20
20
  },
21
21
  "index.js": {
22
22
  "type": "file",
23
- "size": 42276,
24
- "hash": "a97d1d66f4e4fa87ee50eafcd29f425e5aca03a96ada5608eff022b7bf1f1b44"
23
+ "size": 39549,
24
+ "hash": "4620859c4a17c1188e4c5a665b292181a1cc2547d609abe5562b677d9ef8e99d"
25
25
  },
26
26
  "index.js.map": {
27
27
  "type": "file",
28
- "size": 4635,
29
- "hash": "2dca80a02be40564cf441a174d751879bc4727940ad8495989039ec6344ff4fe"
28
+ "size": 4395,
29
+ "hash": "a9ec65ad9479d1d2546caf2c3957e7694d5cfb522afc7f143253d68f08682b79"
30
30
  }
31
31
  }
32
32
  }
@@ -16,6 +16,7 @@ export type PureCircuits = {
16
16
  requestsPath_0: bigint[]): { version: bigint,
17
17
  payload: Uint8Array
18
18
  };
19
+ ethereumCaip2Id(): Uint8Array;
19
20
  evmAddressAbiWord(addr_0: Uint8Array): Uint8Array;
20
21
  numericAbiWord(value_0: bigint): Uint8Array;
21
22
  boolAbiWord(value_0: boolean): Uint8Array;
@@ -23,8 +24,6 @@ export type PureCircuits = {
23
24
  abiWordToBool(word_0: Uint8Array): boolean;
24
25
  calculateSignetAttestationDigest1(requestId_0: Uint8Array,
25
26
  serializedOutput_0: Uint8Array): Uint8Array;
26
- calculateSignetAttestationDigest2(requestId_0: Uint8Array,
27
- serializedOutput_0: Uint8Array): Uint8Array;
28
27
  calculateSignetAttestationDigest32(requestId_0: Uint8Array,
29
28
  serializedOutput_0: Uint8Array): Uint8Array;
30
29
  calculateSignetAttestationDigest100(requestId_0: Uint8Array,
@@ -49,6 +48,7 @@ export type Circuits<PS> = {
49
48
  requestsPath_0: bigint[]): Promise<__compactRuntime.CircuitResults<PS, { version: bigint,
50
49
  payload: Uint8Array
51
50
  }>>;
51
+ ethereumCaip2Id(context: __compactRuntime.CircuitContext<PS>): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
52
52
  evmAddressAbiWord(context: __compactRuntime.CircuitContext<PS>,
53
53
  addr_0: Uint8Array): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
54
54
  numericAbiWord(context: __compactRuntime.CircuitContext<PS>, value_0: bigint): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
@@ -59,9 +59,6 @@ export type Circuits<PS> = {
59
59
  calculateSignetAttestationDigest1(context: __compactRuntime.CircuitContext<PS>,
60
60
  requestId_0: Uint8Array,
61
61
  serializedOutput_0: Uint8Array): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
62
- calculateSignetAttestationDigest2(context: __compactRuntime.CircuitContext<PS>,
63
- requestId_0: Uint8Array,
64
- serializedOutput_0: Uint8Array): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
65
62
  calculateSignetAttestationDigest32(context: __compactRuntime.CircuitContext<PS>,
66
63
  requestId_0: Uint8Array,
67
64
  serializedOutput_0: Uint8Array): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;