Skip to content

Commit 05e2313

Browse files
authored
Merge pull request hyperledger-indy#917 from telus/py-tutorial3
Add how-tos Python tutorial hyperledger-indy#3
2 parents ff227b6 + 4bea0f5 commit 05e2313

File tree

9 files changed

+300
-297
lines changed

9 files changed

+300
-297
lines changed

doc/how-tos/save-schema-and-cred-def/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
This shows how to save a schema and credential definition on the ledger, which is
44
a prerequisite for ["Issue Credential"](../issue-credential/README.md).
55

6-
[ [Python](../not-yet-written.md) | [Java](java/README.md) | [.NET](../not-yet-written.md) | [Node.js](../not-yet-written.md) | [Objective C](../not-yet-written.md) ]
6+
[ [Python](python/README.md) | [Java](java/README.md) | [.NET](../not-yet-written.md) | [Node.js](../not-yet-written.md) | [Objective C](../not-yet-written.md) ]
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Save a Schema and Credential Definition
2+
3+
Indy-SDK Developer Walkthrough #4, Python Edition
4+
5+
[ [Java](../java/README.md) | [.NET](../../not-yet-written.md) | [Node.js](../../not-yet-written.md) | [Objective C](../../not-yet-written.md) ]
6+
7+
8+
## Prerequisites
9+
10+
Setup your workstation with an indy development virtual machine (VM). See [prerequisites](../../prerequisites.md).
11+
12+
Ensure you have the 64-bit version of Python 3 installed, as the 32-bit version may have problems loading the Indy .dll files.
13+
14+
## Steps
15+
16+
### Step 1
17+
18+
In your normal workstation operating system (not the VM), open a Python editor of your
19+
choice and paste the code from [template.py](template.py)
20+
into a new doc. We will be modifying this code in later steps.
21+
22+
Save the doc as `save_schema_and_cred_def.py`
23+
24+
This is a very simple app framework into which you'll plug the code you'll be writing.
25+
26+
Install the required python packages by executing: `$ pip install python3-indy asyncio`
27+
28+
### Step 2
29+
30+
We need to give the SDK some context that it will need
31+
to deal with an indy ledger. This requires us to point the SDK at some
32+
*genesis transactions* that tell the SDK how to contact the ledger on
33+
the network and how to trust that the nodes it contacts possess
34+
appropriate keys. We also need to create a wallet so the SDK can store
35+
DIDs and the key material we're going to use. Also, we need
36+
to create a trust anchor identity that has privileges to create schemas
37+
and credential definitions.
38+
39+
All of these steps are similar to those in simpler how-tos, such as
40+
["Write a DID and Query Its Verkey"](../../write-did-and-query-verkey/python/readme.md).
41+
We'll get this housekeeping out of
42+
the way in a single step here, rather than dwelling on its details.
43+
44+
Copy the contents of [step2.py](step2.py) into
45+
`save_schema_and_cred_def.py` on top of the `Step 2 code goes here` placeholder comment.
46+
47+
Save the updated version of `save_schema_and_cred_def.py`.
48+
49+
Study the changes. Scaffolding code like this is likely to appear in anything
50+
that uses indy.
51+
52+
### Step 3
53+
54+
Now we need to create and define a schema. Schemas in indy are very simple
55+
JSON documents that specify their name and version, and that list attributes
56+
that will appear in a credential. Today, they do not describe data type,
57+
recurrence rules, nesting, and other elaborate constructs. There is work
58+
underway to make them fancier; visit
59+
[#indy-sdk on Rocket.Chat](https://chat.hyperledger.org/channel/indy-sdk) to learn
60+
more.
61+
62+
A sample schema might look like this:
63+
64+
```json
65+
{
66+
"id": "1",
67+
"name": "gvt",
68+
"version": "1.0",
69+
"ver': "1.0",
70+
"attrNames": ["age", "sex", "height", "name"]
71+
}
72+
```
73+
74+
Copy the contents of [step3.py](step3.py) into
75+
`save_schema_and_cred_def.py` on top of the `Step 3 code goes here` placeholder comment.
76+
77+
Save the updated version of `save_schema_and_cred_def.py`.
78+
79+
Notice how this schema is submitted to the ledger by the steward
80+
identity we created previously.
81+
82+
### Step 4
83+
84+
Next, we create a *credential definition*. This references the schema
85+
that we just added, and announces who is going to be issuing credentials
86+
with that schema (our trust anchor identity, in this case), what type of
87+
signature method they plan to use ("CL" = "Camenisch Lysyanskya", the
88+
default method used for zero-knowledge proofs by indy), how they
89+
plan to handle revocation, and so forth.
90+
91+
Copy the contents of [step4.py](step4.py) into
92+
`save_schema_and_cred_def.py` on top of the `Step 4 code goes here` placeholder comment.
93+
94+
Save the updated version of `save_schema_and_cred_def.py``.
95+
96+
### Step 5
97+
98+
Run the [finished code](save_schema_and_cred_def.py) and observe the whole sequence.
99+
100+
## More experiments
101+
102+
You might try the ["Issue a Credential"](../../issue-credential/../not-yet-written.md)
103+
how-to, which can be done in only one step once you complete this one.

doc/how-tos/save-schema-and-cred-def/python/add_claim_def.py

Lines changed: 0 additions & 142 deletions
This file was deleted.

doc/how-tos/save-schema-and-cred-def/python/add_schema.py

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)