Access Control ​
Every new handle starts with transient access (valid only for the current transaction). You must explicitly persist access so handles can be reused in future transactions and decrypted by authorized users.
For a detailed explanation of the permission model, see Nox Smart Contracts: ACL.
Supported types: ebool, eaddress, euint16, euint256, eint16, eint256
Usage ​
euint256 newBalance = Nox.add(balance, deposit);
Nox.allowThis(newBalance); // contract keeps access
Nox.allow(newBalance, msg.sender); // user can compute with this handle
Nox.addViewer(newBalance, msg.sender); // user can decrypt their balance
_balances[msg.sender] = newBalance;isInitialized ​
function isInitialized(euint256 handle) internal pure returns (bool)Returns true if the handle is non-zero (has been assigned a value). Use this to check whether a mapping entry has been set before performing operations on it.
allow ​
function allow(euint256 value, address account) internalGrants persistent admin access to account on the handle. The account can use the handle as input in future computations and manage its permissions.
WARNING
The caller must already have access to the handle. You cannot grant access to a handle you do not control.
allowThis ​
function allowThis(euint256 value) internalShorthand for allow(value, address(this)). Grants persistent access to the calling contract so the handle can be reused in future transactions.
allowTransient ​
function allowTransient(euint256 value, address account) internalGrants one-time access to account for the current transaction only. Transient permissions are cleared at the end of the transaction. Useful for passing handles to another contract within the same transaction without giving permanent access.
isAllowed ​
function isAllowed(euint256 handle, address account) internal view returns (bool)Returns true if account has admin access (persistent or transient) to the handle.
addViewer ​
function addViewer(euint256 value, address viewer) internalGrants viewer permission to viewer. Viewers can decrypt the handle's data through the Handle Gateway using the JS SDK but cannot use the handle as input in computations.
isViewer ​
function isViewer(euint256 handle, address viewer) internal view returns (bool)Returns true if viewer has viewer permission on the handle.
allowPublicDecryption ​
function allowPublicDecryption(euint256 value) internalMakes the handle's data decryptable by anyone. Use this for values that should be publicly visible (e.g. total supply, auction results, public counters).
isPubliclyDecryptable ​
function isPubliclyDecryptable(euint256 handle) internal view returns (bool)Returns true if the handle is marked as publicly decryptable.
