Skip to content

Commit

Permalink
Dev/jgough/9491 consistency demo (#10)
Browse files Browse the repository at this point in the history
* Consistency demo

re: AB#9491

---------

Signed-off-by: Joe Gough <[email protected]>
Co-authored-by: jgough <[email protected]>
Co-authored-by: robinbryce <[email protected]>
  • Loading branch information
3 people authored Jun 12, 2024
1 parent 3e6e5b8 commit 988bb6f
Show file tree
Hide file tree
Showing 10 changed files with 530 additions and 6 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,35 @@ If you want to run the demo directly with golang from the root of the repo:
```
cd completeness
go run .
```

## Consistency Demo

The consistency demo will verify a future log state continues to be consistently recorded based on
an existing signed log state.

### Docker Demo
To run the consistency demo with docker:

```
docker run -v ./consistency:/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.

### Task Demo

To run the demo with a task (https://taskfile.dev/installation/) rune:

```
task demos:consistency
```

### Go Demo

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

```
cd consistency
go run .
```
50 changes: 50 additions & 0 deletions consistency/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

const (
publicTenantID = "tenant/6ea5cd00-c711-3649-6914-7b125928bbb4"

container = "merklelogs"
url = "https://app.datatrails.ai/verifiabledata"

// newStateMMRIndex is the new state of the log at the time of the demo
//
// it is based off of this public event:
// https://app.datatrails.ai/archivist/publicassets/fe022486-3272-4d44-aab5-765a37c17b85/events/3e7a16dd-01d6-44f5-870d-abb9c56d154b
newStateMMRIndex = uint64(830)
)

var (

// sampleSignedStateCbor is the sample signed state for the massif that contains the
// event for the breast cancer diagnosing AI model sample
// found here: https://app.datatrails.ai/archivist/publicassets/3ea5aca3-da02-4bae-b6d0-85a5ab586ed6/events/9a192afe-9253-44d7-8585-c48f237f2134
sampleSignedStateCbor = []byte{
210, 132, 89, 1, 67, 162, 1, 56, 34, 13, 163, 1, 120, 48, 104, 116,
116, 112, 115, 58, 47, 47, 106, 105, 116, 97, 118, 105, 100, 56, 53, 51,
99, 99, 57, 53, 50, 49, 53, 97, 57, 97, 56, 48, 56, 46, 118, 97, 117, 108,
116, 46, 97, 122, 117, 114, 101, 46, 110, 101, 116, 47, 2, 120, 82, 118,
49, 47, 109, 109, 114, 115, 47, 116, 101, 110, 97, 110, 116, 47, 54, 101,
97, 53, 99, 100, 48, 48, 45, 99, 55, 49, 49, 45, 51, 54, 52, 57, 45, 54,
57, 49, 52, 45, 55, 98, 49, 50, 53, 57, 50, 56, 98, 98, 98, 52, 47, 48, 47,
109, 97, 115, 115, 105, 102, 115, 47, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
48, 48, 48, 48, 48, 48, 46, 108, 111, 103, 8, 161, 1, 166, 1, 98, 69, 67, 2,
120, 58, 101, 102, 57, 57, 48, 98, 58, 109, 101, 114, 107, 108, 101, 45, 108,
111, 103, 45, 115, 105, 103, 110, 105, 110, 103, 47, 49, 52, 51, 52, 54, 97,
97, 102, 101, 52, 102, 48, 52, 102, 97, 51, 98, 51, 99, 57, 51, 56, 56, 49,
48, 50, 102, 52, 48, 50, 99, 98, 3, 56, 34, 32, 101, 80, 45, 51, 56, 52, 33,
88, 48, 3, 206, 181, 90, 34, 69, 187, 3, 171, 186, 248, 2, 30, 106, 6, 8, 74,
13, 203, 138, 241, 65, 79, 147, 49, 93, 19, 32, 129, 68, 243, 139, 0, 231, 93,
58, 188, 167, 171, 148, 165, 71, 137, 129, 4, 211, 140, 33, 34, 88, 48, 156, 60,
32, 38, 135, 51, 32, 3, 46, 176, 144, 50, 155, 185, 116, 255, 133, 140, 122, 213,
106, 149, 209, 172, 103, 229, 131, 151, 3, 160, 76, 26, 243, 224, 33, 64, 141, 0, 1,
123, 147, 250, 119, 54, 176, 75, 96, 114, 160, 88, 62, 165, 1, 25, 3, 92, 2, 88, 32,
37, 72, 213, 167, 56, 138, 249, 32, 187, 223, 154, 122, 229, 202, 109, 160, 132, 148,
13, 42, 206, 145, 135, 106, 109, 117, 211, 33, 251, 41, 36, 162, 3, 27, 0, 0, 1, 143,
227, 150, 231, 31, 4, 27, 143, 227, 150, 230, 163, 7, 176, 0, 6, 1, 88, 96, 109, 100,
152, 178, 43, 207, 99, 125, 131, 192, 248, 96, 17, 205, 170, 81, 174, 155, 146, 76,
179, 16, 221, 220, 156, 133, 21, 158, 166, 142, 218, 186, 96, 65, 12, 35, 35, 30, 31,
90, 10, 176, 86, 254, 133, 200, 196, 33, 173, 13, 41, 22, 20, 251, 253, 139, 173, 215,
220, 241, 176, 174, 67, 222, 140, 24, 180, 94, 192, 144, 96, 54, 10, 153, 102, 240, 203,
121, 204, 198, 53, 212, 113, 194, 179, 190, 23, 196, 201, 228, 77, 25, 81, 217, 21, 124,
}
)
44 changes: 44 additions & 0 deletions consistency/existinglogstate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"github.com/datatrails/go-datatrails-common/cose"
"github.com/datatrails/go-datatrails-logverification/logverification"
"github.com/datatrails/go-datatrails-merklelog/massifs"
)

/**
* Existing log state is an existing log state based on the breast cancer diagnosing AI model sample
* found here: https://app.datatrails.ai/archivist/publicassets/3ea5aca3-da02-4bae-b6d0-85a5ab586ed6/events/9a192afe-9253-44d7-8585-c48f237f2134
*
* The existing log state will take the root of the massif the event is found in, in this case the mmrIndex of 511 of the public tenant.
*/

// ExistingSignedState gets the existing signed state for the log at the massif where
//
// the event for the breast cancer diagnosing AI model sample is found.
// The event can be found here: https://app.datatrails.ai/archivist/publicassets/3ea5aca3-da02-4bae-b6d0-85a5ab586ed6/events/9a192afe-9253-44d7-8585-c48f237f2134
//
// Then verifies the existing signed state signature against using the known veriication key.
func ExistingSignedState() (*massifs.MMRState, error) {
signedState, err := cose.NewCoseSign1MessageFromCBOR(sampleSignedStateCbor)
if err != nil {
return nil, err
}

verificationKey, err := VerificationKeyFromFile()
if err != nil {
return nil, err
}

err = signedState.VerifyWithPublicKey(verificationKey, nil)
if err != nil {
return nil, err
}

codec, err := massifs.NewRootSignerCodec()
if err != nil {
return nil, err
}

return logverification.LogState(signedState, codec)
}
53 changes: 53 additions & 0 deletions consistency/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,60 @@ go 1.22
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-merklelog/massifs v0.0.10
)

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
github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.7.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1 // indirect
github.com/Azure/go-amqp v1.0.5 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.24 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.5.13 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
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/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/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
github.com/fxamacker/cbor/v2 v2.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/ldclabs/cose/go v0.0.0-20221214142927-d22c1cfc2154 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openzipkin-contrib/zipkin-go-opentracing v0.5.0 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/veraison/go-cose v1.1.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/bencode v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 988bb6f

Please sign in to comment.