Skip to content

Commit

Permalink
Add sha384 and unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanghao Yang committed Dec 1, 2023
1 parent 08c314e commit 000fc89
Show file tree
Hide file tree
Showing 15 changed files with 841 additions and 118 deletions.
28 changes: 0 additions & 28 deletions contracts/Greeter.sol

This file was deleted.

32 changes: 32 additions & 0 deletions contracts/TestSha2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15;

import { Sha2Ext } from "./lib/Sha2Ext.sol";
import { LibBytes } from "./lib/LibBytes.sol";

contract TestSha2 {
// modify the storage of the contract so that the gas cost of the test is measured.
bool public success;

function sha384External(bytes calldata _data) public pure returns (bytes32, bytes16) {
bytes32 b1;
bytes16 b2;
(b1, b2) = Sha2Ext.sha384(_data);
return (b1, b2);
}

function sha384Gas(bytes calldata _data) external returns (bytes32, bytes16) {
bytes32 b1;
bytes16 b2;
(b1, b2) = Sha2Ext.sha384(_data);
success = true;
return (b1, b2);
}

function sha256Gas(bytes calldata _data) external returns (bytes32) {
bytes32 b1;
b1 = sha256(_data);
success = true;
return (b1);
}
}
Loading

0 comments on commit 000fc89

Please sign in to comment.