<!-- Generated from sources/conventions/v1/aeon-gp-encryption-v1.aeon; do not edit. -->

<a id="aeon-gp-encryption-v1"></a>
# AEON GP Encryption v1

Convention identifier: `aeon.gp.encryption.v1`

---

<a id="purpose"></a>
## 1. Purpose

`aeon.gp.encryption.v1` defines a minimal structure for representing encrypted AEON payloads inside `aeon:envelope`.

It allows AEON documents to carry confidential data while preserving the deterministic document model.

This convention is designed to work with:

- `aeon.gp.security.v1`
- `aeon.gp.integrity.v1`
- `aeon.gp.signature.v1`

---

<a id="scope"></a>
## 2. Scope

`aeon.gp.encryption.v1` defines:

- where encrypted content lives
- how ciphertext is represented
- how recipient keys are identified
- minimal encryption metadata

It does **not** define:

- key exchange protocols
- trust models
- certificate infrastructure
- algorithm approval policies

---

<a id="encryption-model"></a>
## 3. Encryption Model

Encryption replaces the plaintext body with ciphertext while preserving the AEON document structure.

The envelope carries:

- encryption algorithm
- recipient key identifier
- encrypted payload bytes

The decrypted payload must resolve to a valid AEON document body.

---

<a id="envelope-placement"></a>
## 4. Envelope Placement

Encryption is declared inside the envelope:

```aeon
"aeon:envelope":securityEnvelope = {
  encryption:encryptionBlock = { ... }
}
```

Only one encryption section is allowed per envelope unless another convention explicitly defines multiple encryption layers.

---

<a id="encryption-entry-structure"></a>
## 5. Encryption Entry Structure

<a id="required-fields"></a>
### Required fields

| field | meaning |
| :--- | :--- |
| `alg` | encryption algorithm |
| `kid` | recipient key identifier |
| `ciphertext` | encrypted payload |

*Required encryption fields*

Minimal form:

```aeon
encryption:encryptionBlock = {
  alg:string = "xchacha20-poly1305"
  kid:string = "bob"
  ciphertext:bytes = #...
}
```

---

<a id="field-definitions"></a>
## 6. Field Definitions

<a id="alg"></a>
### 6.1 `alg`

Encryption algorithm identifier.

Example:

```aeon
alg = "xchacha20-poly1305"
```

Other possible values:

- `aes-256-gcm`
- `chacha20-poly1305`

The convention does not restrict allowed algorithms.

Profiles may.

---

<a id="kid"></a>
### 6.2 `kid`

Recipient key identifier.

Example:

```aeon
kid = "bob"
```

This identifies the key used to decrypt the ciphertext.

The identifier format is intentionally flexible.

Possible examples:

```aeon
kid = "bob"
kid = "org.example.recipient.1"
kid = "did:example:bob#key1"
```

---

<a id="ciphertext"></a>
### 6.3 `ciphertext`

Encrypted payload.

Example:

```aeon
ciphertext = #AABBCC...
```

This field contains the encrypted AEON payload bytes.

The exact encoding is determined by AEON binary literal rules.

---

<a id="optional-fields"></a>
## 7. Optional Fields

Optional metadata may appear if required by the encryption algorithm.

| field | meaning |
| :--- | :--- |
| `nonce` | encryption nonce |
| `aad` | additional authenticated data |
| `tag` | authentication tag |
| `epk` | ephemeral public key |

*Optional encryption fields*

Example:

```aeon
encryption:encryptionBlock = {
  alg:string = "xchacha20-poly1305"
  kid:string = "bob"
  nonce:bytes = #112233...
  ciphertext:bytes = #AABBCC...
  tag:bytes = #998877...
}
```

These fields are algorithm dependent.

---

<a id="encryption-scope"></a>
## 8. Encryption Scope

Encryption covers the **document body**.

The envelope itself remains visible so processors know how to decrypt the document.

Conceptually:

```text
aeon:header
ciphertext(body)
aeon:envelope
```

---

<a id="combined-signing-and-encryption"></a>
## 9. Combined Signing and Encryption

Documents may combine encryption with signatures.

Example workflow:

1. encrypt payload
2. compute integrity hash
3. sign hash

Example:

```aeon
"aeon:envelope":securityEnvelope = {
  encryption:encryptionBlock = {
    alg:string = "xchacha20-poly1305"
    kid:string = "bob"
    ciphertext:bytes = #...
  }

  integrity:integrityBlock = {
    alg:string = "sha256"
    hash:bytes = #...
  }

  signatures:signatureSet = [
    {
      alg:string = "ed25519"
      kid:string = "alice"
      sig:bytes = #...
    }
  ]
}
```

This allows recipients to verify authenticity after decryption.

---

<a id="verification-decryption-flow"></a>
## 10. Verification / Decryption Flow

A processor decrypting a document should:

1. parse AEON document
2. locate `aeon:envelope.encryption`
3. resolve recipient key using `kid`
4. decrypt `ciphertext`
5. reconstruct the AEON body
6. optionally verify integrity and signatures

---

<a id="failure-conditions"></a>
## 11. Failure Conditions

Decryption must fail if:

- `alg` is missing
- `kid` cannot be resolved
- ciphertext cannot be decrypted
- authentication tag fails
- payload cannot be parsed as AEON

Decryption failure is not a syntax error; it is a processor-level security failure.

---

<a id="example-encrypted-document"></a>
## 12. Example Encrypted Document

```aeon
aeon:header = {
  encoding = "utf-8"
  mode = "strict"
}

"aeon:envelope":securityEnvelope = {
  encryption:encryptionBlock = {
    alg:string = "xchacha20-poly1305"
    kid:string = "bob"
    nonce:bytes = #AA11...
    ciphertext:bytes = #BB22...
    tag:bytes = #CC33...
  }

}
```

In this case the body is encrypted and only recoverable after decryption.

---

<a id="relationship-to-other-conventions"></a>
## 13. Relationship to Other Conventions

`aeon.gp.encryption.v1` works with:

- `aeon.gp.security.v1`
- `aeon.gp.integrity.v1`
- `aeon.gp.signature.v1`

Encryption may appear alongside integrity and signatures.

---

<a id="one-line-definition"></a>
## 14. One-Line Definition

`aeon.gp.encryption.v1` defines a minimal encryption envelope for AEON documents in which the document body is represented as ciphertext inside `aeon:envelope.encryption`.

---

<a id="minimal-encryption-envelope"></a>
## 15. Minimal Encryption Envelope

```aeon
"aeon:envelope":securityEnvelope = {
  encryption:encryptionBlock = {
    alg:string = "xchacha20-poly1305"
    kid:string = "bob"
    ciphertext:bytes = #...
  }
}
```

---

---

## Related documents

- [AEON GP Security Envelope v1](./aeon-gp-security-envelope-v1.md)
- [AEON GP Integrity v1](./aeon-gp-integrity-v1.md)
- [AEON GP Signature v1](./aeon-gp-signature-v1.md)
