Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new verifiable event #13

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# go-datatrails-demos

## Integrity Demo
## Inclusion Demo

The integrity demo will verify the integrity of a datatrails event.
The inclusion demo will verify the inclusion of a datatrails event.

This is achieved by creating an inclusion proof for that event and
then verifying the inclusion proof against the merkle log.
Expand All @@ -11,10 +11,10 @@ If the inclusion proof is verified successfully, we can say that the
datatrails event is included on the merkle log.

### Docker Demo
To run the integrity demo with docker:
To run the inclusion demo with docker:

```
docker run -v ./integrity:/usr/src/myapp -w /usr/src/myapp golang:1.22-alpine go run .
docker run -v ./inclusion:/usr/src/myapp -w /usr/src/myapp golang:1.22-alpine go run .
```

Where the docker command is run from the root of the repo.
Expand All @@ -24,21 +24,21 @@ Where the docker command is run from the root of the repo.
To run the demo with a task (https://taskfile.dev/installation/) rune:

```
task demos:integrity
task demos:inclusion
```

### Go Demo

If you want to run the demo directly with golang from the root of the repo:

```
cd integrity
cd inclusion
go run .
```

## Completeness Demo

The completenesss demo will verify the integrity of a list of datatrails events.
The completenesss demo will verify the inclusion of a list of datatrails events.

This is achieved by checking that **ONLY** the events in the list exist on the log within a range
starting from the first event in the list, ending at the last event in the list.
Expand Down
8 changes: 4 additions & 4 deletions completeness/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
github.com/datatrails/go-datatrails-common v0.16.1
github.com/datatrails/go-datatrails-logverification v0.1.2
github.com/datatrails/go-datatrails-logverification v0.1.5
github.com/stretchr/testify v1.9.0
)

Expand All @@ -26,10 +26,10 @@ require (
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/datatrails/go-datatrails-common-api-gen v0.4.8 // indirect
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.7 // indirect
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.1 // indirect
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10 // indirect
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 // indirect
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1 // indirect
github.com/datatrails/go-datatrails-simplehash v0.0.3 // indirect
github.com/datatrails/go-datatrails-simplehash v0.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
Expand Down
18 changes: 8 additions & 10 deletions completeness/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ github.com/datatrails/go-datatrails-common v0.16.1 h1:kaNOwyu8EmBbIR44daWDiUZxBt
github.com/datatrails/go-datatrails-common v0.16.1/go.mod h1:IEcuwUaFl+bI1tt30r+Ov2+nvpcAZH/kXmAPGFjkwT4=
github.com/datatrails/go-datatrails-common-api-gen v0.4.8 h1:IzrhGHi9TyEASjk06QjsayjtpXYCKuDt78+ffLuOCNM=
github.com/datatrails/go-datatrails-common-api-gen v0.4.8/go.mod h1:zlwFPJXYAK7yqgLtxKUgkF5gw9ddxoqWS+Ruhf+Ksw0=
github.com/datatrails/go-datatrails-logverification v0.1.2 h1:VohfbxpYzbV6nrW2JerUqy7bElyl0oR78ZXY8g80YYI=
github.com/datatrails/go-datatrails-logverification v0.1.2/go.mod h1:0n2sTXhR9LUT5w3+KxqXGMs5XIVRa7Ip2RJ6QgCWpVY=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.7 h1:844V2QxLhVmSkOISu00qHMxs4+XpGU2tHQ433S3akHY=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.7/go.mod h1:eNMW+ZfyGT4ttj/vAE56Ut1uWfdc9zW1W7yIIl2XF1k=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.1 h1:XggMVejsJ72cAL/msjPhQUSQNeElSh/O1zZcvX4d4JU=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.1/go.mod h1:+Oz8O6bns0rF6gr03xJzKTBzUzyskZ8Gics8/qeNzYk=
github.com/datatrails/go-datatrails-logverification v0.1.5 h1:6M1gxC5hrgYrYyLEz3K3NxNIwZvfwXBPVnZXIPqUtQs=
github.com/datatrails/go-datatrails-logverification v0.1.5/go.mod h1:yCYT82iv95QGgvXTxQRb9vSkHF653cjiDXXwOAw3I4s=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10 h1:FhVbydbzRC+tQEpzwnUUWY/P58/h5MFZ8QbZl5BUqEk=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10/go.mod h1:5o8k+btUoxenGw9sy7x85q2qdzsmu9v2ALMk13RTpG4=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 h1:Jxov4/onoFiCISLQNSPy/nyt3USAEvUZpEjlScHJYKI=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2/go.mod h1:+Oz8O6bns0rF6gr03xJzKTBzUzyskZ8Gics8/qeNzYk=
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1 h1:sIyXWKTadqmVEsPj66RlKwRKzNQ7hK9SH1fRjZFDCa8=
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1/go.mod h1:KGdkOtamWG48EN4AXtTHPv6C0jJKrj840IMSkrD+egk=
github.com/datatrails/go-datatrails-simplehash v0.0.3 h1:H4zNsdB9d2KMZ3EqM6n6AMGYB/RquEjANqcNrUlZtp8=
github.com/datatrails/go-datatrails-simplehash v0.0.3/go.mod h1:ML1qlHH+SeaSTphpKw9psCsdI4UaTH3d68GpWOWOKgg=
github.com/datatrails/go-datatrails-simplehash v0.0.5 h1:igu4QRYO87RQXrJlqSm3fgMA2Q0F4jglWqBlfvKrXKQ=
github.com/datatrails/go-datatrails-simplehash v0.0.5/go.mod h1:XuOwViwdL+dyz7fGYIjaByS1ElMFsrVI0goKX0bNimA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -190,7 +190,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
14 changes: 7 additions & 7 deletions completeness/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"os"
"strings"

"github.com/datatrails/go-datatrails-common/azblob"
"github.com/datatrails/go-datatrails-logverification/logverification"
Expand All @@ -19,20 +18,21 @@ import (
*/

// CompletenessDemo of a list of public datatrails events
func CompletenessDemo(eventJson []byte) (omittedEvents []uint64, err error) {

// first we need to strip the 'public' prefix from all identity and assetIdentity fields
// as the hashing schema does not support public prefixing
events := strings.ReplaceAll(eventList, "publicassets/", "assets/")
func CompletenessDemo(eventsJson []byte) (omittedEvents []uint64, err error) {

// then create the merklelog reader
reader, err := azblob.NewReaderNoAuth(url, azblob.WithContainer(container))
if err != nil {
return nil, err
}

verifiableEvents, err := logverification.NewVerifiableEvents(eventsJson)
if err != nil {
return nil, err
}

// now verify the public event is in the merklelog
return logverification.VerifyList(reader, []byte(events), logverification.WithTenantId(publicTenantID))
return logverification.VerifyList(reader, verifiableEvents, logverification.WithTenantId(publicTenantID))

}

Expand Down
4 changes: 2 additions & 2 deletions consistency/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require github.com/stretchr/testify v1.9.0

require (
github.com/datatrails/go-datatrails-common v0.16.1
github.com/datatrails/go-datatrails-logverification v0.1.3
github.com/datatrails/go-datatrails-logverification v0.1.5
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10
)

Expand All @@ -30,7 +30,7 @@ require (
github.com/datatrails/go-datatrails-common-api-gen v0.4.8 // indirect
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 // indirect
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1 // indirect
github.com/datatrails/go-datatrails-simplehash v0.0.3 // indirect
github.com/datatrails/go-datatrails-simplehash v0.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
Expand Down
10 changes: 4 additions & 6 deletions consistency/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ github.com/datatrails/go-datatrails-common v0.16.1 h1:kaNOwyu8EmBbIR44daWDiUZxBt
github.com/datatrails/go-datatrails-common v0.16.1/go.mod h1:IEcuwUaFl+bI1tt30r+Ov2+nvpcAZH/kXmAPGFjkwT4=
github.com/datatrails/go-datatrails-common-api-gen v0.4.8 h1:IzrhGHi9TyEASjk06QjsayjtpXYCKuDt78+ffLuOCNM=
github.com/datatrails/go-datatrails-common-api-gen v0.4.8/go.mod h1:zlwFPJXYAK7yqgLtxKUgkF5gw9ddxoqWS+Ruhf+Ksw0=
github.com/datatrails/go-datatrails-logverification v0.1.3 h1:uiWGmOc6c+QRU74QNG8Xt0hZ42S/wc+hi6Lvs4d7PoI=
github.com/datatrails/go-datatrails-logverification v0.1.3/go.mod h1:MEQHV6izop5w0r+dlwP2v6knozA+KZjUqQcLf5qZCnQ=
github.com/datatrails/go-datatrails-logverification v0.1.5 h1:6M1gxC5hrgYrYyLEz3K3NxNIwZvfwXBPVnZXIPqUtQs=
github.com/datatrails/go-datatrails-logverification v0.1.5/go.mod h1:yCYT82iv95QGgvXTxQRb9vSkHF653cjiDXXwOAw3I4s=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10 h1:FhVbydbzRC+tQEpzwnUUWY/P58/h5MFZ8QbZl5BUqEk=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10/go.mod h1:5o8k+btUoxenGw9sy7x85q2qdzsmu9v2ALMk13RTpG4=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 h1:Jxov4/onoFiCISLQNSPy/nyt3USAEvUZpEjlScHJYKI=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2/go.mod h1:+Oz8O6bns0rF6gr03xJzKTBzUzyskZ8Gics8/qeNzYk=
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1 h1:sIyXWKTadqmVEsPj66RlKwRKzNQ7hK9SH1fRjZFDCa8=
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1/go.mod h1:KGdkOtamWG48EN4AXtTHPv6C0jJKrj840IMSkrD+egk=
github.com/datatrails/go-datatrails-simplehash v0.0.3 h1:H4zNsdB9d2KMZ3EqM6n6AMGYB/RquEjANqcNrUlZtp8=
github.com/datatrails/go-datatrails-simplehash v0.0.3/go.mod h1:ML1qlHH+SeaSTphpKw9psCsdI4UaTH3d68GpWOWOKgg=
github.com/datatrails/go-datatrails-simplehash v0.0.5 h1:igu4QRYO87RQXrJlqSm3fgMA2Q0F4jglWqBlfvKrXKQ=
github.com/datatrails/go-datatrails-simplehash v0.0.5/go.mod h1:XuOwViwdL+dyz7fGYIjaByS1ElMFsrVI0goKX0bNimA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -199,7 +199,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
File renamed without changes.
8 changes: 4 additions & 4 deletions integrity/go.mod → inclusion/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
require github.com/datatrails/go-datatrails-common v0.16.1

require (
github.com/datatrails/go-datatrails-logverification v0.1.2
github.com/datatrails/go-datatrails-logverification v0.1.5
github.com/stretchr/testify v1.9.0
)

Expand All @@ -27,10 +27,10 @@ require (
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/datatrails/go-datatrails-common-api-gen v0.4.8 // indirect
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.7 // indirect
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.1 // indirect
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10 // indirect
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 // indirect
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1 // indirect
github.com/datatrails/go-datatrails-simplehash v0.0.3 // indirect
github.com/datatrails/go-datatrails-simplehash v0.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
Expand Down
18 changes: 8 additions & 10 deletions integrity/go.sum → inclusion/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ github.com/datatrails/go-datatrails-common v0.16.1 h1:kaNOwyu8EmBbIR44daWDiUZxBt
github.com/datatrails/go-datatrails-common v0.16.1/go.mod h1:IEcuwUaFl+bI1tt30r+Ov2+nvpcAZH/kXmAPGFjkwT4=
github.com/datatrails/go-datatrails-common-api-gen v0.4.8 h1:IzrhGHi9TyEASjk06QjsayjtpXYCKuDt78+ffLuOCNM=
github.com/datatrails/go-datatrails-common-api-gen v0.4.8/go.mod h1:zlwFPJXYAK7yqgLtxKUgkF5gw9ddxoqWS+Ruhf+Ksw0=
github.com/datatrails/go-datatrails-logverification v0.1.2 h1:VohfbxpYzbV6nrW2JerUqy7bElyl0oR78ZXY8g80YYI=
github.com/datatrails/go-datatrails-logverification v0.1.2/go.mod h1:0n2sTXhR9LUT5w3+KxqXGMs5XIVRa7Ip2RJ6QgCWpVY=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.7 h1:844V2QxLhVmSkOISu00qHMxs4+XpGU2tHQ433S3akHY=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.7/go.mod h1:eNMW+ZfyGT4ttj/vAE56Ut1uWfdc9zW1W7yIIl2XF1k=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.1 h1:XggMVejsJ72cAL/msjPhQUSQNeElSh/O1zZcvX4d4JU=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.1/go.mod h1:+Oz8O6bns0rF6gr03xJzKTBzUzyskZ8Gics8/qeNzYk=
github.com/datatrails/go-datatrails-logverification v0.1.5 h1:6M1gxC5hrgYrYyLEz3K3NxNIwZvfwXBPVnZXIPqUtQs=
github.com/datatrails/go-datatrails-logverification v0.1.5/go.mod h1:yCYT82iv95QGgvXTxQRb9vSkHF653cjiDXXwOAw3I4s=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10 h1:FhVbydbzRC+tQEpzwnUUWY/P58/h5MFZ8QbZl5BUqEk=
github.com/datatrails/go-datatrails-merklelog/massifs v0.0.10/go.mod h1:5o8k+btUoxenGw9sy7x85q2qdzsmu9v2ALMk13RTpG4=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2 h1:Jxov4/onoFiCISLQNSPy/nyt3USAEvUZpEjlScHJYKI=
github.com/datatrails/go-datatrails-merklelog/mmr v0.0.2/go.mod h1:+Oz8O6bns0rF6gr03xJzKTBzUzyskZ8Gics8/qeNzYk=
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1 h1:sIyXWKTadqmVEsPj66RlKwRKzNQ7hK9SH1fRjZFDCa8=
github.com/datatrails/go-datatrails-merklelog/mmrtesting v0.0.1/go.mod h1:KGdkOtamWG48EN4AXtTHPv6C0jJKrj840IMSkrD+egk=
github.com/datatrails/go-datatrails-simplehash v0.0.3 h1:H4zNsdB9d2KMZ3EqM6n6AMGYB/RquEjANqcNrUlZtp8=
github.com/datatrails/go-datatrails-simplehash v0.0.3/go.mod h1:ML1qlHH+SeaSTphpKw9psCsdI4UaTH3d68GpWOWOKgg=
github.com/datatrails/go-datatrails-simplehash v0.0.5 h1:igu4QRYO87RQXrJlqSm3fgMA2Q0F4jglWqBlfvKrXKQ=
github.com/datatrails/go-datatrails-simplehash v0.0.5/go.mod h1:XuOwViwdL+dyz7fGYIjaByS1ElMFsrVI0goKX0bNimA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -190,7 +190,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
22 changes: 11 additions & 11 deletions integrity/main.go → inclusion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package main

import (
"fmt"
"strings"

"github.com/datatrails/go-datatrails-common/azblob"
"github.com/datatrails/go-datatrails-logverification/logverification"
)

/**
* Tests the integrity of a datatrails event.
* Tests the inclusion of a datatrails event.
*
* This is achieved by creating an inclusion proof of the event,
* then verifying the inclusion proof.
Expand Down Expand Up @@ -84,28 +83,29 @@ const (
url = "https://app.datatrails.ai/verifiabledata"
)

// IntegrityDemo of a public datatrails event
func IntegrityDemo(eventJson []byte) (verified bool, err error) {

// first we need to strip the 'public' prefix from all identity and assetIdentity fields
// as the hashing schema does not support public prefixing
eventNoPublicPrefix := strings.ReplaceAll(event, "publicassets/", "assets/")
// InclusionDemo of a public datatrails event
func InclusionDemo(eventJson []byte) (verified bool, err error) {

// then create the merklelog reader
reader, err := azblob.NewReaderNoAuth(url, azblob.WithContainer(container))
if err != nil {
return false, err
}

verifiableEvent, err := logverification.NewVerifiableEvent(eventJson)
if err != nil {
return false, err
}

// now verify the public event is in the merklelog
return logverification.VerifyEvent(reader, []byte(eventNoPublicPrefix), logverification.WithMassifTenantId(publicTenantID))
return logverification.VerifyEvent(reader, *verifiableEvent, logverification.WithMassifTenantId(publicTenantID))

}

// Demo of the integrity of a public datatrails event
// Demo of the inclusion of a public datatrails event
func main() {

verified, err := IntegrityDemo([]byte(event))
verified, err := InclusionDemo([]byte(event))
if err != nil {
fmt.Printf("\nerror: %v\n", err)
}
Expand Down
6 changes: 3 additions & 3 deletions integrity/main_test.go → inclusion/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/stretchr/testify/assert"
)

// TestIntegrityDemo tests the sample public event
// TestInclusionDemo tests the sample public event
//
// is included on the merklelog.
func TestIntegrityDemo(t *testing.T) {
func TestInclusionDemo(t *testing.T) {

verified, err := IntegrityDemo([]byte(event))
verified, err := InclusionDemo([]byte(event))

assert.Equal(t, nil, err)
assert.Equal(t, true, verified)
Expand Down
4 changes: 2 additions & 2 deletions taskfiles/Taskfile_demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ env_build: &env_build

tasks:

integrity:
inclusion:
desc: "run the intgrity demo"
dir: ../integrity
dir: ../inclusion
cmds:
- cmd: |
Expand Down
Loading