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
88711eab
Commit
88711eab
authored
Oct 06, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this saves like 200M instructions
parent
288c7b42
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
18 deletions
+14
-18
genprecomps.go
minigeth/crypto/btcec/genprecomps.go
+3
-6
precompute.go
minigeth/crypto/btcec/precompute.go
+3
-6
secp256k1.go
minigeth/crypto/btcec/secp256k1.go
+1
-1
run.py
mipigeth/run.py
+7
-5
No files found.
minigeth/crypto/btcec/genprecomps.go
View file @
88711eab
...
...
@@ -11,9 +11,6 @@
package
main
import
(
"bytes"
"compress/zlib"
"encoding/base64"
"fmt"
"log"
"os"
...
...
@@ -30,7 +27,7 @@ func main() {
// Compress the serialized byte points.
serialized
:=
btcec
.
S256
()
.
SerializedBytePoints
()
var
compressed
bytes
.
Buffer
/*
var compressed bytes.Buffer
w := zlib.NewWriter(&compressed)
if _, err := w.Write(serialized); err != nil {
fmt.Println(err)
...
...
@@ -40,7 +37,7 @@ func main() {
// Encode the compressed byte points with base64.
encoded := make([]byte, base64.StdEncoding.EncodedLen(compressed.Len()))
base64
.
StdEncoding
.
Encode
(
encoded
,
compressed
.
Bytes
())
base64.StdEncoding.Encode(encoded, compressed.Bytes())
*/
fmt
.
Fprintln
(
fi
,
"// Copyright (c) 2015 The btcsuite developers"
)
fmt
.
Fprintln
(
fi
,
"// Use of this source code is governed by an ISC"
)
...
...
@@ -51,7 +48,7 @@ func main() {
fmt
.
Fprintln
(
fi
,
"// Auto-generated file (see genprecomps.go)"
)
fmt
.
Fprintln
(
fi
,
"// DO NOT EDIT"
)
fmt
.
Fprintln
(
fi
)
fmt
.
Fprintf
(
fi
,
"var secp256k1BytePoints = %q
\n
"
,
string
(
encod
ed
))
fmt
.
Fprintf
(
fi
,
"var secp256k1BytePoints = %q
\n
"
,
string
(
serializ
ed
))
a1
,
b1
,
a2
,
b2
:=
btcec
.
S256
()
.
EndomorphismVectors
()
fmt
.
Println
(
"The following values are the computed linearly "
+
...
...
minigeth/crypto/btcec/precompute.go
View file @
88711eab
...
...
@@ -5,11 +5,7 @@
package
btcec
import
(
"compress/zlib"
"encoding/base64"
"encoding/binary"
"io/ioutil"
"strings"
)
//go:generate go run -tags gensecp256k1 genprecomps.go
...
...
@@ -29,7 +25,7 @@ func loadS256BytePoints() error {
// Decompress the pre-computed table used to accelerate scalar base
// multiplication.
decoder
:=
base64
.
NewDecoder
(
base64
.
StdEncoding
,
strings
.
NewReader
(
bp
))
/*
decoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(bp))
r, err := zlib.NewReader(decoder)
if err != nil {
return err
...
...
@@ -37,7 +33,8 @@ func loadS256BytePoints() error {
serialized, err := ioutil.ReadAll(r)
if err != nil {
return err
}
}*/
serialized
:=
[]
byte
(
bp
)
// Deserialize the precomputed byte points and set the curve to them.
offset
:=
0
...
...
minigeth/crypto/btcec/secp256k1.go
View file @
88711eab
This diff is collapsed.
Click to expand it.
mipigeth/run.py
View file @
88711eab
...
...
@@ -44,6 +44,7 @@ instrumenting_all = False
instructions_seen
=
set
()
profiler
=
defaultdict
(
int
)
phit
=
0
PROFILE
=
os
.
getenv
(
"PROFILE"
,
False
)
def
hook_code_simple
(
uc
,
address
,
size
,
user_data
):
global
icount
,
bcount
,
phit
#assert size == 4
...
...
@@ -57,12 +58,13 @@ def hook_code_simple(uc, address, size, user_data):
#instructions_seen.add(dat.mnemonic)
#print(sorted(list(instructions_seen)))
symbol
=
r
[
address
]
if
address
in
r
else
"UNKNOWN"
profiler
[
symbol
]
+=
1
phit
+=
1
print
(
"
%10
d(
%2
d):
%8
x
%-80
s
%
s"
%
(
icount
,
newicount
,
address
,
symbol
,
dat
))
if
bcount
%
1000000
==
0
:
for
k
,
v
in
sorted
(
profiler
.
items
(),
key
=
lambda
x
:
-
x
[
1
])[:
10
]:
print
(
"
%-80
s :
%.2
f
%%
"
%
(
k
,
(
v
/
phit
)
*
100.
))
if
PROFILE
:
profiler
[
symbol
]
+=
1
phit
+=
1
if
bcount
%
1000000
==
0
:
for
k
,
v
in
sorted
(
profiler
.
items
(),
key
=
lambda
x
:
-
x
[
1
])[:
10
]:
print
(
"
%-80
s :
%.2
f
%%
"
%
(
k
,
(
v
/
phit
)
*
100.
))
icount
+=
newicount
bcount
+=
1
return
True
...
...
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