Public Decryption ​
A handle can be made publicly decryptable, allowing anyone to decrypt its value and use the handle as an input.
INFO
Anyone can get the decrypted value of a publicly decryptable handle with the publicDecrypt method of the SDK.
Checking Public Decryption ​
The Nox protocol smart contract provides a function to check if a specific handle is publicly decryptable:
solidity
function isPubliclyDecryptable(bytes32 handle) external view returns (bool);isPubliclyDecryptable ABI:
json
[
{
"inputs": [
{
"internalType": "bytes32",
"name": "handle",
"type": "bytes32"
}
],
"name": "isPubliclyDecryptable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]ts
const noxContract = new Contract(
NOX_CONTRACT_ADDRESS,
NOX_CONTRACT_ABI,
provider
);
const isPubliclyDecryptable: boolean =
await noxContract.isPubliclyDecryptable(handle);ts
const isPubliclyDecryptable = await publicClient.readContract({
address: NOX_CONTRACT_ADDRESS,
abi: NOX_CONTRACT_ABI,
functionName: 'isPubliclyDecryptable',
args: [handle],
});Allowing Public Decryption ​
The Nox protocol smart contract provides a function for admins to make a handle publicly decryptable:
INFO
Only allowed admins can make a handle publicly decryptable. (see Manage Admins guide for more details on admins management).
WARNING
Once a handle is made publicly decryptable, it cannot be reversed.
solidity
function allowPublicDecryption(bytes32 handle) external;allowPublicDecryption ABI:
json
[
{
"inputs": [
{
"internalType": "bytes32",
"name": "handle",
"type": "bytes32"
}
],
"name": "allowPublicDecryption",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]ts
const noxContract = new Contract(
NOX_CONTRACT_ADDRESS,
NOX_CONTRACT_ABI,
signer
);
const tx = await noxContract.allowPublicDecryption(handle);
await tx.wait();ts
const [userAddress] = await walletClient.getAddresses();
await walletClient.writeContract({
account: userAddress,
chain: CHAIN,
address: NOX_CONTRACT_ADDRESS,
abi: NOX_CONTRACT_ABI,
functionName: 'allowPublicDecryption',
args: [handle],
});