@inco/lightning 0.4.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 +4 -0
- package/README.md +2 -0
- package/manifest.yaml +23 -0
- package/package.json +2 -5
- package/src/DeployUtils.sol +113 -77
- package/src/IIncoLightning.sol +16 -9
- package/src/IncoLightning.sol +18 -9
- package/src/IncoVerifier.sol +47 -0
- package/src/Lib.alphanet.sol +2 -15
- package/src/Lib.demonet.sol +2 -15
- package/src/Lib.devnet.sol +3 -16
- package/src/Lib.sol +3 -16
- package/src/Lib.template.sol +3 -44
- package/src/Lib.testnet.sol +2 -15
- package/src/Types.sol +7 -0
- package/src/interfaces/IIncoLightning.sol +20 -0
- package/src/interfaces/IIncoVerifier.sol +24 -0
- package/src/interfaces/automata-interfaces/BELE.sol +20 -0
- package/src/interfaces/automata-interfaces/IAutomataEnclaveIdentityDao.sol +28 -0
- package/src/interfaces/automata-interfaces/IFmspcTcbDao.sol +10 -0
- package/src/interfaces/automata-interfaces/IPCCSRouter.sol +94 -0
- package/src/interfaces/automata-interfaces/IPCCSRouterExtended.sol +10 -0
- package/src/interfaces/automata-interfaces/IPcsDao.sol +18 -0
- package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +34 -0
- package/src/interfaces/automata-interfaces/Types.sol +193 -0
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +2 -15
- package/src/libs/incoLightning_demonet_v0_863421733.sol +2 -15
- package/src/libs/incoLightning_devnet_v0_340846814.sol +2 -15
- package/src/libs/incoLightning_devnet_v1_887305889.sol +451 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +2 -15
- package/src/libs/incoLightning_testnet_v1_938327937.sol +451 -0
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +133 -0
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.types.sol +18 -0
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +22 -2
- package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +25 -0
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +24 -0
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +234 -0
- package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +4 -3
- package/src/lightning-parts/DecryptionAttester.sol +45 -0
- package/src/lightning-parts/DecryptionAttester.types.sol +7 -0
- package/src/lightning-parts/EncryptedInput.sol +8 -13
- package/src/lightning-parts/EncryptedOperations.sol +2 -2
- package/src/lightning-parts/TEELifecycle.sol +180 -88
- package/src/lightning-parts/TrivialEncryption.sol +8 -10
- package/src/lightning-parts/interfaces/IDecryptionAttester.sol +9 -0
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +19 -0
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +31 -0
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +26 -0
- package/src/lightning-parts/interfaces/ITrivialEncryption.sol +10 -0
- package/src/lightning-parts/primitives/EventCounter.sol +2 -2
- package/src/lightning-parts/primitives/HandleGeneration.sol +8 -3
- package/src/lightning-parts/primitives/HandleMetadata.sol +1 -1
- package/src/lightning-parts/primitives/LightningAddressGetter.sol +10 -0
- package/src/lightning-parts/primitives/SignatureVerifier.sol +2 -9
- package/src/lightning-parts/primitives/VerifierAddressGetter.sol +13 -0
- package/src/lightning-parts/primitives/{EventCounter.gen.sol → interfaces/IEventCounter.sol} +2 -2
- package/src/lightning-parts/primitives/interfaces/IHandleGeneration.sol +41 -0
- package/src/lightning-parts/primitives/interfaces/ISignatureVerifier.sol +9 -0
- package/src/lightning-parts/primitives/interfaces/IVerifierAddressGetter.sol +8 -0
- package/src/lightning-parts/test/HandleMetadata.t.sol +25 -6
- package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +78 -0
- package/src/periphery/SessionVerifier.sol +63 -0
- package/src/test/AddTwo.sol +18 -33
- package/src/test/FakeIncoInfra/FakeDecryptionAttester.sol +198 -0
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +0 -15
- package/src/test/FakeIncoInfra/FakeQuoteVerifier.sol +10 -6
- package/src/test/FakeIncoInfra/MockOpHandler.sol +0 -7
- package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +19 -7
- package/src/test/FakeIncoInfra/getOpForSelector.sol +0 -3
- package/src/test/IncoTest.sol +12 -11
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +98 -77
- package/src/test/TestAddTwo.t.sol +16 -9
- package/src/test/TestFakeInfra.t.sol +10 -27
- package/src/test/TestUpgrade.t.sol +11 -4
- package/src/test/TestVersion.t.sol +0 -7
- package/src/version/IncoLightningConfig.sol +5 -4
- package/src/version/SessionVerifierConfig.sol +8 -0
- package/src/version/Version.sol +7 -9
- package/src/version/interfaces/IVersion.sol +8 -0
- package/src/DeployTEE.sol +0 -153
- package/src/IncoLightning.gen.sol +0 -15
- package/src/lightning-parts/AccessControl/BaseAccessControlList.gen.sol +0 -24
- package/src/lightning-parts/DecryptionHandler.gen.sol +0 -54
- package/src/lightning-parts/DecryptionHandler.sol +0 -307
- package/src/lightning-parts/DecryptionHandler.types.sol +0 -34
- package/src/lightning-parts/EncryptedInput.gen.sol +0 -16
- package/src/lightning-parts/EncryptedOperations.gen.sol +0 -59
- package/src/lightning-parts/TEELifecycle.gen.sol +0 -58
- package/src/lightning-parts/TrivialEncryption.gen.sol +0 -15
- package/src/lightning-parts/primitives/HandleGeneration.gen.sol +0 -19
- package/src/lightning-parts/primitives/HandleMetadata.gen.sol +0 -4
- package/src/lightning-parts/primitives/SignatureVerifier.gen.sol +0 -16
- package/src/test/FibonacciDecrypt.sol +0 -49
- package/src/test/TEELifecycle/TEELifecycleHWTest.t.sol +0 -119
- package/src/test/TEELifecycle/addnode_data/eoa.txt +0 -1
- package/src/test/TEELifecycle/addnode_data/quote.bin +0 -0
- package/src/test/TEELifecycle/bootstrap_data/ecies_pubkey.bin +0 -1
- package/src/test/TEELifecycle/bootstrap_data/eip712_signature.bin +0 -1
- package/src/test/TEELifecycle/bootstrap_data/eoa.txt +0 -1
- package/src/test/TEELifecycle/bootstrap_data/qe_identity +0 -1
- package/src/test/TEELifecycle/bootstrap_data/qe_identity_signature.bin +0 -1
- package/src/test/TEELifecycle/bootstrap_data/quote.bin +0 -0
- package/src/test/TEELifecycle/bootstrap_data/tcb_info +0 -1
- package/src/test/TEELifecycle/bootstrap_data/tcb_info_signature.bin +0 -1
- package/src/test/TEELifecycle/test_cert/AttestationReportSigningCA.crl +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_Attestation_RootCA.cer +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_PCK_CRL.crl +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_PCK_PlatformCA.cer +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_TCB_Signing.cer +0 -0
- package/src/version/Version.gen.sol +0 -14
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import {IncoTest} from "../../../test/IncoTest.sol";
|
|
5
|
+
import {SessionVerifier, Session} from "../../../periphery/SessionVerifier.sol";
|
|
6
|
+
import {AllowanceVoucher, AllowanceProof} from "../AdvancedAccessControl.sol";
|
|
7
|
+
import {euint256} from "../../../Types.sol";
|
|
8
|
+
import {e, inco} from "../../../Lib.sol";
|
|
9
|
+
import {AdvancedAccessControl} from "../AdvancedAccessControl.sol";
|
|
10
|
+
import {ALLOWANCE_GRANTED_MAGIC_VALUE} from "../../../Types.sol";
|
|
11
|
+
import {IIncoVerifier} from "../../../interfaces/IIncoVerifier.sol";
|
|
12
|
+
|
|
13
|
+
contract SomeContractWithConfidentialData {
|
|
14
|
+
using e for bytes;
|
|
15
|
+
using e for euint256;
|
|
16
|
+
|
|
17
|
+
euint256 public secret;
|
|
18
|
+
|
|
19
|
+
function saveAPersonalSecret(bytes memory ciphertext) public {
|
|
20
|
+
secret = ciphertext.newEuint256(msg.sender);
|
|
21
|
+
secret.allow(msg.sender);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
contract SomeVerifier {
|
|
26
|
+
struct SharerArg {
|
|
27
|
+
bytes32 handleShared;
|
|
28
|
+
address allowedAccount;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
struct RequesterArg {
|
|
32
|
+
bytes2 mustBeBeef;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function someCheck(
|
|
36
|
+
bytes32 handle,
|
|
37
|
+
address account,
|
|
38
|
+
bytes memory sharerArgData,
|
|
39
|
+
bytes memory requesterArgData
|
|
40
|
+
) public pure returns (bytes32) {
|
|
41
|
+
SharerArg memory sharerArg = abi.decode(sharerArgData, (SharerArg));
|
|
42
|
+
RequesterArg memory requesterArg = abi.decode(
|
|
43
|
+
requesterArgData,
|
|
44
|
+
(RequesterArg)
|
|
45
|
+
);
|
|
46
|
+
if (
|
|
47
|
+
requesterArg.mustBeBeef == bytes2(0xbeef) &&
|
|
48
|
+
sharerArg.handleShared == handle &&
|
|
49
|
+
sharerArg.allowedAccount == account
|
|
50
|
+
) {
|
|
51
|
+
return ALLOWANCE_GRANTED_MAGIC_VALUE;
|
|
52
|
+
}
|
|
53
|
+
return bytes32(0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
contract DoesNotVerifyAnything {
|
|
58
|
+
function someCheck(
|
|
59
|
+
bytes32 /* handle */,
|
|
60
|
+
address /* account */,
|
|
61
|
+
bytes memory /* sharerArgData */,
|
|
62
|
+
bytes memory /* requesterArgData */
|
|
63
|
+
) public pure returns (bytes32) {
|
|
64
|
+
return ALLOWANCE_GRANTED_MAGIC_VALUE;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
contract TestAdvancedAccessControl is IncoTest {
|
|
69
|
+
SomeContractWithConfidentialData someContract;
|
|
70
|
+
bytes32 secretHandle;
|
|
71
|
+
IIncoVerifier incoVerifier;
|
|
72
|
+
|
|
73
|
+
function setUp() public override {
|
|
74
|
+
super.setUp();
|
|
75
|
+
someContract = new SomeContractWithConfidentialData();
|
|
76
|
+
bytes memory secretCt = fakePrepareEuint256Ciphertext(42);
|
|
77
|
+
vm.prank(alice);
|
|
78
|
+
someContract.saveAPersonalSecret(secretCt);
|
|
79
|
+
secretHandle = euint256.unwrap(someContract.secret());
|
|
80
|
+
incoVerifier = inco.incoVerifier();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function testAdvancedSharingWithSession() public {
|
|
84
|
+
SessionVerifier sessionVerifier = new SessionVerifier("");
|
|
85
|
+
assertFalse(
|
|
86
|
+
inco.isAllowed(secretHandle, bob),
|
|
87
|
+
"bob should't be allowed on secret yet"
|
|
88
|
+
);
|
|
89
|
+
assertTrue(
|
|
90
|
+
inco.isAllowed(secretHandle, alice),
|
|
91
|
+
"alice should be allowed on secret"
|
|
92
|
+
);
|
|
93
|
+
AllowanceVoucher memory aliceSessionVoucherForBob = AllowanceVoucher({
|
|
94
|
+
sessionNonce: bytes32(0),
|
|
95
|
+
verifyingContract: address(sessionVerifier),
|
|
96
|
+
callFunction: SessionVerifier.canUseSession.selector,
|
|
97
|
+
sharerArgData: abi.encode(
|
|
98
|
+
Session({decrypter: bob, expiresAt: block.timestamp + 1 days})
|
|
99
|
+
)
|
|
100
|
+
});
|
|
101
|
+
AllowanceProof memory bobsProof = getBobsProof(
|
|
102
|
+
aliceSessionVoucherForBob
|
|
103
|
+
);
|
|
104
|
+
assertTrue(
|
|
105
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsProof),
|
|
106
|
+
"bob should be allowed on secret with proof"
|
|
107
|
+
);
|
|
108
|
+
vm.prank(bob);
|
|
109
|
+
inco.claimHandle(secretHandle, bobsProof);
|
|
110
|
+
assertTrue(
|
|
111
|
+
inco.persistAllowed(secretHandle, bob),
|
|
112
|
+
"bob should have claimed persistent allowance on secret"
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function testVoucherSessionIdCheck() public {
|
|
117
|
+
DoesNotVerifyAnything verifier = new DoesNotVerifyAnything();
|
|
118
|
+
AllowanceVoucher memory voucher = AllowanceVoucher({
|
|
119
|
+
sessionNonce: bytes32(0),
|
|
120
|
+
verifyingContract: address(verifier),
|
|
121
|
+
callFunction: verifier.someCheck.selector,
|
|
122
|
+
sharerArgData: ""
|
|
123
|
+
});
|
|
124
|
+
AllowanceProof memory bobsFirstProof = getBobsProof(voucher);
|
|
125
|
+
assertTrue(
|
|
126
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsFirstProof),
|
|
127
|
+
"the initial vouchers session nonce should be 0"
|
|
128
|
+
);
|
|
129
|
+
bytes32 madeUpNonce = bytes32(bytes4(0xdeadbeef));
|
|
130
|
+
voucher = AllowanceVoucher({
|
|
131
|
+
sessionNonce: madeUpNonce,
|
|
132
|
+
verifyingContract: address(verifier),
|
|
133
|
+
callFunction: verifier.someCheck.selector,
|
|
134
|
+
sharerArgData: ""
|
|
135
|
+
});
|
|
136
|
+
AllowanceProof memory invalidBobProof = getBobsProof(voucher);
|
|
137
|
+
// the session nonce should be checked by inco
|
|
138
|
+
vm.expectRevert(
|
|
139
|
+
abi.encodeWithSelector(
|
|
140
|
+
AdvancedAccessControl.InvalidVoucherSessionNonce.selector,
|
|
141
|
+
madeUpNonce,
|
|
142
|
+
bytes32(0)
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, invalidBobProof);
|
|
146
|
+
vm.prank(alice);
|
|
147
|
+
incoVerifier.updateActiveVouchersSessionNonce();
|
|
148
|
+
bytes32 alicesNewNonce = incoVerifier.getActiveVouchersSessionNonce(
|
|
149
|
+
alice
|
|
150
|
+
);
|
|
151
|
+
// previously valid voucher should now be invalid
|
|
152
|
+
vm.expectRevert(
|
|
153
|
+
abi.encodeWithSelector(
|
|
154
|
+
AdvancedAccessControl.InvalidVoucherSessionNonce.selector,
|
|
155
|
+
bytes32(0),
|
|
156
|
+
alicesNewNonce
|
|
157
|
+
)
|
|
158
|
+
);
|
|
159
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsFirstProof);
|
|
160
|
+
voucher = AllowanceVoucher({
|
|
161
|
+
sessionNonce: alicesNewNonce,
|
|
162
|
+
verifyingContract: address(verifier),
|
|
163
|
+
callFunction: verifier.someCheck.selector,
|
|
164
|
+
sharerArgData: ""
|
|
165
|
+
});
|
|
166
|
+
AllowanceProof memory bobsSecondProof = getBobsProof(voucher);
|
|
167
|
+
assertTrue(
|
|
168
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsSecondProof),
|
|
169
|
+
"the voucher should signed with the new nonce should be valid"
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function testSessionVerifierAreCorrectlyCalledAsCheckers() public {
|
|
174
|
+
SomeVerifier verifier = new SomeVerifier();
|
|
175
|
+
AllowanceVoucher memory voucher = AllowanceVoucher({
|
|
176
|
+
sessionNonce: bytes32(0),
|
|
177
|
+
verifyingContract: address(verifier),
|
|
178
|
+
callFunction: verifier.someCheck.selector,
|
|
179
|
+
sharerArgData: abi.encode(
|
|
180
|
+
SomeVerifier.SharerArg({
|
|
181
|
+
handleShared: secretHandle,
|
|
182
|
+
allowedAccount: bob
|
|
183
|
+
})
|
|
184
|
+
)
|
|
185
|
+
});
|
|
186
|
+
AllowanceProof memory bobsProof = AllowanceProof({
|
|
187
|
+
sharer: alice,
|
|
188
|
+
voucher: voucher,
|
|
189
|
+
voucherSignature: getAliceSig(voucher),
|
|
190
|
+
requesterArgData: abi.encode(
|
|
191
|
+
SomeVerifier.RequesterArg({mustBeBeef: bytes2(0xbeef)})
|
|
192
|
+
)
|
|
193
|
+
});
|
|
194
|
+
assertTrue(
|
|
195
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsProof),
|
|
196
|
+
"bob should be allowed on secret with proof"
|
|
197
|
+
);
|
|
198
|
+
bobsProof = AllowanceProof({
|
|
199
|
+
sharer: alice,
|
|
200
|
+
voucher: voucher,
|
|
201
|
+
voucherSignature: getAliceSig(voucher),
|
|
202
|
+
requesterArgData: abi.encode(
|
|
203
|
+
SomeVerifier.RequesterArg({mustBeBeef: bytes2(0xbebe)})
|
|
204
|
+
)
|
|
205
|
+
});
|
|
206
|
+
assertFalse(
|
|
207
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsProof),
|
|
208
|
+
"all parameters should be checked"
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function getBobsProof(
|
|
213
|
+
AllowanceVoucher memory alicesVoucher
|
|
214
|
+
) private view returns (AllowanceProof memory) {
|
|
215
|
+
bytes memory voucherSignature = getAliceSig(alicesVoucher);
|
|
216
|
+
return
|
|
217
|
+
AllowanceProof({
|
|
218
|
+
sharer: alice,
|
|
219
|
+
voucher: alicesVoucher,
|
|
220
|
+
voucherSignature: voucherSignature,
|
|
221
|
+
requesterArgData: ""
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function getAliceSig(
|
|
226
|
+
AllowanceVoucher memory voucher
|
|
227
|
+
) private view returns (bytes memory) {
|
|
228
|
+
return
|
|
229
|
+
getSignatureForDigest(
|
|
230
|
+
incoVerifier.allowanceVoucherDigest(voucher),
|
|
231
|
+
alicePrivKey
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {BaseAccessControlList} from "../BaseAccessControlList.sol";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {VerifierAddressGetter} from "../../primitives/VerifierAddressGetter.sol";
|
|
6
|
+
import {euint256, inco} from "../../../Lib.sol";
|
|
7
|
+
import {IncoTest} from "../../../test/IncoTest.sol";
|
|
7
8
|
|
|
8
9
|
contract TestBaseAccessControl is BaseAccessControlList, IncoTest {
|
|
9
|
-
|
|
10
|
+
constructor() VerifierAddressGetter(address(0)) {}
|
|
10
11
|
|
|
11
12
|
function testHandleZeroIsDisallowed() public view {
|
|
12
13
|
bytes32 handle = bytes32(0);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import {DecryptionAttestation} from "./DecryptionAttester.types.sol";
|
|
5
|
+
import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
|
|
6
|
+
import {SignatureVerifier} from "./primitives/SignatureVerifier.sol";
|
|
7
|
+
import {IDecryptionAttester} from "./interfaces/IDecryptionAttester.sol";
|
|
8
|
+
|
|
9
|
+
// todo pre charging transient decrypted values leads to a superior DevX
|
|
10
|
+
|
|
11
|
+
// todo #1032 add DecryptionAttester to IncoVerifier, will include signature verifier as well and fix #874
|
|
12
|
+
abstract contract DecryptionAttester is
|
|
13
|
+
IDecryptionAttester,
|
|
14
|
+
SignatureVerifier,
|
|
15
|
+
EIP712Upgradeable
|
|
16
|
+
{
|
|
17
|
+
bytes32 constant DecryptionAttestationStructHash =
|
|
18
|
+
keccak256("DecryptionAttestation(bytes32 handle,bytes32 value)");
|
|
19
|
+
|
|
20
|
+
function decryptionAttestationDigest(
|
|
21
|
+
DecryptionAttestation memory decryption
|
|
22
|
+
) public view returns (bytes32) {
|
|
23
|
+
return
|
|
24
|
+
_hashTypedDataV4(
|
|
25
|
+
keccak256(
|
|
26
|
+
abi.encode(
|
|
27
|
+
DecryptionAttestationStructHash,
|
|
28
|
+
decryption.handle,
|
|
29
|
+
decryption.value
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isValidDecryptionAttestation(
|
|
36
|
+
DecryptionAttestation memory decryption,
|
|
37
|
+
bytes memory signature
|
|
38
|
+
) public view returns (bool) {
|
|
39
|
+
return
|
|
40
|
+
isValidSignature(
|
|
41
|
+
decryptionAttestationDigest(decryption),
|
|
42
|
+
signature
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -4,17 +4,16 @@ pragma solidity ^0.8;
|
|
|
4
4
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
5
5
|
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
6
6
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
7
|
-
import {euint256, ebool, eaddress,
|
|
8
|
-
import {
|
|
7
|
+
import {euint256, ebool, eaddress, ETypes} from "../Types.sol";
|
|
8
|
+
import {IEncryptedInput} from "./interfaces/IEncryptedInput.sol";
|
|
9
9
|
import {HandleAlreadyExists} from "../Errors.sol";
|
|
10
10
|
|
|
11
11
|
abstract contract EncryptedInput is
|
|
12
|
-
|
|
12
|
+
IEncryptedInput,
|
|
13
13
|
BaseAccessControlList,
|
|
14
14
|
EventCounter,
|
|
15
15
|
HandleGeneration
|
|
16
16
|
{
|
|
17
|
-
|
|
18
17
|
event NewInput(
|
|
19
18
|
bytes32 indexed result,
|
|
20
19
|
address indexed contractAddress,
|
|
@@ -42,7 +41,10 @@ abstract contract EncryptedInput is
|
|
|
42
41
|
bytes memory ciphertext,
|
|
43
42
|
address user
|
|
44
43
|
) external returns (eaddress newValue) {
|
|
45
|
-
return
|
|
44
|
+
return
|
|
45
|
+
eaddress.wrap(
|
|
46
|
+
newInput(ciphertext, user, ETypes.AddressOrUint160OrBytes20)
|
|
47
|
+
);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
function newInput(
|
|
@@ -58,14 +60,7 @@ abstract contract EncryptedInput is
|
|
|
58
60
|
allowInternal(newHandle, user);
|
|
59
61
|
allowTransientInternal(newHandle, msg.sender);
|
|
60
62
|
uint256 id = getNextEventId();
|
|
61
|
-
emit NewInput(
|
|
62
|
-
newHandle,
|
|
63
|
-
msg.sender,
|
|
64
|
-
user,
|
|
65
|
-
inputType,
|
|
66
|
-
ciphertext,
|
|
67
|
-
id
|
|
68
|
-
);
|
|
63
|
+
emit NewInput(newHandle, msg.sender, user, inputType, ciphertext, id);
|
|
69
64
|
setDigest(abi.encodePacked(newHandle, id));
|
|
70
65
|
}
|
|
71
66
|
}
|
|
@@ -5,10 +5,10 @@ import {euint256, ebool, EOps, SenderNotAllowedForHandle, ETypes, isTypeSupporte
|
|
|
5
5
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
6
6
|
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
7
7
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
8
|
-
import {
|
|
8
|
+
import {IEncryptedOperations} from "./interfaces/IEncryptedOperations.sol";
|
|
9
9
|
|
|
10
10
|
abstract contract EncryptedOperations is
|
|
11
|
-
|
|
11
|
+
IEncryptedOperations,
|
|
12
12
|
BaseAccessControlList,
|
|
13
13
|
EventCounter,
|
|
14
14
|
HandleGeneration
|