@sig-net/midnight 0.16.0 → 0.17.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.
- package/README.md +2 -2
- package/dist/managed/compiler/contract-manifest.json +2 -2
- package/dist/managed/contract/index.js +31 -31
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +4 -22
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +4 -49
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signet-contract-events.d.ts +22 -17
- package/dist/signet-contract-events.d.ts.map +1 -1
- package/dist/signet-contract-events.js +14 -8
- package/dist/signet-contract-events.js.map +1 -1
- package/dist/signet-request-feed.d.ts +23 -20
- package/dist/signet-request-feed.d.ts.map +1 -1
- package/dist/signet-request-feed.js +81 -60
- package/dist/signet-request-feed.js.map +1 -1
- package/dist/signet-request-response-reader.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +4 -2
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ Set up your contract for integration with the Sig Network MPC's sign bidirection
|
|
|
96
96
|
|
|
97
97
|
Compile with the pinned toolchain (currently `compact update 0.33.0-rc.2`), and always pass `--feature-zkir-v3`. Compiled output without that flag is not compatible with the ledger-9 matched stack (node, indexer, proof server).
|
|
98
98
|
|
|
99
|
-
2. Declare the required Sig Network protocol state in your ledger, plus the recommended deployer identity and initialisation state. The event map can sit at ANY ledger field. Each notification that your contract emits carries the map's resolved ledger-tree path (see [The request map's ledger-tree path](#the-request-maps-ledger-tree-path)), and the MPC
|
|
99
|
+
2. Declare the required Sig Network protocol state in your ledger, plus the recommended deployer identity and initialisation state. The event map can sit at ANY ledger field. Each notification that your contract emits declares the stored request's id and carries the map's resolved ledger-tree path (see [The request map's ledger-tree path](#the-request-maps-ledger-tree-path)), and the MPC looks the authenticated request up there by that id.
|
|
100
100
|
|
|
101
101
|
```compact
|
|
102
102
|
// Required: Map of SignBidirectionalEvent signature requests, configured by transaction type.
|
|
@@ -371,7 +371,7 @@ What clients import from `@sig-net/midnight`:
|
|
|
371
371
|
| Convert a foreign execution output into respond bytes | `deserializeEvmOutput` (raw EVM return data to named values) and `serializeRespondOutput` (named values to the packed respond payload the MPC attests): together they rebuild the `serializedOutput` of steps 4 and 5. |
|
|
372
372
|
| Recognise a failed remote execution | `MPC_FAILURE_OUTPUT` and `isMpcFailureOutput`: the MPC's fixed 5-byte failure payload for reverted or replaced transactions. |
|
|
373
373
|
| Verify attestations without the reader | `calculateSignetAttestationDigest` and `verifyRespondBidirectionalSignature`: the checks the reader runs internally, exposed for custom pipelines. |
|
|
374
|
-
| Discover requests MPC-side (responders, background workers) | `SignetRequestFeed`: polls the signet contract's emitted notification events,
|
|
374
|
+
| Discover requests MPC-side (responders, background workers) | `SignetRequestFeed`: polls the signet contract's emitted notification events, looks each declared request id up in the named caller's own request map (the authenticated read), and dedupes by request id. |
|
|
375
375
|
| Call the compiled protocol circuits | `pureCircuits`: the compiled circuits of `Signet.compact`, for example the notification packer. Off-chain code calls these compiled artefacts, so it always agrees with what the contracts prove. |
|
|
376
376
|
|
|
377
377
|
## More examples
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"index.js": {
|
|
22
22
|
"type": "file",
|
|
23
23
|
"size": 49867,
|
|
24
|
-
"hash": "
|
|
24
|
+
"hash": "4f294b5e0d827b405d7fdd753e9558fea009b16fb4a4e47d326d8a38138c0163"
|
|
25
25
|
},
|
|
26
26
|
"index.js.map": {
|
|
27
27
|
"type": "file",
|
|
28
28
|
"size": 4763,
|
|
29
|
-
"hash": "
|
|
29
|
+
"hash": "c80856dbfdbcf04032a19bca94b6273a537ddea36bb4c3102d3f8fe9bce52359"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -453,13 +453,13 @@ export class Contract {
|
|
|
453
453
|
32,
|
|
454
454
|
this._reverseBytes32_0(respondBidirectionalEvent_0.signature.bigR.x),
|
|
455
455
|
'Secp256k1Scalar',
|
|
456
|
-
'Signet.compact line
|
|
456
|
+
'Signet.compact line 398 char 12'),
|
|
457
457
|
s:
|
|
458
458
|
__compactRuntime.convertBytesToField(115792089237316195423570985008687907852837564279074904382605163141518161494336n,
|
|
459
459
|
32,
|
|
460
460
|
this._reverseBytes32_0(respondBidirectionalEvent_0.signature.s),
|
|
461
461
|
'Secp256k1Scalar',
|
|
462
|
-
'Signet.compact line
|
|
462
|
+
'Signet.compact line 399 char 12') },
|
|
463
463
|
mpcResponseKey_0);
|
|
464
464
|
}
|
|
465
465
|
_signetKeyHash_0(pk_0) { return this._persistentHash_0(pk_0); }
|
|
@@ -471,7 +471,7 @@ export class Contract {
|
|
|
471
471
|
_numericAbiWord_0(value_0) {
|
|
472
472
|
const le_0 = Array.from(__compactRuntime.convertBigintToBytes(16,
|
|
473
473
|
value_0,
|
|
474
|
-
'Signet.compact line
|
|
474
|
+
'Signet.compact line 480 char 17'),
|
|
475
475
|
BigInt);
|
|
476
476
|
return Uint8Array.from([...Array.from(new Uint8Array(16), BigInt),
|
|
477
477
|
le_0[15],
|
|
@@ -503,7 +503,7 @@ export class Contract {
|
|
|
503
503
|
((e, i) => e.slice(i, i+16))(word_0,
|
|
504
504
|
Number(0n)),
|
|
505
505
|
'Field',
|
|
506
|
-
'Signet.compact line
|
|
506
|
+
'Signet.compact line 499 char 12')
|
|
507
507
|
===
|
|
508
508
|
0n,
|
|
509
509
|
'ABI word exceeds Uint<128>');
|
|
@@ -512,77 +512,77 @@ export class Contract {
|
|
|
512
512
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
513
513
|
Number(16n)),
|
|
514
514
|
'Field',
|
|
515
|
-
'Signet.compact line
|
|
515
|
+
'Signet.compact line 500 char 17');
|
|
516
516
|
const b1_0 = __compactRuntime.addField(__compactRuntime.mulField(b0_0, 256n),
|
|
517
517
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
518
518
|
1,
|
|
519
519
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
520
520
|
Number(17n)),
|
|
521
521
|
'Field',
|
|
522
|
-
'Signet.compact line
|
|
522
|
+
'Signet.compact line 501 char 30'));
|
|
523
523
|
const b2_0 = __compactRuntime.addField(__compactRuntime.mulField(b1_0, 256n),
|
|
524
524
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
525
525
|
1,
|
|
526
526
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
527
527
|
Number(18n)),
|
|
528
528
|
'Field',
|
|
529
|
-
'Signet.compact line
|
|
529
|
+
'Signet.compact line 502 char 30'));
|
|
530
530
|
const b3_0 = __compactRuntime.addField(__compactRuntime.mulField(b2_0, 256n),
|
|
531
531
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
532
532
|
1,
|
|
533
533
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
534
534
|
Number(19n)),
|
|
535
535
|
'Field',
|
|
536
|
-
'Signet.compact line
|
|
536
|
+
'Signet.compact line 503 char 30'));
|
|
537
537
|
const b4_0 = __compactRuntime.addField(__compactRuntime.mulField(b3_0, 256n),
|
|
538
538
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
539
539
|
1,
|
|
540
540
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
541
541
|
Number(20n)),
|
|
542
542
|
'Field',
|
|
543
|
-
'Signet.compact line
|
|
543
|
+
'Signet.compact line 504 char 30'));
|
|
544
544
|
const b5_0 = __compactRuntime.addField(__compactRuntime.mulField(b4_0, 256n),
|
|
545
545
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
546
546
|
1,
|
|
547
547
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
548
548
|
Number(21n)),
|
|
549
549
|
'Field',
|
|
550
|
-
'Signet.compact line
|
|
550
|
+
'Signet.compact line 505 char 30'));
|
|
551
551
|
const b6_0 = __compactRuntime.addField(__compactRuntime.mulField(b5_0, 256n),
|
|
552
552
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
553
553
|
1,
|
|
554
554
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
555
555
|
Number(22n)),
|
|
556
556
|
'Field',
|
|
557
|
-
'Signet.compact line
|
|
557
|
+
'Signet.compact line 506 char 30'));
|
|
558
558
|
const b7_0 = __compactRuntime.addField(__compactRuntime.mulField(b6_0, 256n),
|
|
559
559
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
560
560
|
1,
|
|
561
561
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
562
562
|
Number(23n)),
|
|
563
563
|
'Field',
|
|
564
|
-
'Signet.compact line
|
|
564
|
+
'Signet.compact line 507 char 30'));
|
|
565
565
|
const b8_0 = __compactRuntime.addField(__compactRuntime.mulField(b7_0, 256n),
|
|
566
566
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
567
567
|
1,
|
|
568
568
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
569
569
|
Number(24n)),
|
|
570
570
|
'Field',
|
|
571
|
-
'Signet.compact line
|
|
571
|
+
'Signet.compact line 508 char 30'));
|
|
572
572
|
const b9_0 = __compactRuntime.addField(__compactRuntime.mulField(b8_0, 256n),
|
|
573
573
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
574
574
|
1,
|
|
575
575
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
576
576
|
Number(25n)),
|
|
577
577
|
'Field',
|
|
578
|
-
'Signet.compact line
|
|
578
|
+
'Signet.compact line 509 char 30'));
|
|
579
579
|
const b10_0 = __compactRuntime.addField(__compactRuntime.mulField(b9_0, 256n),
|
|
580
580
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
581
581
|
1,
|
|
582
582
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
583
583
|
Number(26n)),
|
|
584
584
|
'Field',
|
|
585
|
-
'Signet.compact line
|
|
585
|
+
'Signet.compact line 510 char 30'));
|
|
586
586
|
const b11_0 = __compactRuntime.addField(__compactRuntime.mulField(b10_0,
|
|
587
587
|
256n),
|
|
588
588
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
@@ -590,7 +590,7 @@ export class Contract {
|
|
|
590
590
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
591
591
|
Number(27n)),
|
|
592
592
|
'Field',
|
|
593
|
-
'Signet.compact line
|
|
593
|
+
'Signet.compact line 511 char 30'));
|
|
594
594
|
const b12_0 = __compactRuntime.addField(__compactRuntime.mulField(b11_0,
|
|
595
595
|
256n),
|
|
596
596
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
@@ -598,7 +598,7 @@ export class Contract {
|
|
|
598
598
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
599
599
|
Number(28n)),
|
|
600
600
|
'Field',
|
|
601
|
-
'Signet.compact line
|
|
601
|
+
'Signet.compact line 512 char 30'));
|
|
602
602
|
const b13_0 = __compactRuntime.addField(__compactRuntime.mulField(b12_0,
|
|
603
603
|
256n),
|
|
604
604
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
@@ -606,7 +606,7 @@ export class Contract {
|
|
|
606
606
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
607
607
|
Number(29n)),
|
|
608
608
|
'Field',
|
|
609
|
-
'Signet.compact line
|
|
609
|
+
'Signet.compact line 513 char 30'));
|
|
610
610
|
const b14_0 = __compactRuntime.addField(__compactRuntime.mulField(b13_0,
|
|
611
611
|
256n),
|
|
612
612
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
@@ -614,7 +614,7 @@ export class Contract {
|
|
|
614
614
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
615
615
|
Number(30n)),
|
|
616
616
|
'Field',
|
|
617
|
-
'Signet.compact line
|
|
617
|
+
'Signet.compact line 514 char 30'));
|
|
618
618
|
const b15_0 = __compactRuntime.addField(__compactRuntime.mulField(b14_0,
|
|
619
619
|
256n),
|
|
620
620
|
__compactRuntime.convertBytesToUint(52435875175126190479447740508185965837690552500527637822603658699938581184512n,
|
|
@@ -622,10 +622,10 @@ export class Contract {
|
|
|
622
622
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
623
623
|
Number(31n)),
|
|
624
624
|
'Field',
|
|
625
|
-
'Signet.compact line
|
|
625
|
+
'Signet.compact line 515 char 30'));
|
|
626
626
|
return ((t1) => {
|
|
627
627
|
if (t1 > 340282366920938463463374607431768211455n) {
|
|
628
|
-
throw new __compactRuntime.CompactError('Signet.compact line
|
|
628
|
+
throw new __compactRuntime.CompactError('Signet.compact line 516 char 12: cast from Field or Uint value to smaller Uint value failed: ' + t1 + ' is greater than 340282366920938463463374607431768211455');
|
|
629
629
|
}
|
|
630
630
|
return t1;
|
|
631
631
|
})(b15_0);
|
|
@@ -636,7 +636,7 @@ export class Contract {
|
|
|
636
636
|
((e, i) => e.slice(i, i+31))(word_0,
|
|
637
637
|
Number(0n)),
|
|
638
638
|
'Field',
|
|
639
|
-
'Signet.compact line
|
|
639
|
+
'Signet.compact line 522 char 12')
|
|
640
640
|
===
|
|
641
641
|
0n,
|
|
642
642
|
'ABI word is not a canonical Boolean');
|
|
@@ -645,7 +645,7 @@ export class Contract {
|
|
|
645
645
|
((e, i) => e.slice(i, i+1))(word_0,
|
|
646
646
|
Number(31n)),
|
|
647
647
|
'Field',
|
|
648
|
-
'Signet.compact line
|
|
648
|
+
'Signet.compact line 523 char 18');
|
|
649
649
|
__compactRuntime.assert(last_0 === 0n || last_0 === 1n,
|
|
650
650
|
'ABI word is not a canonical Boolean');
|
|
651
651
|
return last_0 === 1n;
|
|
@@ -704,21 +704,21 @@ export const pureCircuits = {
|
|
|
704
704
|
if (!(typeof(callerAddress_0) === 'object' && callerAddress_0.bytes.buffer instanceof ArrayBuffer && callerAddress_0.bytes.BYTES_PER_ELEMENT === 1 && callerAddress_0.bytes.length === 32)) {
|
|
705
705
|
__compactRuntime.typeError('constructSignBidirectionalEventNotificationV1',
|
|
706
706
|
'argument 1',
|
|
707
|
-
'Signet.compact line
|
|
707
|
+
'Signet.compact line 261 char 3',
|
|
708
708
|
'struct ContractAddress<bytes: Bytes<32>>',
|
|
709
709
|
callerAddress_0)
|
|
710
710
|
}
|
|
711
711
|
if (!(typeof(requestsPathDepth_0) === 'bigint' && requestsPathDepth_0 >= 0n && requestsPathDepth_0 <= 255n)) {
|
|
712
712
|
__compactRuntime.typeError('constructSignBidirectionalEventNotificationV1',
|
|
713
713
|
'argument 2',
|
|
714
|
-
'Signet.compact line
|
|
714
|
+
'Signet.compact line 261 char 3',
|
|
715
715
|
'Uint<0..256>',
|
|
716
716
|
requestsPathDepth_0)
|
|
717
717
|
}
|
|
718
718
|
if (!(Array.isArray(requestsPath_0) && requestsPath_0.length === 4 && requestsPath_0.every((t) => typeof(t) === 'bigint' && t >= 0n && t <= 255n))) {
|
|
719
719
|
__compactRuntime.typeError('constructSignBidirectionalEventNotificationV1',
|
|
720
720
|
'argument 3',
|
|
721
|
-
'Signet.compact line
|
|
721
|
+
'Signet.compact line 261 char 3',
|
|
722
722
|
'Vector<4, Uint<0..256>>',
|
|
723
723
|
requestsPath_0)
|
|
724
724
|
}
|
|
@@ -741,7 +741,7 @@ export const pureCircuits = {
|
|
|
741
741
|
if (!(addr_0.buffer instanceof ArrayBuffer && addr_0.BYTES_PER_ELEMENT === 1 && addr_0.length === 20)) {
|
|
742
742
|
__compactRuntime.typeError('evmAddressAbiWord',
|
|
743
743
|
'argument 1',
|
|
744
|
-
'Signet.compact line
|
|
744
|
+
'Signet.compact line 471 char 3',
|
|
745
745
|
'Bytes<20>',
|
|
746
746
|
addr_0)
|
|
747
747
|
}
|
|
@@ -755,7 +755,7 @@ export const pureCircuits = {
|
|
|
755
755
|
if (!(typeof(value_0) === 'bigint' && value_0 >= 0n && value_0 <= 340282366920938463463374607431768211455n)) {
|
|
756
756
|
__compactRuntime.typeError('numericAbiWord',
|
|
757
757
|
'argument 1',
|
|
758
|
-
'Signet.compact line
|
|
758
|
+
'Signet.compact line 477 char 3',
|
|
759
759
|
'Uint<0..340282366920938463463374607431768211456>',
|
|
760
760
|
value_0)
|
|
761
761
|
}
|
|
@@ -769,7 +769,7 @@ export const pureCircuits = {
|
|
|
769
769
|
if (!(typeof(value_0) === 'boolean')) {
|
|
770
770
|
__compactRuntime.typeError('boolAbiWord',
|
|
771
771
|
'argument 1',
|
|
772
|
-
'Signet.compact line
|
|
772
|
+
'Signet.compact line 490 char 3',
|
|
773
773
|
'Boolean',
|
|
774
774
|
value_0)
|
|
775
775
|
}
|
|
@@ -783,7 +783,7 @@ export const pureCircuits = {
|
|
|
783
783
|
if (!(word_0.buffer instanceof ArrayBuffer && word_0.BYTES_PER_ELEMENT === 1 && word_0.length === 32)) {
|
|
784
784
|
__compactRuntime.typeError('abiWordToUint128',
|
|
785
785
|
'argument 1',
|
|
786
|
-
'Signet.compact line
|
|
786
|
+
'Signet.compact line 498 char 3',
|
|
787
787
|
'Bytes<32>',
|
|
788
788
|
word_0)
|
|
789
789
|
}
|
|
@@ -797,7 +797,7 @@ export const pureCircuits = {
|
|
|
797
797
|
if (!(word_0.buffer instanceof ArrayBuffer && word_0.BYTES_PER_ELEMENT === 1 && word_0.length === 32)) {
|
|
798
798
|
__compactRuntime.typeError('abiWordToBool',
|
|
799
799
|
'argument 1',
|
|
800
|
-
'Signet.compact line
|
|
800
|
+
'Signet.compact line 521 char 3',
|
|
801
801
|
'Bytes<32>',
|
|
802
802
|
word_0)
|
|
803
803
|
}
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
"sourceRoot": "../../../",
|
|
5
5
|
"sources": ["src/circuits.compact", "src/./Signet.compact", "compiler/zkir-v3-library.compact"],
|
|
6
6
|
"names": [],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;MCoQE,MAAA,6CAsBC;;OAAA;MA6HD,MAAA,aAEC;;OAAA;MA6DD,MAAA,iBAEC;;OAAA;MAID,MAAA,cASC;;OAAA;MAID,MAAA,WAEC;;OAAA;MAMD,MAAA,gBAmBC;;OAAA;MAID,MAAA,aAKC;;OAAA;MD5eH,MAAA,iCAKC;;OAAA;MAED,MAAA,kCAKC;;OAAA;MAED,MAAA,mCAKC;;OAAA;MAED,MAAA,iCAYC;;OAAA;;;;GACA;EAnED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEC;EEvCD,AAAA,yBAA8B;UACtB,iBAAI;UACJ,gCACQ;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;;;;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AFqC,MAAe;;;;;;;;+CAAf,MAAe;GAEpD;EAID,AAAA,cASC;;;;UATkC,OAAgB;;;;;;;;4CAAhB,OAAgB;GASlD;EAID,AAAA,WAEC;;;;UAF+B,OAAc;;;;;;;;yCAAd,OAAc;GAE7C;EAMD,AAAA,gBAmBC;;;;UAnBoC,MAAe;;;;;;;;8CAAf,MAAe;GAmBnD;EAID,AAAA,aAKC;;;;UALiC,MAAe;;;;;;;;2CAAf,MAAe;GAKhD;ED5eH,AAAA,iCAKC;;;;UAJC,WAAoB;UACpB,kBAA0B;;;;;;;;;;;;;;;+DAD1B,WAAoB;+DACpB,kBAA0B;GAG3B;EAED,AAAA,kCAKC;;;;UAJC,WAAoB;UACpB,kBAA2B;;;;;;;;;;;;;;;gEAD3B,WAAoB;gEACpB,kBAA2B;GAG5B;EAED,AAAA,mCAKC;;;;UAJC,WAAoB;UACpB,kBAA4B;;;;;;;;;;;;;;;iEAD5B,WAAoB;iEACpB,kBAA4B;GAG7B;EAED,AAAA,iCAYC;;;;UAXC,WAAoB;UACpB,kBAA2B;UAC3B,2BAAoD;UACpD,gBAA8B;;;;;;;;;;;;;;;;;;;;;;+DAH9B,WAAoB;+DACpB,kBAA2B;+DAC3B,2BAAoD;+DACpD,gBAA8B;GAQ/B;;;;;;"
|
|
8
8
|
}
|
|
@@ -45,31 +45,13 @@ export interface SignetRequestsLedger {
|
|
|
45
45
|
* record matches no capacity split.
|
|
46
46
|
*/
|
|
47
47
|
export declare function readSignetRequestsLedgerFromState(raw: RawContractState, requestsIndexPath: readonly number[], noncePath: readonly number[]): SignetRequestsLedger;
|
|
48
|
-
/**
|
|
49
|
-
* Enumerate a contract's WHOLE request index at an arbitrary ledger path:
|
|
50
|
-
* the discovery primitive of the event-based feed. A notification event
|
|
51
|
-
* names only the requester contract and the path of its request map, so the
|
|
52
|
-
* MPC enumerates that map and serves what it has not served before: every
|
|
53
|
-
* record here was read from the caller's own authenticated ledger.
|
|
54
|
-
*
|
|
55
|
-
* Fail-closed like {@link lookupSignetRequestAt}: a path out of range, a
|
|
56
|
-
* non-Map node, or an undecodable cell yields an EMPTY (or smaller) index
|
|
57
|
-
* rather than a throw, so a malformed or adversarial notification can never
|
|
58
|
-
* crash the reader.
|
|
59
|
-
*
|
|
60
|
-
* @param raw - Raw contract state, e.g. `queryContractState(address).data`.
|
|
61
|
-
* @param requestsPath - Resolved ledger-tree path of the request index in
|
|
62
|
-
* `raw`, as the notification carries it.
|
|
63
|
-
* @returns The decoded index, keyed by hex request id, empty when the path
|
|
64
|
-
* holds no readable request map.
|
|
65
|
-
*/
|
|
66
|
-
export declare function readSignetRequestIndexAt(raw: RawContractState, requestsPath: readonly number[]): SignBidirectionalEventIndex;
|
|
67
48
|
/**
|
|
68
49
|
* Look up ONE request by id in a contract's request index at an arbitrary
|
|
69
50
|
* ledger field, the single-record sibling of
|
|
70
|
-
* {@link readSignetRequestsLedgerFromState}
|
|
71
|
-
*
|
|
72
|
-
*
|
|
51
|
+
* {@link readSignetRequestsLedgerFromState}: the discovery primitive of the
|
|
52
|
+
* event-based feed and what a point verification uses. A notification
|
|
53
|
+
* declares the stored request's id and names both the requester contract
|
|
54
|
+
* AND which field holds its index.
|
|
73
55
|
*
|
|
74
56
|
* `undefined` means the id is NOT a member of the index at `requestsPath`
|
|
75
57
|
* (the pointer is forged, stale, points at the wrong field, or the request is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-requests-state-reader.d.ts","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AA6F5C;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,aAAa,EAAE,2BAA2B,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,EACrB,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,oBAAoB,CAqBtB;AAED
|
|
1
|
+
{"version":3,"file":"signature-requests-state-reader.d.ts","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AA6F5C;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,aAAa,EAAE,2BAA2B,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,EACrB,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,oBAAoB,CAqBtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gBAAgB,EACrB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,SAAS,EAAE,YAAY,GACtB,sBAAsB,GAAG,SAAS,CA2BpC"}
|
|
@@ -142,58 +142,13 @@ export function readSignetRequestsLedgerFromState(raw, requestsIndexPath, nonceP
|
|
|
142
142
|
const nonce = u64.fromValue([...nonceCell.value]);
|
|
143
143
|
return { nonce, requestsIndex };
|
|
144
144
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Enumerate a contract's WHOLE request index at an arbitrary ledger path:
|
|
147
|
-
* the discovery primitive of the event-based feed. A notification event
|
|
148
|
-
* names only the requester contract and the path of its request map, so the
|
|
149
|
-
* MPC enumerates that map and serves what it has not served before: every
|
|
150
|
-
* record here was read from the caller's own authenticated ledger.
|
|
151
|
-
*
|
|
152
|
-
* Fail-closed like {@link lookupSignetRequestAt}: a path out of range, a
|
|
153
|
-
* non-Map node, or an undecodable cell yields an EMPTY (or smaller) index
|
|
154
|
-
* rather than a throw, so a malformed or adversarial notification can never
|
|
155
|
-
* crash the reader.
|
|
156
|
-
*
|
|
157
|
-
* @param raw - Raw contract state, e.g. `queryContractState(address).data`.
|
|
158
|
-
* @param requestsPath - Resolved ledger-tree path of the request index in
|
|
159
|
-
* `raw`, as the notification carries it.
|
|
160
|
-
* @returns The decoded index, keyed by hex request id, empty when the path
|
|
161
|
-
* holds no readable request map.
|
|
162
|
-
*/
|
|
163
|
-
export function readSignetRequestIndexAt(raw, requestsPath) {
|
|
164
|
-
const index = new Map();
|
|
165
|
-
let node;
|
|
166
|
-
try {
|
|
167
|
-
node = signetFieldNodeByPath(raw, requestsPath);
|
|
168
|
-
}
|
|
169
|
-
catch {
|
|
170
|
-
return index; // path out of range for this contract
|
|
171
|
-
}
|
|
172
|
-
const map = node.asMap();
|
|
173
|
-
if (map === undefined) {
|
|
174
|
-
return index; // the named field is not a request index
|
|
175
|
-
}
|
|
176
|
-
for (const key of map.keys()) {
|
|
177
|
-
// fromValue consumes its input, so hand each descriptor a copy.
|
|
178
|
-
const requestId = requestIdHex(requestIdType.fromValue([...key.value]));
|
|
179
|
-
const cell = map.get(key)?.asCell();
|
|
180
|
-
if (cell === undefined)
|
|
181
|
-
continue;
|
|
182
|
-
try {
|
|
183
|
-
index.set(requestId, decodeSignBidirectionalEvent(cell.value, requestId));
|
|
184
|
-
}
|
|
185
|
-
catch {
|
|
186
|
-
continue; // a cell that is not a decodable request record
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return index;
|
|
190
|
-
}
|
|
191
145
|
/**
|
|
192
146
|
* Look up ONE request by id in a contract's request index at an arbitrary
|
|
193
147
|
* ledger field, the single-record sibling of
|
|
194
|
-
* {@link readSignetRequestsLedgerFromState}
|
|
195
|
-
*
|
|
196
|
-
*
|
|
148
|
+
* {@link readSignetRequestsLedgerFromState}: the discovery primitive of the
|
|
149
|
+
* event-based feed and what a point verification uses. A notification
|
|
150
|
+
* declares the stored request's id and names both the requester contract
|
|
151
|
+
* AND which field holds its index.
|
|
197
152
|
*
|
|
198
153
|
* `undefined` means the id is NOT a member of the index at `requestsPath`
|
|
199
154
|
* (the pointer is forged, stale, points at the wrong field, or the request is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,+EAA+E;AAC/E,yDAAyD;AACzD,uEAAuE;AACvE,yEAAyE;AACzE,uEAAuE;AACvE,8EAA8E;AAC9E,mFAAmF;AACnF,mEAAmE;AACnE,6EAA6E;AAC7E,iCAAiC;AAIjC,OAAO,EACL,kBAAkB,EAClB,gCAAgC,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,YAAY,GAIb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAS,4BAA4B,CACnC,KAAmB,EACnB,iBAA+B;IAE/B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,yBAAyB,CAAC;IAC1D,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC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AAG,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,IAAI,KAAK,SAAS;YAAE,SAAS;QACjC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,4BAA4B,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,SAAS,GAAG,qBAAqB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;IACjE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACrF,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAElD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAClC,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,+EAA+E;AAC/E,yDAAyD;AACzD,uEAAuE;AACvE,yEAAyE;AACzE,uEAAuE;AACvE,8EAA8E;AAC9E,mFAAmF;AACnF,mEAAmE;AACnE,6EAA6E;AAC7E,iCAAiC;AAIjC,OAAO,EACL,kBAAkB,EAClB,gCAAgC,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,YAAY,GAIb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM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AC,sCAAsC;IAC1D,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IACzB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,CAAC,yCAAyC;IAC7D,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,gEAAgE;QAChE,IAAI,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACxE,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,4BAA4B,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC,CAAC,gDAAgD;QACpE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,2BAA2B;AAC/C,CAAC"}
|
|
@@ -132,7 +132,7 @@ export interface MpcSignature {
|
|
|
132
132
|
* The MPC's signature over the requested EVM transaction (Compact
|
|
133
133
|
* `SignatureRespondedEvent`): decode to an ethers signature with
|
|
134
134
|
* `signatureRespondedEventToSignature`. The emitting event carries the
|
|
135
|
-
* record beside the request id it answers (see {@link
|
|
135
|
+
* record beside the request id it answers (see {@link SignetEventPost});
|
|
136
136
|
* the id routes, and VERIFYING the signature against the transaction the
|
|
137
137
|
* request describes establishes authenticity (see
|
|
138
138
|
* {@link SignetRequestResponseReader.getVerifiedSignatureRespondedEvent}).
|
|
@@ -148,7 +148,7 @@ export interface SignatureRespondedEvent {
|
|
|
148
148
|
* digest and the output travel off chain: readers fetch the output, recompute
|
|
149
149
|
* the digest (`calculateSignetAttestationDigest`) and verify the signature
|
|
150
150
|
* over it. Emitted UNVERIFIED by the signet contract, beside the request id
|
|
151
|
-
* it answers (see {@link
|
|
151
|
+
* it answers (see {@link SignetEventPost}), so that signature check
|
|
152
152
|
* against the expected MPC response key is the only thing separating a
|
|
153
153
|
* genuine post from garbage: in-circuit via
|
|
154
154
|
* `verifyRespondBidirectionalEvent`, off chain via
|
|
@@ -159,15 +159,18 @@ export interface RespondBidirectionalEvent {
|
|
|
159
159
|
signature: MpcSignature;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* A decoded
|
|
162
|
+
* A decoded signet event payload: the request id the emitting circuit
|
|
163
163
|
* disclosed beside the posted record. The id is UNAUTHENTICATED routing
|
|
164
|
-
* data: it scopes reads to one request and proves nothing.
|
|
165
|
-
* record's signature against the request remains the
|
|
166
|
-
* (see
|
|
167
|
-
*
|
|
164
|
+
* data: it scopes reads to one request and proves nothing. For the respond
|
|
165
|
+
* events, verifying the record's signature against the request remains the
|
|
166
|
+
* authenticity check (see
|
|
167
|
+
* {@link SignetRequestResponseReader.getVerifiedSignatureRespondedEvent} and
|
|
168
|
+
* {@link SignetRequestResponseReader.getVerifiedRespondBidirectionalEvent});
|
|
169
|
+
* for the notification, reading the declared request back from the named
|
|
170
|
+
* caller's own ledger does (see signet-request-feed.ts).
|
|
168
171
|
*/
|
|
169
|
-
export interface
|
|
170
|
-
/** The request id the post declares it
|
|
172
|
+
export interface SignetEventPost<TRecord> {
|
|
173
|
+
/** The request id the post declares it concerns, 32 bytes. Routing data only. */
|
|
171
174
|
requestId: Uint8Array;
|
|
172
175
|
/** The posted record, verbatim. */
|
|
173
176
|
event: TRecord;
|
|
@@ -180,7 +183,7 @@ export interface SignetRespondPost<TRecord> {
|
|
|
180
183
|
* @returns The decoded post: declared request id plus record.
|
|
181
184
|
* @throws Error when the payload is too short to hold the packed leaves.
|
|
182
185
|
*/
|
|
183
|
-
export declare function decodeSignatureRespondedEventPayload(payload: Uint8Array):
|
|
186
|
+
export declare function decodeSignatureRespondedEventPayload(payload: Uint8Array): SignetEventPost<SignatureRespondedEvent>;
|
|
184
187
|
/**
|
|
185
188
|
* Decode a {@link SignetEventName.RespondBidirectionalEvent} payload: the
|
|
186
189
|
* decode twin of the `respondBidirectional` circuit's emit literal.
|
|
@@ -189,7 +192,7 @@ export declare function decodeSignatureRespondedEventPayload(payload: Uint8Array
|
|
|
189
192
|
* @returns The decoded post: declared request id plus record.
|
|
190
193
|
* @throws Error when the payload is too short to hold the packed leaves.
|
|
191
194
|
*/
|
|
192
|
-
export declare function decodeRespondBidirectionalEventPayload(payload: Uint8Array):
|
|
195
|
+
export declare function decodeRespondBidirectionalEventPayload(payload: Uint8Array): SignetEventPost<RespondBidirectionalEvent>;
|
|
193
196
|
/**
|
|
194
197
|
* Raw twin of the Compact `SignBidirectionalEventNotification` struct as the
|
|
195
198
|
* `signBidirectional` circuit emits it: the version tag plus the still-packed
|
|
@@ -204,19 +207,21 @@ export interface SignBidirectionalNotificationRecord {
|
|
|
204
207
|
}
|
|
205
208
|
/**
|
|
206
209
|
* Decode a {@link SignetEventName.SignBidirectionalEvent} payload into the
|
|
207
|
-
* raw notification record: the decode twin of
|
|
208
|
-
* circuit's emit literal
|
|
210
|
+
* declared request id and the raw notification record: the decode twin of
|
|
211
|
+
* the `signBidirectional` circuit's emit literal
|
|
212
|
+
* (version (1) ++ requestId (32) ++ notification payload (128)).
|
|
209
213
|
*
|
|
210
214
|
* @param payload - The event's payload.
|
|
211
|
-
* @returns The raw notification record.
|
|
215
|
+
* @returns The decoded post: declared request id plus raw notification record.
|
|
212
216
|
* @throws Error when the payload is too short to hold the record.
|
|
213
217
|
*/
|
|
214
|
-
export declare function decodeSignBidirectionalEventNotificationPayload(payload: Uint8Array): SignBidirectionalNotificationRecord
|
|
218
|
+
export declare function decodeSignBidirectionalEventNotificationPayload(payload: Uint8Array): SignetEventPost<SignBidirectionalNotificationRecord>;
|
|
215
219
|
/**
|
|
216
220
|
* A decoded V1 notification: the flat pointer a client emitted to tell the
|
|
217
221
|
* MPC a request was stored, and WHERE to read the authenticated copy. The
|
|
218
|
-
* event
|
|
219
|
-
*
|
|
222
|
+
* emitting event declares the stored request's id beside this record (see
|
|
223
|
+
* {@link SignetEventPost}): the MPC looks that id up in the request map the
|
|
224
|
+
* notification points at and reads the request from the named caller's own
|
|
220
225
|
* authenticated ledger (see signet-request-feed.ts). The fields themselves
|
|
221
226
|
* confer no authority.
|
|
222
227
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-events.d.ts","sourceRoot":"","sources":["../src/signet-contract-events.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAOzC;;;;GAIG;AACH,oBAAY,eAAe;IACzB,gEAAgE;IAChE,sBAAsB,2BAA2B;IACjD,iDAAiD;IACjD,uBAAuB,4BAA4B;IACnD,0EAA0E;IAC1E,yBAAyB,8BAA8B;CACxD;AAED,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,yDAAyD;AACzD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,OAAO,EAAE,UAAU,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACxE;AAOD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAM9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,eAAe,CAAC,EAAE,MAAM,GACvB,eAAe,EAAE,CAqBnB;AAED;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;;;OAMG;IACH,mBAAmB,CAAC,MAAM,EAAE;QAC1B,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;CACvE;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,8BAA8B,GACvC,iBAAiB,CAsBnB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,CAAC,EAAE,UAAU,CAAC;IACd,6CAA6C;IAC7C,CAAC,EAAE,UAAU,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,qCAAqC;IACrC,IAAI,EAAE,WAAW,CAAC;IAClB,+CAA+C;IAC/C,CAAC,EAAE,UAAU,CAAC;IACd,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,SAAS,EAAE,YAAY,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,yBAAyB;IACxC,mDAAmD;IACnD,SAAS,EAAE,YAAY,CAAC;CACzB;AAED
|
|
1
|
+
{"version":3,"file":"signet-contract-events.d.ts","sourceRoot":"","sources":["../src/signet-contract-events.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAOzC;;;;GAIG;AACH,oBAAY,eAAe;IACzB,gEAAgE;IAChE,sBAAsB,2BAA2B;IACjD,iDAAiD;IACjD,uBAAuB,4BAA4B;IACnD,0EAA0E;IAC1E,y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B/B"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// events. Every signet contract circuit emits one `Misc` contract event
|
|
3
3
|
// (MIP-0002 public log emission) whose 32-byte name tags the event kind and
|
|
4
4
|
// whose 256-byte payload packs the record:
|
|
5
|
-
// SignBidirectionalEvent - version (1) ++ notification payload (128) ++ zeros (
|
|
5
|
+
// SignBidirectionalEvent - version (1) ++ requestId (32) ++ notification payload (128) ++ zeros (95)
|
|
6
6
|
// SignatureRespondedEvent - requestId (32) ++ bigR.x (32) ++ bigR.y (32) ++ s (32) ++ recoveryId (1) ++ zeros (127)
|
|
7
7
|
// RespondBidirectionalEvent - requestId (32) ++ bigR.x (32) ++ bigR.y (32) ++ s (32) ++ recoveryId (1) ++ zeros (127)
|
|
8
8
|
// The decoders here are the byte-plumbing twins of the emit literals in
|
|
9
9
|
// signet-contract.compact: field order and offsets must match byte-for-byte
|
|
10
10
|
// (the signet-contract simulator tests pin the lockstep against real emits).
|
|
11
11
|
// Every event is UNAUTHENTICATED: verification is the reader's job. The
|
|
12
|
-
// request id
|
|
12
|
+
// request id every payload discloses is routing data only, so it scopes
|
|
13
13
|
// reads to one request and proves nothing.
|
|
14
14
|
import { CompactTypeBytes, } from "@midnight-ntwrk/compact-runtime";
|
|
15
15
|
import { bytesToHex, hexToBytes, } from "./signet-requests.js";
|
|
@@ -186,17 +186,20 @@ export function decodeRespondBidirectionalEventPayload(payload) {
|
|
|
186
186
|
}
|
|
187
187
|
/** Offset of the notification's version tag in the event payload. */
|
|
188
188
|
const NOTIFICATION_EVENT_VERSION_OFFSET = 0;
|
|
189
|
+
/** Offset of the declared request id in the event payload. */
|
|
190
|
+
const NOTIFICATION_EVENT_REQUEST_ID_OFFSET = 1;
|
|
189
191
|
/** Offset of the packed notification payload in the event payload. */
|
|
190
|
-
const NOTIFICATION_EVENT_PAYLOAD_OFFSET =
|
|
192
|
+
const NOTIFICATION_EVENT_PAYLOAD_OFFSET = 33;
|
|
191
193
|
/** Byte width of the packed notification payload (Compact `Bytes<128>`). */
|
|
192
194
|
const NOTIFICATION_PAYLOAD_LENGTH = 128;
|
|
193
195
|
/**
|
|
194
196
|
* Decode a {@link SignetEventName.SignBidirectionalEvent} payload into the
|
|
195
|
-
* raw notification record: the decode twin of
|
|
196
|
-
* circuit's emit literal
|
|
197
|
+
* declared request id and the raw notification record: the decode twin of
|
|
198
|
+
* the `signBidirectional` circuit's emit literal
|
|
199
|
+
* (version (1) ++ requestId (32) ++ notification payload (128)).
|
|
197
200
|
*
|
|
198
201
|
* @param payload - The event's payload.
|
|
199
|
-
* @returns The raw notification record.
|
|
202
|
+
* @returns The decoded post: declared request id plus raw notification record.
|
|
200
203
|
* @throws Error when the payload is too short to hold the record.
|
|
201
204
|
*/
|
|
202
205
|
export function decodeSignBidirectionalEventNotificationPayload(payload) {
|
|
@@ -206,8 +209,11 @@ export function decodeSignBidirectionalEventNotificationPayload(payload) {
|
|
|
206
209
|
throw new Error(`signet event payload of ${payload.length} bytes is too short for a packed notification`);
|
|
207
210
|
}
|
|
208
211
|
return {
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
requestId: payload.slice(NOTIFICATION_EVENT_REQUEST_ID_OFFSET, NOTIFICATION_EVENT_PAYLOAD_OFFSET),
|
|
213
|
+
event: {
|
|
214
|
+
version: BigInt(version),
|
|
215
|
+
payload: payload.slice(NOTIFICATION_EVENT_PAYLOAD_OFFSET, end),
|
|
216
|
+
},
|
|
211
217
|
};
|
|
212
218
|
}
|
|
213
219
|
/** Offset of the V1 `callerAddress` in the packed payload (`Bytes<32>` at the front). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-events.js","sourceRoot":"","sources":["../src/signet-contract-events.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wEAAwE;AACxE,4EAA4E;AAC5E,2CAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"signet-contract-events.js","sourceRoot":"","sources":["../src/signet-contract-events.ts"],"names":[],"mappings":"AAA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AAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAC7B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,wBAAwB,GAAG,KAAK,CAAC,CACjF,CAAC;IACF,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/B,aAAa;QACb,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -53,12 +53,13 @@ export interface SignetRequestFeedConfig {
|
|
|
53
53
|
export declare function sleepUnlessAborted(ms: number, signal?: AbortSignal): Promise<void>;
|
|
54
54
|
/**
|
|
55
55
|
* The event-polling request feed. Reads the signet contract's emitted
|
|
56
|
-
* notifications (discovery) and
|
|
57
|
-
* request map (authentication by construction: the
|
|
58
|
-
* caller's ledger), yielding each
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* notifications (discovery) and looks each declared request id up in the
|
|
57
|
+
* pointed-at caller's own request map (authentication by construction: the
|
|
58
|
+
* records come from the caller's ledger), yielding each found request once.
|
|
59
|
+
* A request stored WITHOUT a notification is never discovered: the
|
|
60
|
+
* notification is the doorbell. Dedupes by request id across its lifetime,
|
|
61
|
+
* so a re-notified or still-pending request is not re-yielded. Call
|
|
62
|
+
* {@link forget} to re-arm a request whose downstream processing failed.
|
|
62
63
|
*/
|
|
63
64
|
export declare class SignetRequestFeed {
|
|
64
65
|
private readonly signetContractAddress;
|
|
@@ -75,24 +76,26 @@ export declare class SignetRequestFeed {
|
|
|
75
76
|
/** Whether the policy allow-list admits `callerAddress` (always true when unset). */
|
|
76
77
|
private allowed;
|
|
77
78
|
/**
|
|
78
|
-
* The unique `(callerAddress, requestsPath)` pointers of the
|
|
79
|
-
* emitted notification events, allow-list applied, in ascending
|
|
80
|
-
* caller-address order (event enumeration order is
|
|
81
|
-
* stable sort keeps the poll deterministic).
|
|
82
|
-
*
|
|
83
|
-
*
|
|
79
|
+
* The unique `(callerAddress, requestsPath, requestId)` pointers of the
|
|
80
|
+
* currently emitted notification events, allow-list applied, in ascending
|
|
81
|
+
* (caller-address, request-id) order (event enumeration order is
|
|
82
|
+
* per-source, so a stable sort keeps the poll deterministic). Deduped by
|
|
83
|
+
* the FULL triple, not the id alone, so a forged notification declaring a
|
|
84
|
+
* genuine id under a wrong pointer cannot shadow the genuine one.
|
|
85
|
+
* Undecodable or unsupported-version events are skipped (and logged):
|
|
86
|
+
* they carry no readable pointer, so nothing is lost.
|
|
84
87
|
*
|
|
85
|
-
* @returns The deduplicated pointers to
|
|
88
|
+
* @returns The deduplicated pointers to look up this cycle.
|
|
86
89
|
*/
|
|
87
90
|
private notificationPointers;
|
|
88
91
|
/**
|
|
89
|
-
* One-shot: every request
|
|
90
|
-
*
|
|
91
|
-
* map
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
92
|
+
* One-shot: every notified request that is admitted by the allow-list,
|
|
93
|
+
* not already yielded, and found by id in the pointed-at caller's own
|
|
94
|
+
* request map. A pointer whose caller has no readable state, whose path
|
|
95
|
+
* holds no request map, or whose declared id is not (yet) a member yields
|
|
96
|
+
* nothing WITHOUT marking anything, so a genuine request whose ledger
|
|
97
|
+
* write has not indexed yet is retried next cycle. One caller's state is
|
|
98
|
+
* queried at most once per cycle.
|
|
96
99
|
*
|
|
97
100
|
* @returns The newly-discovered authenticated requests this cycle.
|
|
98
101
|
* @throws Error when the event source itself fails (e.g. the indexer is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-feed.d.ts","sourceRoot":"","sources":["../src/signet-request-feed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signet-request-feed.d.ts","sourceRoot":"","sources":["../src/signet-request-feed.ts"],"names":[],"mappings":"AAoBA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,EAGL,KAAK,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A+ClC;;;;;;;;;;;;OAYG;IACG,IAAI,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAuC9C;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI;IAIrC;;;;;;;;OAQG;IACI,QAAQ,CAAC,IAAI,CAAC,EAAE;QACrB,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC;CAQjD"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
// The MPC's single entry point for discovering signature requests: poll the
|
|
2
2
|
// central signet contract's emitted SignBidirectionalEvent notifications,
|
|
3
|
-
// follow each to the named caller contract, and
|
|
4
|
-
//
|
|
5
|
-
// never an authority: it says only WHERE to look (caller
|
|
6
|
-
// resolved ledger-tree path of its request map)
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
3
|
+
// follow each to the named caller contract, and read the AUTHENTICATED
|
|
4
|
+
// request it declares from that caller's own request map. A notification is
|
|
5
|
+
// a doorbell, never an authority: it says only WHERE to look (caller
|
|
6
|
+
// address + the resolved ledger-tree path of its request map) and WHICH
|
|
7
|
+
// request (the declared id), and every request served comes from the named
|
|
8
|
+
// caller's own ledger. An attacker cannot write into a contract it does not
|
|
9
|
+
// control, so a forged notification can at most re-point at a legitimate
|
|
10
|
+
// caller's stored request, never inject one.
|
|
10
11
|
//
|
|
11
12
|
// The event log has no on-ledger cursor the feed consumes, so the feed's
|
|
12
|
-
// in-memory `yielded` set is the diff cursor: every poll
|
|
13
|
-
//
|
|
13
|
+
// in-memory `yielded` set is the diff cursor: every poll looks up the
|
|
14
|
+
// notified requests and serves what it has not served before.
|
|
14
15
|
//
|
|
15
16
|
// The requester allow-list is an OPTIONAL policy filter here (drop requests
|
|
16
17
|
// from contracts you choose not to serve), never a security requirement and
|
|
17
18
|
// never the discovery mechanism: attribution comes from reading the
|
|
18
19
|
// caller's authenticated state.
|
|
19
20
|
import { decodeSignBidirectionalEventNotificationPayload, decodeSignBidirectionalNotification, SignetEventName, } from "./signet-contract-events.js";
|
|
20
|
-
import {
|
|
21
|
-
import { stripHexPrefix, } from "./signet-requests.js";
|
|
21
|
+
import { lookupSignetRequestAt } from "./signature-requests-state-reader.js";
|
|
22
|
+
import { requestIdHex, stripHexPrefix, } from "./signet-requests.js";
|
|
22
23
|
/** Default gap between poll cycles of {@link SignetRequestFeed.requests}. */
|
|
23
24
|
export const DEFAULT_FEED_POLL_INTERVAL_MS = 3000;
|
|
24
25
|
/**
|
|
@@ -50,12 +51,13 @@ function normalizeAddress(address) {
|
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* The event-polling request feed. Reads the signet contract's emitted
|
|
53
|
-
* notifications (discovery) and
|
|
54
|
-
* request map (authentication by construction: the
|
|
55
|
-
* caller's ledger), yielding each
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
54
|
+
* notifications (discovery) and looks each declared request id up in the
|
|
55
|
+
* pointed-at caller's own request map (authentication by construction: the
|
|
56
|
+
* records come from the caller's ledger), yielding each found request once.
|
|
57
|
+
* A request stored WITHOUT a notification is never discovered: the
|
|
58
|
+
* notification is the doorbell. Dedupes by request id across its lifetime,
|
|
59
|
+
* so a re-notified or still-pending request is not re-yielded. Call
|
|
60
|
+
* {@link forget} to re-arm a request whose downstream processing failed.
|
|
59
61
|
*/
|
|
60
62
|
export class SignetRequestFeed {
|
|
61
63
|
signetContractAddress;
|
|
@@ -86,14 +88,16 @@ export class SignetRequestFeed {
|
|
|
86
88
|
this.allowContracts.has(normalizeAddress(callerAddress)));
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
89
|
-
* The unique `(callerAddress, requestsPath)` pointers of the
|
|
90
|
-
* emitted notification events, allow-list applied, in ascending
|
|
91
|
-
* caller-address order (event enumeration order is
|
|
92
|
-
* stable sort keeps the poll deterministic).
|
|
93
|
-
*
|
|
94
|
-
*
|
|
91
|
+
* The unique `(callerAddress, requestsPath, requestId)` pointers of the
|
|
92
|
+
* currently emitted notification events, allow-list applied, in ascending
|
|
93
|
+
* (caller-address, request-id) order (event enumeration order is
|
|
94
|
+
* per-source, so a stable sort keeps the poll deterministic). Deduped by
|
|
95
|
+
* the FULL triple, not the id alone, so a forged notification declaring a
|
|
96
|
+
* genuine id under a wrong pointer cannot shadow the genuine one.
|
|
97
|
+
* Undecodable or unsupported-version events are skipped (and logged):
|
|
98
|
+
* they carry no readable pointer, so nothing is lost.
|
|
95
99
|
*
|
|
96
|
-
* @returns The deduplicated pointers to
|
|
100
|
+
* @returns The deduplicated pointers to look up this cycle.
|
|
97
101
|
*/
|
|
98
102
|
async notificationPointers() {
|
|
99
103
|
const events = await this.eventSource.querySignetEvents(this.signetContractAddress);
|
|
@@ -101,35 +105,43 @@ export class SignetRequestFeed {
|
|
|
101
105
|
for (const event of events) {
|
|
102
106
|
if (event.name !== SignetEventName.SignBidirectionalEvent)
|
|
103
107
|
continue;
|
|
104
|
-
let
|
|
108
|
+
let pointer;
|
|
105
109
|
try {
|
|
106
|
-
|
|
110
|
+
const post = decodeSignBidirectionalEventNotificationPayload(event.payload);
|
|
111
|
+
const notification = decodeSignBidirectionalNotification(post.event);
|
|
112
|
+
pointer = {
|
|
113
|
+
callerAddress: notification.callerAddress,
|
|
114
|
+
requestsPath: notification.requestsPath,
|
|
115
|
+
requestId: requestIdHex(post.requestId),
|
|
116
|
+
};
|
|
107
117
|
}
|
|
108
118
|
catch (error) {
|
|
109
119
|
console.warn(`SignetRequestFeed: skipping undecodable notification event: ${String(error)}`);
|
|
110
120
|
continue;
|
|
111
121
|
}
|
|
112
|
-
if (!this.allowed(
|
|
122
|
+
if (!this.allowed(pointer.callerAddress))
|
|
113
123
|
continue;
|
|
114
|
-
pointers.set(`${
|
|
115
|
-
callerAddress: notification.callerAddress,
|
|
116
|
-
requestsPath: notification.requestsPath,
|
|
117
|
-
});
|
|
124
|
+
pointers.set(`${pointer.callerAddress}:${pointer.requestsPath.join(",")}:${pointer.requestId}`, pointer);
|
|
118
125
|
}
|
|
119
|
-
return [...pointers.values()].sort((a, b) =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
return [...pointers.values()].sort((a, b) => {
|
|
127
|
+
const byCaller = a.callerAddress < b.callerAddress
|
|
128
|
+
? -1
|
|
129
|
+
: a.callerAddress > b.callerAddress
|
|
130
|
+
? 1
|
|
131
|
+
: 0;
|
|
132
|
+
if (byCaller !== 0)
|
|
133
|
+
return byCaller;
|
|
134
|
+
return a.requestId < b.requestId ? -1 : a.requestId > b.requestId ? 1 : 0;
|
|
135
|
+
});
|
|
124
136
|
}
|
|
125
137
|
/**
|
|
126
|
-
* One-shot: every request
|
|
127
|
-
*
|
|
128
|
-
* map
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
138
|
+
* One-shot: every notified request that is admitted by the allow-list,
|
|
139
|
+
* not already yielded, and found by id in the pointed-at caller's own
|
|
140
|
+
* request map. A pointer whose caller has no readable state, whose path
|
|
141
|
+
* holds no request map, or whose declared id is not (yet) a member yields
|
|
142
|
+
* nothing WITHOUT marking anything, so a genuine request whose ledger
|
|
143
|
+
* write has not indexed yet is retried next cycle. One caller's state is
|
|
144
|
+
* queried at most once per cycle.
|
|
133
145
|
*
|
|
134
146
|
* @returns The newly-discovered authenticated requests this cycle.
|
|
135
147
|
* @throws Error when the event source itself fails (e.g. the indexer is
|
|
@@ -137,28 +149,37 @@ export class SignetRequestFeed {
|
|
|
137
149
|
*/
|
|
138
150
|
async poll() {
|
|
139
151
|
const out = [];
|
|
152
|
+
// Per-cycle caller-state cache: null marks a caller whose state could
|
|
153
|
+
// not be read this cycle (not a contract / transient read error).
|
|
154
|
+
const states = new Map();
|
|
140
155
|
for (const pointer of await this.notificationPointers()) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
if (this.yielded.has(pointer.requestId))
|
|
157
|
+
continue;
|
|
158
|
+
let raw = states.get(pointer.callerAddress);
|
|
159
|
+
if (raw === undefined) {
|
|
160
|
+
try {
|
|
161
|
+
raw =
|
|
162
|
+
(await this.source.queryContractState(pointer.callerAddress))
|
|
163
|
+
?.data ?? null;
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
raw = null;
|
|
167
|
+
}
|
|
168
|
+
states.set(pointer.callerAddress, raw);
|
|
147
169
|
}
|
|
148
|
-
if (
|
|
170
|
+
if (raw === null) {
|
|
149
171
|
continue; // no state at the named caller: nothing to serve yet
|
|
150
172
|
}
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
continue;
|
|
155
|
-
this.yielded.add(requestId);
|
|
156
|
-
out.push({
|
|
157
|
-
callerAddress: pointer.callerAddress,
|
|
158
|
-
requestId,
|
|
159
|
-
request,
|
|
160
|
-
});
|
|
173
|
+
const request = lookupSignetRequestAt(raw, pointer.requestsPath, pointer.requestId);
|
|
174
|
+
if (request === undefined) {
|
|
175
|
+
continue; // forged pointer, or the ledger write has not indexed yet
|
|
161
176
|
}
|
|
177
|
+
this.yielded.add(pointer.requestId);
|
|
178
|
+
out.push({
|
|
179
|
+
callerAddress: pointer.callerAddress,
|
|
180
|
+
requestId: pointer.requestId,
|
|
181
|
+
request,
|
|
182
|
+
});
|
|
162
183
|
}
|
|
163
184
|
return out;
|
|
164
185
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-feed.js","sourceRoot":"","sources":["../src/signet-request-feed.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"signet-request-feed.js","sourceRoot":"","sources":["../src/signet-request-feed.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,uEAAuE;AACvE,4EAA4E;AAC5E,qEAAqE;AACrE,wEAAwE;AACxE,2EAA2E;A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AAC,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,SAAuB;QAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,QAAQ,CAAC,IAEf;QACC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAChC,KAAK,MAAM,QAAQ,IAAI,KAAK;gBAAE,MAAM,QAAQ,CAAC;YAC7C,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO;gBAAE,MAAM;YACjC,MAAM,kBAAkB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,sCAAsC;AACtC,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,wEAAwE;AACxE,iEAAiE;AACjE,mEAAmE;AACnE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,mDAAmD;AAKnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,sCAAsC,EACtC,oCAAoC,EACpC,eAAe,GAKhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EACL,mCAAmC,GAEpC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cA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rB,
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,sCAAsC;AACtC,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,wEAAwE;AACxE,iEAAiE;AACjE,mEAAmE;AACnE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,mDAAmD;AAKnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,sCAAsC,EACtC,oCAAoC,EACpC,eAAe,GAKhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EACL,mCAAmC,GAEpC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,EACd,YAAY,GAGb,MAAM,sBAAsB,CAAC;AAsE9B;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IACrB,MAAM,CAAoC;IAE3D,wEAAwE;IACvD,YAAY,GAAG,IAAI,GAAG,EAGpC,CAAC;IAEJ;;;OAGG;IACH,YAAY,MAAyC;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,mBAAmB,CACvB,SAAuB;QAEvB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,CACnE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CACrC,CAAC;QACF,IA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|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
|
|
41
41
|
"@midnight-ntwrk/midnight-js-types": "5.0.0-beta.4",
|
|
42
42
|
"@noble/curves": "^2.2.0",
|
|
43
|
-
"@sig-net/midnight-serde": "^0.
|
|
43
|
+
"@sig-net/midnight-serde": "^0.17.0",
|
|
44
44
|
"ethers": "^6.17.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
// 1. Client contract stores a SignBidirectionalEvent in a SignBidirectionalEventMap in its own ledger
|
|
45
45
|
// (against the calculated RequestId) and requests a signature from the MPC via a cross contract call
|
|
46
46
|
// against the SignetSigner interface. The Signet singleton emits the
|
|
47
|
-
// SignBidirectionalEventNotification as a contract event.
|
|
47
|
+
// SignBidirectionalEventNotification as a contract event, the RequestId disclosed beside it.
|
|
48
48
|
// 2. MPC polls the Signet singleton contract's events for SignBidirectionalEventNotifications and uses
|
|
49
|
-
// each one to
|
|
49
|
+
// each one to look the declared SignBidirectionalEvent signature request up in the named client's own ledger.
|
|
50
50
|
// It generates the signature and posts a SignatureRespondedEvent (the requested signature) through
|
|
51
51
|
// the Signet singleton, which emits it as a contract event.
|
|
52
52
|
// 3. Client polls the Signet singleton contract's SignatureRespondedEvent events. Each event carries
|
|
@@ -211,6 +211,8 @@ module Signet {
|
|
|
211
211
|
// Called by client contracts to notify the MPC of a SignBidirectionalEvent.
|
|
212
212
|
circuit signBidirectional(
|
|
213
213
|
// Canonical id of the SignBidirectionalEvent (calculate with calculateRequestId).
|
|
214
|
+
// Disclosed in the emitted notification event: the MPC looks this id up in the
|
|
215
|
+
// caller's own request map.
|
|
214
216
|
requestId: RequestId,
|
|
215
217
|
// Versioned notification of the SignBidirectionalEvent
|
|
216
218
|
// (construct with constructSignBidirectionalEventNotificationV1).
|