Why does FHE decryption callback work with one ciphertext but not multiple?

I’m testing Zama’s FHE Solidity library on Sepolia.

When I call FHE.requestDecryption with a single ciphertext, my callback is triggered as expected:

function requestNumber() external {
        euint32 enc = FHE.asEuint32(42);
        encryptedNumber1 = enc;

        FHE.allowThis(encryptedNumber1);
        FHE.allow(encryptedNumber1, msg.sender);

        bytes32[] memory cts = new bytes32[](1);
        cts[0] = FHE.toBytes32(encryptedNumber1);

        uint256 reqId = FHE.requestDecryption(cts, this.onDecryption.selector);
    }


    function onDecryption(uint256 requestId, uint32 value, bytes[] memory signatures) public returns (bool success) {

        decryptedNumber1 = value;
        return true;
    }

But when I try with two ciphertexts, the callback never fires:

function requestNumber() external {
        euint32 enc = FHE.asEuint32(42);
        encryptedNumber1 = enc;

        FHE.allowThis(encryptedNumber1);
        FHE.allow(encryptedNumber1, msg.sender);

        euint32 enc1 = FHE.asEuint32(100);
        encryptedNumber2 = enc1;

        FHE.allowThis(encryptedNumber2);
        FHE.allow(encryptedNumber2, msg.sender);

        bytes32[] memory cts = new bytes32[](2);
        cts[0] = FHE.toBytes32(encryptedNumber1);
        cts[1] = FHE.toBytes32(encryptedNumber2);

        uint256 reqId = FHE.requestDecryption(cts, this.onDecryption.selector);
    }

    function onDecryption(uint256 requestId, uint32[] memory  values, bytes[] memory signatures) public returns (bool success) {
        decryptedNumber1 = values[0];
        decryptedNumber2 = values[1];
        return true;
    }

Questions:

  • Does requestDecryption currently only support one ciphertext?
  • Or am I using the wrong callback signature for arrays?
  • What’s the correct way to handle multiple ciphertext decryptions in one request?
1 Like

This is not how decryption is expected to work currently when handling many values. Please read carefully the example with multiple ciphertexts in docs https://docs.zama.ai/protocol/solidity-guides/smart-contract/oracle#function-arguments
You will see that correct way to handle it is by using function onDecryption(uint256 requestId, uint32 value1, uint32 value2, bytes[] memory signatures) public returns (bool success) { in your case, instead of passing an array of uint32 you should pass 2 uint32 variables.