Soda Labs
Soda Labs Docs

Decryption caller

Implement the Decryption Caller contract to request decryptions and verify the results returned to your callback.

The "Decryption Caller" is a contract that developers should implement to enable secure decryption within a smart contract.

The contract provides a suite of utility functions and modifiers that significantly assist users in the decryption process. These functions include critical features such as request ID handling, output and signatures validation, and several others that streamline the decryption tasks. By utilizing these functions, users can perform complex decryption tasks with ease and efficiency, as the system handles intricate details automatically.

The design and integration of these utility functions play a pivotal role in simplifying user interactions. They eliminate the need for users to manually conduct intricate checks and validations during decryption. This offers two key advantages: first, it ensures that decryption processes are executed with high reliability and accuracy, reducing potential errors; second, it allows users to focus on high-level objectives without getting bogged down by the underlying technical complexities.

Moreover, these functions bring an added layer of security and trust. Since validation and other essential checks are systematically handled, users can confidently rely on the system's integrity and efficiency. This strategic advantage is crucial, not only in enhancing user experience but also in ensuring consistent and secure decryption processes. By offloading these responsibilities, users can save significant time and effort and are empowered to handle more decryption operations seamlessly.

Contract's functions:

Request decryption

function requestDecryption(uint256[] memory handles, bytes4 callbackSelector)
                                                  internal returns (uint256 decryptID)

Inputs:

  • handles: These are identifiers that point to encrypted values stored in Bubble.
  • callbackSelector: This is the function selector (first 4 bytes of a function signature) that will be called later when the decryption result is ready.

Output:

  • decryptID: a unique ID for this decryption request.

This function records the decryption request, sends it to the MPC, and returns a unique request ID that will be used when the MPC sends back the decrypted result to the contract using the callback.

Contract's modifiers:

Verify callback

modifier verifyCallback(uint256 decryptID,
                                bytes[] memory outputs, bytes[] memory signatures)

Inputs for the Modifier

The inputs for this modifier are the parameters for the callback function:

  • decryptID: A unique identifier for the decryption request.
  • outputs: The decryption results for all requested handles.
  • signatures: Unique signatures for each evaluator, validating the requested handles and their outputs.

Before the callback function is executed, this modifier must be invoked to ensure robust security. Its primary function is to verify all provided signatures meticulously. The workflow is designed in such a way that, only upon successful validation of all the signatures, the logic proceeds to the execution phase of the callback functionality. Hence, it serves as a crucial checkpoint that prevents any unauthorized or erroneous entries from triggering the callback, maintaining the integrity and reliability of the operation.

The modifier triggers the verifySignatures function within the GCDecryptionVerifier host contract, which carries out the verification process.

Example of using the modifier:

function callbackValidateCiphertext(uint256 decryptID,
                                    bytes[] calldata output,
                                    bytes[] calldata signatures)
                                    public verifyCallback(decryptID, output, signatures) {
    // Handle the decrypt result
    ciphertextResult = abi.decode(output[0], (uint8));
}

On this page