ERC-7573 Decryption Oracle: Smart Contract for Generation/Verification/Decryption of Encrypted Keys


⚠️ Before you continue: Please read the Disclaimer.
By using this site, software, or contracts, you acknowledge that you have read and accepted it.


Introduction

The finmath keys decryption-oracle project provides open source implementations of the ERC-7573 decryption oracle (for secure stateless delivery-vs-payment).

Interfaces

The interface to the decryption oracle proxy contract and the decryption oracle callback are available via npm at @finmath.net/dvp.

Current Deployments

A decryption oracle contract is currently deployed on   Try it on Remix

Ethereum Mainnet

0xa116A2BDbef2BA379eD6eCED40504D4f28c755fc

Polygon Mainnet

0xB387746f1048645F142cAC13e762A3931f3114Ba

Sepolia (Ethereum Testnet)

0xda273EFE2F491903AB3DAf8Bee1A79A8F64e33E0**</span>

Amoy (Polygon Testnet)

0x86A6A4707526e230B66FE6E15A321b16000C076f

Use these to explore and test the protocol.

Using the Decryption Oracle Contract

The interaction with the decryption oracle is asynchronous following a request*/fulfill* pattern.

Send your request to an instance (addresS) of the decryption oracle contract using one of the following three functions…

interface IDecryptionOracle {
    function requestGenerateEncryptedHashedKey(uint256 id, IDecryptionOracleCallback callback, address receiverContract, bytes memory transaction) external;
    function requestVerifyEncryptedKey(uint256 id, bytes memory encryptedKey, IDecryptionOracleCallback callback, bytes memory transaction) external;
    function requestDecrypt(uint256 id, bytes memory encryptedKey, IDecryptionOracleCallback callback, bytes memory transaction) external;
}

To obtain the result implement the IDecryptionOracleCallback and pass the address of an instance that should receive the results as callback. The results will then be passed to the corresponding method:

interface IDecryptionOracleCallback {
    function onEncryptedHashedKeyGenerated(uint256 id, bytes memory encryptedKey, bytes memory hashedKey, address receiverContract, bytes memory transaction) external;
    function onEncryptedKeyVerified(uint256 id, bytes memory encryptedKey, bytes memory hashedKey, address receiverContract, bytes memory transaction) external;
    function onKeyReleased(uint256 id, bytes memory key) external;
    function onKeyDenied(uint256 id) external;
}

IMPORTANT: The current test deployment requires a very small fee (≈ $0.01) to cover the gas cost and protect against over-use (feeGenerate, feeVerify, feeDecrypt return the current fee in POL or ETH wei). So if oracle is the above address, then you need to call decrypt via

oracle.requestDecrypt{value: KeyDecryptionOracle(payable(address(oracle))).feeDecrypt()}(
  id, encryptedKey, callback, transaction
);

Literature

For a technical/mathematical description of related concepts see https://ssrn.com/abstract=4628811

Standards (Protocols)

IKeyDecryptionOracle and IKeyDecryptionOracleCallaback

For the exact interface definition see the solidity page.

ERC-7573 Secure Delivery-versus-Payment

See ERC 7573.

License

The code is distributed under the Apache License version 2.0, unless otherwise explicitly stated.