[
  {
    "path": "README.md",
    "content": "# README\n\n## Sample Application for Testing the Verification Layer\n\n**🚀 Quick Start with Our Demo Video!**\n\n[![Demo Video](https://img.youtube.com/vi/jawnA9mwhck/0.jpg)](https://www.youtube.com/watch?v=jawnA9mwhck)\n\n*Click on the image above to watch our step-by-step demo video.*\n\n---\n\nThis repository contains a Go program that sends data over a ZeroMQ socket to test a verification layer. The program (`sample.go`) is designed to send Zero-Knowledge (ZK) proofs or any data you specify to a specified endpoint. Shell scripts are included to streamline the building and running processes.\n\n---\n\n## Table of Contents\n\n- [Demo Video](#demo-video)\n- [Overview](#overview)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n  - [Clone the Repository](#clone-the-repository)\n  - [Install Dependencies](#install-dependencies)\n- [Usage](#usage)\n  - [Building the Program](#building-the-program)\n  - [Running the Program](#running-the-program)\n    - [Using a Proof File](#using-a-proof-file)\n    - [Manual Input](#manual-input)\n    - [Using the Default Proof](#using-the-default-proof)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Demo Video\n\nFor a quick and comprehensive walkthrough, watch our **YouTube demo video**:\n\n[![Demo Video](https://img.youtube.com/vi/jawnA9mwhck/0.jpg)](https://www.youtube.com/watch?v=jawnA9mwhck)\n\n*Click on the image above or [this link](https://youtu.be/k5L0-gZzzkc?si=jawnA9mwhck) to view the demo.*\n\n---\n\n## Overview\n\nThe purpose of this project is to:\n\n- Send data (e.g., ZK proofs) over a ZeroMQ socket.\n- Test the verification layer by sending sample or actual proof data.\n- Provide a simple and customizable framework for sending data using Go and ZeroMQ.\n\n---\n\n## Prerequisites\n\nBefore you begin, ensure you have met the following requirements:\n\n- **Go Programming Language**: Install Go (version 1.16 or later recommended). [Download Go](https://golang.org/dl/).\n\n- **ZeroMQ and CZMQ Libraries**: Install ZeroMQ, CZMQ, and `pkg-config` on your system.\n\n  ### macOS (Using Homebrew)\n\n  #### Install Homebrew\n\n  Homebrew is a package manager for macOS that simplifies the installation of software. If you don't have Homebrew installed, follow these steps:\n\n  1. **Open Terminal**: You can find Terminal in **Applications > Utilities**.\n\n  2. **Install Homebrew**: Run the following command in Terminal:\n\n     ```bash\n     /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"\n     ```\n\n     - **Note**: This command downloads and runs the Homebrew installation script from the official repository.\n     - **Follow Prompts**: You may be prompted to enter your password and confirm the installation. Follow the on-screen instructions.\n\n  3. **Verify Installation**:\n\n     ```bash\n     brew --version\n     ```\n\n     This should display the version of Homebrew installed.\n\n  #### Install Dependencies\n\n  With Homebrew installed, proceed to install `pkg-config`, ZeroMQ, and CZMQ:\n\n  ```bash\n  brew update\n  brew install pkg-config\n  brew install zeromq\n  brew install czmq\n  ```\n\n  ### Ubuntu/Debian\n\n  Update your package list and install the required packages:\n\n  ```bash\n  sudo apt-get update\n  sudo apt-get install -y libzmq3-dev libczmq-dev pkg-config\n  ```\n\n  ### CentOS/RHEL\n\n  First, enable the EPEL repository:\n\n  ```bash\n  sudo yum install -y epel-release\n  ```\n\n  Then, install the required packages:\n\n  ```bash\n  sudo yum install -y zeromq-devel czmq-devel pkgconfig\n  ```\n\n  ### Windows\n\n  On Windows, you can use [MSYS2](https://www.msys2.org/) to install the necessary packages.\n\n  **Steps**:\n\n  1. **Install MSYS2**: Download and install it from [https://www.msys2.org/](https://www.msys2.org/).\n\n  2. **Update Package Database**:\n\n     Open the MSYS2 MSYS terminal and run:\n\n     ```bash\n     pacman -Syuu\n     ```\n\n     Close and reopen the terminal if prompted.\n\n  3. **Install Packages**:\n\n     In the MSYS2 MinGW 64-bit terminal, run:\n\n     ```bash\n     pacman -S mingw-w64-x86_64-pkg-config\n     pacman -S mingw-w64-x86_64-zeromq\n     pacman -S mingw-w64-x86_64-czmq\n     ```\n\n  4. **Add to PATH**:\n\n     Ensure that the MinGW binaries are in your system's `PATH`. You can add the following to your environment variables:\n\n     ```\n     C:\\msys64\\mingw64\\bin\n     ```\n\n     Adjust the path if you installed MSYS2 in a different location.\n\n- **Git**: Ensure Git is installed to clone the repository.\n\n---\n\n## Installation\n\n### Clone the Repository\n\nClone this repository to your local machine:\n\n```bash\ngit clone https://github.com/layer-edge/verification-layer-tester.git\ncd verification-layer-tester\n```\n\n### Install Dependencies\n\nInstall the Go package for ZeroMQ:\n\n```bash\ngo get gopkg.in/zeromq/goczmq.v4\n```\n\n**Note**: If you encounter errors related to `pkg-config`, ensure it's installed and properly configured in your system's `PATH` (see [Troubleshooting](#troubleshooting)).\n\n---\n\n## Usage\n\n### Building the Program\n\nUse the provided `build.sh` script to build the `sample` executable:\n\n```bash\n./build.sh\n```\n\nThis script compiles `sample.go` and produces an executable named `sample`.\n\n### Running the Program\n\nUse the `run.sh` script to run the program.\n\n#### Using a Proof File\n\nIf you have a proof file (e.g., `proof.json`), you can provide it as an argument:\n\n```bash\n./run.sh proof.json\n```\n\n#### Manual Input\n\nIf you want to input the proof data manually:\n\n```bash\n./run.sh\n```\n\nWhen prompted, paste your proof data and press Enter.\n\n#### Using the Default Proof\n\nIf you run `./run.sh` and press Enter without typing anything when prompted, the program will use a default proof value defined in `sample.go`.\n\n---\n\n## Troubleshooting\n\n### Common Issues\n\n#### Error: `pkg-config`: executable file not found in $PATH\n\n**Cause**: `pkg-config` is not installed or not in your system's `PATH`.\n\n**Solution**:\n\n- **macOS**:\n\n  ```bash\n  brew install pkg-config\n  ```\n\n- **Ubuntu/Debian**:\n\n  ```bash\n  sudo apt-get install -y pkg-config\n  ```\n\n- **CentOS/RHEL**:\n\n  ```bash\n  sudo yum install -y pkgconfig\n  ```\n\n- **Windows**:\n\n  - Install MSYS2 and use `pacman` to install `pkg-config`.\n\n    ```bash\n    pacman -S mingw-w64-x86_64-pkg-config\n    ```\n\n  - Ensure `C:\\msys64\\mingw64\\bin` is added to your system's `PATH`.\n\n#### Cannot Connect to Endpoint\n\n- **Solution**:\n\n  - Verify that the endpoint in `sample.go` is correct and accessible.\n  - Replace `tcp://34.71.52.251:40000` with your own endpoint if necessary.\n\n#### Missing Dependencies\n\n- **Solution**:\n\n  - Ensure all Go packages and system libraries are installed.\n\n    ```bash\n    go get gopkg.in/zeromq/goczmq.v4\n    ```\n\n#### Permission Denied\n\n- **Solution**:\n\n  - Ensure the scripts are executable:\n\n    ```bash\n    chmod +x build.sh run.sh\n    ```\n\n#### ZeroMQ Issues\n\n- **Solution**:\n\n  - Ensure that ZeroMQ and CZMQ are properly installed on your system.\n  - Verify installation:\n\n    ```bash\n    pkg-config --modversion libzmq\n    pkg-config --modversion libczmq\n    ```\n\n### Need Help?\n\nIf you're still experiencing issues, please provide:\n\n- Error messages or logs.\n- Details about your operating system and environment.\n- Steps you've already tried.\n\nFeel free to open an issue on the repository or contact the maintainers.\n\n---\n\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. **Fork the Repository**: Click on the 'Fork' button on GitHub.\n\n2. **Clone Your Fork**:\n\n   ```bash\n   git clone https://github.com/layer-edge/verification-layer-tester.git\n   ```\n\n3. **Create a Feature Branch**:\n\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n4. **Commit Your Changes**:\n\n   ```bash\n   git commit -am 'Add some feature'\n   ```\n\n5. **Push to the Branch**:\n\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n6. **Create a Pull Request**: Open a pull request on GitHub.\n\n---\n\n## License\n\nThis project is licensed under the MIT License.\n"
  },
  {
    "path": "build.sh",
    "content": "#!/bin/bash\n\necho \"Building the sample program...\"\ngo build -o sample sample.go\n\nif [ $? -eq 0 ]; then\n    echo \"Build successful.\"\nelse\n    echo \"Build failed.\"\n    exit 1\nfi\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/layer-edge/verification-layer-tester\n\ngo 1.23\n\nrequire gopkg.in/zeromq/goczmq.v4 v4.1.0 // indirect\n"
  },
  {
    "path": "go.sum",
    "content": "gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI=\ngopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0=\n"
  },
  {
    "path": "run.sh",
    "content": "#!/bin/bash\n\nif [ -f sample ]; then\n    echo \"Running the sample program...\"\n    if [ $# -eq 1 ]; then\n        ./sample \"$1\"\n    else\n        ./sample\n    fi\nelse\n    echo \"Executable not found. Please run ./build.sh first.\"\n    exit 1\nfi\n"
  },
  {
    "path": "sample.go",
    "content": "package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"gopkg.in/zeromq/goczmq.v4\"\n    \"log\"\n    \"os\"\n    \"strings\"\n    \"time\"\n)\n\nfunc main() {\n    ep := \"tcp://34.71.52.251:40000\"\n    sample := goczmq.NewReqChanneler(ep)\n    if sample == nil {\n        log.Fatal(\"Failed to subscribe to endpoint: \", ep)\n    }\n    defer sample.Destroy()\n\n    // Prompt the user for input\n    reader := bufio.NewReader(os.Stdin)\n    fmt.Print(\"Enter proof data (or press Enter to use default): \")\n    input, _ := reader.ReadString('\\n')\n    input = strings.TrimSpace(input)\n\n    // Let the socket connect\n    time.Sleep(5 * time.Second)\n\n    // Prepare the proof data\n    var proof [][]byte\n    if input == \"\" {\n        // Use default value if no input is provided\n        proof = [][]byte{[]byte(\"proofblock\"), []byte(\"timestamp :\" + time.Now().String()), []byte(\"0x0000000000000000000\")}\n    } else {\n        // Use user-provided input\n        proof = [][]byte{[]byte(\"proofblock\"), []byte(input), []byte(\"!!!!!\")}\n    }\n\n    // Send the proof\n    sample.SendChan <- proof\n    fmt.Printf(\"Proof sent: %s\\n\", proof)\n\n    // Receive the response\n    resp := <-sample.RecvChan\n    fmt.Printf(\"Response received: %s\\n\", resp)\n}\n"
  }
]