zuni-lab / zuni-application

Document: https://dvlab-document.vercel.app/docs/overview
https://wearedvlab.systems/
MIT License
2 stars 0 forks source link

Cryptography core #5

Closed galin-chung-nguyen closed 1 year ago

galin-chung-nguyen commented 1 year ago

Hi guys, this is my proposal about the cryptography core for the system. Please raise questions in case you need me to clarify something or give me some feedbacks to improve it! Thank you! @tranvinh146 @tranhuyducseven

1. Credential format

2.4 Verifier verifies submission

Step 1: Verifier decrypt the requestedData: requestedData = ECCDecrypt(verifier_private_key, encryptedRequestedData) Step 2: Verifier run the check:

vinhtrand8 commented 1 year ago

About Credential format:

vinhtrand8 commented 1 year ago

In 2.1. section, Issuer issues a credential,

Step 4: Send the credential (only public fields) to holder -> holder stores credential in local storage

Should the tech be like that:

  1. BE stores this credential (public fields),
  2. When user logs in app, mobile will fetch data from db.
  3. If new credential is issued, alert and require them to authenticate to get private key.
  4. Using private key decrypt encryptedData,
  5. Store complete credential (private & public fields) to local device.
vinhtrand8 commented 1 year ago

About 2.2 Verifier creates a schema, we should have a field (nonce or challenge) to prevent relay attack ref. For example, a challenge is a random number for every request schema, it can prevent an holder from creating a Verifiable Presentation and send it for his friends,

vinhtrand8 commented 1 year ago

We should follow W3C term

galin-chung-nguyen commented 1 year ago

About 2.2 Verifier creates a schema, we should have a field (nonce or challenge) to prevent relay attack ref. For example, a challenge is a random number for every request schema, it can prevent an holder from creating a Verifiable Presentation and send it for his friends,

It feels like the nonce couldn't help here. Because this is not jwt. Once the attacker observed the data sent (proof + encryptedData), they just submit the same things and the check will still pass. We might solve this by filtering the duplicated submissions, or using some other methods. @tranvinh146 What do you think?

vinhtrand8 commented 1 year ago
{
    "name": "Computer Science University Degree Check",
    "verifier": "asdnfklj234o123498ssdfasdjfagsdf",
    "checks":[
        ...
    ],
    "requests": ["0.schoolName", "1.name"],
        "nonce": "0x123456789abcdef" // add this field
}

I think checking a signature of nonce is easier than storing and checking duplicated submissions. Holder has just sent ( proof + encryptedData + signature(nonce) ), so verifier can make sure that holder owns the particular key in DID document (verifier can check assertMethod in DID document of holder).

cc @galin-chung-nguyen

galin-chung-nguyen commented 1 year ago

But if someone does replay attack, they could just send all of proof + encryptedData + signature(nonce), the verifier cannot realize whether it is the real holder or the attacker @tranvinh146

vinhtrand8 commented 1 year ago

In my case, each request can use only one time, so malicious user can not use this proof to send other verifiers.

P/S: maybe we need to discuss in the next meeting.