# Crypt4GH v1 Quickstart

## Installation

```bash
pip install "ai4gh[crypt4gh]"
```

## Work with Crypt4GH Headers

```python
from ai4gh.specs.crypt4gh.models import Header, HeaderPacket, DataEncryptionParameters

# Parse a Crypt4GH header
header = Header(
    magic_number="crypt4gh",
    version=1,
    header_packet_count=1,
    header_packets=[
        HeaderPacket(
            packet_type=0,
            data_encryption_parameters=DataEncryptionParameters(
                data_encryption_method=0,  # ChaCha20-IETF-Poly1305
            ),
        ),
    ],
)

print(f"Version: {header.version}")
print(f"Packets: {header.header_packet_count}")
```

## Concepts

Crypt4GH is a file-level encryption standard used by GA4GH for secure data transfer:

- **Envelope encryption**: Data encrypted with a symmetric key, key encrypted with recipient's public key
- **Selective decryption**: Different recipients can decrypt different portions
- **Streaming**: Encrypted files can be read without full decryption

## Data Models

```python
from ai4gh.specs.crypt4gh.models import (
    Header,
    HeaderPacket,
    DataEncryptionParameters,
    DataEditList,
)
```
