Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2ef57c8c
Commit
2ef57c8c
authored
3 years ago
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test is wrong
parent
a5e93d4e
develop
exchain
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
MIPSMemory.sol
contracts/MIPSMemory.sol
+8
-1
libkeccak.js
test/libkeccak.js
+8
-3
No files found.
contracts/MIPSMemory.sol
View file @
2ef57c8c
...
...
@@ -35,8 +35,15 @@ contract MIPSMemory {
largePreimage[msg.sender] = c.A;
}
function AddLargePreimageFinal(uint64[17] calldata data) public {
function AddLargePreimageFinal() public view returns (bytes32) {
Lib_Keccak256.CTX memory c;
c.A = largePreimage[msg.sender];
// TODO: do this properly and save the hash
// when this is updated, it won't be "view"
return bytes32((uint256(c.A[0]) << 192) |
(uint256(c.A[1]) << 128) |
(uint256(c.A[2]) << 64) |
c.A[3]);
}
function AddMerkleState(bytes32 stateHash, uint32 addr, uint32 value, string calldata proof) public {
...
...
This diff is collapsed.
Click to expand it.
test/libkeccak.js
View file @
2ef57c8c
const
{
keccak256
}
=
require
(
"
@ethersproject/keccak256
"
);
const
{
expect
}
=
require
(
"
chai
"
);
describe
(
"
MIPSMemory contract
"
,
function
()
{
...
...
@@ -11,11 +12,15 @@ describe("MIPSMemory contract", function () {
await
mm
.
AddLargePreimageInit
();
console
.
log
(
"
preimage initted
"
);
var
a
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
];
const
a
=
[
"
0x0100000000000000
"
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0x8
0
];
await
mm
.
AddLargePreimageUpdate
(
a
);
console
.
log
(
"
preimage updated
"
);
var
tst
=
await
mm
.
largePreimage
(
owner
.
address
,
0
);
console
.
log
(
tst
);
/*var tst1 = await mm.largePreimage(owner.address, 0);
console.log(tst);*/
const
hash
=
await
mm
.
AddLargePreimageFinal
();
console
.
log
(
"
comp hash is
"
,
hash
);
console
.
log
(
"
real hash is
"
,
keccak256
(
new
Uint8Array
(
0
)));
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment