This shell script can be used to quickly generate a large volume of VCs for testing purposes. The generated VCs use the bare-minimum schema and contain essentially nothing aside from a unique UUID each, in the id field.
To generate these VC ids, they use the commonplace uuidgen command. For more realistic sample VCs, simply start with a credential definition from a real-world context, and populate values for all the fields, such as names and addresses, with command-line tools or spreadsheets of dummy data.
Batch Issuance Set Up
#!/bin/sh
# Exit if any command in this script fails.
set -e
if [ -e issuer_key.jwk ]; then
echo 'Using existing keypair.'
else
didkit generate-ed25519-key > issuer_key.jwk
echo 'Generated keypair.'
fi
issuer=$(didkit key-to-did-key -k issuer_key.jwk)
printf 'Issuer DID: %s\n' "$issuer"
issuer_vm=$(didkit key-to-verification-method -k issuer_key.jwk)
printf 'Issuer verification method: %s\n' "$issuer_vm"
In this script, a verification method is derived from a local key and manually passed with the -v parameter. This is not the default behavior of DIDKit's verification function, but it greatly accelerates the verification of a large batch of VCs being testing against the known key material and verification method of a known issuer.
Were one to remove the key.jwk check, the generation of a verification method, and the passing of that method to the verification function, a verification method would be extracted for each VC verified, from the DID Document of the issuer, which would be resolved each time as specified in the VC being verified. This is the default behavior of DIDKit.
#!/bin/sh
# Exit if any command in this script fails.
set -e
if [ ! -e issuer_key.jwk ]; then
echo 'Missing keypair.' >&2
exit 1
fi
issuer_vm=$(didkit key-to-verification-method -k issuer_key.jwk)
printf 'Issuer verification method: %s\n' "$issuer_vm"
Define Verification Ordered Function
verify_credential() {
if ! out=$(didkit vc-verify-credential \
-v "$issuer_vm" \
-p assertionMethod)
then
printf "verify failed: %s" "$out" >&2
return 1
fi
}
Run verification function on loop
Here we loop through the file created above, verifying the credential contained on each line.