aboutsummaryrefslogtreecommitdiffstats
path: root/signer
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2018-06-12 21:26:08 +0800
committerGuillaume Ballet <gballet@gmail.com>2018-06-12 21:26:08 +0800
commit0255951587ef0eada5d162f3404bc481f70a2ce2 (patch)
tree6aa0c1c9405df6a88f4cbeb72e170e6e19cf55d5 /signer
parent85cd64df0e3331e46f41ec86a647f1b8ff306eda (diff)
downloadgo-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.gz
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.bz2
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.lz
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.xz
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.zst
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.zip
crypto: replace ToECDSAPub with error-checking func UnmarshalPubkey (#16932)
ToECDSAPub was unsafe because it returned a non-nil key with nil X, Y in case of invalid input. This change replaces ToECDSAPub with UnmarshalPubkey across the codebase.
Diffstat (limited to 'signer')
-rw-r--r--signer/core/api.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/signer/core/api.go b/signer/core/api.go
index 45933284b..1372646de 100644
--- a/signer/core/api.go
+++ b/signer/core/api.go
@@ -432,13 +432,11 @@ func (api *SignerAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (c
}
sig[64] -= 27 // Transform yellow paper V from 27/28 to 0/1
hash, _ := SignHash(data)
- rpk, err := crypto.Ecrecover(hash, sig)
+ rpk, err := crypto.SigToPub(hash, sig)
if err != nil {
return common.Address{}, err
}
- pubKey := crypto.ToECDSAPub(rpk)
- recoveredAddr := crypto.PubkeyToAddress(*pubKey)
- return recoveredAddr, nil
+ return crypto.PubkeyToAddress(*rpk), nil
}
// SignHash is a helper function that calculates a hash for the given message that can be