signer: linter fixes, remove deprecated crypto dependency

This commit is contained in:
Martin Holst Swende 2019-02-05 15:06:37 +01:00
parent 700e1d4e7f
commit c45f41cb6e
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
3 changed files with 7 additions and 6 deletions

View file

@ -19,12 +19,12 @@ package accounts
import (
"fmt"
"golang.org/x/crypto/sha3"
"math/big"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
)
@ -188,7 +188,9 @@ func TextHash(data []byte) []byte {
// This gives context to the signed message and prevents signing of transactions.
func TextAndHash(data []byte) ([]byte, string) {
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), string(data))
return crypto.Keccak256([]byte(msg)), msg
hasher := sha3.NewLegacyKeccak256()
hasher.Write([]byte(msg))
return hasher.Sum(nil), msg
}
// WalletEventType represents the different event types that can be fired by

View file

@ -21,7 +21,6 @@ import (
"context"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/consensus/clique"
"math/big"
"mime"
"regexp"
@ -35,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"

View file

@ -637,8 +637,7 @@ function ApproveSignData(r){
return
}
message := "baz bazonk foo"
hash, _ := core.SignTextPlain([]byte(message))
raw := hexutil.Bytes(message)
hash, rawdata := accounts.TextAndHash([]byte(message))
addr, _ := mixAddr("0x694267f14675d7e1b9494fd8d72fefe1755710fa")
fmt.Printf("address %v %v\n", addr.String(), addr.Original())
@ -655,7 +654,7 @@ function ApproveSignData(r){
Message: nvt,
Hash: hash,
Meta: core.Metadata{Remote: "remoteip", Local: "localip", Scheme: "inproc"},
Rawdata: raw,
Rawdata: []byte(rawdata),
})
if err != nil {
t.Fatalf("Unexpected error %v", err)