OpenIDZK lets a Google, Apple or X account sign GUM Network transactions with a
`0x40` [typed signature](/protocol/typed-signatures). The provider signs a login
token, an OpenID Connect ID token, that commits to a session key on your device.
GUM's sign-in services check your login token when you sign in, return your
address salt and generate a zero-knowledge proof. The proof shows validators
that the token is genuine and ties the session key to your address, without
revealing the token. **Your email and social account ID never go on-chain, and
GUM doesn't store them.** For a plain-language overview, see
[Private social login](/accounts/openidzk).

## The nonce binding

The provider copies the OpenID Connect `nonce` into the token it signs. Your
device sets it to:

```formula
nonce = base64url( SHA-256( session_pubkey ‖ exp_slot ‖ user_rand ) )
```

| Input            | Size                       | What it is                            |
| ---------------- | -------------------------- | ------------------------------------- |
| `session_pubkey` | 32 bytes                   | The session key's Ed25519 public key  |
| `exp_slot`       | 8 bytes, u64 little-endian | The slot at which the session expires |
| `user_rand`      | 8 bytes, u64 little-endian | A random value chosen at sign-in      |

The nonce is 43 base64url characters, without padding. Because the provider's
signature covers it, the token authorizes exactly this session key until this
slot.

## The address and its salt

```formula
digest  = SHA-256( authority_account ‖ sub ‖ salt )
address = digest[0..30] ‖ 0x40 ‖ bump
```

| Input               | What it is                                                                                                                                  |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `authority_account` | A 32-byte account in GUM Network's OpenID registry for one provider and one client ID (`aud`). It lists that provider's registered signing keys. |
| `sub`               | The provider's ID for your account, taken from the token and padded with zeros to 256 bytes                                                 |
| `salt`              | Returned by GUM's salt service for your account                                                                                             |
| `bump`              | The smallest value that puts the address off the Ed25519 curve, as for every [typed address](/protocol/typed-signatures#addresses)          |

The salt keeps your address unlinkable to your social account: without it,
anyone who knew your provider account ID could hash it with the public
authority account and find your address. The salt service returns the same salt
each time you sign in with the same account, so the same sign-in derives the
same address. Each provider has its own authority account, so Google, Apple and
X sign-ins give different addresses, even for the same person.

## The proof

The proof is a 256-byte Groth16 proof on the BN254 curve: point A (G1, 64
bytes), point B (G2, 128 bytes) and point C (G1, 64 bytes), all uncompressed.
It shows that the prover knows an ID token for which:

1. The RS256 signature is valid under the public RSA-2048 modulus, with
   exponent 65537.
2. The `nonce` claim equals the nonce hash above, for the public session key
   and expiry slot.
3. The `aud` claim equals the public `aud`.
4. The first 30 bytes of `SHA-256(authority_account ‖ sub ‖ salt)`, with `sub`
   read from the token, equal the first 30 bytes of the public address.

The token's header and payload, its RSA signature, `sub`, `user_rand` and the
salt are private inputs: the proof doesn't reveal them, and none goes on-chain.
The token's header and payload can be up to 1,524 bytes in base64url, and the
decoded payload up to 1,143 bytes.

Validators rebuild all 29 public inputs, each a BN254 field element, from the
signature and the signer's address, so a proof only verifies for the address
it was made for.

## What validators check

1. **Signature verification.** The signature is at most 816 bytes. The
   signer's address carries tag `0x40` in byte 30 and the smallest bump. The
   Groth16 proof verifies against the rebuilt public inputs, and the session
   key's Ed25519 signature verifies over the message.
2. **Expiry.** The transaction is rejected once the current slot reaches
   `exp_slot`.
3. **Registry.** The authority account must exist and belong to the OpenID
   registry program. The `aud` registered on it must equal the signature's
   `aud`, and the hash of the signature's RSA key must be one of the keys it
   lists.

Validators read provider keys from the on-chain registry, never from the
provider. When a provider rotates its signing keys, the registry follows, and
sessions proven with a retired key stop verifying. The GUM app then asks you to
sign in again.

## Signature layout and size

```layout
OpenIDZK (0x40) signature
  1 byte          tag, 0x40
  32 bytes        authority_account
  1 byte          key spec, 0 = RSA with RS256
  2 + 256 bytes   RSA modulus, with a compact-u16 length
  1–2 + n bytes   aud, with a compact-u16 length, n ≤ 160
  2 + 256 bytes   Groth16 proof, with a compact-u16 length
  32 bytes        session_pubkey
  8 bytes         exp_slot, u64 little-endian
  64 bytes        session key's Ed25519 signature over the message
```

The signature is 655 bytes plus the length of `aud`, or one byte more when
`aud` is longer than 127 bytes, up to 816 bytes. A typical Google client ID is
72 bytes, which gives a 727-byte signature. See
[Transaction wire format](/protocol/wire-format).

## Providers

| Provider | Where the ID token comes from                                                                                                                                                                  |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Google   | Google's OpenID Connect sign-in                                                                                                                                                                |
| Apple    | Sign in with Apple. New Apple sign-ups are paused during an Apple sign-in migration.                                                                                                           |
| X        | X has no native OpenID Connect, so a GUM-run OpenID bridge signs you in with X and issues an RS256 ID token that carries your nonce. Its `sub` is a hash of your X user ID, not the ID itself. |
