@cofhe/mock-contracts 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cofhe/mock-contracts Changelog
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 342fd0f: Fix SSR compatibility (`@cofhe/sdk/web` no longer crashes Next.js builds with `self is not defined`) by lazy-loading `tfhe`. Align `@cofhe/mock-contracts` with `@fhenixprotocol/cofhe-contracts@^0.1.3` (updated `TestBed.sol` to use current decrypt API, added missing `ITaskManager` batch methods to `MockTaskManager.sol`).
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
@@ -697,4 +697,29 @@ contract MockTaskManager is ITaskManager, MockCoFHE {
697
697
  function isPubliclyAllowed(uint256 ctHash) external view returns (bool) {
698
698
  revert NotImplemented();
699
699
  }
700
+
701
+ function verifyDecryptResultBatch(
702
+ uint256[] calldata ctHashes,
703
+ uint256[] calldata results,
704
+ bytes[] calldata signatures
705
+ ) external view returns (bool) {
706
+ for (uint256 i = 0; i < ctHashes.length; i++) {
707
+ if (!_verifyDecryptResult(ctHashes[i], results[i], signatures[i], true)) {
708
+ return false;
709
+ }
710
+ }
711
+ return true;
712
+ }
713
+
714
+ function verifyDecryptResultBatchSafe(
715
+ uint256[] calldata ctHashes,
716
+ uint256[] calldata results,
717
+ bytes[] calldata signatures
718
+ ) external view returns (bool[] memory) {
719
+ bool[] memory out = new bool[](ctHashes.length);
720
+ for (uint256 i = 0; i < ctHashes.length; i++) {
721
+ out[i] = _verifyDecryptResult(ctHashes[i], results[i], signatures[i], false);
722
+ }
723
+ return out;
724
+ }
700
725
  }
@@ -1,6 +1,8 @@
1
1
  // SPDX-License-Identifier: UNLICENSED
2
2
  pragma solidity ^0.8.13;
3
3
 
4
+ import { TASK_MANAGER_ADDRESS } from '@fhenixprotocol/cofhe-contracts/FHE.sol';
5
+ import { ITaskManager } from '@fhenixprotocol/cofhe-contracts/ICofhe.sol';
4
6
  import '@fhenixprotocol/cofhe-contracts/FHE.sol';
5
7
 
6
8
  /// @title TestBed
@@ -78,7 +80,10 @@ contract TestBed {
78
80
  /// @notice Requests decryption of `eNumber`.
79
81
  /// @dev In real CoFHE this is asynchronous; in mocks it is simulated.
80
82
  function decrypt() public {
81
- FHE.decrypt(eNumber);
83
+ // The standalone `FHE.decrypt(...)` helper was removed in
84
+ // fhenixprotocol/cofhe-contracts 0.1.3, so we now go through the
85
+ // task manager interface directly.
86
+ ITaskManager(TASK_MANAGER_ADDRESS).createDecryptTask(uint256(numberHash), msg.sender);
82
87
  }
83
88
 
84
89
  /// @notice Reads a decryption result (reverts if not ready depending on implementation).
package/dist/index.d.mts CHANGED
@@ -587,6 +587,50 @@ declare const MockTaskManagerArtifact: {
587
587
  readonly internalType: "bool";
588
588
  }];
589
589
  readonly stateMutability: "view";
590
+ }, {
591
+ readonly type: "function";
592
+ readonly name: "verifyDecryptResultBatch";
593
+ readonly inputs: readonly [{
594
+ readonly name: "ctHashes";
595
+ readonly type: "uint256[]";
596
+ readonly internalType: "uint256[]";
597
+ }, {
598
+ readonly name: "results";
599
+ readonly type: "uint256[]";
600
+ readonly internalType: "uint256[]";
601
+ }, {
602
+ readonly name: "signatures";
603
+ readonly type: "bytes[]";
604
+ readonly internalType: "bytes[]";
605
+ }];
606
+ readonly outputs: readonly [{
607
+ readonly name: "";
608
+ readonly type: "bool";
609
+ readonly internalType: "bool";
610
+ }];
611
+ readonly stateMutability: "view";
612
+ }, {
613
+ readonly type: "function";
614
+ readonly name: "verifyDecryptResultBatchSafe";
615
+ readonly inputs: readonly [{
616
+ readonly name: "ctHashes";
617
+ readonly type: "uint256[]";
618
+ readonly internalType: "uint256[]";
619
+ }, {
620
+ readonly name: "results";
621
+ readonly type: "uint256[]";
622
+ readonly internalType: "uint256[]";
623
+ }, {
624
+ readonly name: "signatures";
625
+ readonly type: "bytes[]";
626
+ readonly internalType: "bytes[]";
627
+ }];
628
+ readonly outputs: readonly [{
629
+ readonly name: "";
630
+ readonly type: "bool[]";
631
+ readonly internalType: "bool[]";
632
+ }];
633
+ readonly stateMutability: "view";
590
634
  }, {
591
635
  readonly type: "function";
592
636
  readonly name: "verifyDecryptResultSafe";
@@ -2474,7 +2518,7 @@ type EncryptedInputStruct = {
2474
2518
  signature: BytesLike;
2475
2519
  };
2476
2520
  interface MockTaskManagerInterface extends Interface {
2477
- getFunction(nameOrSignature: 'MOCK_logAllow' | 'MOCK_setInEuintKey' | 'acl' | 'aggregator' | 'allow' | 'allowForDecryption' | 'allowGlobal' | 'allowTransient' | 'createDecryptTask' | 'createRandomTask' | 'createTask' | 'decryptResultSigner' | 'exists' | 'getDecryptResult' | 'getDecryptResultSafe' | 'handleDecryptResult' | 'handleError' | 'inMockStorage' | 'initialize' | 'isAllowed' | 'isAllowedWithPermission' | 'isInitialized' | 'isPubliclyAllowed' | 'logOps' | 'mockStorage' | 'publishDecryptResult' | 'publishDecryptResultBatch' | 'removeFirstLetter' | 'setACLContract' | 'setAggregator' | 'setDecryptResultSigner' | 'setLogOps' | 'setSecurityZoneMax' | 'setSecurityZoneMin' | 'setSecurityZones' | 'setVerifierSigner' | 'sliceString' | 'verifyDecryptResult' | 'verifyDecryptResultSafe' | 'verifyInput'): FunctionFragment;
2521
+ getFunction(nameOrSignature: 'MOCK_logAllow' | 'MOCK_setInEuintKey' | 'acl' | 'aggregator' | 'allow' | 'allowForDecryption' | 'allowGlobal' | 'allowTransient' | 'createDecryptTask' | 'createRandomTask' | 'createTask' | 'decryptResultSigner' | 'exists' | 'getDecryptResult' | 'getDecryptResultSafe' | 'handleDecryptResult' | 'handleError' | 'inMockStorage' | 'initialize' | 'isAllowed' | 'isAllowedWithPermission' | 'isInitialized' | 'isPubliclyAllowed' | 'logOps' | 'mockStorage' | 'publishDecryptResult' | 'publishDecryptResultBatch' | 'removeFirstLetter' | 'setACLContract' | 'setAggregator' | 'setDecryptResultSigner' | 'setLogOps' | 'setSecurityZoneMax' | 'setSecurityZoneMin' | 'setSecurityZones' | 'setVerifierSigner' | 'sliceString' | 'verifyDecryptResult' | 'verifyDecryptResultBatch' | 'verifyDecryptResultBatchSafe' | 'verifyDecryptResultSafe' | 'verifyInput'): FunctionFragment;
2478
2522
  getEvent(nameOrSignatureOrTopic: 'DecryptionResult' | 'ProtocolNotification' | 'TaskCreated'): EventFragment;
2479
2523
  encodeFunctionData(functionFragment: 'MOCK_logAllow', values: [string, BigNumberish, AddressLike]): string;
2480
2524
  encodeFunctionData(functionFragment: 'MOCK_setInEuintKey', values: [BigNumberish, BigNumberish]): string;
@@ -2514,6 +2558,8 @@ interface MockTaskManagerInterface extends Interface {
2514
2558
  encodeFunctionData(functionFragment: 'setVerifierSigner', values: [AddressLike]): string;
2515
2559
  encodeFunctionData(functionFragment: 'sliceString', values: [string, BigNumberish, BigNumberish]): string;
2516
2560
  encodeFunctionData(functionFragment: 'verifyDecryptResult', values: [BigNumberish, BigNumberish, BytesLike]): string;
2561
+ encodeFunctionData(functionFragment: 'verifyDecryptResultBatch', values: [BigNumberish[], BigNumberish[], BytesLike[]]): string;
2562
+ encodeFunctionData(functionFragment: 'verifyDecryptResultBatchSafe', values: [BigNumberish[], BigNumberish[], BytesLike[]]): string;
2517
2563
  encodeFunctionData(functionFragment: 'verifyDecryptResultSafe', values: [BigNumberish, BigNumberish, BytesLike]): string;
2518
2564
  encodeFunctionData(functionFragment: 'verifyInput', values: [EncryptedInputStruct, AddressLike]): string;
2519
2565
  decodeFunctionResult(functionFragment: 'MOCK_logAllow', data: BytesLike): Result;
@@ -2554,6 +2600,8 @@ interface MockTaskManagerInterface extends Interface {
2554
2600
  decodeFunctionResult(functionFragment: 'setVerifierSigner', data: BytesLike): Result;
2555
2601
  decodeFunctionResult(functionFragment: 'sliceString', data: BytesLike): Result;
2556
2602
  decodeFunctionResult(functionFragment: 'verifyDecryptResult', data: BytesLike): Result;
2603
+ decodeFunctionResult(functionFragment: 'verifyDecryptResultBatch', data: BytesLike): Result;
2604
+ decodeFunctionResult(functionFragment: 'verifyDecryptResultBatchSafe', data: BytesLike): Result;
2557
2605
  decodeFunctionResult(functionFragment: 'verifyDecryptResultSafe', data: BytesLike): Result;
2558
2606
  decodeFunctionResult(functionFragment: 'verifyInput', data: BytesLike): Result;
2559
2607
  }
@@ -2705,6 +2753,20 @@ interface MockTaskManager extends BaseContract {
2705
2753
  ], [
2706
2754
  boolean
2707
2755
  ], 'view'>;
2756
+ verifyDecryptResultBatch: TypedContractMethod<[
2757
+ ctHashes: BigNumberish[],
2758
+ results: BigNumberish[],
2759
+ signatures: BytesLike[]
2760
+ ], [
2761
+ boolean
2762
+ ], 'view'>;
2763
+ verifyDecryptResultBatchSafe: TypedContractMethod<[
2764
+ ctHashes: BigNumberish[],
2765
+ results: BigNumberish[],
2766
+ signatures: BytesLike[]
2767
+ ], [
2768
+ boolean[]
2769
+ ], 'view'>;
2708
2770
  verifyDecryptResultSafe: TypedContractMethod<[
2709
2771
  ctHash: BigNumberish,
2710
2772
  result: BigNumberish,
@@ -2774,6 +2836,20 @@ interface MockTaskManager extends BaseContract {
2774
2836
  getFunction(nameOrSignature: 'setVerifierSigner'): TypedContractMethod<[signer: AddressLike], [void], 'nonpayable'>;
2775
2837
  getFunction(nameOrSignature: 'sliceString'): TypedContractMethod<[str: string, start: BigNumberish, length: BigNumberish], [string], 'view'>;
2776
2838
  getFunction(nameOrSignature: 'verifyDecryptResult'): TypedContractMethod<[ctHash: BigNumberish, result: BigNumberish, signature: BytesLike], [boolean], 'view'>;
2839
+ getFunction(nameOrSignature: 'verifyDecryptResultBatch'): TypedContractMethod<[
2840
+ ctHashes: BigNumberish[],
2841
+ results: BigNumberish[],
2842
+ signatures: BytesLike[]
2843
+ ], [
2844
+ boolean
2845
+ ], 'view'>;
2846
+ getFunction(nameOrSignature: 'verifyDecryptResultBatchSafe'): TypedContractMethod<[
2847
+ ctHashes: BigNumberish[],
2848
+ results: BigNumberish[],
2849
+ signatures: BytesLike[]
2850
+ ], [
2851
+ boolean[]
2852
+ ], 'view'>;
2777
2853
  getFunction(nameOrSignature: 'verifyDecryptResultSafe'): TypedContractMethod<[ctHash: BigNumberish, result: BigNumberish, signature: BytesLike], [boolean], 'view'>;
2778
2854
  getFunction(nameOrSignature: 'verifyInput'): TypedContractMethod<[input: EncryptedInputStruct, sender: AddressLike], [bigint], 'nonpayable'>;
2779
2855
  getEvent(key: 'DecryptionResult'): TypedContractEvent<DecryptionResultEvent.InputTuple, DecryptionResultEvent.OutputTuple, DecryptionResultEvent.OutputObject>;
package/dist/index.d.ts CHANGED
@@ -587,6 +587,50 @@ declare const MockTaskManagerArtifact: {
587
587
  readonly internalType: "bool";
588
588
  }];
589
589
  readonly stateMutability: "view";
590
+ }, {
591
+ readonly type: "function";
592
+ readonly name: "verifyDecryptResultBatch";
593
+ readonly inputs: readonly [{
594
+ readonly name: "ctHashes";
595
+ readonly type: "uint256[]";
596
+ readonly internalType: "uint256[]";
597
+ }, {
598
+ readonly name: "results";
599
+ readonly type: "uint256[]";
600
+ readonly internalType: "uint256[]";
601
+ }, {
602
+ readonly name: "signatures";
603
+ readonly type: "bytes[]";
604
+ readonly internalType: "bytes[]";
605
+ }];
606
+ readonly outputs: readonly [{
607
+ readonly name: "";
608
+ readonly type: "bool";
609
+ readonly internalType: "bool";
610
+ }];
611
+ readonly stateMutability: "view";
612
+ }, {
613
+ readonly type: "function";
614
+ readonly name: "verifyDecryptResultBatchSafe";
615
+ readonly inputs: readonly [{
616
+ readonly name: "ctHashes";
617
+ readonly type: "uint256[]";
618
+ readonly internalType: "uint256[]";
619
+ }, {
620
+ readonly name: "results";
621
+ readonly type: "uint256[]";
622
+ readonly internalType: "uint256[]";
623
+ }, {
624
+ readonly name: "signatures";
625
+ readonly type: "bytes[]";
626
+ readonly internalType: "bytes[]";
627
+ }];
628
+ readonly outputs: readonly [{
629
+ readonly name: "";
630
+ readonly type: "bool[]";
631
+ readonly internalType: "bool[]";
632
+ }];
633
+ readonly stateMutability: "view";
590
634
  }, {
591
635
  readonly type: "function";
592
636
  readonly name: "verifyDecryptResultSafe";
@@ -2474,7 +2518,7 @@ type EncryptedInputStruct = {
2474
2518
  signature: BytesLike;
2475
2519
  };
2476
2520
  interface MockTaskManagerInterface extends Interface {
2477
- getFunction(nameOrSignature: 'MOCK_logAllow' | 'MOCK_setInEuintKey' | 'acl' | 'aggregator' | 'allow' | 'allowForDecryption' | 'allowGlobal' | 'allowTransient' | 'createDecryptTask' | 'createRandomTask' | 'createTask' | 'decryptResultSigner' | 'exists' | 'getDecryptResult' | 'getDecryptResultSafe' | 'handleDecryptResult' | 'handleError' | 'inMockStorage' | 'initialize' | 'isAllowed' | 'isAllowedWithPermission' | 'isInitialized' | 'isPubliclyAllowed' | 'logOps' | 'mockStorage' | 'publishDecryptResult' | 'publishDecryptResultBatch' | 'removeFirstLetter' | 'setACLContract' | 'setAggregator' | 'setDecryptResultSigner' | 'setLogOps' | 'setSecurityZoneMax' | 'setSecurityZoneMin' | 'setSecurityZones' | 'setVerifierSigner' | 'sliceString' | 'verifyDecryptResult' | 'verifyDecryptResultSafe' | 'verifyInput'): FunctionFragment;
2521
+ getFunction(nameOrSignature: 'MOCK_logAllow' | 'MOCK_setInEuintKey' | 'acl' | 'aggregator' | 'allow' | 'allowForDecryption' | 'allowGlobal' | 'allowTransient' | 'createDecryptTask' | 'createRandomTask' | 'createTask' | 'decryptResultSigner' | 'exists' | 'getDecryptResult' | 'getDecryptResultSafe' | 'handleDecryptResult' | 'handleError' | 'inMockStorage' | 'initialize' | 'isAllowed' | 'isAllowedWithPermission' | 'isInitialized' | 'isPubliclyAllowed' | 'logOps' | 'mockStorage' | 'publishDecryptResult' | 'publishDecryptResultBatch' | 'removeFirstLetter' | 'setACLContract' | 'setAggregator' | 'setDecryptResultSigner' | 'setLogOps' | 'setSecurityZoneMax' | 'setSecurityZoneMin' | 'setSecurityZones' | 'setVerifierSigner' | 'sliceString' | 'verifyDecryptResult' | 'verifyDecryptResultBatch' | 'verifyDecryptResultBatchSafe' | 'verifyDecryptResultSafe' | 'verifyInput'): FunctionFragment;
2478
2522
  getEvent(nameOrSignatureOrTopic: 'DecryptionResult' | 'ProtocolNotification' | 'TaskCreated'): EventFragment;
2479
2523
  encodeFunctionData(functionFragment: 'MOCK_logAllow', values: [string, BigNumberish, AddressLike]): string;
2480
2524
  encodeFunctionData(functionFragment: 'MOCK_setInEuintKey', values: [BigNumberish, BigNumberish]): string;
@@ -2514,6 +2558,8 @@ interface MockTaskManagerInterface extends Interface {
2514
2558
  encodeFunctionData(functionFragment: 'setVerifierSigner', values: [AddressLike]): string;
2515
2559
  encodeFunctionData(functionFragment: 'sliceString', values: [string, BigNumberish, BigNumberish]): string;
2516
2560
  encodeFunctionData(functionFragment: 'verifyDecryptResult', values: [BigNumberish, BigNumberish, BytesLike]): string;
2561
+ encodeFunctionData(functionFragment: 'verifyDecryptResultBatch', values: [BigNumberish[], BigNumberish[], BytesLike[]]): string;
2562
+ encodeFunctionData(functionFragment: 'verifyDecryptResultBatchSafe', values: [BigNumberish[], BigNumberish[], BytesLike[]]): string;
2517
2563
  encodeFunctionData(functionFragment: 'verifyDecryptResultSafe', values: [BigNumberish, BigNumberish, BytesLike]): string;
2518
2564
  encodeFunctionData(functionFragment: 'verifyInput', values: [EncryptedInputStruct, AddressLike]): string;
2519
2565
  decodeFunctionResult(functionFragment: 'MOCK_logAllow', data: BytesLike): Result;
@@ -2554,6 +2600,8 @@ interface MockTaskManagerInterface extends Interface {
2554
2600
  decodeFunctionResult(functionFragment: 'setVerifierSigner', data: BytesLike): Result;
2555
2601
  decodeFunctionResult(functionFragment: 'sliceString', data: BytesLike): Result;
2556
2602
  decodeFunctionResult(functionFragment: 'verifyDecryptResult', data: BytesLike): Result;
2603
+ decodeFunctionResult(functionFragment: 'verifyDecryptResultBatch', data: BytesLike): Result;
2604
+ decodeFunctionResult(functionFragment: 'verifyDecryptResultBatchSafe', data: BytesLike): Result;
2557
2605
  decodeFunctionResult(functionFragment: 'verifyDecryptResultSafe', data: BytesLike): Result;
2558
2606
  decodeFunctionResult(functionFragment: 'verifyInput', data: BytesLike): Result;
2559
2607
  }
@@ -2705,6 +2753,20 @@ interface MockTaskManager extends BaseContract {
2705
2753
  ], [
2706
2754
  boolean
2707
2755
  ], 'view'>;
2756
+ verifyDecryptResultBatch: TypedContractMethod<[
2757
+ ctHashes: BigNumberish[],
2758
+ results: BigNumberish[],
2759
+ signatures: BytesLike[]
2760
+ ], [
2761
+ boolean
2762
+ ], 'view'>;
2763
+ verifyDecryptResultBatchSafe: TypedContractMethod<[
2764
+ ctHashes: BigNumberish[],
2765
+ results: BigNumberish[],
2766
+ signatures: BytesLike[]
2767
+ ], [
2768
+ boolean[]
2769
+ ], 'view'>;
2708
2770
  verifyDecryptResultSafe: TypedContractMethod<[
2709
2771
  ctHash: BigNumberish,
2710
2772
  result: BigNumberish,
@@ -2774,6 +2836,20 @@ interface MockTaskManager extends BaseContract {
2774
2836
  getFunction(nameOrSignature: 'setVerifierSigner'): TypedContractMethod<[signer: AddressLike], [void], 'nonpayable'>;
2775
2837
  getFunction(nameOrSignature: 'sliceString'): TypedContractMethod<[str: string, start: BigNumberish, length: BigNumberish], [string], 'view'>;
2776
2838
  getFunction(nameOrSignature: 'verifyDecryptResult'): TypedContractMethod<[ctHash: BigNumberish, result: BigNumberish, signature: BytesLike], [boolean], 'view'>;
2839
+ getFunction(nameOrSignature: 'verifyDecryptResultBatch'): TypedContractMethod<[
2840
+ ctHashes: BigNumberish[],
2841
+ results: BigNumberish[],
2842
+ signatures: BytesLike[]
2843
+ ], [
2844
+ boolean
2845
+ ], 'view'>;
2846
+ getFunction(nameOrSignature: 'verifyDecryptResultBatchSafe'): TypedContractMethod<[
2847
+ ctHashes: BigNumberish[],
2848
+ results: BigNumberish[],
2849
+ signatures: BytesLike[]
2850
+ ], [
2851
+ boolean[]
2852
+ ], 'view'>;
2777
2853
  getFunction(nameOrSignature: 'verifyDecryptResultSafe'): TypedContractMethod<[ctHash: BigNumberish, result: BigNumberish, signature: BytesLike], [boolean], 'view'>;
2778
2854
  getFunction(nameOrSignature: 'verifyInput'): TypedContractMethod<[input: EncryptedInputStruct, sender: AddressLike], [bigint], 'nonpayable'>;
2779
2855
  getEvent(key: 'DecryptionResult'): TypedContractEvent<DecryptionResultEvent.InputTuple, DecryptionResultEvent.OutputTuple, DecryptionResultEvent.OutputObject>;
package/dist/index.js CHANGED
@@ -754,6 +754,64 @@ var MockTaskManagerArtifact = {
754
754
  ],
755
755
  stateMutability: "view"
756
756
  },
757
+ {
758
+ type: "function",
759
+ name: "verifyDecryptResultBatch",
760
+ inputs: [
761
+ {
762
+ name: "ctHashes",
763
+ type: "uint256[]",
764
+ internalType: "uint256[]"
765
+ },
766
+ {
767
+ name: "results",
768
+ type: "uint256[]",
769
+ internalType: "uint256[]"
770
+ },
771
+ {
772
+ name: "signatures",
773
+ type: "bytes[]",
774
+ internalType: "bytes[]"
775
+ }
776
+ ],
777
+ outputs: [
778
+ {
779
+ name: "",
780
+ type: "bool",
781
+ internalType: "bool"
782
+ }
783
+ ],
784
+ stateMutability: "view"
785
+ },
786
+ {
787
+ type: "function",
788
+ name: "verifyDecryptResultBatchSafe",
789
+ inputs: [
790
+ {
791
+ name: "ctHashes",
792
+ type: "uint256[]",
793
+ internalType: "uint256[]"
794
+ },
795
+ {
796
+ name: "results",
797
+ type: "uint256[]",
798
+ internalType: "uint256[]"
799
+ },
800
+ {
801
+ name: "signatures",
802
+ type: "bytes[]",
803
+ internalType: "bytes[]"
804
+ }
805
+ ],
806
+ outputs: [
807
+ {
808
+ name: "",
809
+ type: "bool[]",
810
+ internalType: "bool[]"
811
+ }
812
+ ],
813
+ stateMutability: "view"
814
+ },
757
815
  {
758
816
  type: "function",
759
817
  name: "verifyDecryptResultSafe",