# Reputation Proof

* There are two types of reputation proof in Unirep:

1. ***Reputation proof***: how much reputation that a user has, which includes reputation from all attesters and airdropped karma.
2. ***Reputation from attester proof:*** how much reputation from a specified attester, which is indicated by attester id

* Both of the reputation proofs are generated by user with a semaphore identity and the proof can be verified by everyone at the Unirep smart contract.

### 1. Reputation proof

* This proof will be generated with a post, a comment, an upvote and a downvote action. The proof is used to ensure that a user has enough reputation to make the action.&#x20;
* There is another option that a user can choose to prove how much reputation he has and it exceeds the required reputation for the action.
* See [User Interaction Functions](/unirep-social/cli/user-interaction-functions.md)
* After user made an action, it will create a proof with `Unirep.reputationProof`prefix. Other users can verify this proof at the Unirep smart contract.

### `verifyReputationProof`

```
npx ts-node cli/index.ts verifyReputationProof 
                  [-h] 
                  [-e ETH_PROVIDER] 
                  [-ep EPOCH] 
                  -epk EPOCH_KEY 
                  -pf PROOF 
                  -th TRANSACTION_HASH 
                  [-mr MIN_REP]
                  [-b START_BLOCK] 
                  -x CONTRACT
```

* This command will help other users with a proof with `Unirep.reputationProof`prefix to call the Unirep smart contract to verify the proof.
* The input should match the claim that the prover provides.
* Actions includes: `publishPost`, `leaveComment`, and `vote`&#x20;

### Options

```
  -e ETH_PROVIDER, --eth-provider ETH_PROVIDER
                        A connection string to an Ethereum provider. Default: http://localhost:8545
  -ep EPOCH, --epoch EPOCH
                        The latest epoch user transitioned to. Default: current epoch
  -epk EPOCH_KEY, --epoch-key EPOCH_KEY
                        The user's epoch key (in hex representation)
  -pf PROOF, --proof PROOF
                        The snark proof of the user's epoch key and reputation
  -th TRANSACTION_HASH, --transaction-hash TRANSACTION_HASH
                        The transaction hash of where user submit the reputation nullifiers
  -mr MIN_REP, --min-rep MIN_REP
                        The minimum reputation score the user has
  -b START_BLOCK, --start-block START_BLOCK
                        The block the Unirep contract is deployed. Default: 0
  -x CONTRACT, --contract CONTRACT
                        The Unirep Social 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.
```

### 2. Reputation proof from attester

### `genReputationProofFromAttester`

```
npx ts-node cli/index.ts genReputationProofFromAttester 
                  [-h] 
                  [-e ETH_PROVIDER] 
                  -id IDENTITY 
                  -a ATTESTER_ID
                  [-mp MIN_POS_REP]
                  [-mn MAX_NEG_REP]
                  [-md MIN_REP_DIFF]
                  [-gp GRAFFITI_PREIMAGE]
                  [-b START_BLOCK] 
                  -x CONTRACT
                  [-db]
```

* The prover (the user with a semaphore identity) can choose to prove how much reputation he receives from a certain attester id, including:
  * *minimum positive reputation*  received from the attester since the first epoch
  * *maximum* *negative reputation* received from the attester since the first epoch
  * *minimum* *difference between positive and negative reputation* from the attester since the first epoch
  * what is the graffiti pre-image of the reputation, where the graffiti is optional to be attached from the attester
* If the reputation matches the user's claim, the Circom circuit will generate a valid proof.
* A string with `Unirep.reputationProofFromAttester` prefix is the proof of the reputation claim.

### 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
  -a ATTESTER_ID, --attester-id ATTESTER_ID
                        The attester id (in hex representation)
  -mp MIN_POS_REP, --min-pos-rep MIN_POS_REP
                        The minimum positive score the attester given to the user
  -mn MAX_NEG_REP, --max-neg-rep MAX_NEG_REP
                        The maximum negative score the attester given to the user
  -md MIN_REP_DIFF, --min-rep-diff MIN_REP_DIFF
                        The difference between positive and negative scores the attester given to the user
  -gp GRAFFITI_PREIMAGE, --graffiti-preimage GRAFFITI_PREIMAGE
                        The pre-image of the graffiti for the reputation the attester given to the user (in hex representation)
  -b START_BLOCK, --start-block START_BLOCK
                        The block the Unirep contract is deployed. Default: 0
  -x CONTRACT, --contract CONTRACT
                        The Unirep Social contract address
  -db, --from-database  Indicate if to generate proving circuit from database
```

#### 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.
```

###

### `verifyReputationProofFromAttester`

```
npx ts-node cli/index.ts verifyReputationProofFromAttester 
                  [-h] 
                  [-e ETH_PROVIDER]
                  [-ep EPOCH] 
                  -a ATTESTER_ID
                  [-mp MIN_POS_REP]
                  [-mn MAX_NEG_REP]
                  [-md MIN_REP_DIFF]
                  [-gp GRAFFITI_PREIMAGE] 
                  -pf PROOF 
                  [-b START_BLOCK] 
                  -x CONTRACT
```

* This command will help other users with a proof with `Unirep.reputationProofFromAttester`prefix to call the Unirep smart contract to verify the proof.
* The input should match the claim that the prover provides.

### Options

```
  -e ETH_PROVIDER, --eth-provider ETH_PROVIDER
                        A connection string to an Ethereum provider. Default: 
                        http://localhost:8545
  -ep EPOCH, --epoch EPOCH
                        The latest epoch user transitioned to. Default: 
                        current epoch
  -a ATTESTER_ID, --attester-id ATTESTER_ID
                        The attester id (in hex representation)
  -mp MIN_POS_REP, --min-pos-rep MIN_POS_REP
                        The minimum positive score the attester given to the 
                        user
  -mn MAX_NEG_REP, --max-neg-rep MAX_NEG_REP
                        The maximum negative score the attester given to the 
                        user
  -md MIN_REP_DIFF, --min-rep-diff MIN_REP_DIFF
                        The difference between positive and negative scores 
                        the attester given to the user
  -gp GRAFFITI_PREIMAGE, --graffiti-preimage GRAFFITI_PREIMAGE
                        The pre-image of the graffiti for the reputation the 
                        attester given to the user (in hex representation)
  -pf PROOF, --proof PROOF
                        The snark proof of the user's epoch key
  -b START_BLOCK, --start-block START_BLOCK
                        The block the Unirep contract is deployed. Default: 0
  -x CONTRACT, --contract CONTRACT
                        The Unirep Social 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.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://unirep.gitbook.io/unirep-social/cli/reputation-proof.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
