Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Created April 23, 2024 06:07
Show Gist options
  • Save Turupawn/952ce19406a9c54f490f13dbdf5cd4ed to your computer and use it in GitHub Desktop.
Save Turupawn/952ce19406a9c54f490f13dbdf5cd4ed to your computer and use it in GitHub Desktop.

1. Clone the repo

git clone https://github.com/Sindri-Labs/sindri-resources.git
cd sindri-resources/circuit_database/circom/multiplier2

2. Change your circuit name

sindri.json

{
  "$schema": "https://sindri.app/api/v1/sindri-manifest-schema.json",
  "name": "EDIT-NAME",
  "circuitPath": "./circuit.circom",
  "circuitType": "circom",
  "curve": "bn254",
  "provingScheme": "groth16",
  "witnessCompiler": "c++"
}

3. Deploy and generate a proof

#nvm use 20 # I tested with this npm version
npx sindri@latest deploy
npx sindri@latest proof create --input input.json

4. Install the sindri SDK and get a Remix compatible proof

Create a python script file.

script.python

from sindri import Sindri

sindri = Sindri("sindri_YOUR_SINDRI_API_KEY", verbose_level=2)


x = sindri.get_proof(
    "YOUR-PROOF-ID",
    True,
    True,
    True,
    False
)

Now we can get the proof.

pip install sindri
python3 script.py

5. Depoly the verifier and the custom logic contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

interface IVerifier {
    function verifyProof(
                uint[2] memory a,
                uint[2][2] memory b,
                uint[2] memory c,
                uint[1] memory input
            ) external view returns (bool r);
}

contract CustomLogic {
    uint public verifyCount;
    address verifierAddress;

    constructor(address verifierAddress_) {
        verifierAddress = verifierAddress_;
    }

    function verifyProof(
                uint[2] memory a,
                uint[2][2] memory b,
                uint[2] memory c,
                uint[1] memory input
            ) public
    {
        require(IVerifier(verifierAddress).verifyProof(a, b, c, input), "Invalid proof");
        verifyCount += 1;
    }
}

Learn more on the official docs: https://sindri.app/docs/quick-start/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment