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(Keys_Incoming): Decrypt incoming ciphertext #5868

Closed
Tracked by #5606
LHerskind opened this issue Apr 19, 2024 · 4 comments
Closed
Tracked by #5606

feat(Keys_Incoming): Decrypt incoming ciphertext #5868

LHerskind opened this issue Apr 19, 2024 · 4 comments
Assignees

Comments

@LHerskind
Copy link
Contributor

LHerskind commented Apr 19, 2024

Implementation in typescript

Following #5867 and #5899 we need to also be able to decode. This don't need to happen in a circuit so we simply do it in typescript. This should be able to take a look back at aztec-connect to see if it can get some information from there as it was also using AES.

Take into account #5901.

In aztec connect the ciphertext was called the viewing_key so should be helpful for finding the information.

Very close to #5902

@github-project-automation github-project-automation bot moved this to Todo in A3 Apr 19, 2024
@LHerskind LHerskind changed the title feat(Keys_Viewing): Decrypt ciphertext feat(Keys_Viewing): Decrypt incoming ciphertext Apr 22, 2024
@LHerskind LHerskind changed the title feat(Keys_Viewing): Decrypt incoming ciphertext feat(Keys_Incoming): Decrypt incoming ciphertext May 1, 2024
@sklppy88 sklppy88 moved this from Todo to In Progress in A3 May 6, 2024
@LHerskind
Copy link
Contributor Author

As part of #5899 and #5867 there are typescript parts for encrypting and decryption these two.
We mainly need to deal with the combination of them into something that looks more like the encrypted log buffer that we have currently.

@LHerskind
Copy link
Contributor Author

Related information in #5901 (comment).

@LHerskind
Copy link
Contributor Author

LHerskind commented May 8, 2024

This should be addressed along with #5901 to not have too many conflicts.

The l1_note_payload should be altered to take the eph_pk, header and body as outlined from the diagram, using the classes to handle decryption of those individually.

There should be a l1_note_payload::fromEncryptedBuffer function that does something along these lines:

  constructor(eph_public_key: Fr, header: EncryptedLogHeader, body: EncryptedLogBody) {}

  static fromEncryptedBuffer(data: Buffer, incomingViewingSecretKey: GrumpkinPrivateKey): L1NotePayload | undefined {
    const reader = BufferReader.asReader(data);
    const ephPK = Fr.fromBuffer(reader);
    const header = EncryptedLogHeader.fromCiphertext(data, incomingViewingSecretKey, ephPK);

    const appSecretKey = Fr.random();

    // slice data
    const body = EncryptedLogBody.fromCiphertext(data, appSecretKey, ephPK);

    return new L1NotePayload(ephPK, header, body);
  }

Similar changes should happen in the note processor to get this going.

Places to look:

  • note_processor.ts
  • l1_note_payload.ts
  • client_execution_context.ts
    • The emitEncryptedLog should just take the raw array for tag and encrypted data
  • private_context.nr
    • The emit_encrypted_log need to compute the header, body etc and compute the bytes that is to be emitted.
  • logs.nr
    • The emit_encrypted_log oracle should be altered to take raw bytes and not return anything.

@LHerskind LHerskind assigned LHerskind and unassigned sklppy88 May 10, 2024
@LHerskind
Copy link
Contributor Author

Was fixed in #6251 and #6411

@github-project-automation github-project-automation bot moved this from In Progress to Done in A3 May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants