Skip to content

Commit

Permalink
Merge pull request #821 from datatrails/steve/scitt-updates
Browse files Browse the repository at this point in the history
Update SCITT getting started headings
  • Loading branch information
SteveLasker committed Apr 25, 2024
2 parents 632e65d + cefec17 commit 3494072
Showing 1 changed file with 40 additions and 30 deletions.
70 changes: 40 additions & 30 deletions content/developers/developer-patterns/scitt-api/index.md
Expand Up @@ -73,8 +73,8 @@ Clone the [DataTrails SCITT Examples](https://github.com/datatrails/datatrails-s
# File representing the signed statement to be registered
SIGNED_STATEMENT_FILE="signed-statement.cbor"

# Feed ID, used to correlate a collection of statements about an artifact
FEED="my-product-id"
# Subject is a property used to correlate a collection of statements about an artifact
SUBJECT="my-product-id"
```

## Create a Signing Key
Expand All @@ -89,39 +89,49 @@ For the Quickstart, create a testing [COSE Key](https://cose-wg.github.io/cose-s
openssl ecparam -name prime256v1 -genkey -out $SIGNING_KEY
```

## Generating a Payload
## Generate a Payload

1. Create a simple json payload
Create any payload you wish to register on DataTrails. JSON based payloads are indexed for query capabilities.

```bash
cat > payload.json <<EOF
{
"author": "fred",
"title": "my biography",
"reviews": "mixed"
}
EOF
```
{{< note >}}
The current version of the DataTrails SCITT API is limited to JSON payloads.
This will be relaxed in a future release
{{< /note >}}

1. Create a COSE Signed Statement for the `payload.json` file
```bash
cat > payload.json <<EOF
{
"author": "fred",
"title": "my biography",
"reviews": "mixed"
}
EOF
```

```bash
python scitt/create_signed_statement.py \
--signing-key-file $SIGNING_KEY \
--issuer $ISSUER \
--feed $FEED \
--content-type "application/json" \
--payload-file payload.json \
--output-file $SIGNED_STATEMENT_FILE
## Create a COSE Signed Statement

1. Register the Statement
Using the `payload.json` file, create a COSE Signed Statement

```bash
OPERATION_ID=$(curl -X POST -H @$HOME/.datatrails/bearer-token.txt \
--data-binary @$SIGNED_STATEMENT_FILE \
https://app.datatrails.ai/archivist/v1/publicscitt/entries \
| jq -r .operationID)
```
```bash
python scitt/create_signed_statement.py \
--signing-key-file $SIGNING_KEY \
--issuer $ISSUER \
--feed $SUBJECT \
--content-type "application/json" \
--payload-file payload.json \
--output-file $SIGNED_STATEMENT_FILE
```

## Register the SCITT Statement on DataTrails

Submit the Signed Statement to DataTrails, using the credentials in the `bearer-token.txt`

```bash
OPERATION_ID=$(curl -X POST -H @$HOME/.datatrails/bearer-token.txt \
--data-binary @$SIGNED_STATEMENT_FILE \
https://app.datatrails.ai/archivist/v1/publicscitt/entries \
| jq -r .operationID)
```

1. Monitor for the Statement to be anchored. Once `"status": "succeeded"`, proceed to the next step

Expand All @@ -147,7 +157,7 @@ By querying the series of statements, consumers can verify who did what and when

```bash
curl -H @$HOME/.datatrails/bearer-token.txt \
"https://app.datatrails.ai/archivist/v2/publicassets/-/events?event_attributes.feed_id=$FEED" | jq
https://app.datatrails.ai/archivist/v2/publicassets/-/events?event_attributes.feed_id=$SUBJECT | jq
```

{{< note >}}
Expand Down

0 comments on commit 3494072

Please sign in to comment.