-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh | ||
set -e | ||
cd "$(dirname "$0")" | ||
|
||
# Create and use temp directory if does not already exist | ||
dir=did-ion-test | ||
if test -d "$dir" | ||
then | ||
printf 'Directory already exists: %s\n' "$dir" >&2 | ||
exit 1 | ||
fi | ||
mkdir "$dir" | ||
cd "$dir" | ||
|
||
# Generate initial update keypair and initial recovery keypair | ||
didkit generate-secp256k1-key > 1-u.jwk | ||
didkit generate-secp256k1-key > 1-r.jwk | ||
# Construct Create operation with initial public keys | ||
didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json | ||
# Get long-form and short-form DID from Create operation | ||
longdid=$(didkit did-from-tx < 1-create.json) | ||
shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') | ||
didsuffix=$(echo -n "$shortdid" | sed 's/.*://') | ||
echo "Sidetree DID Suffix: $didsuffix" | ||
echo "DID (long-form/unpublished): $longdid" | ||
echo "DID (short-form/canonical): $shortdid" | ||
|
||
# Now that the DID suffix is set, rename the directory to it. | ||
cd .. | ||
mv "$dir" "$didsuffix" | ||
cd "$didsuffix" | ||
|
||
# Submit Create operation | ||
export DID_ION_API_URL=http://localhost:3000/ | ||
read -p "Press enter to submit Create operation. " _ | ||
didkit did-submit-tx < 1-create.json | ||
|
||
# Construct Deactivate operation to add verification key to DID document | ||
didkit did-deactivate "$shortdid" -k 1-r.jwk | tee 2-deactivate.json | ||
# Submit operation | ||
read -p 'Press enter to submit Deactivate operation. ' _ | ||
if ! didkit did-submit-tx < 2-deactivate.json | ||
then | ||
# Provide retry in case submission failed, e.g. because the | ||
# create operation has not yet been processed. | ||
read -p 'Press enter to retry Deactivate operation. ' _ | ||
didkit did-submit-tx < 2-deactivate.json | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
set -e | ||
cd "$(dirname "$0")" | ||
|
||
# Create and use temp directory if does not already exist | ||
dir=did-ion-test | ||
if test -d "$dir" | ||
then | ||
printf 'Directory already exists: %s\n' "$dir" >&2 | ||
exit 1 | ||
fi | ||
mkdir "$dir" | ||
cd "$dir" | ||
|
||
# Generate initial update keypair and initial recovery keypair | ||
didkit generate-secp256k1-key > 1-u.jwk | ||
didkit generate-secp256k1-key > 1-r.jwk | ||
# Construct Create operation with initial public keys | ||
didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json | ||
# Get long-form and short-form DID from Create operation | ||
longdid=$(didkit did-from-tx < 1-create.json) | ||
shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') | ||
didsuffix=$(echo -n "$shortdid" | sed 's/.*://') | ||
echo "Sidetree DID Suffix: $didsuffix" | ||
echo "DID (long-form/unpublished): $longdid" | ||
echo "DID (short-form/canonical): $shortdid" | ||
|
||
# Now that the DID suffix is set, rename the directory to it. | ||
cd .. | ||
mv "$dir" "$didsuffix" | ||
cd "$didsuffix" | ||
|
||
# Submit Create operation | ||
export DID_ION_API_URL=http://localhost:3000/ | ||
read -p "Press enter to submit Create operation. " _ | ||
didkit did-submit-tx < 1-create.json | ||
|
||
# Generate new update keypair and recovery keypair for recover operation | ||
didkit generate-secp256k1-key > 2-u.jwk | ||
didkit generate-secp256k1-key > 2-r.jwk | ||
|
||
# Construct Recover operation | ||
didkit did-recover "$shortdid" -R 1-r.jwk -r 2-r.jwk -u 2-u.jwk | tee 2-recover.json | ||
# Submit operation | ||
read -p 'Press enter to submit Recover operation. ' _ | ||
if ! didkit did-submit-tx < 2-recover.json | ||
then | ||
# Provide retry in case submission failed, e.g. because the | ||
# create operation has not yet been processed. | ||
read -p 'Press enter to retry Recover operation. ' _ | ||
didkit did-submit-tx < 2-recover.json | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh | ||
set -e | ||
cd "$(dirname "$0")" | ||
export DID_ION_API_URL=http://localhost:3000/ | ||
|
||
if false; then | ||
|
||
# Create and use temp directory if does not already exist | ||
dir=did-ion-test | ||
if test -d "$dir" | ||
then | ||
printf 'Directory already exists: %s\n' "$dir" >&2 | ||
exit 1 | ||
fi | ||
mkdir "$dir" | ||
cd "$dir" | ||
|
||
# Generate initial update keypair and initial recovery keypair | ||
didkit generate-secp256k1-key > 1-u.jwk | ||
didkit generate-secp256k1-key > 1-r.jwk | ||
# Construct Create operation with initial public keys | ||
didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json | ||
# Get long-form and short-form DID from Create operation | ||
longdid=$(didkit did-from-tx < 1-create.json) | ||
shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') | ||
didsuffix=$(echo -n "$shortdid" | sed 's/.*://') | ||
echo "Sidetree DID Suffix: $didsuffix" | ||
echo "DID (long-form/unpublished): $longdid" | ||
echo "DID (short-form/canonical): $shortdid" | ||
|
||
# Now that the DID suffix is set, rename the directory to it. | ||
cd .. | ||
mv "$dir" "$didsuffix" | ||
cd "$didsuffix" | ||
|
||
|
||
# Submit Create operation | ||
read -p "Press enter to submit Create operation. " _ | ||
didkit did-submit-tx < 1-create.json | ||
|
||
else | ||
|
||
cd EiD9XruTmYlnZNAqYMjKDSosqnHkAHuw8GeR8nIGpr7nCg | ||
shortdid=did:ion:test:EiD9XruTmYlnZNAqYMjKDSosqnHkAHuw8GeR8nIGpr7nCg | ||
|
||
fi | ||
|
||
# Construct DID URL for new service endpoint | ||
svc="$shortdid#svc-1" | ||
|
||
# Construct Update operation to add verification key to DID document | ||
didkit did-update -U 1-u.jwk -u 2-u.jwk \ | ||
set-service "$svc" \ | ||
-t DIDKitDemoService \ | ||
-e https://demo.didkit.dev/ \ | ||
| tee 2-update.json | ||
# Submit Update operation | ||
read -p 'Press enter to submit Update operation. ' _ | ||
if ! didkit did-submit-tx < 2-update.json | ||
then | ||
read -p 'Press enter to retry submit operation. ' _ | ||
didkit did-submit-tx < 2-update.json | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
set -e | ||
cd "$(dirname "$0")" | ||
|
||
# Create and use temp directory if does not already exist | ||
dir=did-ion-test | ||
if test -d "$dir" | ||
then | ||
printf 'Directory already exists: %s\n' "$dir" >&2 | ||
exit 1 | ||
fi | ||
mkdir "$dir" | ||
cd "$dir" | ||
|
||
# Generate initial update keypair and initial recovery keypair | ||
didkit generate-secp256k1-key > 1-u.jwk | ||
didkit generate-secp256k1-key > 1-r.jwk | ||
# Construct Create operation with initial public keys | ||
didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json | ||
# Get long-form and short-form DID from Create operation | ||
longdid=$(didkit did-from-tx < 1-create.json) | ||
shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') | ||
didsuffix=$(echo -n "$shortdid" | sed 's/.*://') | ||
echo "Sidetree DID Suffix: $didsuffix" | ||
echo "DID (long-form/unpublished): $longdid" | ||
echo "DID (short-form/canonical): $shortdid" | ||
|
||
# Now that the DID suffix is set, rename the directory to it. | ||
cd .. | ||
mv "$dir" "$didsuffix" | ||
cd "$didsuffix" | ||
|
||
# Submit Create operation | ||
export DID_ION_API_URL=http://localhost:3000/ | ||
read -p "Press enter to submit Create operation. " _ | ||
didkit did-submit-tx < 1-create.json | ||
|
||
# Generate verification key to be added to DID document | ||
didkit generate-secp256k1-key > 2-v.jwk | ||
# Construct DID URL for new verification method | ||
vm="$shortdid#key-1" | ||
|
||
# Generate new update key keypair | ||
didkit generate-secp256k1-key > 2-u.jwk | ||
# Construct Update operation to add verification key to DID document | ||
didkit did-update -U 1-u.jwk -u 2-u.jwk \ | ||
set-verification-method "$vm" -k 2-v.jwk \ | ||
--authentication --assertionMethod -t JsonWebKey2020 \ | ||
| tee 2-update.json | ||
# Submit Update operation | ||
read -p 'Press enter to submit Update operation. ' _ | ||
if ! didkit did-submit-tx < 2-update.json | ||
then | ||
read -p 'Press enter to retry submit operation. ' _ | ||
didkit did-submit-tx < 2-update.json | ||
fi | ||
|