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

Use whole unsigned VC as VC proof signature payload #2404

Merged
merged 9 commits into from
Jan 19, 2024

Conversation

kziemianek
Copy link
Member

@kziemianek kziemianek commented Jan 14, 2024

  • Changes the input for VC proof signature calculation from enclave's mrenclave to VC json.
  • Removes all logic/calls from VCManagement related to VCRegistry.

After this change newly issued VC content can be verified just by verifying proof's signature, there would be no need to reach out to onchain's VCRegistry.

Copy link

linear bot commented Jan 14, 2024

@kziemianek kziemianek added the C0-breaking Breaking change that will cause existing client to break label Jan 14, 2024
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

Nice and clean, not much to complain, thanks!

About the registry - this PR removes it completely. I'm thinking in the future, we might want to add "publish vc" feature where the user can link the selected VCs to their DID to make them public, so that anyone can see them by tracking down the DID. For that we'll need (again) a registry 🤔

Comment on lines +282 to +283
const lastRegisteredEnclave = (await apiAtVcIssuedBlock.query.teerex.enclaveRegistry(enclaveCount))
.value as TeerexPrimitivesEnclave;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think checking scheduledEnclave should be more accurate - enclave registration needs to comply with it too. Right now I can't think of any case where scheduledEnclave and enclaveRegistry don't match though

Btw even if we want to check enclaveRegistry we should enclaveCount from the parachainBlockHash height

Copy link
Member Author

Choose a reason for hiding this comment

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

But Teerex's ScheduledEnclave is empty so there is no value to compare against :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah in dev it's not populated, but in production it shouldn't be empty

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

@kziemianek kziemianek Jan 15, 2024

Choose a reason for hiding this comment

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

Maybe we can always populate it with worker's mrenclave for first validateer in dev see: #2382 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

@Kailai-Wang, @felixfaisal what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

fyi: the vc-sdk uses scheduledEnclave's value

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Kailai-Wang @kziemianek I think we can always populate it for first validateer.

@kziemianek
Copy link
Member Author

Nice and clean, not much to complain, thanks!

About the registry - this PR removes it completely. I'm thinking in the future, we might want to add "publish vc" feature where the user can link the selected VCs to their DID to make them public, so that anyone can see them by tracking down the DID. For that we'll need (again) a registry 🤔

VCRegistry remains untouched - previously generated VCs can still be validated using it. It just can't be altered anymore because logic/calls are gone. I'm still waiting for decision on what we are going to do with old VCs.

@kziemianek kziemianek requested a review from a team January 15, 2024 12:00
Copy link
Contributor

@jonalvarezz jonalvarezz left a comment

Choose a reason for hiding this comment

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

lgtm

const enclaveCount = await context.api.query.teerex.enclaveCount();
// prepare teerex enclave registry data for further checks
const parachainBlockHash = await context.api.query.system.blockHash(vcPayloadJson.parachainBlockNumber);
const apiAtVcIssuedBlock = await context.api.at(parachainBlockHash);
Copy link
Contributor

Choose a reason for hiding this comment

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

parachainBlockNumber is the block used to calculate the VC, and it won't match the VC's Issuance block. Is it likely that the registered enclave changes between those two instances? better said, should we account for such a case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the time of VC's issuance is not important here - it doesn't matter what happens next after VC was generated as long as the VC was generated by legit enclave, but I would love to hear other opinions too.

@Kailai-Wang
Copy link
Collaborator

Nice and clean, not much to complain, thanks!
About the registry - this PR removes it completely. I'm thinking in the future, we might want to add "publish vc" feature where the user can link the selected VCs to their DID to make them public, so that anyone can see them by tracking down the DID. For that we'll need (again) a registry 🤔

VCRegistry remains untouched - previously generated VCs can still be validated using it. It just can't be altered anymore because logic/calls are gone. I'm still waiting for decision on what we are going to do with old VCs.

Yea I'm not talking about old VCs, but rather in the future - but OK we can always add it back whenever needed.

@kziemianek
Copy link
Member Author

I will delete VCRegistry storage from VCManagement pallet.

@kziemianek
Copy link
Member Author

Requested review again as there are new changes.

Copy link
Contributor

@jonalvarezz jonalvarezz left a comment

Choose a reason for hiding this comment

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

set it on fire 🔥

pallets/vc-management/src/schema.rs Show resolved Hide resolved
@kziemianek
Copy link
Member Author

I'll update weights and merge it.

Co-authored-by: kziemianek <kziemianek@users.noreply.github.com>
@kziemianek kziemianek enabled auto-merge (squash) January 19, 2024 11:32
kziemianek and others added 2 commits January 19, 2024 13:01
Co-authored-by: kziemianek <kziemianek@users.noreply.github.com>
@kziemianek kziemianek merged commit d0759fb into dev Jan 19, 2024
31 checks passed
@kziemianek kziemianek deleted the p-350-use-embedded-proof-for-vc-validation branch January 22, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C0-breaking Breaking change that will cause existing client to break
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants