forked from cerc-io/plugeth
Renamed Sha3Bin to Sha3
This commit is contained in:
parent
f3196c915a
commit
9d86a49a73
@ -144,12 +144,12 @@ func CreateBlock(root interface{},
|
||||
|
||||
// Returns a hash of the block
|
||||
func (block *Block) Hash() ethutil.Bytes {
|
||||
return ethcrypto.Sha3Bin(ethutil.NewValue(block.header()).Encode())
|
||||
//return ethcrypto.Sha3Bin(block.Value().Encode())
|
||||
return ethcrypto.Sha3(ethutil.NewValue(block.header()).Encode())
|
||||
//return ethcrypto.Sha3(block.Value().Encode())
|
||||
}
|
||||
|
||||
func (block *Block) HashNoNonce() []byte {
|
||||
return ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{block.PrevHash,
|
||||
return ethcrypto.Sha3(ethutil.Encode([]interface{}{block.PrevHash,
|
||||
block.UncleSha, block.Coinbase, block.state.Trie.Root,
|
||||
block.TxSha, block.Difficulty, block.Number, block.MinGasPrice,
|
||||
block.GasLimit, block.GasUsed, block.Time, block.Extra}))
|
||||
@ -237,7 +237,7 @@ func (block *Block) SetUncles(uncles []*Block) {
|
||||
block.Uncles = uncles
|
||||
|
||||
// Sha of the concatenated uncles
|
||||
block.UncleSha = ethcrypto.Sha3Bin(ethutil.Encode(block.rlpUncles()))
|
||||
block.UncleSha = ethcrypto.Sha3(ethutil.Encode(block.rlpUncles()))
|
||||
}
|
||||
|
||||
func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) {
|
||||
|
@ -61,7 +61,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
|
||||
t = time.Now()
|
||||
}
|
||||
|
||||
sha := ethcrypto.Sha3Bin(big.NewInt(r.Int63()).Bytes())
|
||||
sha := ethcrypto.Sha3(big.NewInt(r.Int63()).Bytes())
|
||||
if pow.Verify(hash, diff, sha) {
|
||||
return sha
|
||||
}
|
||||
|
@ -13,13 +13,13 @@ import (
|
||||
|
||||
var ZeroHash256 = make([]byte, 32)
|
||||
var ZeroHash160 = make([]byte, 20)
|
||||
var EmptyShaList = ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{}))
|
||||
var EmptyShaList = ethcrypto.Sha3(ethutil.Encode([]interface{}{}))
|
||||
|
||||
var GenesisHeader = []interface{}{
|
||||
// Previous hash (none)
|
||||
ZeroHash256,
|
||||
// Sha of uncles
|
||||
ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{})),
|
||||
ethcrypto.Sha3(ethutil.Encode([]interface{}{})),
|
||||
// Coinbase
|
||||
ZeroHash160,
|
||||
// Root state
|
||||
@ -42,7 +42,7 @@ var GenesisHeader = []interface{}{
|
||||
// Extra
|
||||
nil,
|
||||
// Nonce
|
||||
ethcrypto.Sha3Bin(big.NewInt(42).Bytes()),
|
||||
ethcrypto.Sha3(big.NewInt(42).Bytes()),
|
||||
}
|
||||
|
||||
var Genesis = []interface{}{GenesisHeader, []interface{}{}, []interface{}{}}
|
||||
|
@ -66,7 +66,7 @@ func (self *Transaction) TotalValue() *big.Int {
|
||||
func (tx *Transaction) Hash() []byte {
|
||||
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data}
|
||||
|
||||
return ethcrypto.Sha3Bin(ethutil.NewValue(data).Encode())
|
||||
return ethcrypto.Sha3(ethutil.NewValue(data).Encode())
|
||||
}
|
||||
|
||||
func (tx *Transaction) CreatesContract() bool {
|
||||
@ -80,9 +80,9 @@ func (tx *Transaction) IsContract() bool {
|
||||
|
||||
func (tx *Transaction) CreationAddress(state *ethstate.State) []byte {
|
||||
// Generate a new address
|
||||
addr := ethcrypto.Sha3Bin(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
|
||||
addr := ethcrypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
|
||||
//for i := uint64(0); state.GetStateObject(addr) != nil; i++ {
|
||||
// addr = ethcrypto.Sha3Bin(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce + i}).Encode())[12:]
|
||||
// addr = ethcrypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce + i}).Encode())[12:]
|
||||
//}
|
||||
|
||||
return addr
|
||||
@ -120,7 +120,7 @@ func (tx *Transaction) Sender() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ethcrypto.Sha3Bin(pubkey[1:])[12:]
|
||||
return ethcrypto.Sha3(pubkey[1:])[12:]
|
||||
}
|
||||
|
||||
func (tx *Transaction) Sign(privk []byte) error {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ethcrypto
|
||||
|
||||
import (
|
||||
//"code.google.com/p/go.crypto/sha3"
|
||||
"crypto/sha256"
|
||||
|
||||
"code.google.com/p/go.crypto/ripemd160"
|
||||
@ -12,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// TODO refactor, remove (bin)
|
||||
func Sha3Bin(data []byte) []byte {
|
||||
func Sha3(data []byte) []byte {
|
||||
d := sha3.NewKeccak256()
|
||||
d.Write(data)
|
||||
|
||||
@ -21,7 +20,7 @@ func Sha3Bin(data []byte) []byte {
|
||||
|
||||
// Creates an ethereum address given the bytes and the nonce
|
||||
func CreateAddress(b []byte, nonce uint64) []byte {
|
||||
return Sha3Bin(ethutil.NewValue([]interface{}{b, nonce}).Encode())[12:]
|
||||
return Sha3(ethutil.NewValue([]interface{}{b, nonce}).Encode())[12:]
|
||||
}
|
||||
|
||||
func Sha256(data []byte) []byte {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package ethcrypto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/obscuren/secp256k1-go"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type KeyPair struct {
|
||||
@ -32,7 +33,7 @@ func NewKeyPairFromSec(seckey []byte) (*KeyPair, error) {
|
||||
|
||||
func (k *KeyPair) Address() []byte {
|
||||
if k.address == nil {
|
||||
k.address = Sha3Bin(k.PublicKey[1:])[12:]
|
||||
k.address = Sha3(k.PublicKey[1:])[12:]
|
||||
}
|
||||
return k.address
|
||||
}
|
||||
|
@ -431,6 +431,8 @@ func (s *Ethereum) Start(seed bool) {
|
||||
}
|
||||
|
||||
func (s *Ethereum) Seed() {
|
||||
// Sorry Py person. I must blacklist. you perform badly
|
||||
s.blacklist = append(s.blacklist, ethutil.Hex2Bytes("64656330303561383532336435376331616537643864663236623336313863373537353163636634333530626263396330346237336262623931383064393031"))
|
||||
ips := PastPeers()
|
||||
if len(ips) > 0 {
|
||||
for _, ip := range ips {
|
||||
|
@ -304,7 +304,7 @@ func (c *StateObject) RlpEncode() []byte {
|
||||
func (c *StateObject) CodeHash() ethutil.Bytes {
|
||||
var codeHash []byte
|
||||
if len(c.Code) > 0 {
|
||||
codeHash = ethcrypto.Sha3Bin(c.Code)
|
||||
codeHash = ethcrypto.Sha3(c.Code)
|
||||
}
|
||||
|
||||
return codeHash
|
||||
|
@ -67,7 +67,7 @@ func (cache *Cache) PutValue(v interface{}, force bool) interface{} {
|
||||
|
||||
enc := value.Encode()
|
||||
if len(enc) >= 32 || force {
|
||||
sha := ethcrypto.Sha3Bin(enc)
|
||||
sha := ethcrypto.Sha3(enc)
|
||||
|
||||
cache.nodes[string(sha)] = NewNode(sha, value, true)
|
||||
cache.IsDirty = true
|
||||
|
@ -490,7 +490,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
|
||||
case SHA3:
|
||||
require(2)
|
||||
size, offset := stack.Popn()
|
||||
data := ethcrypto.Sha3Bin(mem.Get(offset.Int64(), size.Int64()))
|
||||
data := ethcrypto.Sha3(mem.Get(offset.Int64(), size.Int64()))
|
||||
|
||||
stack.Push(ethutil.BigD(data))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user