@sig-net/midnight 0.27.0-rc.3 → 0.27.0-rc.5
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/README.md +4 -3
- package/dist/abi-serde.d.ts +18 -0
- package/dist/abi-serde.d.ts.map +1 -1
- package/dist/abi-serde.js +28 -0
- package/dist/abi-serde.js.map +1 -1
- package/dist/compact-descriptors.d.ts +6 -5
- package/dist/compact-descriptors.d.ts.map +1 -1
- package/dist/compact-descriptors.js +4 -4
- package/dist/compact-descriptors.js.map +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/ecdsa-attestation.d.ts +2 -1
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +4 -1
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/epsilon-derivation.d.ts +8 -8
- package/dist/epsilon-derivation.js +7 -7
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +181 -0
- package/dist/managed/compiler/contract-manifest.json +16 -8
- package/dist/managed/contract/index.d.ts +48 -0
- package/dist/managed/contract/index.js +561 -349
- package/dist/managed/contract/index.js.map +2 -2
- package/dist/managed/zkir/assertTronExpirationWindowV1.zkir +63 -0
- package/dist/signature-requests-state-reader.d.ts +16 -10
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +31 -13
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +52 -7
- package/dist/signature-response-verification.d.ts.map +1 -1
- package/dist/signature-response-verification.js +63 -13
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-events.d.ts +1 -1
- package/dist/signet-request-id.js +3 -3
- package/dist/signet-request-id.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +112 -34
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +279 -96
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +9 -5
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +6 -2
- package/dist/signet-requests.js.map +1 -1
- package/dist/signet-tron-record-decoding.d.ts +2 -0
- package/dist/signet-tron-record-decoding.d.ts.map +1 -1
- package/dist/signet-tron-record-decoding.js +2 -0
- package/dist/signet-tron-record-decoding.js.map +1 -1
- package/dist/signet-tron-requests.d.ts +7 -3
- package/dist/signet-tron-requests.d.ts.map +1 -1
- package/dist/signet-tron-requests.js +6 -2
- package/dist/signet-tron-requests.js.map +1 -1
- package/dist/tron-node-api.d.ts +83 -0
- package/dist/tron-node-api.d.ts.map +1 -0
- package/dist/tron-node-api.js +134 -0
- package/dist/tron-node-api.js.map +1 -0
- package/dist/tron-transactions.d.ts +38 -1
- package/dist/tron-transactions.d.ts.map +1 -1
- package/dist/tron-transactions.js +35 -0
- package/dist/tron-transactions.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +79 -10
- package/src/circuits.compact +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tron-transactions.js","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,4CAA4C,GAE7C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"tron-transactions.js","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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CAAC;IACvF,MAAM,GAAG,GAAG,uBAAuB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACnE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAe;IAC/C,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAe,EAAE,SAAuB;IACjF,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;QACrC,GAAG,iBAAiB,CAAC,CAAC,CAAC;QACvB,GAAG,iBAAiB,CAAC,CAAC,CAAC;QACvB,UAAU;KACX,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,IAAI,CAAC;QACrB,GAAG,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC;QAC/B,GAAG,oBAAoB,CAAC,CAAC,EAAE,cAAc,CAAC;KAC3C,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight",
|
|
3
|
-
"version": "0.27.0-rc.
|
|
3
|
+
"version": "0.27.0-rc.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@midnight-ntwrk/compact-runtime": "0.21.0",
|
|
50
50
|
"@midnight-ntwrk/midnight-js-types": "5.0.0",
|
|
51
51
|
"@noble/curves": "^2.2.0",
|
|
52
|
-
"@sig-net/midnight-serde": "^0.27.0-rc.
|
|
52
|
+
"@sig-net/midnight-serde": "^0.27.0-rc.5",
|
|
53
53
|
"ethers": "^6.17.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -93,7 +93,7 @@ module Signet {
|
|
|
93
93
|
|
|
94
94
|
// MPC Key Derivation Parameters.
|
|
95
95
|
// Every key the MPC signs with is scoped by the requesting contract:
|
|
96
|
-
// derivedSigningKey = f(mpcRootKey
|
|
96
|
+
// derivedSigningKey = f(mpcRootKey, keyVersion, caip2ChainId, sender, hex::encode(path))
|
|
97
97
|
// where caip2ChainId is the CAIP-2 id of the ORIGINATING chain (the Midnight
|
|
98
98
|
// variant for requests made from Midnight contracts), not this record's target
|
|
99
99
|
// executionDest. The path is 32 opaque bytes of the client contract's choosing (e.g. a
|
|
@@ -103,7 +103,7 @@ module Signet {
|
|
|
103
103
|
// CRITICAL: the MPC renders the path as hex::encode(path) for key derivation (lowercase hex
|
|
104
104
|
// of the full 32 bytes, no trimming, no 0x prefix). The sender is always part
|
|
105
105
|
// of the derivation, so no contract can reach another contract's derived keys.
|
|
106
|
-
keyVersion: Uint<8>; //
|
|
106
|
+
keyVersion: Uint<8>; // Version of the MPC signing keys. Always 1.
|
|
107
107
|
sender: ContractAddress; // Address of the client contract that stores and notifies of this
|
|
108
108
|
// request. Set with kernel.self().
|
|
109
109
|
path: Bytes<32>; // Key derivation path: 32 opaque bytes, client contract's choice.
|
|
@@ -178,7 +178,8 @@ module Signet {
|
|
|
178
178
|
params: Bytes<64>,
|
|
179
179
|
outputDeserializationSchema: Bytes<LenOutputDeserialization>,
|
|
180
180
|
): SignBidirectionalEventV1<TxParams, LenOutputDeserialization, 0> {
|
|
181
|
-
|
|
181
|
+
// 1 is the latest version the MPC supports, and it drops a request naming any other.
|
|
182
|
+
assert(keyVersion == 1, "keyVersion must be 1");
|
|
182
183
|
assert(signatureDest == MPCDestination.unused, "signatureDest must be unused");
|
|
183
184
|
assert(params == default<Bytes<64>>, "params must be zero");
|
|
184
185
|
// The protocol reserves the "midnight response key" path for the MPC's
|
|
@@ -344,7 +345,7 @@ module Signet {
|
|
|
344
345
|
// mpcResponseKey is derived like request signing keys, with the path set to the
|
|
345
346
|
// fixed "midnight response key" (a protocol string that enters the derivation
|
|
346
347
|
// verbatim, unlike a request's hex-encoded 32 path bytes):
|
|
347
|
-
// mpcResponseKey = f(mpcRootKey
|
|
348
|
+
// mpcResponseKey = f(mpcRootKey, keyVersion, caip2ChainId, sender, "midnight response key")
|
|
348
349
|
//
|
|
349
350
|
// The output travels off chain. The event carries everything the digest is
|
|
350
351
|
// computed from, so its signature checks without the output
|
|
@@ -371,9 +372,9 @@ module Signet {
|
|
|
371
372
|
// calculateAttestedOutputHashV1 of the serialised output, signed into the
|
|
372
373
|
// digest.
|
|
373
374
|
outputHash: Bytes<32>;
|
|
374
|
-
// The attestation digest the signature is over (calculateSignetAttestationDigestV1)
|
|
375
|
-
//
|
|
376
|
-
//
|
|
375
|
+
// The attestation digest the signature is over (calculateSignetAttestationDigestV1).
|
|
376
|
+
// The verifying circuits recompute it from the fields above and refuse an
|
|
377
|
+
// event whose copy differs.
|
|
377
378
|
digest: Bytes<32>;
|
|
378
379
|
// The MPC's ECDSA signature over the attestation digest.
|
|
379
380
|
signature: Signature;
|
|
@@ -420,8 +421,8 @@ module Signet {
|
|
|
420
421
|
|
|
421
422
|
// Verifies a RespondBidirectionalEvent's signature against the MPC response
|
|
422
423
|
// key, without the output: recomputes the digest from the event's request
|
|
423
|
-
// id, block height, output kind, output length and output hash
|
|
424
|
-
// digest field
|
|
424
|
+
// id, block height, output kind, output length and output hash, and
|
|
425
|
+
// requires the event's digest field to equal it. A true result proves the MPC attested this
|
|
425
426
|
// outcome for this request, and an output the event carries only as its
|
|
426
427
|
// length and hash: a client that consumes output bytes checks them against
|
|
427
428
|
// that length and hash with verifyAttestedOutputV1, or verifies with
|
|
@@ -454,7 +455,7 @@ module Signet {
|
|
|
454
455
|
|
|
455
456
|
// secp256k1EcdsaVerify aborts on the identity point, so the key check
|
|
456
457
|
// must short-circuit before it.
|
|
457
|
-
|
|
458
|
+
const signed = mpcResponseKey != default<Secp256k1Point> && secp256k1EcdsaVerify(
|
|
458
459
|
digest,
|
|
459
460
|
Secp256k1EcdsaSignature {
|
|
460
461
|
r: respondBidirectionalEvent.signature.bigR.x as Secp256k1Scalar,
|
|
@@ -462,6 +463,7 @@ module Signet {
|
|
|
462
463
|
},
|
|
463
464
|
mpcResponseKey
|
|
464
465
|
);
|
|
466
|
+
return respondBidirectionalEvent.digest == digest && signed;
|
|
465
467
|
}
|
|
466
468
|
|
|
467
469
|
// Whether serializedOutput is the output an attestation declares: its width
|
|
@@ -749,6 +751,73 @@ module Signet {
|
|
|
749
751
|
return calculateRequestIdV1(preimage);
|
|
750
752
|
}
|
|
751
753
|
|
|
754
|
+
// ---- Tron admission checks -------------------------------------------------------------------------
|
|
755
|
+
// The MPC drops a Tron request it cannot encode or whose validity window it does not admit at the
|
|
756
|
+
// source block (the block of the transaction that notifies it), and a dropped request is never
|
|
757
|
+
// answered: no signature and no attestation, so nothing can settle it. A client contract runs these
|
|
758
|
+
// checks so that such a request is refused on Midnight instead.
|
|
759
|
+
|
|
760
|
+
// The largest value of Tron's int64 wire fields (timestamp, expiration, fee_limit, call_value).
|
|
761
|
+
export pure circuit tronInt64Max(): Uint<64> {
|
|
762
|
+
return 9223372036854775807;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// The longest validity window the MPC admits, in seconds: an expiration at most 24 h past the
|
|
766
|
+
// source block, java-tron's own cap.
|
|
767
|
+
export pure circuit tronMaxExpirationSpanSeconds(): Uint<64> {
|
|
768
|
+
return 86400;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Asserts every numeric field fits its int64 wire field, which the MPC needs to encode the
|
|
772
|
+
// transaction, and that the transaction expires after its own timestamp.
|
|
773
|
+
export pure circuit assertTronTxParamsV1<#maxCalldataWords>(
|
|
774
|
+
txParams: TronTxParams<maxCalldataWords>
|
|
775
|
+
): [] {
|
|
776
|
+
assert(txParams.timestamp <= tronInt64Max(), "Tron timestamp exceeds int64");
|
|
777
|
+
assert(txParams.expiration <= tronInt64Max(), "Tron expiration exceeds int64");
|
|
778
|
+
assert(txParams.feeLimit <= tronInt64Max(), "Tron fee limit exceeds int64");
|
|
779
|
+
assert(txParams.callValue <= tronInt64Max(), "Tron call value exceeds int64");
|
|
780
|
+
assert(txParams.expiration > txParams.timestamp, "Tron expiration must follow its timestamp");
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// Asserts the MPC admits a transaction expiring at `expiration` (milliseconds) from a request this
|
|
784
|
+
// block notifies: the window must still be open at the block time and close within the 24 h cap,
|
|
785
|
+
// with the caller's margins in seconds on both sides. The MPC reads the block time in whole
|
|
786
|
+
// seconds, and so does the ledger, so the checks compare whole seconds: `expirationSeconds` must
|
|
787
|
+
// be floor(expiration / 1000), which Compact cannot divide, so the caller computes it (a witness)
|
|
788
|
+
// and this circuit asserts it. Passing makes the expiration at least
|
|
789
|
+
// (minRemainingSeconds + 1) s after the block time and at least capMarginSeconds s inside the cap.
|
|
790
|
+
// The block time is the ledger's at the including block, not the prover's, so a transaction that
|
|
791
|
+
// passed here when proved fails if its block comes too late or too early.
|
|
792
|
+
export circuit assertTronExpirationWindowV1(
|
|
793
|
+
expiration: Uint<64>,
|
|
794
|
+
expirationSeconds: Uint<64>,
|
|
795
|
+
minRemainingSeconds: Uint<64>,
|
|
796
|
+
capMarginSeconds: Uint<64>
|
|
797
|
+
): [] {
|
|
798
|
+
// The block-time comparisons disclose their bounds, so every input is disclosed: a request
|
|
799
|
+
// publishes its expiration anyway.
|
|
800
|
+
const ms = disclose(expiration);
|
|
801
|
+
const seconds = disclose(expirationSeconds);
|
|
802
|
+
const minRemaining = disclose(minRemainingSeconds);
|
|
803
|
+
assert(
|
|
804
|
+
seconds * 1000 <= ms && ms < seconds * 1000 + 1000,
|
|
805
|
+
"expirationSeconds is not the expiration in whole seconds"
|
|
806
|
+
);
|
|
807
|
+
// Block time < seconds - minRemaining.
|
|
808
|
+
assert(
|
|
809
|
+
seconds > minRemaining && blockTimeLt((seconds - minRemaining) as Uint<64>),
|
|
810
|
+
"Tron expiration too close to the block time"
|
|
811
|
+
);
|
|
812
|
+
// Block time >= seconds + 1 + capMargin - 24 h; trivially so when that is <= 0.
|
|
813
|
+
const earliest = seconds + 1 + disclose(capMarginSeconds);
|
|
814
|
+
assert(
|
|
815
|
+
earliest <= tronMaxExpirationSpanSeconds() ||
|
|
816
|
+
blockTimeGte((earliest - tronMaxExpirationSpanSeconds()) as Uint<64>),
|
|
817
|
+
"Tron expiration too far past the block time"
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
|
|
752
821
|
// ---- ABI Calldata Word Construction Utilities ------------------------------------------------------
|
|
753
822
|
// Canonical ABI word builders and readers. Words MUST be stored in canonical
|
|
754
823
|
// ABI form (big-endian, per the ABI spec). These utilities help construct
|
package/src/circuits.compact
CHANGED
|
@@ -18,6 +18,9 @@ export {
|
|
|
18
18
|
ethereumCaip2Id,
|
|
19
19
|
tronCaip2Id,
|
|
20
20
|
tronAddress,
|
|
21
|
+
tronInt64Max,
|
|
22
|
+
tronMaxExpirationSpanSeconds,
|
|
23
|
+
assertTronExpirationWindowV1,
|
|
21
24
|
evmAddressAbiWord,
|
|
22
25
|
numericAbiWord,
|
|
23
26
|
boolAbiWord,
|
|
@@ -192,3 +195,9 @@ export pure circuit calculateTronRequestIdV1_2_34(
|
|
|
192
195
|
): RequestId {
|
|
193
196
|
return calculateTronRequestIdV1<2, 34>(request);
|
|
194
197
|
}
|
|
198
|
+
|
|
199
|
+
// The Tron admission checks a client contract runs before notifying the MPC, at the 2-word
|
|
200
|
+
// calldata capacity of an ERC20-style transfer (tests only, like the oracles above).
|
|
201
|
+
export pure circuit assertTronTxParamsV1_2(txParams: TronTxParams<2>): [] {
|
|
202
|
+
assertTronTxParamsV1<2>(txParams);
|
|
203
|
+
}
|