diff --git a/go.sum b/go.sum index 9ca44d69e4b39c1b33d72251977b9bf29e5de3ee..4be9aee64cb4521d07133ec858a313da95469c58 100644 --- a/go.sum +++ b/go.sum @@ -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/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/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/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= 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 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/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/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/plugins/bundleprocessor/bundleprocessor.go b/plugins/bundleprocessor/bundleprocessor.go index 30c8b6d58df353ee39235320bcb3b013bd39f669..9dade9b6e6551106f9b672f7cb65fcc72982163a 100644 --- a/plugins/bundleprocessor/bundleprocessor.go +++ b/plugins/bundleprocessor/bundleprocessor.go @@ -1,7 +1,7 @@ package bundleprocessor import ( - "github.com/iotadevelopment/go/packages/ternary" + "github.com/iotaledger/goshimmer/packages/curl" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" @@ -54,12 +54,18 @@ func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction) newBundle.SetTransactionHashes(mapTransactionsToTransactionHashes(bundleTransactions)) 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 { 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) diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 5da9cc4db4ee3140fa9e38a08129e1a20fafbf42..ee4cc3d467d3b7fe3c9a01cd9767d373deea87d3 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -29,6 +29,7 @@ func TestProcessSolidBundleHead(t *testing.T) { Events.BundleSolid.Attach(events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { fmt.Println("IT HAPPENED") fmt.Println(bundle.GetHash()) + fmt.Println(bundle.GetBundleEssenceHash()) })) result, err := ProcessSolidBundleHead(tx1) diff --git a/plugins/validator/plugin.go b/plugins/validator/plugin.go index dce2129b6d57b502f65a8f1621149ce8fa7e7119..c0c7b64b70f7257d9997a6cc99cd196a336f129f 100644 --- a/plugins/validator/plugin.go +++ b/plugins/validator/plugin.go @@ -8,7 +8,6 @@ import ( "github.com/iotaledger/goshimmer/plugins/bundleprocessor" "github.com/iotaledger/iota.go/address" . "github.com/iotaledger/iota.go/consts" - "github.com/iotaledger/iota.go/kerl" "github.com/iotaledger/iota.go/signing" . "github.com/iotaledger/iota.go/trinary" ) @@ -63,7 +62,7 @@ func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransacti } // 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 { return false, err }