# Project export: PollPass

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: TreeHacks 2024
- Tagline: Web-based integration of Crossmint's API for ZK proofs to handle verifiable credentials. The goal is to maintain the integrity of the voting process by validating user eligibility through safe means.
- Devpost: https://devpost.com/software/pollpass
- GitHub: http://github.com/bdok23/Treehacks
- Team: 1 GitHub contributor(s) — bdok23 (13 commits)

## Devpost submission (written by the team)

### Overview

A Democratic World This projects aims to counter voting fraud through the use of zero-knowledge proofs so that key information is public but private information is hidden. Draws This verifies voter eligibility and credentials without identifying personal user data. And all of the important voting information is public on the blockchain. This fundamental platform could potentially be scaled to the level of governmental organizations for use across many countries. Takeaways The project provided a cool working stack utilizing an innovative and important idea. We hope that security in such systems will become more robust through the use of advanced technologies.

## README (from the GitHub repository)

# Treehacks - PollPass
The GPT integrates with Crossmint's API for ZK proofs to handle verifiable credentials. The goal is to maintain the integrity of the voting process by validating user eligibility through safe means.


 
To update: ADD A .gitignore file


## Detected evidence (automated analysis)

Indexed codebase: 22 recognized source files, 37 KB.
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- Node.js (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (26 of 26)

```
.DS_Store
.gitattributes
a.js
app.js
b.js
createType.js
createVCCollection.js
finale.js
index.html
index2.html
indexScript.js
issueCredential.js
LICENSE
package.json
README.md
retrieveCredential.js
revokeCredential.js
script.js
server.js
style.css
styles.css
test.js
test2.js
test3.js
verifyCredential.js
voting.html
```

### Dependencies

- package.json: express@^4.18.2, node-fetch@^3.3.2

### Recent commits (newest first)

- Update README.md
- Delete charlie.js
- Delete plsdaddy.js
- fixed a.js
- ASID
- 1
- 1
- commit
- a and b update
- please
- aoisuhdoi
- ok
- nothing works
- voting.html
- index.html
- css styles
- favicon
- updated yet again
- final update
- VCCollection

## Key source files (fetched from GitHub, selected and truncated for size)

### package.json

```
{
  "name": "treehacks",
  "version": "1.0.0",
  "description": "hackathon",
  "main": "createType.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2",
    "node-fetch": "^3.3.2"
  }
}

```

### app.js

```javascript
document.getElementById('voterInfoForm').addEventListener('submit', function(event) {
    event.preventDefault(); // Prevent the default form submission

    // Capture user input
    const userData = {
        name: document.getElementById('name').value,
        age: document.getElementById('age').value,
        citizenship: document.getElementById('citizenship').value
    };

    // Send the user data to the server
    fetch('/process-voter-data', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(userData)
    })
    .then(response => response.json())
    .then(data => {
        // Display the result from the server
        document.getElementById('verificationResult').textContent = JSON.stringify(data);
    })
    .catch(error => console.error('Error:', error));
});

```

### server.js

```javascript
const express = require('express');
const bodyParser = require('body-parser');
// Assume `fetch` is available or use a node-fetch package for server-side fetch operations

const app = express();
app.use(bodyParser.json());

app.post('/process-voter-data', async (req, res) => {
    const { name, age, citizenship } = req.body;

    // Here, you would implement the logic to interact with the Crossmint API
    // This includes creating types, collections, issuing credentials based on the provided data
    // And finally, verifying the credentials

    // For demonstration, this just returns a simple message
    // In practice, you would replace this with your actual logic to interact with Crossmint and other services
    res.json({ message: "Voter processed", eligibility: age >= 18 && citizenship === "US" });
});

const PORT = 3000;
app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));

```

### script.js

```javascript
function vote(option) {
    // Perform any logic related to voting, if needed
    // For example, you might want to send the vote to a server or update a database

    // Update the styling to signify the chosen option
    const buttons = document.querySelectorAll('.voting-button');
    buttons.forEach(button => {
        if (button.textContent.includes(option)) {
            button.classList.add('chosen-option');
        } else {
            button.classList.remove('chosen-option');
        }
    });
}
```

### index2.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Voter Verification</title>
</head>
<body>
    <form id="voterInfoForm">
        <input type="text" id="name" placeholder="Your Name" required>
        <input type="number" id="age" placeholder="Your Age" required>
        <select id="citizenship" required>
            <option value="">Your Citizenship</option>
            <option value="US">US</option>
            <option value="Other">Other</option>
        </select>
        <button type="submit">Submit</button>
    </form>
    <div id="verificationResult"></div>
    <script src="app.js"></script>
</body>
</html>

```

### retrieveCredential.js

```javascript
const contractAddress = "0x0949BA9675211bcFcE7a3bB8d08cc1dfc0b0B8BD";
const tokenId = "1";
const options = {
  method: "GET",
  headers: {
    "X-API-KEY": "sk_staging_AGQCMCiEigeFJttJ3BbSjyBDbaxjMW4DB6kQ9vW2hLVaLKc36QQUWdYZHnhYvfTXS4Y9Y4w7VNke1qRStay1nkqCCK2KDpjHa2RdLx54Sm3qUfFUP4AKq5qXQLZcs5SNsFxohxZqgde8rVnJi9WGsDFVnsdVH8ABeq17m4qkGVTfYXxpyFa4CJ16V9rEUgb9SuWsTeob386JVrvQ5q5XZrrV",
  },
};

fetch(
  `https://staging.crossmint.com/api/unstable/nfts/polygon:${contractAddress}:${tokenId}/credentials`,
  options
)
  .then((response) => response.json())
  .then((response) => console.log(JSON.stringify(response)))
  .catch((err) => console.error(err));

```

### indexScript.js

```javascript
function verifyAndSubmit() {
    // Get values from the form elements
    const name = document.getElementById('name').value;
    const age = parseInt(document.getElementById('age').value);
    const citizenship = document.getElementById('citizenship').value;

    // Check eligibility conditions
    const isEligible = age >= 18 && citizenship === 'US' && jsonData.isValid;

    console.log(jsonData.isValid)

    // If eligible, redirect to voting.html
    if (isEligible) {
        alert('You are eligible! Redirecting to voting.html...');
        window.location.href = 'voting.html';
        return false; // Prevent the form from submitting
    } else {
        alert('You are not eligible.');
        return false; // Prevent the form from submitting
    }
}
```

### voting.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Voting Options</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <div class="container">
        <h1>Choose Your Vote</h1>

        <div class="voting-options">
            <button class="voting-button" onclick="vote('Option 1')">Option 1</button>
            <button class="voting-button" onclick="vote('Option 2')">Option 2</button>
            <button class="voting-button" onclick="vote('Option 3')">Option 3</button>
            <button class="voting-button" onclick="vote('Other')">Other</button>
        </div>
    </div>

    <script src="script.js" defer></script>

</body>
</html>

```

### createType.js

```javascript
const options = {
  method: "POST",
  headers: {
    "X-API-KEY": "sk_staging_AGQCMCiEigeFJttJ3BbSjyBDbaxjMW4DB6kQ9vW2hLVaLKc36QQUWdYZHnhYvfTXS4Y9Y4w7VNke1qRStay1nkqCCK2KDpjHa2RdLx54Sm3qUfFUP4AKq5qXQLZcs5SNsFxohxZqgde8rVnJi9WGsDFVnsdVH8ABeq17m4qkGVTfYXxpyFa4CJ16V9rEUgb9SuWsTeob386JVrvQ5q5XZrrV",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    credentialSubjectSchema: [
      { name: "voterID", type: "string" },
      { name: "age", type: "string" },
      { name: "citizenship", type: "string" },
      { name: "eligibleToVote", type: "bool" }
    ]
  }),
};

fetch("https://staging.crossmint.com/api/unstable/credentials/types", options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));

  
```

### createVCCollection.js

```javascript
const options = {
  method: "POST",
  headers: {
    "X-API-KEY": "sk_staging_AGQCMCiEigeFJttJ3BbSjyBDbaxjMW4DB6kQ9vW2hLVaLKc36QQUWdYZHnhYvfTXS4Y9Y4w7VNke1qRStay1nkqCCK2KDpjHa2RdLx54Sm3qUfFUP4AKq5qXQLZcs5SNsFxohxZqgde8rVnJi9WGsDFVnsdVH8ABeq17m4qkGVTfYXxpyFa4CJ16V9rEUgb9SuWsTeob386JVrvQ5q5XZrrV", // Replace with your actual API key
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    chain: "polygon",
    credentials: {
      type: "urn:uuid:7d2c35d9-6b14-49e5-bb6d-3966c11c597b" // Replace with the ID obtained after creating a credential type
    },
    metadata: {
      name: "Voter Verification Credentials 2024", // Example name, adjust as needed
      description: "Collection of verifiable credentials for voter authentication in the 2024 elections." // Example description, adjust as needed
    }
  }),
};

fetch("https://staging.crossmint.com/api/unstable/collections/", options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));

```

[10 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]