add did web in README

This commit is contained in:
Cayo Puigdefabregas 2024-05-30 11:12:04 +02:00
parent 1c14e11d73
commit 8eb0b70f0a
2 changed files with 67 additions and 3 deletions

View File

@ -20,7 +20,7 @@ For now the installation is from the repository:
pip install -e . pip install -e .
``` ```
#Cli # Cli
The mode of use under the command line would be the following: The mode of use under the command line would be the following:
## generate a key pair: ## generate a key pair:
@ -29,10 +29,17 @@ The mode of use under the command line would be the following:
``` ```
## generate a did identifier: ## generate a did identifier:
### did key
```sh ```sh
python did.py -n did -k keypair.json python did.py -n did -k keypair.json
``` ```
### did web
```sh
python did.py -n did -k keypair.json -u https://localhost/user1/dids/
```
## generate an example signed credential: ## generate an example signed credential:
An example of a credential is generated, which is the one that appears in the credential_tmpl template in the file [templates.py](templates.py) An example of a credential is generated, which is the one that appears in the credential_tmpl template in the file [templates.py](templates.py)
```sh ```sh
@ -54,7 +61,7 @@ An example of a credential is generated, which is the one that appears in the cr
python verify_vp.py presentation_signed.json python verify_vp.py presentation_signed.json
``` ```
# Use as a lib # Use as a library
In the tests you can find examples of use. Now I will explain the usual cases In the tests you can find examples of use. Now I will explain the usual cases
## generate a key pair: ## generate a key pair:
@ -64,12 +71,22 @@ In the tests you can find examples of use. Now I will explain the usual cases
``` ```
## generate a did identifier: ## generate a did identifier:
### did key
```python ```python
from pyvckit.did import generate_keys, generate_did from pyvckit.did import generate_keys, generate_did
key = generate_keys() key = generate_keys()
did = generate_did(key) did = generate_did(key)
``` ```
### did web
```python
from pyvckit.did import generate_keys, generate_did
key = generate_keys()
url = "https://localhost/user1/dids/"
did = generate_did(key, url)
```
## generate a signed credential: ## generate a signed credential:
Assuming **credential** is a valid credential. Assuming **credential** is a valid credential.
**credential** is a string variable **credential** is a string variable
@ -108,3 +125,15 @@ Assuming **vc** is a properly signed verifiable credential
from pyvckit.verify_vp import verify_vp from pyvckit.verify_vp import verify_vp
verified = verify_vp(json.dumps(vp)) verified = verify_vp(json.dumps(vp))
``` ```
## creation of did document:
This command will create a json document and a url path where to place this document. The did must be a web did.
This document is an example and in production it must be adapted to contain the revoked verifiable credentials.
```python
from pyvckit.did import generate_keys, generate_did, gen_did_document
key = generate_keys()
url = "https://localhost/did-registry"
did = generate_did(key, url)
definitive_url, document = gen_did_document(did, key)
```

View File

@ -29,10 +29,17 @@ El modo de uso bajo la linea de comandos seria el siguiente:
``` ```
## generar un identificador did: ## generar un identificador did:
### did key
```sh ```sh
python did.py -n did -k keypair.json python did.py -n did -k keypair.json
``` ```
### did web
```sh
python did.py -n did -k keypair.json -u https://localhost/user1/dids/
```
## generar una credencial firmada de ejemplo: ## generar una credencial firmada de ejemplo:
Se genera un ejemplo de credencial que es el que aparece en la plantilla credential_tmpl del fichero [templates.py](templates.py) Se genera un ejemplo de credencial que es el que aparece en la plantilla credential_tmpl del fichero [templates.py](templates.py)
```sh ```sh
@ -54,6 +61,12 @@ Se genera un ejemplo de credencial que es el que aparece en la plantilla credent
python verify_vp.py presentation_signed.json python verify_vp.py presentation_signed.json
``` ```
## creación del documento did:
Este comando creara un documento json y una ruta url donde colocar este documento. El did tiene que ser un did web.
```sh
python did.py -k keypair.json -g did:web:localhost:did-registry:z6MkiNc8xqJLcG7QR1wzD9HPs5oPQEaWNcVf92QsbppNiB7C
```
# Uso como librería # Uso como librería
En los test podras encontrar ejemplos de uso. Ahora explicare los casos habituales En los test podras encontrar ejemplos de uso. Ahora explicare los casos habituales
@ -64,12 +77,22 @@ En los test podras encontrar ejemplos de uso. Ahora explicare los casos habitual
``` ```
## generar un identificador did: ## generar un identificador did:
### did key
```python ```python
from pyvckit.did import generate_keys, generate_did from pyvckit.did import generate_keys, generate_did
key = generate_keys() key = generate_keys()
did = generate_did(key) did = generate_did(key)
``` ```
### did web
```python
from pyvckit.did import generate_keys, generate_did
key = generate_keys()
url = "https://localhost/user1/dids/"
did = generate_did(key, url)
```
## generar una credencial firmada: ## generar una credencial firmada:
Suponiendo que **credential** es una credencial válida. Suponiendo que **credential** es una credencial válida.
**credential** es una variable de tipo string **credential** es una variable de tipo string
@ -108,3 +131,15 @@ Suponiendo que **vc** es una credencial verificable correctamente firmada
from pyvckit.verify_vp import verify_vp from pyvckit.verify_vp import verify_vp
verified = verify_vp(json.dumps(vp)) verified = verify_vp(json.dumps(vp))
``` ```
## creación del documento did:
Este comando creara un documento json y una ruta url donde colocar este documento. El did tiene que ser un did web.
Este documento es un ejemplo y en producción hay que adaptarlo para contener las credenciales verificables revocadas.
```python
from pyvckit.did import generate_keys, generate_did, gen_did_document
key = generate_keys()
url = "https://localhost/did-registry"
did = generate_did(key, url)
definitive_url, document = gen_did_document(did, key)
```