Skip to content
Snippets Groups Projects
Commit 4bfcb797 authored by Hans Moog's avatar Hans Moog
Browse files

Feat: bundleHash gets calculated for value bundles

parent 97a87d17
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 ...@@ -19,6 +19,7 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/ethereum/go-ethereum v1.8.27 h1:d+gkiLaBDk5fn3Pe/xNVaMrB/ozI+AUB2IlVBp29IrY= github.com/ethereum/go-ethereum v1.8.27 h1:d+gkiLaBDk5fn3Pe/xNVaMrB/ozI+AUB2IlVBp29IrY=
github.com/ethereum/go-ethereum v1.8.27/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= github.com/ethereum/go-ethereum v1.8.27/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
...@@ -104,6 +105,7 @@ golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cj ...@@ -104,6 +105,7 @@ golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cj
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
......
package bundleprocessor package bundleprocessor
import ( import (
"github.com/iotadevelopment/go/packages/ternary" "github.com/iotaledger/goshimmer/packages/curl"
"github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/bundle"
"github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata"
...@@ -54,12 +54,18 @@ func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction) ...@@ -54,12 +54,18 @@ func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction)
newBundle.SetTransactionHashes(mapTransactionsToTransactionHashes(bundleTransactions)) newBundle.SetTransactionHashes(mapTransactionsToTransactionHashes(bundleTransactions))
if newBundle.IsValueBundle() { if newBundle.IsValueBundle() {
var concatenatedBundleEssences = make(ternary.Trits, len(bundleTransactions)*value_transaction.BUNDLE_ESSENCE_SIZE) var concatenatedBundleEssences = make(trinary.Trits, len(bundleTransactions)*value_transaction.BUNDLE_ESSENCE_SIZE)
for i, bundleTransaction := range bundleTransactions { for i, bundleTransaction := range bundleTransactions {
copy(concatenatedBundleEssences[value_transaction.BUNDLE_ESSENCE_SIZE*i:value_transaction.BUNDLE_ESSENCE_SIZE*(i+1)], bundleTransaction.GetBundleEssence()) copy(concatenatedBundleEssences[value_transaction.BUNDLE_ESSENCE_SIZE*i:value_transaction.BUNDLE_ESSENCE_SIZE*(i+1)], bundleTransaction.GetBundleEssence())
} }
// calc + set bundle hash var resp = make(trinary.Trits, 243)
hasher := curl.NewCurl(243, 81)
hasher.Absorb(concatenatedBundleEssences, 0, len(concatenatedBundleEssences))
hasher.Squeeze(resp, 0, 243)
newBundle.SetBundleEssenceHash(trinary.MustTritsToTrytes(resp))
} }
Events.BundleSolid.Trigger(newBundle, bundleTransactions) Events.BundleSolid.Trigger(newBundle, bundleTransactions)
......
...@@ -29,6 +29,7 @@ func TestProcessSolidBundleHead(t *testing.T) { ...@@ -29,6 +29,7 @@ func TestProcessSolidBundleHead(t *testing.T) {
Events.BundleSolid.Attach(events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { Events.BundleSolid.Attach(events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) {
fmt.Println("IT HAPPENED") fmt.Println("IT HAPPENED")
fmt.Println(bundle.GetHash()) fmt.Println(bundle.GetHash())
fmt.Println(bundle.GetBundleEssenceHash())
})) }))
result, err := ProcessSolidBundleHead(tx1) result, err := ProcessSolidBundleHead(tx1)
......
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
"github.com/iotaledger/goshimmer/plugins/bundleprocessor" "github.com/iotaledger/goshimmer/plugins/bundleprocessor"
"github.com/iotaledger/iota.go/address" "github.com/iotaledger/iota.go/address"
. "github.com/iotaledger/iota.go/consts" . "github.com/iotaledger/iota.go/consts"
"github.com/iotaledger/iota.go/kerl"
"github.com/iotaledger/iota.go/signing" "github.com/iotaledger/iota.go/signing"
. "github.com/iotaledger/iota.go/trinary" . "github.com/iotaledger/iota.go/trinary"
) )
...@@ -63,7 +62,7 @@ func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransacti ...@@ -63,7 +62,7 @@ func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransacti
} }
// validate all the fragments against the address using Kerl // validate all the fragments against the address using Kerl
valid, err := signing.ValidateSignatures(address, fragments, bundleHash, kerl.NewKerl()) valid, err := signing.ValidateSignatures(address, fragments, bundleHash, signing.NewKerl)
if err != nil { if err != nil {
return false, err return false, err
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment