Verifiable Credential Data Model [WIP]
This crates implements w3's Verifiable Credential Data Model
specifications.
This means it will create, read, update and delete (a.k.a. CRUD) all properties of a
Verifiable Credential
and a Verifiable Presentation
. As well as interacting with other
Verifiable Credential
and Verifiable Presentation
.
A
Verifiable Credential
or aVerifiable Presentation
can represent all of the same information that a physical credential represents. The addition of technologies, such as digital signatures, makes verifiable credentials more tamper-evident and more trustworthy than their physical counterparts. In the physical world, a credential might consist of:
- Information related to identifying the subject of the credential (for example, a photo, name, or identification number)
- Information related to the issuing authority (for example, a city government, national agency, or certification body)
- Information related to the type of credential this is (for example, a Dutch passport, an American driving license, or a health insurance card)
- Information related to specific attributes or properties being asserted by the issuing authority about the subject (for example, nationality, the classes of vehicle entitled to drive, or date of birth)
- Evidence related to how the credential was derived
- Information related to constraints on the credential (for example, expiration date, or terms of use).
We want to help developers create these scenarios and making it easy to interact with other following the same specifications.
Prerequisites
-
Clang >= 8.0 clear_on_drop library needs Clang >= 8.0, otherwise clang won't recognize the wasm32-unknown-unknown triple defined by this architecture.
- Install clang 8.0 in Ubuntu/Debian:
Configure update-alternatives to work aside with multiple clang versions (Sets Clang 8 as default version):
Installation
Rust
Add gitlab repository to Cargo.toml
:
Javascript
Now the library is installed for javascript. In order to be able to use a wasm library in javascript follow the following steps:
- Create in root a file called
config-overrides.js
with the following code in it:
const path = require;
module.exports = ;
- Install
wasm-loader
yarn add wasm-loader
- Load wasm library in component. Add this code:
let vcdm ;
try catch
let claim = ;
console.log;
Getting started with JavaScript
// Constructing a Claim
let claim =
.
.
.
.
.
.;
console.log;
// Contructing a Verifiable Credential
let vc =
// Setters overwrite values of property
.
.
// Setting another credential totally different and defined by user
.
// Adders push values to the vector properties
.
.;
console.log;
// Contructing a Verifiable Presentation
let vp =
.
.
// Add the created Verifiable Credential
.
.;
console.log;
or equivalently...
let vp_json = ;
let vp = vcdm.;
console.log;
Signing (Javascript)
Linked Data (Javascript)
// Signature from claim
let claim =
.
.
.
.
.
.;
const keys = ;
const signature = claim.
console.log
// Proof from claim (signature is created automatically)
const proof = vcdm.
// Verify signature from proof & claim
console.log
// Verify signature from claim
console.log
Zenroom (Javascript)
Not implemented
Getting started with Rust
let vc_json_str = r#"{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"type": ["VerifiableCredential"],
"id": "",
"issuer": "",
"claims": [{
"id": "",
"credentialStatus": {
"id": "",
"type": ""
},
"credentialSubject": [],
"issuer": "",
"issuanceDate": "",
"type": ["VerifiableCredential"]
}],
"proof": [{
"type": "",
"created": "",
"verificationMethod": "",
"signatureValue": ""
}],
"nonRevocationProof": [{
"type": "",
"created": "",
"verificationMethod": "",
"signatureValue": ""
}]
}"#;
let _ver_cred_from_json: VerifiableCredential = from_str.unwrap;
Equivalent to:
let mut ver_cred_vcdm =
new;
ver_cred_vcdm.set_proof;
ver_cred_vcdm.set_credential_subject;
ver_cred_vcdm.set_issuance_date;
ver_cred_vcdm.set_issuer;
ver_cred_vcdm.set_credential_status;
Signing (Rust)
There are two types of signing claims, with Linked Data or using Zenroom.
Linked Data (Rust)
// Signature from claim
ley keys = vec!;
// Creating Claim
let c: Claim = from_str.unwrap;
// Proof from claim (signature is created automatically)
let p: Proof = from_claim_and_keys;
// Verify signature from proof & claim
assert_eq!;
// Verify signature from claim
println!
Zenroom (Rust)
Not implemented
Roadmap
- [ X ] Basic CRUD implementation on properties.
- [ X ] Basic CRUD implementation on Optional properties.
- [ X ] Verifying basic cryptographic proofs.
- Implementation of Zero-Knowledge proof using Zenroom.
- Connecting to
Verifiable Data Registry
. - Validation for necessary properties.
- Implementation of Roles (
Issuer
,Holder
,Verifier
).
Contributing
Please, contribute to vcdm
! The more the better! Feel free to to open an issue and/or contacting directly with the owner for any request or suggestion.
Acknowledgment
This library is created to satisfy w3's specifications.
Code of conduct
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4
License
This project is distributed under the terms of both the Apache License (Version 2.0) and the MIT license, specified in LICENSE-APACHE and LICENSE-MIT respectively.