Skip to main content
Attested reveal is similar to Attested Decrypt. The major difference is that anyone can request a decryption with attestation after e.reveal() has been called on a handle, allowing anyone to submit the decryption result back on-chain.
Once revealed with e.reveal(), the ciphertext is considered public and can be accessed by anyone. This action can not be undone.

Getting Started

Let’s examine this example contract:
import {euint256, e, inco} from "@inco/lightning/src/Lib.sol";
import {DecryptionAttestation} from "@inco/lightning/src/lightning-parts/DecryptionAttester.types.sol";

contract TestAttestedReveal {
    euint256 randomNumber;
    uint256 decryptedNumber;

    constructor(address owner) payable {
        require(msg.value == inco.getFee(), "Fee not paid");
        randomNumber = e.rand();
        e.reveal(randomNumber);
    }

    function GetHandle() external returns (euint256) {
        return randomNumber;
    }

    function SubmitDecryption(
        DecryptionAttestation memory decryption,
        bytes memory signature
    ) external {
        require(
            inco.incoVerifier().isValidDecryptionAttestation(decryption, signature),
            "Invalid Signature"
        );
        require(euint256.unwrap(randomNumber) == decryption.handle, "Handle mismatch");
        decryptedNumber = uint256(decryption.value);
    }
}
This contract creates a random 256bit integer and immediately calls e.reveal(), allowing anyone to decrypt, perform computation on it or request an attestation, even though we haven’t explicitly granted permission to any particular address.
import { getViemChain, supportedChains, type HexString, type SupportedChainId } from '@inco/js';
import { createWalletClient, custom } from 'viem';

 //Connect to Metamask or other wallet provider
const walletClient = createWalletClient({
  chain: getViemChain(supportedChains.baseSepolia),
  transport: custom(window.ethereum!)
})

const zap = Lightning.latest('testnet', supportedChains.baseSepolia);

const results = await zap.attestedReveal(
    ["0x<revealed_handle>" as HexString]
);

const plaintext = results[0].plaintext;
The result contains the plaintext with covalidator signature. It can be used to submit back the decryption on-chain by calling “SubmitDecryption” as an alternative to the old callbacks.