aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/secp256k1
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-02-29 22:05:37 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-02-29 22:05:37 +0800
commit4044a8cea44cd4cee3a8ddaf51a76b71c9d22042 (patch)
tree1aa3776381e8e117b66e4a8ed1bf83e29d966ff1 /crypto/secp256k1
parentc541b38fb36587d23c60f5e2f2b9b3c8700ec489 (diff)
parent61be63bb9b8527bb3e2357ad35a0f4ef29304da1 (diff)
downloadgo-tangerine-1.3.4.tar
go-tangerine-1.3.4.tar.gz
go-tangerine-1.3.4.tar.bz2
go-tangerine-1.3.4.tar.lz
go-tangerine-1.3.4.tar.xz
go-tangerine-1.3.4.tar.zst
go-tangerine-1.3.4.zip
Merge pull request #2258 from obscuren/release/1.3.4v1.3.4
Homestead Release Candidate
Diffstat (limited to 'crypto/secp256k1')
-rw-r--r--crypto/secp256k1/README.md25
-rw-r--r--crypto/secp256k1/secp256.go21
2 files changed, 12 insertions, 34 deletions
diff --git a/crypto/secp256k1/README.md b/crypto/secp256k1/README.md
deleted file mode 100644
index 5a86147d4..000000000
--- a/crypto/secp256k1/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-secp256k1-go
-=======
-
-golang secp256k1 library
-
-Implements cryptographic operations for the secp256k1 ECDSA curve used by Bitcoin.
-
-Installing
-===
-
-GMP library headers are required to build. On Debian-based systems, the package is called `libgmp-dev`.
-
-```
-sudo apt-get install libgmp-dev
-```
-
-Now compiles with cgo!
-
-Test
-===
-
-To run tests do
-```
-go tests
-``` \ No newline at end of file
diff --git a/crypto/secp256k1/secp256.go b/crypto/secp256k1/secp256.go
index 41a5608a5..83f2a5f26 100644
--- a/crypto/secp256k1/secp256.go
+++ b/crypto/secp256k1/secp256.go
@@ -20,14 +20,8 @@ package secp256k1
/*
#cgo CFLAGS: -I./libsecp256k1
-#cgo darwin CFLAGS: -I/usr/local/include
-#cgo freebsd CFLAGS: -I/usr/local/include
-#cgo linux,arm CFLAGS: -I/usr/local/arm/include
-#cgo LDFLAGS: -lgmp
-#cgo darwin LDFLAGS: -L/usr/local/lib
-#cgo freebsd LDFLAGS: -L/usr/local/lib
-#cgo linux,arm LDFLAGS: -L/usr/local/arm/lib
-#define USE_NUM_GMP
+#cgo CFLAGS: -I./libsecp256k1/src/
+#define USE_NUM_NONE
#define USE_FIELD_10X26
#define USE_FIELD_INV_BUILTIN
#define USE_SCALAR_8X32
@@ -44,6 +38,7 @@ import "C"
import (
"errors"
+ "math/big"
"unsafe"
"github.com/ethereum/go-ethereum/crypto/randentropy"
@@ -60,9 +55,17 @@ import (
*/
// holds ptr to secp256k1_context_struct (see secp256k1/include/secp256k1.h)
-var context *C.secp256k1_context
+var (
+ context *C.secp256k1_context
+ N *big.Int
+ HalfN *big.Int
+)
func init() {
+ N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
+ // N / 2 == 57896044618658097711785492504343953926418782139537452191302581570759080747168
+ HalfN, _ = new(big.Int).SetString("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0", 16)
+
// around 20 ms on a modern CPU.
context = C.secp256k1_context_create(3) // SECP256K1_START_SIGN | SECP256K1_START_VERIFY
C.secp256k1_context_set_illegal_callback(context, C.callbackFunc(C.secp256k1GoPanicIllegal), nil)