@sig-net/midnight 0.19.0 → 0.21.0-rc.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.
Files changed (85) hide show
  1. package/README.md +42 -2
  2. package/dist/abi-serde.d.ts +32 -30
  3. package/dist/abi-serde.d.ts.map +1 -1
  4. package/dist/abi-serde.js +139 -75
  5. package/dist/abi-serde.js.map +1 -1
  6. package/dist/byte-codecs.d.ts +62 -0
  7. package/dist/byte-codecs.d.ts.map +1 -0
  8. package/dist/byte-codecs.js +116 -0
  9. package/dist/byte-codecs.js.map +1 -0
  10. package/dist/compact-descriptors.d.ts +89 -0
  11. package/dist/compact-descriptors.d.ts.map +1 -0
  12. package/dist/compact-descriptors.js +139 -0
  13. package/dist/compact-descriptors.js.map +1 -0
  14. package/dist/constants.d.ts +18 -43
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +19 -45
  17. package/dist/constants.js.map +1 -1
  18. package/dist/ecdsa-attestation.d.ts +66 -96
  19. package/dist/ecdsa-attestation.d.ts.map +1 -1
  20. package/dist/ecdsa-attestation.js +115 -140
  21. package/dist/ecdsa-attestation.js.map +1 -1
  22. package/dist/epsilon-derivation.d.ts +24 -31
  23. package/dist/epsilon-derivation.d.ts.map +1 -1
  24. package/dist/epsilon-derivation.js +52 -62
  25. package/dist/epsilon-derivation.js.map +1 -1
  26. package/dist/index.d.ts +10 -9
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +17 -8
  29. package/dist/index.js.map +1 -1
  30. package/dist/managed/compiler/contract-info.json +0 -22
  31. package/dist/managed/compiler/contract-manifest.json +8 -8
  32. package/dist/managed/contract/index.d.ts +0 -3
  33. package/dist/managed/contract/index.js +102 -225
  34. package/dist/managed/contract/index.js.map +1 -1
  35. package/dist/raw-contract-state.d.ts +25 -0
  36. package/dist/raw-contract-state.d.ts.map +1 -0
  37. package/dist/raw-contract-state.js +52 -0
  38. package/dist/raw-contract-state.js.map +1 -0
  39. package/dist/signature-requests-state-reader.d.ts +18 -44
  40. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  41. package/dist/signature-requests-state-reader.js +82 -146
  42. package/dist/signature-requests-state-reader.js.map +1 -1
  43. package/dist/signature-response-verification.d.ts +9 -8
  44. package/dist/signature-response-verification.d.ts.map +1 -1
  45. package/dist/signature-response-verification.js +20 -17
  46. package/dist/signature-response-verification.js.map +1 -1
  47. package/dist/signet-contract-events.d.ts +67 -66
  48. package/dist/signet-contract-events.d.ts.map +1 -1
  49. package/dist/signet-contract-events.js +57 -52
  50. package/dist/signet-contract-events.js.map +1 -1
  51. package/dist/signet-evtype2tx-record-decoding.d.ts +18 -0
  52. package/dist/signet-evtype2tx-record-decoding.d.ts.map +1 -0
  53. package/dist/signet-evtype2tx-record-decoding.js +97 -0
  54. package/dist/signet-evtype2tx-record-decoding.js.map +1 -0
  55. package/dist/signet-evtype2tx-requests.d.ts +43 -87
  56. package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
  57. package/dist/signet-evtype2tx-requests.js +59 -130
  58. package/dist/signet-evtype2tx-requests.js.map +1 -1
  59. package/dist/signet-request-id.d.ts +14 -0
  60. package/dist/signet-request-id.d.ts.map +1 -0
  61. package/dist/signet-request-id.js +27 -0
  62. package/dist/signet-request-id.js.map +1 -0
  63. package/dist/signet-request-response-reader.d.ts +34 -56
  64. package/dist/signet-request-response-reader.d.ts.map +1 -1
  65. package/dist/signet-request-response-reader.js +56 -68
  66. package/dist/signet-request-response-reader.js.map +1 -1
  67. package/dist/signet-requests.d.ts +28 -92
  68. package/dist/signet-requests.d.ts.map +1 -1
  69. package/dist/signet-requests.js +39 -141
  70. package/dist/signet-requests.js.map +1 -1
  71. package/dist/testing.d.ts +3 -0
  72. package/dist/testing.d.ts.map +1 -0
  73. package/dist/testing.js +20 -0
  74. package/dist/testing.js.map +1 -0
  75. package/package.json +12 -3
  76. package/src/Signet.compact +149 -198
  77. package/src/circuits.compact +9 -16
  78. package/dist/signature-state-reading.d.ts +0 -43
  79. package/dist/signature-state-reading.d.ts.map +0 -1
  80. package/dist/signature-state-reading.js +0 -74
  81. package/dist/signature-state-reading.js.map +0 -1
  82. package/dist/signet-request-feed.d.ts +0 -126
  83. package/dist/signet-request-feed.d.ts.map +0 -1
  84. package/dist/signet-request-feed.js +0 -216
  85. package/dist/signet-request-feed.js.map +0 -1
@@ -2,13 +2,11 @@
2
2
  //
3
3
  // This belongs in github.com/sig-net/signet.js, kept here until upstreamed.
4
4
  //
5
- // v2.0.0 (COLON-separated) is the only scheme the MPC answers. The v1.0.0
6
- // COMMA-separated form is `key_version 0` in the MPC's KDF and is not served;
7
- // the Compact contracts also assert `keyVersion >= 1`, which selects v2. The
8
- // two schemes hash different strings and derive different accounts, so a
9
- // v1 signer silently gets the wrong address rather than an error.
5
+ // v2.0.0 (COLON-separated) is the only scheme the MPC answers: the Compact
6
+ // contracts assert `keyVersion >= 1`, which selects v2.
10
7
  import { secp256k1 } from "@noble/curves/secp256k1.js";
11
8
  import { computeAddress, keccak256, SigningKey, toUtf8Bytes } from "ethers";
9
+ import { bigintToBytes32BE, bytesToBigintBE, stripHexPrefix } from "./byte-codecs.js";
12
10
  import { SECP256K1_ORDER } from "./ecdsa-attestation.js";
13
11
  /**
14
12
  * Domain prefix of the sig-net v2.0.0 epsilon derivation scheme. The full
@@ -23,42 +21,50 @@ export const EPSILON_DERIVATION_PREFIX = "sig.network v2.0.0 epsilon derivation"
23
21
  export const MIDNIGHT_TESTNET_CHAIN_ID = "midnight:testnet";
24
22
  /**
25
23
  * The FIXED derivation path of the MPC's respond-bidirectional RESPONSE key
26
- * for Midnight client contracts, mirroring the real MPC's per-chain
27
- * `<chain> response key` convention (sig-net/mpc
28
- * chain-signatures/node/src/respond_bidirectional.rs, where the epsilon
29
- * requester is the requesting tx's SENDER). The response key is derived PER
30
- * CLIENT CONTRACT from (the client contract's own address, this path): it is
31
- * not the MPC root key and not the key that signs the requested transaction.
32
- *
33
- * The key depends on the client contract's address, and a Midnight contract
34
- * address is a hash over the deploy (constructor arguments included), so the
35
- * key cannot exist before the deploy transaction is built. Client contracts
36
- * therefore pin its hash with a one-shot `initialise` circuit right after
37
- * deploy (never a constructor seal) and verify RespondBidirectionalEvents
38
- * against the pin.
24
+ * for Midnight client contracts. It enters the derivation string verbatim,
25
+ * mirroring the real MPC's per-chain `<chain> response key` convention
26
+ * (sig-net/mpc chain-signatures/node/src/respond_bidirectional.rs). The
27
+ * response key is derived PER CLIENT CONTRACT from (the client contract's
28
+ * own address, this path): it is not the MPC root key and not the key that
29
+ * signs the requested transaction. Client contracts pin its hash with a
30
+ * one-shot `initialise` circuit after deploy and verify
31
+ * RespondBidirectionalEvents against the pin.
39
32
  */
40
33
  export const MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH = "midnight response key";
34
+ /**
35
+ * Normalise a Midnight contract address for use as the requester component
36
+ * of the derivation string: strip an optional `0x` prefix and lowercase.
37
+ * Both sides of the protocol (the deploy pinning a key and the MPC signing
38
+ * with it) derive through this, so the rendering always agrees.
39
+ *
40
+ * @param contractAddress - The Midnight contract address, with or without `0x`.
41
+ * @returns The address as lowercase hex with no prefix.
42
+ */
43
+ function normaliseRequesterAddress(contractAddress) {
44
+ return stripHexPrefix(contractAddress).toLowerCase();
45
+ }
41
46
  /**
42
47
  * Derive the EVM address the MPC network signs from for a given Midnight
43
48
  * contract and derivation path, using the sig-net v2.0.0 epsilon scheme:
44
- * `epsilon = keccak256("<prefix>:<chainId>:<contractAddress>:<path>")` and
45
- * `derivedPubKey = mpcRootPubKey + epsilon * G` on secp256k1.
46
- *
47
- * The MPC treats `path` as an opaque string: the vault's own account uses the
48
- * literal path `"vault"`, a user's account uses the lowercase hex of their
49
- * identity commitment.
49
+ * `epsilon = keccak256("<prefix>:<chainId>:<requester>:<path>")` and
50
+ * `derivedPubKey = mpcRootPubKey + epsilon * G` on secp256k1. The MPC
51
+ * treats `path` as an opaque string.
50
52
  *
51
53
  * @param mpcSecp256k1PubkeyHex - The MPC root secp256k1 public key as 0x-hex
52
- * (compressed or uncompressed; normalized internally).
54
+ * (compressed or uncompressed, normalised internally).
53
55
  * @param contractAddress - The Midnight contract address the request
54
- * originates from (the "requester" in the derivation string).
55
- * @param path - The derivation path string (e.g. `"vault"` or a commitment
56
- * hex).
56
+ * originates from (`0x` prefix optional, case-insensitive: it enters the
57
+ * derivation string through {@link normaliseRequesterAddress}).
58
+ * @param path - The derivation path string. For an account derived from an
59
+ * on-ledger request record, this is the MPC's rendering of the record's
60
+ * `path: Bytes<32>`: the lowercase hex of the FULL 32 bytes, no `0x`
61
+ * prefix and no trimming ({@link bytesToHex} of the raw bytes), so
62
+ * `0xab..00` and `0xab..` derive different accounts.
57
63
  * @param chainId - CAIP-2 chain id component of the derivation string.
58
64
  * @returns The derived EVM address as a 0x-prefixed EIP-55 checksummed string.
59
65
  */
60
66
  export function deriveEvmAddress(mpcSecp256k1PubkeyHex, contractAddress, path, chainId = MIDNIGHT_TESTNET_CHAIN_ID) {
61
- const derivedPoint = deriveChildPoint(mpcSecp256k1PubkeyHex, contractAddress, path, chainId);
67
+ const derivedPoint = deriveChildPoint(mpcSecp256k1PubkeyHex, normaliseRequesterAddress(contractAddress), path, chainId);
62
68
  return computeAddress(`0x${derivedPoint.toHex(false)}`);
63
69
  }
64
70
  /**
@@ -79,32 +85,26 @@ export function deriveEpsilon(requester, path, chainId = MIDNIGHT_TESTNET_CHAIN_
79
85
  // server's scalar arithmetic reduces implicitly.
80
86
  return BigInt(keccak256(toUtf8Bytes(fullPath))) % SECP256K1_ORDER;
81
87
  }
82
- /** Derive the child public key as a noble curve point (internal shape). */
88
+ /**
89
+ * Derive the child public key as a noble curve point (internal shape).
90
+ *
91
+ * @param mpcSecp256k1PubkeyHex - The MPC root public key in SEC1 hex.
92
+ * @param requester - The normalised requester address.
93
+ * @param path - The derivation path component.
94
+ * @param chainId - The chain id component.
95
+ * @returns The derived child point on secp256k1.
96
+ */
83
97
  function deriveChildPoint(mpcSecp256k1PubkeyHex, requester, path, chainId) {
84
98
  const epsilon = deriveEpsilon(requester, path, chainId);
85
99
  const rootPubKeyHex = SigningKey.computePublicKey(mpcSecp256k1PubkeyHex, false);
86
100
  const rootPoint = secp256k1.Point.fromHex(rootPubKeyHex.slice(2));
87
101
  return epsilon === 0n ? rootPoint : rootPoint.add(secp256k1.Point.BASE.multiply(epsilon));
88
102
  }
89
- /**
90
- * Normalise a Midnight contract address for use as the requester component
91
- * of the derivation string: strip an optional `0x` prefix and lowercase.
92
- * Both sides of the protocol (the deploy pinning a key and the MPC signing
93
- * with it) derive through this, so the rendering always agrees.
94
- */
95
- function normaliseRequesterAddress(contractAddress) {
96
- const hex = contractAddress.startsWith("0x") || contractAddress.startsWith("0X")
97
- ? contractAddress.slice(2)
98
- : contractAddress;
99
- return hex.toLowerCase();
100
- }
101
103
  /**
102
104
  * Derive the MPC's respond-bidirectional RESPONSE key for one client
103
105
  * contract, public side: what the client pins via its `initialise` circuit
104
- * (`MPC_RESPONSE_KEY`) and what response verification checks against. See
105
- * {@link MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH} for the scheme (the requester
106
- * is the client contract's own address, mirroring the real MPC's
107
- * sender-scoped derivation).
106
+ * and what response verification checks against. See
107
+ * {@link MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH} for the scheme.
108
108
  *
109
109
  * @param mpcSecp256k1PubkeyHex - The MPC root secp256k1 public key as 0x-hex
110
110
  * (compressed or uncompressed).
@@ -120,34 +120,24 @@ export function deriveMidnightResponseKey(mpcSecp256k1PubkeyHex, clientContractA
120
120
  * Derive the MPC's respond-bidirectional RESPONSE key for one client
121
121
  * contract, secret side: `(rootSecret + epsilon) mod n`. MPC-side only
122
122
  * (the fakenet signer, test harnesses): a real client never holds the root
123
- * key. The result feeds `signAttestationDigest` directly.
123
+ * key.
124
124
  *
125
- * @param mpcRootSecretKey - The 32-byte MPC root secret key (big-endian, the
126
- * standard secp256k1 encoding).
125
+ * @param mpcRootSecretKey - The 32-byte MPC root secret key (big-endian).
127
126
  * @param clientContractAddress - The client contract's Midnight address
128
127
  * (`0x` prefix optional, case-insensitive).
129
128
  * @returns The 32-byte response secret key (big-endian).
130
- * @throws Error if the root key is not 32 bytes or the derived scalar is 0.
129
+ * @throws {Error} If the root key is not 32 bytes or the derived scalar is 0.
131
130
  */
132
131
  export function deriveMidnightResponseSecretKey(mpcRootSecretKey, clientContractAddress) {
133
132
  if (mpcRootSecretKey.length !== 32) {
134
- throw new Error(`MPC root secret key must be 32 bytes, got ${mpcRootSecretKey.length}`);
135
- }
136
- let root = 0n;
137
- for (const byte of mpcRootSecretKey) {
138
- root = (root << 8n) | BigInt(byte);
133
+ throw new Error(`MPC root secret key must be 32 bytes, got ${String(mpcRootSecretKey.length)}`);
139
134
  }
135
+ const root = bytesToBigintBE(mpcRootSecretKey);
140
136
  const epsilon = deriveEpsilon(normaliseRequesterAddress(clientContractAddress), MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, MIDNIGHT_TESTNET_CHAIN_ID);
141
137
  const child = (root + epsilon) % SECP256K1_ORDER;
142
138
  if (child === 0n) {
143
139
  throw new Error("derived response secret key is zero (invalid scalar)");
144
140
  }
145
- const out = new Uint8Array(32);
146
- let value = child;
147
- for (let i = 31; i >= 0; i--) {
148
- out[i] = Number(value & 0xffn);
149
- value >>= 8n;
150
- }
151
- return out;
141
+ return bigintToBytes32BE(child);
152
142
  }
153
143
  //# sourceMappingURL=epsilon-derivation.js.map
@@ -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,0EAA0E;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,yEAAyE;AACzE,kEAAkE;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW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./signet-requests.ts";
3
- export * from "./signet-evtype2tx-requests.ts";
4
- export * from "./signature-state-reading.ts";
2
+ export { bigintToBytes32, bigintToBytes32BE, BLS_ORDER, bytesToBigint, bytesToBigintBE, bytesToHex, hexToBytes, stripHexPrefix, } from "./byte-codecs.ts";
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";
5
+ export { type RawContractState, signetFieldNodeByPath } from "./raw-contract-state.ts";
5
6
  export * from "./signature-requests-state-reader.ts";
6
- export * from "./signet-contract-events.ts";
7
7
  export * from "./signature-response-verification.ts";
8
+ export * from "./signet-contract-events.ts";
9
+ export { abiWordToBool, abiWordToUint128, assembleCalldata, boolAbiWord, type EvmAccessListEntry, evmAddressAbiWord, type EvmCalldata, type EvmType2TxParams, numericAbiWord, signBidirectionalEventToSignedEvmTransaction, signBidirectionalEventToUnsignedEvmTransaction, } from "./signet-evtype2tx-requests.ts";
10
+ export { calculateRequestId } from "./signet-request-id.ts";
8
11
  export * from "./signet-request-response-reader.ts";
9
- export * from "./signet-request-feed.ts";
10
- export * from "./constants.ts";
11
- export * from "./epsilon-derivation.ts";
12
- export * from "./ecdsa-attestation.ts";
12
+ export { type ContractAddress, 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
14
  /**
14
15
  * Compiled pure circuits of Signet.compact (run `yarn compile` first).
15
16
  * Off-chain code MUST use these instead of re-porting the algorithms:
16
17
  * they are the same compiled logic the contracts prove.
17
18
  */
18
- export { pureCircuits, type PureCircuits } from "./managed/contract/index.js";
19
+ export { type PureCircuits, pureCircuits } from "./managed/contract/index.js";
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AAEvC;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
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,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,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -2,17 +2,26 @@
2
2
  // library (wire structs, state readers, event decoders, request feed,
3
3
  // crypto) plus the compiled pure circuits of the shared Compact module.
4
4
  export * from "./abi-serde.js";
5
- export * from "./signet-requests.js";
6
- export * from "./signet-evtype2tx-requests.js";
7
- export * from "./signature-state-reading.js";
5
+ export { bigintToBytes32, bigintToBytes32BE, BLS_ORDER, bytesToBigint, bytesToBigintBE, bytesToHex, hexToBytes, stripHexPrefix, } from "./byte-codecs.js";
6
+ // Explicit lists for the request/state modules: the runtime descriptor
7
+ // toolkit (compact-descriptors.ts and the per-module record descriptors) is
8
+ // package-internal, consumed only through the reader and request functions.
9
+ export * from "./constants.js";
10
+ // Selective: deriveMidnightResponseSecretKey takes the MPC root secret, so
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";
13
+ export { signetFieldNodeByPath } from "./raw-contract-state.js";
8
14
  export * from "./signature-requests-state-reader.js";
9
- export * from "./signet-contract-events.js";
10
15
  export * from "./signature-response-verification.js";
16
+ export * from "./signet-contract-events.js";
17
+ export { abiWordToBool, abiWordToUint128, assembleCalldata, boolAbiWord, evmAddressAbiWord, numericAbiWord, signBidirectionalEventToSignedEvmTransaction, signBidirectionalEventToUnsignedEvmTransaction, } from "./signet-evtype2tx-requests.js";
18
+ export { calculateRequestId } from "./signet-request-id.js";
11
19
  export * from "./signet-request-response-reader.js";
12
- export * from "./signet-request-feed.js";
13
- export * from "./constants.js";
14
- export * from "./epsilon-derivation.js";
15
- export * from "./ecdsa-attestation.js";
20
+ export { MPCDestination, MPCSignatureAlgorithm, parseRequestIdHex, PATH_BYTES, requestIdBytes, requestIdHex, toSignBidirectionalEventIndex, TxParamType, } from "./signet-requests.js";
21
+ // Explicit list: ecdsa-attestation.ts also backs the ./testing entry point
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";
16
25
  /**
17
26
  * Compiled pure circuits of Signet.compact (run `yarn compile` first).
18
27
  * 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,cAA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AACpD,OAAO,EAGL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EAEV,cAAc,EAEd,YAAY,EAIZ,6BAA6B,EAC7B,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EAEf,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EAAqB,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
@@ -64,28 +64,6 @@
64
64
  ]
65
65
  }
66
66
  },
67
- {
68
- "name": "signetKeyHash",
69
- "pure": true,
70
- "proof": false,
71
- "arguments": [
72
- {
73
- "name": "pk",
74
- "type": {
75
- "type-name": "Alias",
76
- "name": "Secp256k1Point",
77
- "type": {
78
- "type-name": "Opaque",
79
- "tsType": "Secp256k1Point"
80
- }
81
- }
82
- }
83
- ],
84
- "result-type": {
85
- "type-name": "Bytes",
86
- "length": 32
87
- }
88
- },
89
67
  {
90
68
  "name": "evmAddressAbiWord",
91
69
  "pure": true,
@@ -7,26 +7,26 @@
7
7
  "type": "directory",
8
8
  "contract-info.json": {
9
9
  "type": "file",
10
- "size": 8200,
11
- "hash": "07a63a0b166c651d4f9eb662029bacc81b0825311959ac67405d3996c064a84c"
10
+ "size": 7740,
11
+ "hash": "90cf4d016fbbcfae53716bb2849b230df5593d2d0e3c63cf7b0eea54a4c7b429"
12
12
  }
13
13
  },
14
14
  "contract": {
15
15
  "type": "directory",
16
16
  "index.d.ts": {
17
17
  "type": "file",
18
- "size": 6518,
19
- "hash": "9c63efc21d21c87c4a1989454c35158c8d783fd86131a5697edfd5e8f9db4bba"
18
+ "size": 6274,
19
+ "hash": "a8033193fc158fb0432c3636d04670db812a2ba97c22f5e669ae77e4d3dac0cd"
20
20
  },
21
21
  "index.js": {
22
22
  "type": "file",
23
- "size": 49867,
24
- "hash": "4f294b5e0d827b405d7fdd753e9558fea009b16fb4a4e47d326d8a38138c0163"
23
+ "size": 38481,
24
+ "hash": "b9a95365410dd59527b651a0b6c4f96b464667f6bd3d0f30bb3f393a2d2a9e3d"
25
25
  },
26
26
  "index.js.map": {
27
27
  "type": "file",
28
- "size": 4763,
29
- "hash": "c80856dbfdbcf04032a19bca94b6273a537ddea36bb4c3102d3f8fe9bce52359"
28
+ "size": 4291,
29
+ "hash": "813db2ccfb2cc310777b361899a7213f2734aea8e09566072e5aaa30380e2b80"
30
30
  }
31
31
  }
32
32
  }
@@ -16,7 +16,6 @@ export type PureCircuits = {
16
16
  requestsPath_0: bigint[]): { version: bigint,
17
17
  payload: Uint8Array
18
18
  };
19
- signetKeyHash(pk_0: __compactRuntime.Secp256k1Point): Uint8Array;
20
19
  evmAddressAbiWord(addr_0: Uint8Array): Uint8Array;
21
20
  numericAbiWord(value_0: bigint): Uint8Array;
22
21
  boolAbiWord(value_0: boolean): Uint8Array;
@@ -48,8 +47,6 @@ export type Circuits<PS> = {
48
47
  requestsPath_0: bigint[]): Promise<__compactRuntime.CircuitResults<PS, { version: bigint,
49
48
  payload: Uint8Array
50
49
  }>>;
51
- signetKeyHash(context: __compactRuntime.CircuitContext<PS>,
52
- pk_0: __compactRuntime.Secp256k1Point): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
53
50
  evmAddressAbiWord(context: __compactRuntime.CircuitContext<PS>,
54
51
  addr_0: Uint8Array): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;
55
52
  numericAbiWord(context: __compactRuntime.CircuitContext<PS>, value_0: bigint): Promise<__compactRuntime.CircuitResults<PS, Uint8Array>>;