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
54a6f4d7
Commit
54a6f4d7
authored
Sep 25, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check the hash in python
parent
5b7fac08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
embedded_mips.go
minigeth/oracle/embedded_mips.go
+2
-3
run.py
risc/run.py
+10
-3
No files found.
minigeth/oracle/embedded_mips.go
View file @
54a6f4d7
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
package
oracle
package
oracle
import
(
import
(
"fmt"
"math/big"
"math/big"
"os"
"os"
"reflect"
"reflect"
...
@@ -58,12 +57,12 @@ func Output(output common.Hash) {
...
@@ -58,12 +57,12 @@ func Output(output common.Hash) {
ret
:=
byteAt
(
0x30000800
,
0x20
)
ret
:=
byteAt
(
0x30000800
,
0x20
)
copy
(
ret
,
output
.
Bytes
())
copy
(
ret
,
output
.
Bytes
())
if
output
==
inputs
[
5
]
{
/*
if output == inputs[5] {
fmt.Println("good transition")
fmt.Println("good transition")
} else {
} else {
fmt.Println(output, "!=", inputs[5])
fmt.Println(output, "!=", inputs[5])
panic("BAD transition :((")
panic("BAD transition :((")
}
}
*/
Halt
()
Halt
()
}
}
...
...
risc/run.py
View file @
54a6f4d7
...
@@ -286,8 +286,8 @@ mu.mem_map(brk_start, 1024*1024*1024)
...
@@ -286,8 +286,8 @@ mu.mem_map(brk_start, 1024*1024*1024)
# input oracle
# input oracle
mu
.
mem_map
(
0x30000000
,
0x2000000
)
mu
.
mem_map
(
0x30000000
,
0x2000000
)
dat
=
open
(
"/tmp/eth/13284469"
,
"rb"
)
.
read
()
inputs
=
open
(
"/tmp/eth/13284469"
,
"rb"
)
.
read
()
mu
.
mem_write
(
0x30000000
,
dat
)
mu
.
mem_write
(
0x30000000
,
inputs
)
# regs at 0xC0000000 in merkle
# regs at 0xC0000000 in merkle
...
@@ -353,6 +353,7 @@ def hook_mem_invalid(uc, access, address, size, value, user_data):
...
@@ -353,6 +353,7 @@ def hook_mem_invalid(uc, access, address, size, value, user_data):
pc
=
uc
.
reg_read
(
UC_MIPS_REG_PC
)
pc
=
uc
.
reg_read
(
UC_MIPS_REG_PC
)
if
pc
==
0xDEAD0000
:
if
pc
==
0xDEAD0000
:
died_well
=
True
died_well
=
True
return
False
print
(
"UNMAPPED MEMORY:"
,
access
,
hex
(
address
),
size
,
"at"
,
hex
(
pc
))
print
(
"UNMAPPED MEMORY:"
,
access
,
hex
(
address
),
size
,
"at"
,
hex
(
pc
))
return
False
return
False
mu
.
hook_add
(
UC_HOOK_MEM_READ_UNMAPPED
|
UC_HOOK_MEM_WRITE_UNMAPPED
,
hook_mem_invalid
)
mu
.
hook_add
(
UC_HOOK_MEM_READ_UNMAPPED
|
UC_HOOK_MEM_WRITE_UNMAPPED
,
hook_mem_invalid
)
...
@@ -365,7 +366,13 @@ try:
...
@@ -365,7 +366,13 @@ try:
mu
.
emu_start
(
entry
,
0
)
mu
.
emu_start
(
entry
,
0
)
except
unicorn
.
UcError
:
except
unicorn
.
UcError
:
pass
pass
hexdump
(
mu
.
mem_read
(
0x30000800
,
0x20
))
if
not
died_well
:
if
not
died_well
:
raise
Exception
(
"program exitted early"
)
raise
Exception
(
"program exitted early"
)
real_hash
=
binascii
.
hexlify
(
inputs
[
-
0x20
:])
compare_hash
=
binascii
.
hexlify
(
mu
.
mem_read
(
0x30000800
,
0x20
))
print
(
"compare"
,
real_hash
,
"to computed"
,
compare_hash
)
if
real_hash
!=
compare_hash
:
raise
Exception
(
"wrong hash"
)
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