Skip to content

Commit

Permalink
clean up update function
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Jan 27, 2024
1 parent 904e532 commit 5fdf84e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions contracts/Blake2s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ library Blake2s {
// BLAKE2s block size is 64 bytes
ctx.t += ctx.c; // Increment counter t by the number of bytes in the buffer
compress(ctx, false);

//clear input buffer counter after compressing
ctx.b[0] = 0;
ctx.b[1] = 0;
//clear buffer counter after compressing
ctx.c = 0;
}

Expand Down
18 changes: 18 additions & 0 deletions contracts/TestContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pragma solidity 0.8.20;

import {Blake2s} from "./Blake2s.sol";
import "hardhat/console.sol";

contract TestContract {
function hash(bytes memory input) public pure returns (bytes32) {
Blake2s.BLAKE2s_ctx memory ctx;
ctx.c = 23989;






// return Blake2s.toBytes32(input);
}
}
10 changes: 0 additions & 10 deletions test/Blake2s.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ describe("Blake2s", function () {
});


it("should return the right hash", async () => {
const input = "hello worl,d";
const expected = crypto.createHash('blake2s256').update(input).digest();
const res = await testContract.hash(toUtf8Bytes(input))
console.log("res", res)


})


it("small digest", async () => {
const input = "hello world";

Expand Down

0 comments on commit 5fdf84e

Please sign in to comment.