1 // Copyright 2015 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
5 // This file is ignored during the regular build due to the following build tag.
6 // It is called by go generate and used to automatically generate pre-computed
7 // tables used to accelerate operations.
20 "github.com/btcsuite/btcd/btcec"
24 fi, err := os.Create("secp256k1.go")
30 // Compress the serialized byte points.
31 serialized := btcec.S256().SerializedBytePoints()
32 var compressed bytes.Buffer
33 w := zlib.NewWriter(&compressed)
34 if _, err := w.Write(serialized); err != nil {
40 // Encode the compressed byte points with base64.
41 encoded := make([]byte, base64.StdEncoding.EncodedLen(compressed.Len()))
42 base64.StdEncoding.Encode(encoded, compressed.Bytes())
44 fmt.Fprintln(fi, "// Copyright (c) 2015 The btcsuite developers")
45 fmt.Fprintln(fi, "// Use of this source code is governed by an ISC")
46 fmt.Fprintln(fi, "// license that can be found in the LICENSE file.")
48 fmt.Fprintln(fi, "package btcec")
50 fmt.Fprintln(fi, "// Auto-generated file (see genprecomps.go)")
51 fmt.Fprintln(fi, "// DO NOT EDIT")
53 fmt.Fprintf(fi, "var secp256k1BytePoints = %q\n", string(encoded))
55 a1, b1, a2, b2 := btcec.S256().EndomorphismVectors()
56 fmt.Println("The following values are the computed linearly " +
57 "independent vectors needed to make use of the secp256k1 " +
59 fmt.Printf("a1: %x\n", a1)
60 fmt.Printf("b1: %x\n", b1)
61 fmt.Printf("a2: %x\n", a2)
62 fmt.Printf("b2: %x\n", b2)