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

refactor!: VCs in core #798

Merged
merged 10 commits into from
Oct 9, 2023
Merged

refactor!: VCs in core #798

merged 10 commits into from
Oct 9, 2023

Conversation

rflechtner
Copy link
Contributor

@rflechtner rflechtner commented Aug 23, 2023

fixes KILTProtocol/ticket#2827

Moves the VC type credentials into the core package and removes legacy credential support from it.
THIS DOES NOT YET IMPLEMENT A USER FRIENDLY ISSUANCE, PRESENTATION AND VERIFICATION API - THIS IS TBD!

To be done in a follow-up PR:

  • Add support for presentation signing and verification
  • Implement simple apis for credential verification, presentation, and issuance

How to test:

Play around with it?

Checklist:

  • I have verified that the code works
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)
    • Either PR or Ticket to update the Docs
    • Link the PR/Ticket here

* @param initialCTypes An array of CTypes with which the cache is to be initialized.
* @returns A function that takes a CType id and looks up a CType definition in an internal cache, and if not found, tries to fetch it from the KILT blochchain.
*/
export function newCachingCTypeLoader(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to CType features

/**
* Credential context URL required for Kilt credentials.
*/
export const CONTEXT_URL = 'https://www.kilt.io/contexts/credentials'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved constants to the files to which they relate most to make the relationships of the them clearer

export const spiritnetGenesisHash = hexToU8a(
'0x411f057b9107718c9624d6aa4a3f23c1653898297f3d4d529d9bb6511a39dd21'
)
export const KILT_ATTESTER_LEGITIMATION_V1_TYPE = 'KiltAttesterLegitimationV1'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wanted to expose them under the KiltCredentialV1 namespace but was afraid circular dependencies may break things, so they are defined here and exposed there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

signing is still TBD

Comment on lines +8 to +11
export * from './suites/index.js'
export * from './purposes/index.js'
export * from './documentLoader.js'
export { validationContexts as contexts } from './context/index.js'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this package only contains the jsonld-signatures support now. moved this a level up

console.info('Credential proof verified')

await KiltRevocationStatusV1.check(issued)
console.info('Credential status verified')
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

presentation also still missing

@rflechtner rflechtner requested a review from ntn-x2 August 23, 2023 21:58
Copy link
Member

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

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

I. Love. It. Very very nice. We just need to expose an easier way to verify a credential, and a way to sign presentations, and then we're golden.

packages/core/src/ctype/CTypeLoader.ts Show resolved Hide resolved
Base automatically changed from rf-legacy-credentials-package to vc-refactor October 4, 2023 12:45
@rflechtner rflechtner marked this pull request as ready for review October 5, 2023 11:42
@rflechtner
Copy link
Contributor Author

Note that test pass, just the coverage is too low at the moment - I would defer ramping up coverage to when we have the complete feature set implemented though.

@rflechtner rflechtner merged commit 1cf468f into vc-refactor Oct 9, 2023
@rflechtner rflechtner deleted the rf-vcs-in-core-2 branch October 9, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants