Skip to content

<feat>(gateway-contracts): decrypt multiple values in Solidity with list of integers in API #837

@matteoettam09

Description

@matteoettam09

Describe the issue

Any short term plan to start supporting APIs like:

function callbackPreProcessDecrypt(
    uint256 requestID,
    uint128[] calldata decryptedValues,
    bytes[] calldata signatures
) external {

As far as I understand, also looking at the examples, there is no way to pass variable-size lists as cyphertexts and then get the decrypted list back.

In my use case I cannot hardcode separate decrypted variables
The payload is prepared with something like:

for (uint16 i = 0; i < mTokens; ++i) {
    address token = _currentEpoch.tokens[i];
    euint128 position = _currentEpoch.encryptedInitialBatchPortfolio[token];
    FHE.allowThis(position);
    cypherTexts[nVaults + i] = FHE.toBytes32(position);
}
FHE.requestDecryption(cypherTexts, this.callbackPreProcessDecrypt.selector);

And I cannot afford to hardcode

(
    uint256 requestID,
    uint128 value1, uint128 value2, uint128 value3, uint128 value4,
    uint128 value5, uint128 value6, uint128 value7, uint128 value8,
    bytes[] calldata signatures
) external {

If the signature was placed before in the API, I could do something like this (which now is impossible because I would need to manually extract the signature as well):

    /// @inheritdoc IInternalStateOrchestrator
    function callbackPreProcessDecrypt(uint256 requestID, bytes[] memory signatures) external {
        FHE.checkSignatures(requestID, signatures);   

        uint256 offset = 36;

        uint128[] memory values = new uint128[](encryptedValuesLength);
        for (uint16 i = 0; i < encryptedValuesLength; i++) {
            values[i] = uint128(uint256(bytes32(msg.data[offset:offset + 32])));
            console.log("value in the callback", values[i]);
            offset += 32;
        }
}

Context

OrionFinanceAI/protocol@132956a

Steps to Reproduce or Propose

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions