# `Peer`

A class in `fastatp.peer` ([source](https://github.com/jacoblapenna/fastatp/blob/main/fastatp/peer.py#L63)).

```python
Peer(
    did: str | None = None,
    signing_key: PrivateKey | Signer | None = None,
    *,
    resolver: DIDResolver | None = None,
    authorize: AuthorizeHook | None = None,
)
```

Symmetric participant: a DID, optionally a signing key, a resolver.

`did` + `signing_key` let the peer own repos ([`PeerServer`](https://fastatp.com/api/peerserver.md) hosts
them); `resolver` (default: [`web_resolver`](https://fastatp.com/api/web-resolver.md)) lets it verify other
peers' records. Either side can be omitted.

## Attributes

- `did`
- `signer: Signer | None`
- `resolver: DIDResolver`
- `authorize`

## Methods

### `create_repo`

```python
async create_repo(store: Any = None, *, storage: Any = None) -> Any
```

A signed present-state repo for this peer's DID, over `storage`
(one database for blocks, heads and blobs) or a bare block `store`.

### `verify`

```python
async verify(
    proof: bytes,
    *,
    expected_signer: str | None = None,
    path: str | None = None,
    context: Any = None,
) -> Lexicon
```

Verify a record proof and return the typed Lexicon instance.

Flow: parse the proof CAR -> commit `did` (issuer) -> resolve DID
document -> verify commit signature (rotation keys rejected) ->
re-derive the record's membership in the signed MST root -> parse the
record by `$type` -> run the `authorize()` hook.

A proof normally witnesses exactly one record; pass `path`
(`collection/rkey`) to select one from a multi-record slice.

Raises [`VerificationError`](https://fastatp.com/api/verificationerror.md) subclasses (SignatureInvalid,
SignerMismatch, NotAuthorized, UnknownLexicon) for anything wrong
with the proof or the resolved document. Resolution failures
propagate as themselves so callers can retry: [`DIDNotFound`](https://fastatp.com/api/didnotfound.md)
(miss) and [`DIDResolutionTimeout`](https://fastatp.com/api/didresolutiontimeout.md) (transient network failure —
deliberately NOT wrapped as a verification failure).

### `verify_detailed`

```python
async verify_detailed(
    proof: bytes,
    *,
    expected_signer: str | None = None,
    path: str | None = None,
    context: Any = None,
) -> VerifiedRecord
```

Like `verify`, but also returns the issuer DID, the record's
CID, and its `collection/rkey` path — all computed in the single CAR
decode `verify` already does. Callers that need this metadata (e.g.
push intake building an Envelope) use this to avoid a redundant decode.
