> ## Documentation Index
> Fetch the complete documentation index at: https://docs.world.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Go

> Lightweight Go module for generating RP signatures.

The Go module is a **backend signing utility only**. It is used to generate `rp_context` signatures for IDKit requests, and does not
run client-side IDKit request flows.

## Install

```bash theme={null}
go get github.com/worldcoin/idkit/go/idkit@latest
```

## Generate RP signature

### One-shot signing

Use `SignRequest` with functional options for the simplest integration:

```go theme={null}
import "github.com/worldcoin/idkit/go/idkit"

// For uniqueness proofs: include the action
sig, err := idkit.SignRequest(
	os.Getenv("RP_SIGNING_KEY"),
	idkit.WithAction("my-action"),
)
if err != nil {
	// handle error
}

rpContext := map[string]any{
	"rp_id":      "rp_xxxxx",
	"nonce":      sig.Nonce,
	"created_at": sig.CreatedAt,
	"expires_at": sig.ExpiresAt,
	"signature":  sig.Sig,
}
```

### Reusable signer

For high-throughput backends, create a `Signer` once and reuse it. This parses the key upfront and avoids repeated allocations.

```go theme={null}
signer, err := idkit.NewSigner(os.Getenv("RP_SIGNING_KEY"))
if err != nil {
	log.Fatal(err)
}

// Use in your request handler
sig, err := signer.SignRequest(
	idkit.WithAction("my-action"),
	idkit.WithTTL(600), // optional, default 300s
)
```

## API

### Functions

| Function                                 | Description                                |
| ---------------------------------------- | ------------------------------------------ |
| `SignRequest(signingKeyHex, opts...)`    | One-shot signing with options              |
| `SignRequestWithTTL(signingKeyHex, ttl)` | Convenience wrapper with custom TTL        |
| `NewSigner(signingKeyHex)`               | Creates a reusable `Signer` from a hex key |

### Options

| Option               | Description                                                                          |
| -------------------- | ------------------------------------------------------------------------------------ |
| `WithAction(action)` | Hashes and appends the action to the signed payload (required for uniqueness proofs) |
| `WithTTL(ttl)`       | Overrides the default 300-second TTL                                                 |

### `RpSignature`

```go theme={null}
type RpSignature struct {
	Sig       string `json:"sig"`        // 0x-prefixed, 65-byte hex
	Nonce     string `json:"nonce"`      // 0x-prefixed, 32-byte field element
	CreatedAt uint64 `json:"created_at"` // Unix seconds
	ExpiresAt uint64 `json:"expires_at"` // Unix seconds
}
```

## Related pages

* [RP Signatures](/world-id/idkit/signatures) — algorithm details, pseudocode, and test vectors
* [Integrate IDKit](/world-id/idkit/integrate)
