oasisprotocol / sapphire-paratime

Oasis Sapphire - the confidential EVM-compatible ParaTime for the Oasis Network
https://oasisprotocol.org/sapphire
Apache License 2.0
39 stars 27 forks source link

contracts: implement HMAC SHA512-256, as it's used throughout the Oasis ecosystem #439

Closed CedarMist closed 1 month ago

netlify[bot] commented 1 month ago

Deploy Preview for oasisprotocol-sapphire-paratime canceled.

Name Link
Latest commit 60ec07dc339549ede8a34d93e8b8c22a07a01938
Latest deploy log https://app.netlify.com/sites/oasisprotocol-sapphire-paratime/deploys/6717aa6125598f00081c1b95
CedarMist commented 1 month ago

@matevz I forgot to run format on the code after adding comments.

For clarity, which style do you prefer:

diff --git a/contracts/contracts/HMAC_sha512_256.sol b/contracts/contracts/HMAC_sha512_256.sol
index 119f907..06becfc 100644
--- a/contracts/contracts/HMAC_sha512_256.sol
+++ b/contracts/contracts/HMAC_sha512_256.sol
@@ -51,12 +51,12 @@ function HMAC_sha512_256(bytes memory key, bytes memory message)
             let size := mload(key)
             // Call the identity precompile to copy memory
             success := staticcall(
-                gas(),           // Forward all available gas
-                PRECOMPILE_IDENTITY_ADDRESS,  // Address of the identity precompile
-                add(32, key),    // Start of the key data (skip the length prefix)
-                size,            // Length of data to copy
-                buf,             // Destination to copy to
-                size             // Amount of memory to copy
+                gas(), // Forward all available gas
+                PRECOMPILE_IDENTITY_ADDRESS, // Address of the identity precompile
+                add(32, key), // Start of the key data (skip the length prefix)
+                size, // Length of data to copy
+                buf, // Destination to copy to
+                size // Amount of memory to copy
             )
         }
CedarMist commented 1 month ago

The auth tests are still causing intermittent failures

CedarMist commented 1 month ago

SIWE auth tests are still intermittently failing

matevz commented 1 month ago

SIWE auth tests are still intermittently failing

I think I found the issue https://github.com/oasisprotocol/sapphire-paratime/issues/443. Will fix it