# n_signer C Reference Client

This directory provides a minimal copy/paste-friendly C client for `n_signer`.

## Files

- `nsigner_client.h` / `nsigner_client.c`:
  - Unix abstract socket connect helper
  - length-prefixed frame send/receive
  - generic request API
  - helpers for `get_public_key` and `sign_event`
  - optional TCP auth envelope attachment via `auth_envelope_build_for_request()`

## API at a glance

```c
nsigner_client_t client;
nsigner_client_init(&client);

nsigner_client_connect_unix(&client, "nsigner", 5000);

char *resp = NULL;
nsigner_client_get_public_key(&client, "1", "", &resp);
free(resp);

nsigner_client_close(&client);
```

## Auth envelope usage

If transport requires auth envelopes (for TCP mode), set a private key once:

```c
unsigned char privkey[32] = { /* caller key */ };
nsigner_client_set_auth(&client, privkey, "example-client");
```

Subsequent requests automatically include an `auth` object.

## Ownership rules

- Any `out_response_json` returned by the API must be freed by caller using `free()`.
- `nsigner_client_close()` only closes the socket; it does not free the client struct itself.

## License

Source files in this directory use SPDX `0BSD` headers for permissive reuse in external projects.
