-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: store verifiable credentials in cord blockchain #152
base: main
Are you sure you want to change the base?
Conversation
await cord.init({ address: CORD_CHAIN_ADDRESS }) | ||
|
||
// Retrieve the identities used to create schemas and credentials. | ||
// TODO: `Alice` works, but a newly created account doesn't. Why? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few developer accounts are funded by default. If you are creating a new account, transfer some credits from one of the developer accounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did do that, and it threw an 'insufficient funds to pay transaction fees' error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are building a tool to request for funds through a portal. Once we host it, will share more details, for now, just msg the account ID which need some tokens in CORD discord.
*/ | ||
export const createCredential = async (certificate, holderId) => { | ||
// Get the identity of the holder. | ||
// TODO: Make this `holderId`, but that would need all the holders to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all identity data stays off-chain by default. Chain only captures the SS58encoded public address as part of the extrinsic. The chain has a module to register an identity and verify it. This functionality is mostly used for issuer identities
* | ||
* @returns {Promise<stream>} - The saved stream on the chain. | ||
*/ | ||
export const createCredential = async (certificate, holderId) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates the intermediary credential format for storage and chain anchoring. Export to VC and ISO mDL(planned) are supported. Please take a look at the demo-vc code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the demo-vc code
Will do!
signingKeyPairType: 'sr25519', | ||
}) | ||
// Create the schema and register it once `createClient` is called. | ||
const schemaContent = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dummy schema for the demo. Ideally, the schema associated with the credential should be passed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess here, we use schemas defined as per the workflow, (like teachers.json and students.json) etc. The same should be passed for credential, so the content validation also happens based on the schema.
@gamemaker1 I see that you're storing the VCs in the cord chain in certificate-API. Whenever the user requests a visual certificate this API will be triggered. So the VC will be stored in the cord multiple times. |
@tejash-jl Thanks for pointing that out, I will move this code to the signer instead. |
As an example to use the CORD SDK methods through REST APIs, we have pushed a sample project , which can be tweaked as per the usecase. I went through the sunbird-core services a bit, and I agree that the best place to integrate with CORD would be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this efforts @gamemaker1. Been 6 month to this PR, had it in backlog to review, but somehow lost in queue.
Thanks to @ChakshuGautam for reminding me on this. This fits in the use case of what was discussed in Sunbird-RC/community#330 upto a large extent.
Is there a way to mark this feature as optional (or in beta) through config? That way, only if enabled people get to use it, instead of forcing it on them?
"scripts": { | ||
"start": "node main.js", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"@cord.network/sdk": "^0.7.5-0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest version where '@cord.network/vc-export' package is also working is "^0.7.9-1"
signingKeyPairType: 'sr25519', | ||
}) | ||
// Create the schema and register it once `createClient` is called. | ||
const schemaContent = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess here, we use schemas defined as per the workflow, (like teachers.json and students.json) etc. The same should be passed for credential, so the content validation also happens based on the schema.
}, | ||
"type": "object" | ||
} | ||
const spaceContent = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be technically dynamic, but for SunbirdRC usecase, can be static per deployment. If we don't put any dynamic part here, (something like instance id, or timestamp of creation), there may be issue of space identifier exists error from the chain. Hence if you look at the demo scripts, we added a 'uuid()' to the title to make it dynamic in every run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, same applies to Schema. There should be an element of difference between two schemas.
rejectOn: cord.Chain.IS_ERROR, | ||
}) | ||
|
||
return createdStream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to get VC from the stream can be checked from below code
https://github.com/dhiway/cord-agent-app-v1/blob/main/src/cord/stream.ts#L73...L79
Same gets verified similarly by below logic:
https://github.com/dhiway/cord-agent-app-v1/blob/main/src/controller/record.ts#L318...L335
await cord.init({ address: CORD_CHAIN_ADDRESS }) | ||
|
||
// Retrieve the identities used to create schemas and credentials. | ||
// TODO: `Alice` works, but a newly created account doesn't. Why? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are building a tool to request for funds through a portal. Once we host it, will share more details, for now, just msg the account ID which need some tokens in CORD discord.
As per the proposal to integrate Sunbird RC and CORD outlined here.