From a71e034f319a4e33236b2eee7e7e58b4605ad2db Mon Sep 17 00:00:00 2001 From: Robin Bryce Date: Wed, 30 Oct 2024 10:29:54 +0000 Subject: [PATCH] updates for cose receipts algorithms --- go.mod | 9 ++------- go.sum | 4 ++++ integrationsupport/massifseal.go | 2 +- logverification/proof.go | 2 +- logverification/seal.go | 2 +- logverification/verifylist.go | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 4064798..9af0175 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.22 require ( github.com/datatrails/go-datatrails-common v0.18.0 github.com/datatrails/go-datatrails-common-api-gen v0.4.5 - github.com/datatrails/go-datatrails-merklelog/massifs v0.1.1 - github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 + github.com/datatrails/go-datatrails-merklelog/massifs v0.2.0 + github.com/datatrails/go-datatrails-merklelog/mmr v0.1.0 github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.1.0 github.com/datatrails/go-datatrails-simplehash v0.0.5 github.com/stretchr/testify v1.9.0 @@ -14,11 +14,6 @@ require ( google.golang.org/protobuf v1.34.2 ) -replace ( - github.com/datatrails/go-datatrails-merklelog/massifs => ../go-datatrails-merklelog/massifs - github.com/datatrails/go-datatrails-merklelog/mmr => ../go-datatrails-merklelog/mmr -) - require ( github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 // indirect diff --git a/go.sum b/go.sum index 4e454a2..626d2d4 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,10 @@ github.com/datatrails/go-datatrails-common v0.18.0 h1:OeNP4EdIjhLHnE/mdN2/kp6Fq+ github.com/datatrails/go-datatrails-common v0.18.0/go.mod h1:fBDqKHRLUYcictdWdLrIhKNhieKVE2r0II8vyETCuhM= github.com/datatrails/go-datatrails-common-api-gen v0.4.5 h1:QtxIFSdOEf6bhHZd7g/MfWdCWfPEtwTQNDz3K9u33+c= github.com/datatrails/go-datatrails-common-api-gen v0.4.5/go.mod h1:OQN91xvlW6xcWTFvwsM2Nn4PZwFAIOE52FG7yRl4QPQ= +github.com/datatrails/go-datatrails-merklelog/massifs v0.2.0 h1:UK8SsH6X1a2MFSrKBCvSgwRGRy94ZDXsgXrAyBy6bDU= +github.com/datatrails/go-datatrails-merklelog/massifs v0.2.0/go.mod h1:bISXyzOXbHJS2AANP1nc+07AJ+OlKDOs+wFP6oc2oSY= +github.com/datatrails/go-datatrails-merklelog/mmr v0.1.0 h1:DKHY1rgLQ+8JoVZfSrMOwPytgQy7+oyYQ8EWHryEXE4= +github.com/datatrails/go-datatrails-merklelog/mmr v0.1.0/go.mod h1:B/Kkz4joZTiTz0q/9FFAgHR+Tcn6UxtphMuCzamAc9Q= github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.1.0 h1:q9RXtAGydXKSJjARnFObNu743cbfIOfERTXiiVa2tF4= github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.1.0/go.mod h1:rWFjeK1NU7qnhl9+iKdjASpw/CkPwDAOPHsERYR7uEQ= github.com/datatrails/go-datatrails-simplehash v0.0.5 h1:igu4QRYO87RQXrJlqSm3fgMA2Q0F4jglWqBlfvKrXKQ= diff --git a/integrationsupport/massifseal.go b/integrationsupport/massifseal.go index fd8d950..fde2770 100644 --- a/integrationsupport/massifseal.go +++ b/integrationsupport/massifseal.go @@ -25,7 +25,7 @@ func GenerateMassifSeal(t *testing.T, testContext mmrtesting.TestContext, lastEv require.Nil(t, err) mmrSize := massifContext.RangeCount() - peaks, err := mmr.PeakHashes(&massifContext, mmrSize) + peaks, err := mmr.PeakHashes(&massifContext, mmrSize-1) require.Nil(t, err) id, epoch, err := massifs.SplitIDTimestampHex(lastEvent.MerklelogEntry.Commit.Idtimestamp) require.Nil(t, err) diff --git a/logverification/proof.go b/logverification/proof.go index c762526..a2670bd 100644 --- a/logverification/proof.go +++ b/logverification/proof.go @@ -18,7 +18,7 @@ func EventProof(verifiableEvent VerifiableEvent, massif *massifs.MassifContext) // Get the size of the complete tenant MMR mmrSize := massif.RangeCount() - proof, err := mmr.IndexProof(massif, mmrSize, verifiableEvent.MerkleLog.Commit.Index) + proof, err := mmr.InclusionProof(massif, mmrSize-1, verifiableEvent.MerkleLog.Commit.Index) if err != nil { return nil, err } diff --git a/logverification/seal.go b/logverification/seal.go index 0c58fb3..5ea21b7 100644 --- a/logverification/seal.go +++ b/logverification/seal.go @@ -48,7 +48,7 @@ func SignedLogState( // of the data. If verification succeeds when this computed root is added to signedStateNow, then // we can be confident that DataTrails signed this state, and that the root matches your data. - logState.Peaks, err = mmr.PeakHashes(&massifContext, logState.MMRSize) + logState.Peaks, err = mmr.PeakHashes(&massifContext, logState.MMRSize-1) if err != nil { return nil, fmt.Errorf("SignedLogState failed: unable to get root for massifContextNow: %w", err) } diff --git a/logverification/verifylist.go b/logverification/verifylist.go index d79a9ed..f03f745 100644 --- a/logverification/verifylist.go +++ b/logverification/verifylist.go @@ -349,7 +349,7 @@ func VerifyEventInList( // we can do an inclusion proof of the leaf node on the merkle log. mmrSize := massifContext.RangeCount() - inclusionProof, err := mmr.IndexProof(massifContext, mmrSize, leafMMRIndex) + inclusionProof, err := mmr.InclusionProof(massifContext, mmrSize-1, leafMMRIndex) if err != nil { return Unknown, err }