Skip to content

Commit

Permalink
Update Suave.sol library to flashbots/suave-geth@ad7a8c1 (#101)
Browse files Browse the repository at this point in the history
Co-authored-by: sukoneck <[email protected]>
  • Loading branch information
github-actions[bot] and sukoneck authored Aug 12, 2024
1 parent 45fcec8 commit 54951e8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/forge/SuaveAddrs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@ import "../suavelib/Suave.sol";

library SuaveAddrs {
function getSuaveAddrs() external pure returns (address[] memory) {
address[] memory addrList = new address[](21);
address[] memory addrList = new address[](23);

addrList[0] = Suave.IS_CONFIDENTIAL_ADDR;
addrList[1] = Suave.BUILD_ETH_BLOCK;
addrList[2] = Suave.BUILD_ETH_BLOCK_TO;
addrList[3] = Suave.CONFIDENTIAL_RETRIEVE;
addrList[4] = Suave.CONFIDENTIAL_STORE;
addrList[5] = Suave.CONTEXT_GET;
addrList[6] = Suave.DO_HTTPREQUEST;
addrList[7] = Suave.ETHCALL;
addrList[8] = Suave.EXTRACT_HINT;
addrList[9] = Suave.FETCH_DATA_RECORDS;
addrList[10] = Suave.FILL_MEV_SHARE_BUNDLE;
addrList[11] = Suave.NEW_BUILDER;
addrList[12] = Suave.NEW_DATA_RECORD;
addrList[13] = Suave.PRIVATE_KEY_GEN;
addrList[14] = Suave.RANDOM_BYTES;
addrList[15] = Suave.SIGN_ETH_TRANSACTION;
addrList[16] = Suave.SIGN_MESSAGE;
addrList[17] = Suave.SIMULATE_BUNDLE;
addrList[18] = Suave.SIMULATE_TRANSACTION;
addrList[19] = Suave.SUBMIT_BUNDLE_JSON_RPC;
addrList[20] = Suave.SUBMIT_ETH_BLOCK_TO_RELAY;
addrList[1] = Suave.AES_DECRYPT;
addrList[2] = Suave.AES_ENCRYPT;
addrList[3] = Suave.BUILD_ETH_BLOCK;
addrList[4] = Suave.BUILD_ETH_BLOCK_TO;
addrList[5] = Suave.CONFIDENTIAL_RETRIEVE;
addrList[6] = Suave.CONFIDENTIAL_STORE;
addrList[7] = Suave.CONTEXT_GET;
addrList[8] = Suave.DO_HTTPREQUEST;
addrList[9] = Suave.ETHCALL;
addrList[10] = Suave.EXTRACT_HINT;
addrList[11] = Suave.FETCH_DATA_RECORDS;
addrList[12] = Suave.FILL_MEV_SHARE_BUNDLE;
addrList[13] = Suave.NEW_BUILDER;
addrList[14] = Suave.NEW_DATA_RECORD;
addrList[15] = Suave.PRIVATE_KEY_GEN;
addrList[16] = Suave.RANDOM_BYTES;
addrList[17] = Suave.SIGN_ETH_TRANSACTION;
addrList[18] = Suave.SIGN_MESSAGE;
addrList[19] = Suave.SIMULATE_BUNDLE;
addrList[20] = Suave.SIMULATE_TRANSACTION;
addrList[21] = Suave.SUBMIT_BUNDLE_JSON_RPC;
addrList[22] = Suave.SUBMIT_ETH_BLOCK_TO_RELAY;

return addrList;
}
Expand Down
30 changes: 30 additions & 0 deletions src/suavelib/Suave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ library Suave {

address public constant IS_CONFIDENTIAL_ADDR = 0x0000000000000000000000000000000042010000;

address public constant AES_DECRYPT = 0x000000000000000000000000000000005670000D;

address public constant AES_ENCRYPT = 0x000000000000000000000000000000005670000e;

address public constant BUILD_ETH_BLOCK = 0x0000000000000000000000000000000042100001;

address public constant BUILD_ETH_BLOCK_TO = 0x0000000000000000000000000000000042100006;
Expand Down Expand Up @@ -165,6 +169,32 @@ library Suave {
}
}

/// @notice Decrypts a message using given bytes as a cipher.
/// @param key Private key used to decrypt the ciphertext
/// @param ciphertext Message to decrypt
/// @return message Decrypted message
function aesDecrypt(bytes memory key, bytes memory ciphertext) internal returns (bytes memory) {
(bool success, bytes memory data) = AES_DECRYPT.call(abi.encode(key, ciphertext));
if (!success) {
revert PeekerReverted(AES_DECRYPT, data);
}

return abi.decode(data, (bytes));
}

/// @notice Encrypts a message using given bytes as a cipher.
/// @param key Private key used to encrypt the message
/// @param message Message to encrypt
/// @return ciphertext Encrypted message
function aesEncrypt(bytes memory key, bytes memory message) internal returns (bytes memory) {
(bool success, bytes memory data) = AES_ENCRYPT.call(abi.encode(key, message));
if (!success) {
revert PeekerReverted(AES_ENCRYPT, data);
}

return abi.decode(data, (bytes));
}

/// @notice Constructs an Ethereum block based on the provided data records. No blobs are returned.
/// @param blockArgs Arguments to build the block
/// @param dataId ID of the data record with mev-share bundle data
Expand Down

0 comments on commit 54951e8

Please sign in to comment.