> For the complete documentation index, see [llms.txt](https://unirep.gitbook.io/unirep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unirep.gitbook.io/unirep/package/cli/epoch-key-and-proof.md).

# Epoch Key And Proof

* An epoch key is the only way that a user can receive reputation.
* A user can generate an epoch key with a nonce, the nonce should be less than `numEpochKeyNoncePerEpoch`.
* A user generates the epoch key with a circom circuit and the epoch key and proof can be verified by attesters and other users.

## `genEpochKeyAndProof`

```
npx ts-node cli/index.ts genEpochKeyAndProof 
                  [-h] 
                  [-e ETH_PROVIDER] 
                  -id IDENTITY 
                  -n EPOCH_KEY_NONCE 
                  -x CONTRACT
```

* epoch key and base64url encoded epoch key proof and public signals will be printed
* A string with `Unirep.epk.proof` prefix is the proof of this epoch key
* A string with `Unirep.epk.publicSignals` prefix is the public signals of this proof The public signals includes
  * the current epoch
  * the epoch key
  * the global state tree root.
* Attesters and other users can verify if the epoch key is in the current epoch and if the user has a leaf in the global state tree.

### Options

```
  -e ETH_PROVIDER, --eth-provider ETH_PROVIDER
                        A connection string to an Ethereum provider. Default: http://localhost:8545
  -id IDENTITY, --identity IDENTITY
                        The (serialized) user's identity
  -n EPOCH_KEY_NONCE, --epoch-key-nonce EPOCH_KEY_NONCE
                        The epoch key nonce
  -x CONTRACT, --contract CONTRACT
                        The Unirep contract address
```

#### Options inherited from parent commands <a href="#options-inherited-from-parent-commands" id="options-inherited-from-parent-commands"></a>

```
  -h, --help            Show this help message and exit.
```

{% hint style="info" %}
source: [core/cli/genEpochKeyAndProof.ts](https://github.com/Unirep/Unirep/blob/main/packages/core/cli/genEpochKeyAndProof.ts)
{% endhint %}

## `verifyEpochKeyProof`

```
npx ts-node cli/index.ts verifyEpochKeyProof 
                  [-h] 
                  [-e ETH_PROVIDER] 
                  -p PUBLIC_SIGNALS 
                  -pf PROOF 
                  -x CONTRACT
```

* This command will help other users with an epoch key proof with `Unirep.epk.proof` prefix and it public signals with `Unirep.epk.publicSignals` prefix to call the Unirep smart contract to verify the proof.

### Options

```
  -e ETH_PROVIDER, --eth-provider ETH_PROVIDER
                        A connection string to an Ethereum provider. Default: http://localhost:8545
  -p PUBLIC_SIGNALS, --public-signals PUBLIC_SIGNALS
                        The snark public signals of the user's epoch key
  -pf PROOF, --proof PROOF
                        The snark proof of the user's epoch key
  -x CONTRACT, --contract CONTRACT
                        The Unirep contract address
```

#### Options inherited from parent commands <a href="#options-inherited-from-parent-commands" id="options-inherited-from-parent-commands"></a>

```
  -h, --help            Show this help message and exit.
```

{% hint style="info" %}
source: [core/cli/verifyEpochKeyProof.ts](https://github.com/Unirep/Unirep/blob/main/packages/core/cli/verifyEpochKeyProof.ts)
{% endhint %}

## `submitEpochKeyProof`

```
npx ts-node cli/index.ts submitEpochKeyProof 
                  [-h] 
                  [-e ETH_PROVIDER] 
                  -p PUBLIC_SIGNALS 
                  -pf PROOF 
                  -x CONTRACT 
                  -d ETH_PRIVKEY
```

* Epoch key proof should be submitted to UniRep and get the index of the proof.
* Then the attester can submit attestation to the epoch key with a valid proof index.
* Only if the epoch key proof is valid, the attestation can be processed.

### Options

```
  -e ETH_PROVIDER, --eth-provider ETH_PROVIDER
                        A connection string to an Ethereum provider. Default: http://localhost:8545
  -p PUBLIC_SIGNALS, --public-signals PUBLIC_SIGNALS
                        The snark public signals of the user's epoch key
  -pf PROOF, --proof PROOF
                        The snark proof of the user's epoch key
  -x CONTRACT, --contract CONTRACT
                        The Unirep contract address
  -d ETH_PRIVKEY, --eth-privkey ETH_PRIVKEY
                        The attester's Ethereum private key
```

#### Options inherited from parent commands <a href="#options-inherited-from-parent-commands" id="options-inherited-from-parent-commands"></a>

```
  -h, --help            Show this help message and exit.
```

{% hint style="info" %}
source: [core/cli/submitEpochKeyProof.ts](https://github.com/Unirep/Unirep/blob/main/packages/core/cli/submitEpochKeyProof.ts)
{% endhint %}
