aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-01-17 04:32:46 +0800
committerobscuren <geffobscura@gmail.com>2014-01-17 04:32:46 +0800
commit815313c759acaf7cf2e295a61fa58d5ccdb0d126 (patch)
treee95879f0d1cb4e1e57d63b51eea37323956b2836
parentfd7e79f4e3604435d87b21349c8dd31052ef8a78 (diff)
downloadgo-tangerine-815313c759acaf7cf2e295a61fa58d5ccdb0d126.tar.gz
go-tangerine-815313c759acaf7cf2e295a61fa58d5ccdb0d126.tar.zst
go-tangerine-815313c759acaf7cf2e295a61fa58d5ccdb0d126.zip
Added more opcodes
-rw-r--r--block_manager.go38
1 files changed, 36 insertions, 2 deletions
diff --git a/block_manager.go b/block_manager.go
index 4ddc3952b..ce852612a 100644
--- a/block_manager.go
+++ b/block_manager.go
@@ -1,10 +1,13 @@
package main
import (
+ "bytes"
"errors"
"fmt"
"github.com/ethereum/ethutil-go"
+ "github.com/obscuren/secp256-go"
"log"
+ "math"
"math/big"
)
@@ -421,9 +424,40 @@ out:
// x = floor(10^21 / floor(diff^0.5))
bm.stack.Push(x.String())
- case oSHA256:
- case oRIPEMD160:
+ case oSHA256, oRIPEMD160:
+ // This is probably save
+ // ceil(pop / 32)
+ length := int(math.Ceil(float64(ethutil.Big(bm.stack.Pop()).Uint64()) / 32.0))
+ // New buffer which will contain the concatenated popped items
+ data := new(bytes.Buffer)
+ for i := 0; i < length; i++ {
+ // Encode the number to bytes and have it 32bytes long
+ num := ethutil.NumberToBytes(ethutil.Big(bm.stack.Pop()).Bytes(), 256)
+ data.WriteString(string(num))
+ }
+
+ if op == oSHA256 {
+ bm.stack.Push(base.SetBytes(ethutil.Sha256Bin(data.Bytes())).String())
+ } else {
+ bm.stack.Push(base.SetBytes(ethutil.Ripemd160(data.Bytes())).String())
+ }
case oECMUL:
+ y := bm.stack.Pop()
+ x := bm.stack.Pop()
+ n := bm.stack.Pop()
+
+ if ethutil.Big(x).Cmp(ethutil.Big(y))
+ data := new(bytes.Buffer)
+ data.WriteString(x)
+ data.WriteString(y)
+ if secp256.VerifyPubkeyValidity(data.Bytes()) == 1 {
+ // TODO
+ } else {
+ // Invalid, push infinity
+ bm.stack.Push("0")
+ bm.stack.Push("0")
+ }
+
case oECADD:
case oECSIGN:
case oECRECOVER: