diff --git a/accounts/scwallet/wallet.go b/accounts/scwallet/wallet.go
index 4c0824eb92de371ce22e815dd8491287f627ceb9..71b2c68af1f070eb583a1f60263ef0c1121fc5f4 100644
--- a/accounts/scwallet/wallet.go
+++ b/accounts/scwallet/wallet.go
@@ -37,7 +37,6 @@ import (
 	"github.com/ethereum/go-ethereum/common"
 	"github.com/ethereum/go-ethereum/core/types"
 	"github.com/ethereum/go-ethereum/crypto"
-	"github.com/ethereum/go-ethereum/crypto/secp256k1"
 	"github.com/ethereum/go-ethereum/log"
 	pcsc "github.com/gballet/go-libpcsclite"
 	"github.com/status-im/keycard-go/derivationpath"
@@ -1050,33 +1049,25 @@ func (s *Session) sign(path accounts.DerivationPath, hash []byte) ([]byte, error
 // determinePublicKey uses a signature and the X component of a public key to
 // recover the entire public key.
 func determinePublicKey(sig, pubkeyX []byte) ([]byte, error) {
-	for v := 0; v < 2; v++ {
-		sig[64] = byte(v)
-		pubkey, err := crypto.Ecrecover(DerivationSignatureHash[:], sig)
-		if err == nil {
-			if bytes.Equal(pubkey, pubkeyX) {
-				return pubkey, nil
-			}
-		} else if v == 1 || err != secp256k1.ErrRecoverFailed {
-			return nil, err
-		}
-	}
-	return nil, ErrPubkeyMismatch
+	return makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkeyX)
 }
 
 // makeRecoverableSignature uses a signature and an expected public key to
 // recover the v value and produce a recoverable signature.
 func makeRecoverableSignature(hash, sig, expectedPubkey []byte) ([]byte, error) {
+	var libraryError error
 	for v := 0; v < 2; v++ {
 		sig[64] = byte(v)
-		pubkey, err := crypto.Ecrecover(hash, sig)
-		if err == nil {
+		if pubkey, err := crypto.Ecrecover(hash, sig); err == nil {
 			if bytes.Equal(pubkey, expectedPubkey) {
 				return sig, nil
 			}
-		} else if v == 1 || err != secp256k1.ErrRecoverFailed {
-			return nil, err
+		} else {
+			libraryError = err
 		}
 	}
+	if libraryError != nil {
+		return nil, libraryError
+	}
 	return nil, ErrPubkeyMismatch
 }
diff --git a/p2p/discover/node.go b/p2p/discover/node.go
index 8d4af166bba4f00ba02c18799d4044d1a9f4f7b4..a7d9ce7368c05e8dce5ef6b112667abfb11cab98 100644
--- a/p2p/discover/node.go
+++ b/p2p/discover/node.go
@@ -25,7 +25,6 @@ import (
 
 	"github.com/ethereum/go-ethereum/common/math"
 	"github.com/ethereum/go-ethereum/crypto"
-	"github.com/ethereum/go-ethereum/crypto/secp256k1"
 	"github.com/ethereum/go-ethereum/p2p/enode"
 )
 
@@ -64,7 +63,7 @@ func (e encPubkey) id() enode.ID {
 // recoverNodeKey computes the public key used to sign the
 // given hash from the signature.
 func recoverNodeKey(hash, sig []byte) (key encPubkey, err error) {
-	pubkey, err := secp256k1.RecoverPubkey(hash, sig)
+	pubkey, err := crypto.Ecrecover(hash, sig)
 	if err != nil {
 		return key, err
 	}
diff --git a/p2p/rlpx.go b/p2p/rlpx.go
index 0697ef3b01540d9d5e9fb402fba646ea15d94782..0636431f53abef08ec9d828c34487aeb35cc3ed3 100644
--- a/p2p/rlpx.go
+++ b/p2p/rlpx.go
@@ -38,7 +38,6 @@ import (
 	"github.com/ethereum/go-ethereum/common/bitutil"
 	"github.com/ethereum/go-ethereum/crypto"
 	"github.com/ethereum/go-ethereum/crypto/ecies"
-	"github.com/ethereum/go-ethereum/crypto/secp256k1"
 	"github.com/ethereum/go-ethereum/rlp"
 	"github.com/golang/snappy"
 	"golang.org/x/crypto/sha3"
@@ -400,7 +399,7 @@ func (h *encHandshake) handleAuthMsg(msg *authMsgV4, prv *ecdsa.PrivateKey) erro
 		return err
 	}
 	signedMsg := xor(token, h.initNonce)
-	remoteRandomPub, err := secp256k1.RecoverPubkey(signedMsg, msg.Signature[:])
+	remoteRandomPub, err := crypto.Ecrecover(signedMsg, msg.Signature[:])
 	if err != nil {
 		return err
 	}
diff --git a/rpc/constants_unix.go b/rpc/constants_unix.go
new file mode 100644
index 0000000000000000000000000000000000000000..2f98d6499b7a0229f66044b10b1c6e1eb97f1f52
--- /dev/null
+++ b/rpc/constants_unix.go
@@ -0,0 +1,33 @@
+// Copyright 2019 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+
+package rpc
+
+/*
+#include <sys/un.h>
+
+int max_socket_path_size() {
+struct sockaddr_un s;
+return sizeof(s.sun_path);
+}
+*/
+import "C"
+
+var (
+	max_path_size = C.max_socket_path_size()
+)
diff --git a/rpc/constants_unix_nocgo.go b/rpc/constants_unix_nocgo.go
new file mode 100644
index 0000000000000000000000000000000000000000..ecb231f92714b41b41f91c507b62cf0a1683507b
--- /dev/null
+++ b/rpc/constants_unix_nocgo.go
@@ -0,0 +1,25 @@
+// Copyright 2019 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+// +build !cgo,!windows
+
+package rpc
+
+var (
+	//  On Linux, sun_path is 108 bytes in size
+	// see http://man7.org/linux/man-pages/man7/unix.7.html
+	max_path_size = 108
+)
diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go
index 707b47fd77a9a2542d1d897aa70903c9c8b09ba0..da6ce294d7afd88fa5eed2c342bff7101df14884 100644
--- a/rpc/ipc_unix.go
+++ b/rpc/ipc_unix.go
@@ -1,4 +1,4 @@
-// Copyright 2015 The go-ethereum Authors
+// Copyright 2019 The go-ethereum Authors
 // This file is part of the go-ethereum library.
 //
 // The go-ethereum library is free software: you can redistribute it and/or modify
@@ -28,20 +28,10 @@ import (
 	"github.com/ethereum/go-ethereum/log"
 )
 
-/*
-#include <sys/un.h>
-
-int max_socket_path_size() {
-struct sockaddr_un s;
-return sizeof(s.sun_path);
-}
-*/
-import "C"
-
 // ipcListen will create a Unix socket on the given endpoint.
 func ipcListen(endpoint string) (net.Listener, error) {
-	if len(endpoint) > int(C.max_socket_path_size()) {
-		log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", C.max_socket_path_size()),
+	if len(endpoint) > int(max_path_size) {
+		log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size),
 			"endpoint", endpoint)
 	}