Unirep
  • 👏Welcome
  • 🧩Introduction
  • 🎮Getting Started
    • Install & build 🛠
    • Start with cli commands 🔌
      • 0. Install and build
      • 1. Spin up the testing chain
      • 2. Deploy Unirep contract
      • 3. User generates semaphore identity
      • 4. User signs up
      • 5. Attester signs up
      • 6. User generates epoch key and epoch key proof
      • 7. Attesters/Users verify epoch key proof
      • 8. Submit epoch key proof to Unirep smart contract
      • 9. Attester attest to epoch key
      • 10. Epoch transition
      • 11. User state transition
      • 12. User generates reputation proof
      • 13. Attesters/ Users verify the reputation proof
      • 14. User generates sign up proof
      • 15. Attesters/ Users verify the sign up proof
    • Start with Typescript 📠
      • 0. Install packages
      • 1. deploy
      • 2. User signs up
      • 3. Attester signs up
      • 4. Epoch key proof
      • 5. Attest
      • 6. Epoch transition
      • 7. User state transition
      • 8. Reputation proof
    • Computation happens off-chain ℹ️
  • ☀️Protocol
    • Glossary
      • Users and Attesters
      • Epoch
      • Epoch Key
      • Reputation
      • Trees
      • Nullifiers
      • Epoch Transition
      • User State Transition
    • Circuits
      • Epoch Key Proof
      • Reputation Proof
      • User Sign Up Proof
      • User State Transition Proof
    • Contract
      • Sign up
      • Attestations
      • Epoch transition
      • User state transition
      • Verify proofs
  • 🌈Package usage
    • @unirep/crypto
    • @unirep/circuits
    • @unirep/contracts
    • @unirep/core
    • @unirep/subgraph
    • cli
      • Deploy Unirep Contract
      • User Identity
      • User Sign Up
      • Epoch Key And Proof
      • Attestation
      • Epoch transition
      • User state transition
      • Reputation Proof
      • Airdrop Reputation
      • Spend Reputation
  • 🌻Applications
    • Unirep Social
Powered by GitBook
On this page
  • genEpochKeyAndProof
  • Options
  • verifyEpochKeyProof
  • Options
  • submitEpochKeyProof
  • Options

Was this helpful?

Edit on GitHub
  1. Package usage
  2. cli

Epoch Key And Proof

User generates an epoch key and a proof of this epoch key

  • 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

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

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

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

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

  -h, --help            Show this help message and exit.
PreviousUser Sign UpNextAttestation

Last updated 2 years ago

Was this helpful?

source:

source:

source:

🌈
core/cli/genEpochKeyAndProof.ts
core/cli/verifyEpochKeyProof.ts
core/cli/submitEpochKeyProof.ts