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

Update SCITT getting started headings #821

Merged
merged 3 commits into from Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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