Skip to content

feat(Keys_Incoming): Decrypt incoming ciphertext #5868

Closed

Description

@LHerskind

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

Activity

  1. changed the title [-]feat(Keys_Viewing): Decrypt ciphertext[/-] [+]feat(Keys_Viewing): Decrypt incoming ciphertext[/+] on Apr 22, 2024
  2. changed the title [-]feat(Keys_Viewing): Decrypt incoming ciphertext[/-] [+]feat(Keys_Incoming): Decrypt incoming ciphertext[/+] on May 1, 2024
  3. moved this from Todo to In Progress in A3on May 6, 2024
  4. LHerskind commented on May 8, 2024

    @LHerskind
    ContributorAuthor

    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.

  5. LHerskind commented on May 8, 2024

    @LHerskind
    ContributorAuthor

    Related information in #5901 (comment).

  6. LHerskind commented on May 8, 2024

    @LHerskind
    ContributorAuthor

    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.
  7. LHerskind commented on May 18, 2024

    @LHerskind
    ContributorAuthor

    Was fixed in #6251 and #6411

  8. moved this from In Progress to Done in A3on May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions