-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtest-is-publicly-decryptable.js
More file actions
executable file
·47 lines (37 loc) · 1.39 KB
/
test-is-publicly-decryptable.js
File metadata and controls
executable file
·47 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
import { ACL } from '../../../lib/internal.js';
import { logCLI, parseCommonOptions } from '../../utils.js';
import { FHETestAddresses } from './fheTest.js';
import { ethers } from 'ethers';
// npx . test is-publicly-decryptable --type euint32 --network devnet
// npx . test is-publicly-decryptable --type euint32 --network testnet
// npx . test is-publicly-decryptable --type euint32 --network mainnet
export async function testFHETestIsPubliclyDecryptableCommand(options) {
const { config, provider, signer, zamaFhevmApiKey } =
parseCommonOptions(options);
if (!FHETestAddresses[config.name]) {
logCLI(`❌ FHETest is not deployed on network ${config.name}`, options);
process.exit(1);
}
const contractAddress = FHETestAddresses[config.name];
// Turn 'euint32' into 'Euint32'
const t = 'E' + options.type.substring(1);
const funcName = `makePubliclyDecryptable${t}`;
const getFuncName = `get${t}`;
const contract = new ethers.Contract(
contractAddress,
[
`function ${funcName}() external`,
`function ${getFuncName}() view returns (bytes32)`,
],
signer,
);
const handle = await contract[getFuncName]();
logCLI(`🏈 handle: ${handle}`);
const acl = new ACL({
aclContractAddress: config.fhevmInstanceConfig.aclContractAddress,
provider,
});
const ok = await acl.isAllowedForDecryption([handle]);
console.log(ok[0]);
}