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:
function isPubliclyDecryptable(bytes32 handle) external view returns (bool);isPubliclyDecryptable ABI:
[
{
"inputs": [
{
"internalType": "bytes32",
"name": "handle",
"type": "bytes32"
}
],
"name": "isPubliclyDecryptable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]const noxContract = new Contract(
NOX_CONTRACT_ADDRESS,
NOX_CONTRACT_ABI,
provider
);
const isPubliclyDecryptable: boolean =
await noxContract.isPubliclyDecryptable(handle);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.
Anyone can decrypt and store the value once it is public. Revoking public access would not erase copies already made.
function allowPublicDecryption(bytes32 handle) external;allowPublicDecryption ABI:
[
{
"inputs": [
{
"internalType": "bytes32",
"name": "handle",
"type": "bytes32"
}
],
"name": "allowPublicDecryption",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]const noxContract = new Contract(
NOX_CONTRACT_ADDRESS,
NOX_CONTRACT_ABI,
signer
);
const tx = await noxContract.allowPublicDecryption(handle);
await tx.wait();const [userAddress] = await walletClient.getAddresses();
await walletClient.writeContract({
account: userAddress,
chain: CHAIN,
address: NOX_CONTRACT_ADDRESS,
abi: NOX_CONTRACT_ABI,
functionName: 'allowPublicDecryption',
args: [handle],
});