This repository was archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Aleo docs #66
Merged
Merged
Aleo docs #66
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1a4f854
add basic aleo doc
fairingrey 484bda1
finish up aleo docs
fairingrey df0279a
Update docs/didkit-examples/core-functions-with-aleo.md
fairingrey 3611497
Update docs/didkit-examples/core-functions-with-aleo.md
fairingrey 56624dd
Update docs/didkit-examples/core-functions-with-aleo.md
fairingrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,126 @@ | ||
| --- | ||
| id: core-functions-with-aleo | ||
| title: Core Functions with Aleo | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
| DIDKit also supports the use of Aleo accounts as verifiable credentials. | ||
|
|
||
| This is an example shell script using all the core functions of DIDKit-CLI: key | ||
| generation, credential/presentation issuance and verification. | ||
|
|
||
| _Note 1: This script is meant to be in a DIDKit-CLI source directory. See the | ||
| complete script below for setup details._ | ||
|
|
||
| _Note 2: Currently Aleo support is only available through the | ||
| `feat/aleo-sig-pkh` branch of the ssi library. When building the DIDKit CLI the | ||
| feature `ssi/aleosig` must also be enabled._ | ||
|
|
||
| ### Start with a keypair | ||
|
|
||
| The SSI library can generate an Aleo keypair as an example: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/spruceid/ssi | ||
| cd ssi | ||
| git checkout feat/aleo-sig-pkh | ||
| cargo run --example genaleojwk --features=aleosig > aleokey.jwk | ||
| ``` | ||
|
|
||
| You can also provide the details of an existing Aleo account, although you will | ||
| need to do some extra work for DIDKit to use it. | ||
|
|
||
| The Aleo private JWK format used by DIDKit is non-standard. An example: | ||
|
|
||
| ```json | ||
| { | ||
| "kty": "OKP", | ||
| "crv": "AleoTestnet1Key", | ||
| "x": "78_Jh_c7Fw46fX31xS9Ifdg_LeuabZ2p2aIl5fn9zw0", | ||
| "d": "f4a9dNLd0omQcg3SEajVHGqEqwFHDGD9yNc2xpzuiZ3sSJjIf5AnEYXWCQ" | ||
| } | ||
| ``` | ||
|
|
||
| The format is as follows: | ||
|
|
||
| - kty: "OKP" | ||
| - crv: "AleoTestnet1Key" | ||
| - x: An Aleo account address derived from the private key using Aleo Testnet1 | ||
| parameters, as a Base64 value (without the "aleo" prefix that appears in its' | ||
| Base58 format) | ||
| - d: An Aleo private key converted from Base58 (where it starts with | ||
| "APrivateKey1") to Base64 value | ||
fairingrey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Generate a DID:Key document | ||
|
|
||
| This document gets wrapped around the keypair generated (or passed) in the | ||
| previous step. For more context on the DID:key method, see the | ||
| [specification](https://w3c-ccg.github.io/did-method-key/). | ||
|
|
||
| ```bash | ||
| key=aleokey.jwk | ||
| did=$(didkit key-to-did pkh:aleo -k $key) | ||
| ``` | ||
|
|
||
| ### Prepare credential for issuing. | ||
|
|
||
| Here, we'll issue an example credential (unsigned) and save it to a file. For | ||
| more info about what these properties mean, see the Verifiable Credentials Data | ||
| Model [specification](https://w3c.github.io/vc-data-model/). | ||
fairingrey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```bash | ||
| cat > credential-unsigned.jsonld <<EOF | ||
| { | ||
| "@context": ["https://www.w3.org/2018/credentials/v1"], | ||
| "type": ["VerifiableCredential"], | ||
| "issuer": "$did", | ||
| "issuanceDate": "$issued", | ||
| "credentialSubject": {} | ||
| } | ||
| EOF | ||
| ``` | ||
|
|
||
| ### Issue the verifiable credential. | ||
|
|
||
| - We ask DIDKit to issue a verifiable credential using the given keypair file, | ||
| passing the unsigned credential on standard input. | ||
|
|
||
| ```bash | ||
| didkit vc-issue-credential -k $key < credential-unsigned.jsonld \ | ||
| > credential-signed.jsonld | ||
| ``` | ||
|
|
||
| ### Verify a verifiable credential. | ||
|
|
||
| - We pass the newly-issued signed verifiable credential back to didkit for | ||
| verification. | ||
|
|
||
| ```bash | ||
| didkit vc-verify-credential < credential-signed.jsonld | ||
| ``` | ||
|
|
||
| ### Appendix: whole script without comments | ||
|
|
||
| ```bash | ||
| #!/bin/sh | ||
| set -ex | ||
| key=../ssi/tests/aleotestnet1-2021-11-22.json | ||
| did=$(didkit key-to-did pkh:aleo -k $key) | ||
| issued=$(date -uIsec) | ||
|
|
||
| cat > credential-unsigned.jsonld <<EOF | ||
| { | ||
| "@context": ["https://www.w3.org/2018/credentials/v1"], | ||
| "type": ["VerifiableCredential"], | ||
| "issuer": "$did", | ||
| "issuanceDate": "$issued", | ||
| "credentialSubject": {} | ||
| } | ||
| EOF | ||
|
|
||
| didkit vc-issue-credential -k $key < credential-unsigned.jsonld \ | ||
| > credential-signed.jsonld | ||
|
|
||
| didkit vc-verify-credential < credential-signed.jsonld | ||
| ``` | ||
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.