aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <w@cobinhood.com>2018-10-11 14:05:09 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:49 +0800
commitccaefd2fa1b7a28ff2310f2ee339a460563a4ff0 (patch)
treee4fb30d2979b610a94a30cc7eb82ba4412ee694c /core
parentbfb2740f4d72ebb2116b72f7acfcebfe1cee6560 (diff)
downloadgo-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.tar
go-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.tar.gz
go-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.tar.bz2
go-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.tar.lz
go-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.tar.xz
go-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.tar.zst
go-tangerine-ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0.zip
core: vm: check pk ownership in stake()
Diffstat (limited to 'core')
-rw-r--r--core/vm/governance.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index e4c3b31e3..b78d1bf94 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -1182,7 +1182,18 @@ func (g *GovernanceContract) stake(publicKey []byte) ([]byte, error) {
return nil, errExecutionReverted
}
- // TODO(w): check of pk belongs to the address.
+ pk, err := crypto.DecompressPubkey(publicKey)
+ if err != nil {
+ g.penalize()
+ return nil, errExecutionReverted
+ }
+
+ // Make sure the public key belongs to the caller.
+ if crypto.PubkeyToAddress(*pk) != caller {
+ g.penalize()
+ return nil, errExecutionReverted
+ }
+
offset = g.state.nodesLength()
g.state.pushNode(&nodeInfo{
owner: caller,