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

Implemented step 1 and 2 for WoT. Still need to notify the POR subjec… #2

Closed
wants to merge 0 commits into from

Conversation

ykocaogullar
Copy link
Contributor

Implemented following functionalities:

  • Fetch stranger certificate by keylocator
  • Request POR certificate issued by every other known (authenticated) user
    • If my cert store has N other users, send N interests for each
    • If not getting at least one POR, abort (treat as data verification failure)
  • Cross-sign stranger public key as POR certificate
  • Putting POR certificate into cert store
  • POR subject serves all POR it received

Missing functionality: Notify the POR subject a new POR is generated, let it fetch by name

@zjkmxy zjkmxy self-requested a review February 20, 2024 10:28
@zjkmxy zjkmxy self-assigned this Feb 20, 2024
@zjkmxy
Copy link
Collaborator

zjkmxy commented Feb 20, 2024

Hello. Please run pnpm format, pnpm lint and pnpm test locally and fix the errors.

If you are using VSCode, the following settings are recommended:

{
  "editor.defaultFormatter": "denoland.vscode-deno",
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "[typescript]": {
    "editor.defaultFormatter": "denoland.vscode-deno"
  },
  "deno.enable": true,
  "deno.lint": true,
  "deno.unstable": true
}

@zjkmxy
Copy link
Collaborator

zjkmxy commented Feb 29, 2024

How is your progress on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to implement a new class in a new file instead of changing the existing one. It will break the currently running workspace.

*/
export class CertStorage implements SecurityAgent {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please implement the same interface.
Also, preserve the code in L24, L32, L72, L138 and L146.

@@ -82,6 +82,7 @@ export class CertStorage implements SecurityAgent {

// Cache result certificates
this.storage.set(result.name.toString(), Encoder.encode(result));
this.trustedNames.push(result.name.toString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

trustedNames is not persistent in a storage, which means it will become empty after the program restarts.
You need to modify the create function to compute this array.

@@ -60,7 +60,7 @@ export class CertStorage implements SecurityAgent {
*/
async getCertificate(keyName: Name, localOnly: boolean): Promise<Certificate | undefined> {
const certBytes = await this.storage.get(keyName.toString());
if (certBytes === undefined || certBytes.length === 0) { // Length 0 happens for parallel access reason
if (certBytes === undefined) {
if (localOnly) {
return undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You haven't done anything for an unrecognized certficate. Do you need to fetch the PoR?

Also, the function generatePoR is not used anywhere. Do you want users to generate PoR manually?

Comment on lines 160 to 167
const parts: string[] = item.split('/');
let partsBeforeKey: string = '';
for (let i = 0; i < parts.length; i++) { //put <Z_a name encoded> together with a loop
if (parts[i].includes('KEY')) {
break;
}
partsBeforeKey += parts[i] + '/';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

First, I don't think this is the correct behavior. I think <Tb keyid> is a single component containing the encoded name. Please confirm with @tianyuan129 .
If this behavior is correct, you can still get rid of the loop. See Name.append

// return if we found that one of the users we trust, also trusts the new user
const response: Certificate | undefined = await this.getCertificate(
new Name(strangerKeyname + partsBeforeKey + 'v1'),
false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This means PoR can be recursively signed by other unknown certifcates. Please check if the behavior if desired.

Comment on lines 191 to 193
if (foreignPoR == undefined) {
throw new Error('Data verification failure: No POR certificate found issued by trusted user');
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This reads as "a PoR cannot be generated without an existing one".
Then, how can the first PoR be generated?

}

// Get public key of C_b
const certificate: Certificate | undefined = await this.getCertificate(new Name(strangerKeyname), false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to fetch a certificate when generating PoR?

Comment on lines 214 to 220
// Create a self-signed certificate, i.e. the PoR
const proofOfZoneRecognition = await Certificate.build({
name: certName,
validity: validityPeriod,
publicKeySpki: publicKey,
signer: this._signer,
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why a PoR is self-signed?

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