Commit 88711eab authored by George Hotz's avatar George Hotz

this saves like 200M instructions

parent 288c7b42
......@@ -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(encoded))
fmt.Fprintf(fi, "var secp256k1BytePoints = %q\n", string(serialized))
a1, b1, a2, b2 := btcec.S256().EndomorphismVectors()
fmt.Println("The following values are the computed linearly " +
......
......@@ -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
......
This diff is collapsed.
......@@ -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("%10d(%2d): %8x %-80s %s" % (icount, newicount, address, symbol, dat))
if bcount%1000000 == 0:
for k,v in sorted(profiler.items(), key=lambda x: -x[1])[:10]:
print("%-80s : %.2f%%" % (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("%-80s : %.2f%%" % (k, (v/phit)*100.))
icount += newicount
bcount += 1
return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment