@inco/lightning 0.8.0-devnet-4 → 0.8.0-devnet-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.
Files changed (40) hide show
  1. package/README.md +59 -1
  2. package/manifest.yaml +22 -0
  3. package/package.json +1 -1
  4. package/src/DeployUtils.sol +71 -25
  5. package/src/IncoLightning.sol +27 -7
  6. package/src/IncoVerifier.sol +18 -1
  7. package/src/Lib.alphanet.sol +390 -3
  8. package/src/Lib.demonet.sol +390 -3
  9. package/src/Lib.devnet.sol +391 -4
  10. package/src/Lib.sol +391 -4
  11. package/src/Lib.template.sol +387 -0
  12. package/src/Lib.testnet.sol +390 -3
  13. package/src/libs/incoLightning_alphanet_v0_297966649.sol +390 -3
  14. package/src/libs/incoLightning_alphanet_v1_725458969.sol +390 -3
  15. package/src/libs/incoLightning_alphanet_v2_976644394.sol +390 -3
  16. package/src/libs/incoLightning_demonet_v0_863421733.sol +390 -3
  17. package/src/libs/incoLightning_demonet_v2_467437523.sol +390 -3
  18. package/src/libs/incoLightning_devnet_v0_340846814.sol +390 -3
  19. package/src/libs/incoLightning_devnet_v1_904635675.sol +390 -3
  20. package/src/libs/incoLightning_devnet_v2_295237520.sol +390 -3
  21. package/src/libs/incoLightning_devnet_v3_976859633.sol +390 -3
  22. package/src/libs/incoLightning_devnet_v4_409204766.sol +921 -0
  23. package/src/libs/incoLightning_testnet_v0_183408998.sol +390 -3
  24. package/src/libs/incoLightning_testnet_v2_889158349.sol +390 -3
  25. package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +65 -4
  26. package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +71 -5
  27. package/src/lightning-parts/DecryptionAttester.sol +16 -3
  28. package/src/lightning-parts/EncryptedInput.sol +48 -2
  29. package/src/lightning-parts/EncryptedOperations.sol +134 -1
  30. package/src/lightning-parts/Fee.sol +29 -6
  31. package/src/lightning-parts/primitives/EventCounter.sol +36 -5
  32. package/src/lightning-parts/primitives/HandleGeneration.sol +38 -6
  33. package/src/lightning-parts/primitives/HandleMetadata.sol +28 -0
  34. package/src/lightning-parts/primitives/LightningAddressGetter.sol +10 -0
  35. package/src/lightning-parts/primitives/VerifierAddressGetter.sol +10 -0
  36. package/src/lightning-parts/primitives/test/SignatureVerifier.t.sol +0 -2
  37. package/src/periphery/IncoUtils.sol +1 -0
  38. package/src/periphery/SessionVerifier.sol +35 -7
  39. package/src/test/TestFakeInfra.t.sol +536 -1
  40. package/src/version/IncoLightningConfig.sol +2 -2
@@ -357,7 +357,6 @@ contract TestSignatureVerifier is TestUtils, SignatureVerifier {
357
357
  // Create 3 signatures: Alice, Bob (both valid), and Dave (invalid)
358
358
  // After sorting, Dave's signature will be placed according to his address
359
359
  // As long as the first 2 signatures checked are from valid signers, it should pass
360
- bytes[] memory signatures = new bytes[](3);
361
360
  bytes memory aliceSig = getSignatureForDigest(digest, alicePrivKey);
362
361
  bytes memory bobSig = getSignatureForDigest(digest, bobPrivKey);
363
362
  bytes memory daveSig = getSignatureForDigest(digest, davePrivKey);
@@ -413,7 +412,6 @@ contract TestSignatureVerifier is TestUtils, SignatureVerifier {
413
412
  bytes32 digest = keccak256("test message");
414
413
 
415
414
  // Create signatures where an invalid signer (Dave) will be in the first threshold
416
- bytes[] memory signatures = new bytes[](3);
417
415
  bytes memory aliceSig = getSignatureForDigest(digest, alicePrivKey);
418
416
  bytes memory bobSig = getSignatureForDigest(digest, bobPrivKey);
419
417
  bytes memory daveSig = getSignatureForDigest(digest, davePrivKey);
@@ -4,6 +4,7 @@ pragma solidity ^0.8;
4
4
  import {StorageSlot} from "@openzeppelin/contracts/utils/StorageSlot.sol";
5
5
 
6
6
  // Re-export FEE constant for convenience - consumers can import both IncoUtils and FEE from this file
7
+ // forge-lint: disable-next-line(unused-import)
7
8
  import {FEE} from "../lightning-parts/Fee.sol";
8
9
 
9
10
  contract IncoUtils {
@@ -12,18 +12,33 @@ import {
12
12
  import {Version} from "../version/Version.sol";
13
13
  import {ALLOWANCE_GRANTED_MAGIC_VALUE} from "../Types.sol";
14
14
 
15
- /// @notice a Session grants a temporary access to a decrypter to all data held by the sharer
16
- /// @dev abi encode this struct in the sharerArgData field of the voucher
15
+ /// @notice A Session grants temporary access to a decrypter for all data held by the sharer
16
+ /// @dev ABI encode this struct in the sharerArgData field of the voucher.
17
+ /// The session is valid only if:
18
+ /// 1. The current block timestamp is before expiresAt
19
+ /// 2. The requesting account matches the authorized decrypter
17
20
  struct Session {
21
+ /// @notice The address authorized to decrypt the sharer's data
18
22
  address decrypter;
23
+ /// @notice Unix timestamp after which the session is no longer valid
19
24
  uint256 expiresAt;
20
25
  }
21
26
 
22
- /// @notice Inco access sharing verifier mainly meant for browser dapp sessions, grants access to all data held by
23
- /// the sharer to one decrypter for a limited time.
24
- /// @dev define the selector of canUseSession in the voucher to use this verifier
27
+ /// @title SessionVerifier
28
+ /// @notice Inco access sharing verifier for browser dApp sessions
29
+ /// @dev Grants access to all encrypted data held by the sharer to one decrypter for a limited time.
30
+ /// This is the recommended pattern for dApps that need to decrypt user data during a browsing session.
31
+ ///
32
+ /// Usage:
33
+ /// 1. User signs a voucher containing a Session struct with their chosen decrypter and expiration
34
+ /// 2. The voucher specifies canUseSession.selector as the callFunction
35
+ /// 3. When the decrypter requests access, this contract verifies the session is still valid
36
+ ///
37
+ /// To use this verifier, set the voucher's callFunction to SessionVerifier.canUseSession.selector
25
38
  contract SessionVerifier is UUPSUpgradeable, OwnableUpgradeable, Version {
26
39
 
40
+ /// @notice Initializes the SessionVerifier with version information
41
+ /// @param salt Unique salt used for deterministic deployment via CreateX
27
42
  constructor(bytes32 salt)
28
43
  Version(
29
44
  SESSION_VERIFIER_MAJOR_VERSION,
@@ -34,7 +49,13 @@ contract SessionVerifier is UUPSUpgradeable, OwnableUpgradeable, Version {
34
49
  )
35
50
  {}
36
51
 
37
- // todo add text mention of what is being signed
52
+ /// @notice Verifies if an account can use a session to access encrypted data
53
+ /// @dev This function is called by the ACL system when validating access permissions.
54
+ /// The session grants blanket access to all handles owned by the sharer - the handle
55
+ /// parameter is intentionally ignored.
56
+ /// @param account The address requesting access (must match session.decrypter)
57
+ /// @param sharerArgData ABI-encoded Session struct containing decrypter address and expiration
58
+ /// @return ALLOWANCE_GRANTED_MAGIC_VALUE if session is valid, bytes32(0) otherwise
38
59
  function canUseSession(
39
60
  bytes32, /* handle */
40
61
  address account,
@@ -54,14 +75,21 @@ contract SessionVerifier is UUPSUpgradeable, OwnableUpgradeable, Version {
54
75
  return bytes32(0);
55
76
  }
56
77
 
78
+ /// @notice Authorizes contract upgrades (restricted to owner only)
79
+ /// @dev Required by UUPSUpgradeable. Only the contract owner can upgrade.
57
80
  function _authorizeUpgrade(address) internal view override {
58
81
  require(msg.sender == owner());
59
82
  }
60
83
 
84
+ /// @notice Initializes the contract with an owner address
85
+ /// @dev Must be called immediately after deployment via proxy. Can only be called once.
86
+ /// @param owner The address that will own this contract and can authorize upgrades
61
87
  function initialize(address owner) public initializer {
62
88
  __Ownable_init(owner);
63
89
  }
64
90
 
65
- fallback() external {} // must be included for createX deploy
91
+ /// @notice Required for CreateX deterministic deployment
92
+ /// @dev Empty fallback allows the contract to be deployed via CreateX's create2 mechanism
93
+ fallback() external {}
66
94
 
67
95
  }
@@ -540,19 +540,554 @@ contract TestFakeInfra is IncoTest {
540
540
  assertEq(getBoolValue(inputContract.b()), true);
541
541
  }
542
542
 
543
- function testUninitializedHandleIsDisallowed() public {
543
+ function testUninitializedHandleIsDisallowed_Add() public {
544
544
  bytes32 randomHandle = keccak256("random handle");
545
545
  euint256 a = e.asEuint256(12);
546
546
  vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
547
547
  a.add(euint256.wrap(randomHandle));
548
548
  }
549
549
 
550
+ function testUninitializedHandleIsDisallowed_Sub() public {
551
+ bytes32 randomHandle = keccak256("random handle");
552
+ euint256 a = e.asEuint256(12);
553
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
554
+ a.sub(euint256.wrap(randomHandle));
555
+ }
556
+
550
557
  function testECastAllowed() public {
551
558
  bytes32 invalidHandle = keccak256("invalid handle");
552
559
  vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, invalidHandle, address(this)));
553
560
  euint256.wrap(invalidHandle).asEbool();
554
561
  }
555
562
 
563
+ function testUninitializedHandleIsDisallowed_Add_Lhs() public {
564
+ bytes32 randomHandle = keccak256("random handle add lhs");
565
+ euint256 b = e.asEuint256(4);
566
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
567
+ euint256.wrap(randomHandle).add(b);
568
+ }
569
+
570
+ function testUninitializedHandleIsDisallowed_Sub_Lhs() public {
571
+ bytes32 randomHandle = keccak256("random handle sub lhs");
572
+ euint256 b = e.asEuint256(4);
573
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
574
+ euint256.wrap(randomHandle).sub(b);
575
+ }
576
+
577
+ function testUninitializedHandleIsDisallowed_Mul_Lhs() public {
578
+ bytes32 randomHandle = keccak256("random handle mul lhs");
579
+ euint256 b = e.asEuint256(4);
580
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
581
+ euint256.wrap(randomHandle).mul(b);
582
+ }
583
+
584
+ function testUninitializedHandleIsDisallowed_Mul_Rhs() public {
585
+ bytes32 randomHandle = keccak256("random handle mul rhs");
586
+ euint256 a = e.asEuint256(10);
587
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
588
+ a.mul(euint256.wrap(randomHandle));
589
+ }
590
+
591
+ function testUninitializedHandleIsDisallowed_Div_Lhs() public {
592
+ bytes32 randomHandle = keccak256("random handle div lhs");
593
+ euint256 b = e.asEuint256(4);
594
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
595
+ euint256.wrap(randomHandle).div(b);
596
+ }
597
+
598
+ function testUninitializedHandleIsDisallowed_Div_Rhs() public {
599
+ bytes32 randomHandle = keccak256("random handle div rhs");
600
+ euint256 a = e.asEuint256(10);
601
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
602
+ a.div(euint256.wrap(randomHandle));
603
+ }
604
+
605
+ function testUninitializedHandleIsDisallowed_Rem_Lhs() public {
606
+ bytes32 randomHandle = keccak256("random handle rem lhs");
607
+ euint256 b = e.asEuint256(4);
608
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
609
+ euint256.wrap(randomHandle).rem(b);
610
+ }
611
+
612
+ function testUninitializedHandleIsDisallowed_Rem_Rhs() public {
613
+ bytes32 randomHandle = keccak256("random handle rem rhs");
614
+ euint256 a = e.asEuint256(10);
615
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
616
+ a.rem(euint256.wrap(randomHandle));
617
+ }
618
+
619
+ function testUninitializedHandleIsDisallowed_And_Lhs() public {
620
+ bytes32 randomHandle = keccak256("random handle and lhs");
621
+ euint256 b = e.asEuint256(0xFF);
622
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
623
+ euint256.wrap(randomHandle).and(b);
624
+ }
625
+
626
+ function testUninitializedHandleIsDisallowed_And_Rhs() public {
627
+ bytes32 randomHandle = keccak256("random handle and rhs");
628
+ euint256 a = e.asEuint256(0xFF);
629
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
630
+ a.and(euint256.wrap(randomHandle));
631
+ }
632
+
633
+ function testUninitializedHandleIsDisallowed_Or_Lhs() public {
634
+ // Craft handle with valid Uint256 type byte (8) at bits 8-15
635
+ bytes32 randomHandle =
636
+ bytes32((uint256(keccak256("random handle or lhs")) & ~(uint256(0xFF) << 8)) | (uint256(8) << 8));
637
+ euint256 b = e.asEuint256(0xFF);
638
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
639
+ euint256.wrap(randomHandle).or(b);
640
+ }
641
+
642
+ function testUninitializedHandleIsDisallowed_Or_Rhs() public {
643
+ // Craft handle with valid Uint256 type byte (8) at bits 8-15
644
+ bytes32 randomHandle =
645
+ bytes32((uint256(keccak256("random handle or rhs")) & ~(uint256(0xFF) << 8)) | (uint256(8) << 8));
646
+ euint256 a = e.asEuint256(0xFF);
647
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
648
+ a.or(euint256.wrap(randomHandle));
649
+ }
650
+
651
+ function testUninitializedHandleIsDisallowed_Xor_Lhs() public {
652
+ // Craft handle with valid Uint256 type byte (8) at bits 8-15
653
+ bytes32 randomHandle =
654
+ bytes32((uint256(keccak256("random handle xor lhs")) & ~(uint256(0xFF) << 8)) | (uint256(8) << 8));
655
+ euint256 b = e.asEuint256(0xFF);
656
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
657
+ euint256.wrap(randomHandle).xor(b);
658
+ }
659
+
660
+ function testUninitializedHandleIsDisallowed_Xor_Rhs() public {
661
+ bytes32 randomHandle = keccak256("random handle xor rhs");
662
+ euint256 a = e.asEuint256(0xFF);
663
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
664
+ a.xor(euint256.wrap(randomHandle));
665
+ }
666
+
667
+ function testUninitializedHandleIsDisallowed_Shl_Lhs() public {
668
+ bytes32 randomHandle = keccak256("random handle shl lhs");
669
+ euint256 b = e.asEuint256(2);
670
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
671
+ euint256.wrap(randomHandle).shl(b);
672
+ }
673
+
674
+ function testUninitializedHandleIsDisallowed_Shl_Rhs() public {
675
+ bytes32 randomHandle = keccak256("random handle shl rhs");
676
+ euint256 a = e.asEuint256(10);
677
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
678
+ a.shl(euint256.wrap(randomHandle));
679
+ }
680
+
681
+ function testUninitializedHandleIsDisallowed_Shr_Lhs() public {
682
+ bytes32 randomHandle = keccak256("random handle shr lhs");
683
+ euint256 b = e.asEuint256(2);
684
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
685
+ euint256.wrap(randomHandle).shr(b);
686
+ }
687
+
688
+ function testUninitializedHandleIsDisallowed_Shr_Rhs() public {
689
+ bytes32 randomHandle = keccak256("random handle shr rhs");
690
+ euint256 a = e.asEuint256(10);
691
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
692
+ a.shr(euint256.wrap(randomHandle));
693
+ }
694
+
695
+ function testUninitializedHandleIsDisallowed_Rotl_Lhs() public {
696
+ bytes32 randomHandle = keccak256("random handle rotl lhs");
697
+ euint256 b = e.asEuint256(2);
698
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
699
+ euint256.wrap(randomHandle).rotl(b);
700
+ }
701
+
702
+ function testUninitializedHandleIsDisallowed_Rotl_Rhs() public {
703
+ bytes32 randomHandle = keccak256("random handle rotl rhs");
704
+ euint256 a = e.asEuint256(10);
705
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
706
+ a.rotl(euint256.wrap(randomHandle));
707
+ }
708
+
709
+ function testUninitializedHandleIsDisallowed_Rotr_Lhs() public {
710
+ bytes32 randomHandle = keccak256("random handle rotr lhs");
711
+ euint256 b = e.asEuint256(2);
712
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
713
+ euint256.wrap(randomHandle).rotr(b);
714
+ }
715
+
716
+ function testUninitializedHandleIsDisallowed_Rotr_Rhs() public {
717
+ bytes32 randomHandle = keccak256("random handle rotr rhs");
718
+ euint256 a = e.asEuint256(10);
719
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
720
+ a.rotr(euint256.wrap(randomHandle));
721
+ }
722
+
723
+ function testUninitializedHandleIsDisallowed_Eq_Lhs() public {
724
+ bytes32 randomHandle = keccak256("random handle eq lhs");
725
+ euint256 b = e.asEuint256(10);
726
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
727
+ euint256.wrap(randomHandle).eq(b);
728
+ }
729
+
730
+ function testUninitializedHandleIsDisallowed_Eq_Rhs() public {
731
+ bytes32 randomHandle = keccak256("random handle eq rhs");
732
+ euint256 a = e.asEuint256(10);
733
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
734
+ a.eq(euint256.wrap(randomHandle));
735
+ }
736
+
737
+ function testUninitializedHandleIsDisallowed_Ne_Lhs() public {
738
+ bytes32 randomHandle = keccak256("random handle ne lhs");
739
+ euint256 b = e.asEuint256(10);
740
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
741
+ euint256.wrap(randomHandle).ne(b);
742
+ }
743
+
744
+ function testUninitializedHandleIsDisallowed_Ne_Rhs() public {
745
+ bytes32 randomHandle = keccak256("random handle ne rhs");
746
+ euint256 a = e.asEuint256(10);
747
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
748
+ a.ne(euint256.wrap(randomHandle));
749
+ }
750
+
751
+ function testUninitializedHandleIsDisallowed_Ge_Lhs() public {
752
+ bytes32 randomHandle = keccak256("random handle ge lhs");
753
+ euint256 b = e.asEuint256(10);
754
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
755
+ euint256.wrap(randomHandle).ge(b);
756
+ }
757
+
758
+ function testUninitializedHandleIsDisallowed_Ge_Rhs() public {
759
+ bytes32 randomHandle = keccak256("random handle ge rhs");
760
+ euint256 a = e.asEuint256(10);
761
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
762
+ a.ge(euint256.wrap(randomHandle));
763
+ }
764
+
765
+ function testUninitializedHandleIsDisallowed_Gt_Lhs() public {
766
+ bytes32 randomHandle = keccak256("random handle gt lhs");
767
+ euint256 b = e.asEuint256(10);
768
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
769
+ euint256.wrap(randomHandle).gt(b);
770
+ }
771
+
772
+ function testUninitializedHandleIsDisallowed_Gt_Rhs() public {
773
+ bytes32 randomHandle = keccak256("random handle gt rhs");
774
+ euint256 a = e.asEuint256(10);
775
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
776
+ a.gt(euint256.wrap(randomHandle));
777
+ }
778
+
779
+ function testUninitializedHandleIsDisallowed_Le_Lhs() public {
780
+ bytes32 randomHandle = keccak256("random handle le lhs");
781
+ euint256 b = e.asEuint256(10);
782
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
783
+ euint256.wrap(randomHandle).le(b);
784
+ }
785
+
786
+ function testUninitializedHandleIsDisallowed_Le_Rhs() public {
787
+ bytes32 randomHandle = keccak256("random handle le rhs");
788
+ euint256 a = e.asEuint256(10);
789
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
790
+ a.le(euint256.wrap(randomHandle));
791
+ }
792
+
793
+ function testUninitializedHandleIsDisallowed_Lt_Lhs() public {
794
+ bytes32 randomHandle = keccak256("random handle lt lhs");
795
+ euint256 b = e.asEuint256(10);
796
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
797
+ euint256.wrap(randomHandle).lt(b);
798
+ }
799
+
800
+ function testUninitializedHandleIsDisallowed_Lt_Rhs() public {
801
+ bytes32 randomHandle = keccak256("random handle lt rhs");
802
+ euint256 a = e.asEuint256(10);
803
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
804
+ a.lt(euint256.wrap(randomHandle));
805
+ }
806
+
807
+ function testUninitializedHandleIsDisallowed_Min_Lhs() public {
808
+ bytes32 randomHandle = keccak256("random handle min lhs");
809
+ euint256 b = e.asEuint256(10);
810
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
811
+ euint256.wrap(randomHandle).min(b);
812
+ }
813
+
814
+ function testUninitializedHandleIsDisallowed_Min_Rhs() public {
815
+ bytes32 randomHandle = keccak256("random handle min rhs");
816
+ euint256 a = e.asEuint256(10);
817
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
818
+ a.min(euint256.wrap(randomHandle));
819
+ }
820
+
821
+ function testUninitializedHandleIsDisallowed_Max_Lhs() public {
822
+ bytes32 randomHandle = keccak256("random handle max lhs");
823
+ euint256 b = e.asEuint256(10);
824
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
825
+ euint256.wrap(randomHandle).max(b);
826
+ }
827
+
828
+ function testUninitializedHandleIsDisallowed_Max_Rhs() public {
829
+ bytes32 randomHandle = keccak256("random handle max rhs");
830
+ euint256 a = e.asEuint256(10);
831
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
832
+ a.max(euint256.wrap(randomHandle));
833
+ }
834
+
835
+ function testUninitializedHandleIsDisallowed_AsEuint256FromEbool() public {
836
+ bytes32 randomHandle = keccak256("random handle ebool to euint256");
837
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
838
+ ebool.wrap(randomHandle).asEuint256();
839
+ }
840
+
841
+ function testUninitializedHandleIsDisallowed_Not() public {
842
+ bytes32 randomHandle = keccak256("random handle not");
843
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
844
+ ebool.wrap(randomHandle).not();
845
+ }
846
+
847
+ function testUninitializedHandleIsDisallowed_EboolAnd_Lhs() public {
848
+ // Craft handle with valid Bool type byte (0) at bits 8-15
849
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle ebool and lhs")) & ~(uint256(0xFF) << 8));
850
+ ebool b = e.asEbool(true);
851
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
852
+ ebool.wrap(randomHandle).and(b);
853
+ }
854
+
855
+ function testUninitializedHandleIsDisallowed_EboolAnd_Rhs() public {
856
+ // Craft handle with valid Bool type byte (0) at bits 8-15
857
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle ebool and rhs")) & ~(uint256(0xFF) << 8));
858
+ ebool a = e.asEbool(true);
859
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
860
+ a.and(ebool.wrap(randomHandle));
861
+ }
862
+
863
+ function testUninitializedHandleIsDisallowed_EboolOr_Lhs() public {
864
+ // Craft handle with valid Bool type byte (0) at bits 8-15
865
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle ebool or lhs")) & ~(uint256(0xFF) << 8));
866
+ ebool b = e.asEbool(false);
867
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
868
+ ebool.wrap(randomHandle).or(b);
869
+ }
870
+
871
+ function testUninitializedHandleIsDisallowed_EboolOr_Rhs() public {
872
+ // Craft handle with valid Bool type byte (0) at bits 8-15
873
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle ebool or rhs")) & ~(uint256(0xFF) << 8));
874
+ ebool a = e.asEbool(false);
875
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
876
+ a.or(ebool.wrap(randomHandle));
877
+ }
878
+
879
+ function testUninitializedHandleIsDisallowed_EboolXor_Lhs() public {
880
+ // Craft handle with valid Bool type byte (0) at bits 8-15
881
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle ebool xor lhs")) & ~(uint256(0xFF) << 8));
882
+ ebool b = e.asEbool(true);
883
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
884
+ ebool.wrap(randomHandle).xor(b);
885
+ }
886
+
887
+ function testUninitializedHandleIsDisallowed_EboolXor_Rhs() public {
888
+ // Craft handle with valid Bool type byte (0) at bits 8-15
889
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle ebool xor rhs")) & ~(uint256(0xFF) << 8));
890
+ ebool a = e.asEbool(true);
891
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
892
+ a.xor(ebool.wrap(randomHandle));
893
+ }
894
+
895
+ function testUninitializedHandleIsDisallowed_EaddressEq_Lhs() public {
896
+ bytes32 randomHandle = keccak256("random handle eaddress eq lhs");
897
+ eaddress b = e.asEaddress(address(0xdeadbeef));
898
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
899
+ eaddress.wrap(randomHandle).eq(b);
900
+ }
901
+
902
+ function testUninitializedHandleIsDisallowed_EaddressEq_Rhs() public {
903
+ bytes32 randomHandle = keccak256("random handle eaddress eq rhs");
904
+ eaddress a = e.asEaddress(address(0xdeadbeef));
905
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
906
+ a.eq(eaddress.wrap(randomHandle));
907
+ }
908
+
909
+ function testUninitializedHandleIsDisallowed_EaddressNe_Lhs() public {
910
+ bytes32 randomHandle = keccak256("random handle eaddress ne lhs");
911
+ eaddress b = e.asEaddress(address(0xdeadbeef));
912
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
913
+ eaddress.wrap(randomHandle).ne(b);
914
+ }
915
+
916
+ function testUninitializedHandleIsDisallowed_EaddressNe_Rhs() public {
917
+ bytes32 randomHandle = keccak256("random handle eaddress ne rhs");
918
+ eaddress a = e.asEaddress(address(0xdeadbeef));
919
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
920
+ a.ne(eaddress.wrap(randomHandle));
921
+ }
922
+
923
+ function testUninitializedHandleIsDisallowed_SelectEuint256_Control() public {
924
+ bytes32 randomHandle = keccak256("random handle select euint256 control");
925
+ euint256 ifTrue = e.asEuint256(10);
926
+ euint256 ifFalse = e.asEuint256(20);
927
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
928
+ ebool.wrap(randomHandle).select(ifTrue, ifFalse);
929
+ }
930
+
931
+ function testUninitializedHandleIsDisallowed_SelectEuint256_IfTrue() public {
932
+ // Craft handle with valid Uint256 type byte (8) at bits 8-15
933
+ bytes32 randomHandle = bytes32(
934
+ (uint256(keccak256("random handle select euint256 iftrue")) & ~(uint256(0xFF) << 8)) | (uint256(8) << 8)
935
+ );
936
+ ebool control = e.asEbool(true);
937
+ euint256 ifFalse = e.asEuint256(20);
938
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
939
+ control.select(euint256.wrap(randomHandle), ifFalse);
940
+ }
941
+
942
+ function testUninitializedHandleIsDisallowed_SelectEuint256_IfFalse() public {
943
+ // Craft handle with valid Uint256 type byte (8) at bits 8-15
944
+ bytes32 randomHandle = bytes32(
945
+ (uint256(keccak256("random handle select euint256 iffalse")) & ~(uint256(0xFF) << 8)) | (uint256(8) << 8)
946
+ );
947
+ ebool control = e.asEbool(false);
948
+ euint256 ifTrue = e.asEuint256(10);
949
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
950
+ control.select(ifTrue, euint256.wrap(randomHandle));
951
+ }
952
+
953
+ function testUninitializedHandleIsDisallowed_SelectEbool_Control() public {
954
+ // Craft handle with valid Bool type byte (0) at bits 8-15
955
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle select ebool control")) & ~(uint256(0xFF) << 8));
956
+ ebool ifTrue = e.asEbool(true);
957
+ ebool ifFalse = e.asEbool(false);
958
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
959
+ ebool.wrap(randomHandle).select(ifTrue, ifFalse);
960
+ }
961
+
962
+ function testUninitializedHandleIsDisallowed_SelectEbool_IfTrue() public {
963
+ // Craft handle with valid Bool type byte (0) at bits 8-15
964
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle select ebool iftrue")) & ~(uint256(0xFF) << 8));
965
+ ebool control = e.asEbool(true);
966
+ ebool ifFalse = e.asEbool(false);
967
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
968
+ control.select(ebool.wrap(randomHandle), ifFalse);
969
+ }
970
+
971
+ function testUninitializedHandleIsDisallowed_SelectEbool_IfFalse() public {
972
+ // Craft handle with valid Bool type byte (0) at bits 8-15
973
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle select ebool iffalse")) & ~(uint256(0xFF) << 8));
974
+ ebool control = e.asEbool(false);
975
+ ebool ifTrue = e.asEbool(true);
976
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
977
+ control.select(ifTrue, ebool.wrap(randomHandle));
978
+ }
979
+
980
+ function testUninitializedHandleIsDisallowed_SelectEaddress_Control() public {
981
+ // Craft handle with valid Bool type byte (0) at bits 8-15 for control
982
+ bytes32 randomHandle =
983
+ bytes32(uint256(keccak256("random handle select eaddress control")) & ~(uint256(0xFF) << 8));
984
+ eaddress ifTrue = e.asEaddress(address(0x1));
985
+ eaddress ifFalse = e.asEaddress(address(0x2));
986
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
987
+ ebool.wrap(randomHandle).select(ifTrue, ifFalse);
988
+ }
989
+
990
+ function testUninitializedHandleIsDisallowed_SelectEaddress_IfTrue() public {
991
+ // Craft handle with valid AddressOrUint160OrBytes20 type byte (7) at bits 8-15
992
+ bytes32 randomHandle = bytes32(
993
+ (uint256(keccak256("random handle select eaddress iftrue")) & ~(uint256(0xFF) << 8)) | (uint256(7) << 8)
994
+ );
995
+ ebool control = e.asEbool(true);
996
+ eaddress ifFalse = e.asEaddress(address(0x2));
997
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
998
+ control.select(eaddress.wrap(randomHandle), ifFalse);
999
+ }
1000
+
1001
+ function testUninitializedHandleIsDisallowed_SelectEaddress_IfFalse() public {
1002
+ // Craft handle with valid AddressOrUint160OrBytes20 type byte (7) at bits 8-15
1003
+ bytes32 randomHandle = bytes32(
1004
+ (uint256(keccak256("random handle select eaddress iffalse")) & ~(uint256(0xFF) << 8)) | (uint256(7) << 8)
1005
+ );
1006
+ ebool control = e.asEbool(false);
1007
+ eaddress ifTrue = e.asEaddress(address(0x1));
1008
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1009
+ control.select(ifTrue, eaddress.wrap(randomHandle));
1010
+ }
1011
+
1012
+ function testUninitializedHandleIsDisallowed_AllowEuint256() public {
1013
+ bytes32 randomHandle = keccak256("random handle allow euint256");
1014
+ address recipient = address(0x1234);
1015
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1016
+ euint256.wrap(randomHandle).allow(recipient);
1017
+ }
1018
+
1019
+ function testUninitializedHandleIsDisallowed_AllowEbool() public {
1020
+ bytes32 randomHandle = keccak256("random handle allow ebool");
1021
+ address recipient = address(0x1234);
1022
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1023
+ ebool.wrap(randomHandle).allow(recipient);
1024
+ }
1025
+
1026
+ function testUninitializedHandleIsDisallowed_AllowEaddress() public {
1027
+ bytes32 randomHandle = keccak256("random handle allow eaddress");
1028
+ address recipient = address(0x1234);
1029
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1030
+ eaddress.wrap(randomHandle).allow(recipient);
1031
+ }
1032
+
1033
+ function testUninitializedHandleIsDisallowed_AllowThisEuint256() public {
1034
+ bytes32 randomHandle = keccak256("random handle allowThis euint256");
1035
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1036
+ euint256.wrap(randomHandle).allowThis();
1037
+ }
1038
+
1039
+ function testUninitializedHandleIsDisallowed_AllowThisEbool() public {
1040
+ bytes32 randomHandle = keccak256("random handle allowThis ebool");
1041
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1042
+ ebool.wrap(randomHandle).allowThis();
1043
+ }
1044
+
1045
+ function testUninitializedHandleIsDisallowed_AllowThisEaddress() public {
1046
+ bytes32 randomHandle = keccak256("random handle allowThis eaddress");
1047
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1048
+ eaddress.wrap(randomHandle).allowThis();
1049
+ }
1050
+
1051
+ function testUninitializedHandleIsDisallowed_RevealEuint256() public {
1052
+ bytes32 randomHandle = keccak256("random handle reveal euint256");
1053
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1054
+ euint256.wrap(randomHandle).reveal();
1055
+ }
1056
+
1057
+ function testUninitializedHandleIsDisallowed_RevealEbool() public {
1058
+ bytes32 randomHandle = keccak256("random handle reveal ebool");
1059
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1060
+ ebool.wrap(randomHandle).reveal();
1061
+ }
1062
+
1063
+ function testUninitializedHandleIsDisallowed_RevealEaddress() public {
1064
+ bytes32 randomHandle = keccak256("random handle reveal eaddress");
1065
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1066
+ eaddress.wrap(randomHandle).reveal();
1067
+ }
1068
+
1069
+ function testUninitializedHandleIsDisallowed_SanitizeEuint256() public {
1070
+ bytes32 randomHandle = keccak256("random handle sanitize euint256");
1071
+ euint256 a = e.asEuint256(10);
1072
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1073
+ a.add(euint256.wrap(randomHandle).s());
1074
+ }
1075
+
1076
+ function testUninitializedHandleIsDisallowed_SanitizeEbool() public {
1077
+ // Craft handle with valid Bool type byte (0) at bits 8-15
1078
+ bytes32 randomHandle = bytes32(uint256(keccak256("random handle sanitize ebool")) & ~(uint256(0xFF) << 8));
1079
+ ebool a = e.asEbool(true);
1080
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1081
+ a.and(ebool.wrap(randomHandle).s());
1082
+ }
1083
+
1084
+ function testUninitializedHandleIsDisallowed_SanitizeEaddress() public {
1085
+ bytes32 randomHandle = keccak256("random handle sanitize eaddress");
1086
+ eaddress a = e.asEaddress(address(0x1));
1087
+ vm.expectRevert(abi.encodeWithSelector(SenderNotAllowedForHandle.selector, randomHandle, address(this)));
1088
+ a.eq(eaddress.wrap(randomHandle).s());
1089
+ }
1090
+
556
1091
  function testCreateQuote() public view {
557
1092
  bytes memory mrtd =
558
1093
  hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";