mirror of https://github.com/poanetwork/quorum.git
Merge pull request #5 from obscuren/private-tx
core, core/types: implemented private transaction check
This commit is contained in:
commit
9392153a75
|
@ -17,7 +17,6 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
|
@ -85,9 +84,7 @@ func (p *StateProcessor) Process(block *types.Block, publicState, privateState *
|
|||
// ApplyTransactions returns the generated receipts and vm logs during the
|
||||
// execution of the state transition phase.
|
||||
func ApplyTransaction(config *ChainConfig, bc *BlockChain, gp *GasPool, publicState, privateState *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, cfg vm.Config) (*types.Receipt, vm.Logs, *big.Int, error) {
|
||||
txData := tx.Data()
|
||||
private := len(txData) > 4 && bytes.Equal(txData[:4], crypto.Keccak256(txData[4:])[:4])
|
||||
if !private {
|
||||
if !tx.IsPrivate() {
|
||||
privateState = publicState
|
||||
}
|
||||
_, gas, err := ApplyMessage(NewEnv(publicState, privateState, config, bc, tx, header, cfg), tx, gp)
|
||||
|
|
|
@ -294,6 +294,10 @@ func (tx *Transaction) SignatureValues() (v byte, r *big.Int, s *big.Int) {
|
|||
return tx.data.V, new(big.Int).Set(tx.data.R), new(big.Int).Set(tx.data.S)
|
||||
}
|
||||
|
||||
func (tx *Transaction) IsPrivate() bool {
|
||||
return tx.data.V == 37 || tx.data.V == 38
|
||||
}
|
||||
|
||||
func (tx *Transaction) publicKey(homestead bool) ([]byte, error) {
|
||||
if !crypto.ValidateSignatureValues(tx.data.V, tx.data.R, tx.data.S, homestead) {
|
||||
return nil, ErrInvalidSig
|
||||
|
@ -305,6 +309,9 @@ func (tx *Transaction) publicKey(homestead bool) ([]byte, error) {
|
|||
copy(sig[32-len(r):32], r)
|
||||
copy(sig[64-len(s):64], s)
|
||||
sig[64] = tx.data.V - 27
|
||||
if tx.data.V > 28 {
|
||||
sig[64] -= 10
|
||||
}
|
||||
|
||||
// recover the public key from the signature
|
||||
hash := tx.SigHash()
|
||||
|
|
Loading…
Reference in New Issue