Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gamemaker1
Copy link
Contributor

As per the proposal to integrate Sunbird RC and CORD outlined here.

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?

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.

Copy link
Contributor Author

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.

Copy link

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

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) => {

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

Copy link
Contributor Author

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 = {

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.

Copy link

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.

@tejash-jl
Copy link
Member

@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.
It's better to put this part of the certificate signer, so you store it in the cord once the VC is generated.
Maybe we can design it as a plugin which we can attach to SB-RC to be executed post generating the VC. So only those who need can enable this plugin.

@gamemaker1
Copy link
Contributor Author

@tejash-jl Thanks for pointing that out, I will move this code to the signer instead.

@amarts
Copy link

amarts commented Aug 23, 2022

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 certificate-signer. I will deploy and run some more tests with sunbird and we can checkout how we can integrate better.

Copy link

@amarts amarts left a 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",
Copy link

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 = {
Copy link

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 = {
Copy link

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.

Copy link

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants