diff options
author | Wei-Ning Huang <w@cobinhood.com> | 2018-10-11 14:05:09 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:23:38 +0800 |
commit | 6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4 (patch) | |
tree | 0a52dbab62410117fa32d2f2cb1d489481448452 /core | |
parent | b30675ce058e2c0b4f06a1e814eea7ac9c165555 (diff) | |
download | go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.tar go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.tar.gz go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.tar.bz2 go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.tar.lz go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.tar.xz go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.tar.zst go-tangerine-6ec5fe5c618125f4d00e3f4cd8a5dc2bbddf1dc4.zip |
core: vm: check pk ownership in stake()
Diffstat (limited to 'core')
-rw-r--r-- | core/vm/governance.go | 13 |
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, |