GitHunt
ZA

zametkikostik/Polygon-Immortal-Auth-SDK

The first decentralized, gasless 2FA infrastructure on Polygon. One-time payment, lifetime security. Powered by Biconomy Account Abstraction & IPFS.

πŸ›‘οΈ Polygon Immortal Auth SDK

The first decentralized, serverless, and gasless 2FA infrastructure built on Polygon & Biconomy.

License: MIT
Network: Polygon
Powered by Biconomy
Storage: IPFS


πŸš€ Overview

Polygon Immortal Auth is a "Build-and-Forget" 2FA solution. It allows users to migrate from Google Authenticator to a secure, blockchain-based vault with zero-gas fees after a one-time activation.

πŸ’Ž Key Features for Polygon Village Grants

Feature Description
⚑ Gasless UX (EIP-712) Powered by Biconomy Paymaster. Users sign messages; Businesses or Treasury pays gas
🏒 B2B Ready Corporate accounts sponsor security for employees via smart-contract whitelisting
πŸ“₯ 1-Click Migration Built-in parser for otpauth:// URIs and QR-code scanning from legacy 2FA apps
☁️ Infinite Availability Hosted on IPFS. No servers, no downtimes, no censorship
πŸ” Client-Side Privacy AES-256-GCM encryption where key is user's wallet signature (EIP-191)
πŸ’° Pay Once Model Single activation fee (2 POL), unlimited gasless operations forever

πŸ›  Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MetaMask      │────▢│   Biconomy       │────▢│   Polygon       β”‚
β”‚   (User Wallet) β”‚     β”‚   Paymaster      β”‚     β”‚   Smart Contractβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                        β”‚
         β–Ό                       β–Ό                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AES-256-GCM    β”‚     β”‚  Gas Sponsorship β”‚     β”‚  ERC-2771       β”‚
β”‚  Encryption     β”‚     β”‚  (Business/Treasury)    β”‚  Meta-Tx        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   IPFS Storage   β”‚
                        β”‚   (Encrypted)    β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Layer Technology
Smart Contract Solidity 0.8.19 (Polygon, ERC-2771 compatible)
Relayer Biconomy SDK v3 for meta-transactions
Storage Encrypted blobs on IPFS, CID stored on-chain
Frontend Pure HTML/JS/CSS (IPFS-ready, no build required)
Encryption CryptoJS AES-256-GCM with EIP-191 signature key

πŸ“¦ For Developers (SDK)

Integrate decentralized 2FA into your DApp in 3 lines of code:

import { ImmortalAuthSDK } from '@polygon/immortal-auth';

const sdk = new ImmortalAuthSDK(provider, biconomyKey);
await sdk.activate(); // One-time setup (2 POL)
const codes = await sdk.loadVault(); // Gasless!

Installation

npm install @polygon/immortal-auth

Quick Start

import { ImmortalAuthSDK } from '@polygon/immortal-auth';

// Initialize
const sdk = new ImmortalAuthSDK({
  provider: window.ethereum,
  contractAddress: '0x...',
  biconomyApiKey: 'YOUR_API_KEY',
  chainId: 137 // Polygon Mainnet
});

// Connect wallet
await sdk.connect();

// Activate vault (one-time, 2 POL)
if (!await sdk.isActivated()) {
  await sdk.activate({ value: ethers.parseEther('2') });
}

// Save vault (gasless via Biconomy)
await sdk.saveVault({
  services: [
    { name: 'Gmail', secret: 'JBSWY3DPEHPK3PXP' },
    { name: 'GitHub', secret: 'GEZDGNBVGY3TQOJQ' }
  ]
});

// Load vault (free view call)
const vault = await sdk.loadVault();
console.log(vault.services); // [{ name, secret, code }, ...]

// Generate TOTP code
const code = sdk.generateTOTP('JBSWY3DPEHPK3PXP');
console.log(code); // "123456"

πŸ— Smart Contract API

Core Functions

// Activate vault (one-time payment: 2 POL)
function activateVault() external payable;

// Save encrypted vault data (gasless via Biconomy)
function saveVault(string calldata ipfsHash) external;

// Get vault IPFS hash (free view call)
function getVault(address user) external view returns (string memory);

// Check if user has activated vault
function isActivated(address user) external view returns (bool);

// Get full vault info
function getVaultInfo(address user) external view returns (
    string memory ipfsHash,
    uint256 activatedAt,
    uint256 updatedAt,
    bool exists
);

B2B Functions

// Business deposit for employee gas sponsorship
function businessDeposit() external payable;

// Link employee to business (whitelist for gasless)
function linkEmployee(address employee) external;

// Unlink employee
function unlinkEmployee(address employee) external;

// Check if user is sponsored employee
function isEmployee(address user) external view returns (bool);

πŸ” Security Model

Encryption Flow

User Wallet β†’ signMessage("Unlock Vault") β†’ keccak256 β†’ AES-256 Key
                    β”‚
                    β–Ό
Services Array β†’ JSON.stringify β†’ AES-GCM Encrypt β†’ IPFS
                    β”‚
                    β–Ό
            Only wallet owner can decrypt

Security Guarantees

Threat Protection
Server Hack βœ… No servers. Data on IPFS (encrypted)
Contract Hack βœ… Only IPFS hashes stored. Data encrypted client-side
Key Leak βœ… Key derived from signature. Never stored/transmitted
Phishing βœ… Unique signature message per app. Can't be reused
Censorship βœ… IPFS + Blockchain. Impossible to delete

πŸ“± User Flow

Migration from Google Authenticator

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  1. Open Immortal Auth                                      β”‚
β”‚     └─> Connect MetaMask                                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  2. Activate Vault                                          β”‚
β”‚     └─> Pay 2 POL (one-time)                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  3. Migrate 2FA Codes                                       β”‚
β”‚     β”œβ”€> Option A: Scan QR from Google Auth export           β”‚
β”‚     β”œβ”€> Option B: Import otpauth-migration:// URI           β”‚
β”‚     └─> Option C: Manual entry (name + secret)              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  4. Save to Blockchain (Gasless!)                           β”‚
β”‚     └─> Sign message. Biconomy pays gas.                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  5. Done! βœ…                                                β”‚
β”‚     └─> Unlimited gasless 2FA forever                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Deployment Guide

1. Deploy Smart Contract

# Using Remix IDE
# 1. Open https://remix.ethereum.org/
# 2. Load contracts/ImmortalWeb32FA.sol
# 3. Compile with Solidity 0.8.19
# 4. Deploy:
#    - Network: Polygon Mainnet
#    - Constructor args:
#      - _trustedForwarder: 0x1D0013... (Biconomy Forwarder)
#      - _platformAddress: 0x... (Fee recipient)

2. Configure Frontend

Edit index.html:

const CONFIG = {
  CONTRACT_ADDRESS: '0xYOUR_DEPLOYED_CONTRACT',
  BICONOMY_API_KEY: 'YOUR_API_KEY_FROM_DASHBOARD',
  BICONOMY_PAYMASTER_URL: 'https://paymaster.biconomy.io/api/v1/59140/your-key',
  CHAIN_ID: 137,
  RPC_URL: 'https://polygon-rpc.com'
};

3. Deploy to IPFS

# Using Pinata
pinata pin file index.html --pinataMetadata '{"name": "Immortal Auth"}'

# Or using IPFS CLI
ipfs add -r ./www
# Copy CID: bafybeig...

4. Access via Gateway

https://ipfs.io/ipfs/bafybeig...
https://gateway.pinata.cloud/ipfs/bafybeig...

πŸ“Š Gas Cost Analysis

Operation Traditional Immortal Auth Savings
Activation ~$0.50 ~$0.50 (2 POL) 0%
Save Vault ~$0.10 $0 (Gasless) 100%
Load Vault Free (view) Free (view) -
Annual Cost (12 saves) ~$1.70 ~$0.50 70%

Note: With Biconomy sponsorship, users pay $0 after activation.


πŸ† Polygon Village Grants Alignment

Why This Project Fits

Grant Criteria How We Match
Polygon Native Built exclusively on Polygon Mainnet
Gasless Innovation Biconomy integration for meta-transactions
B2B Potential Corporate sponsorship model for employee 2FA
Migration Tool Direct import from Google/Authy ecosystems
Decentralized IPFS hosting, no centralized servers
Open Source MIT License, fully auditable code

Requested Support

  • Grant Funding: For security audit and Biconomy Paymaster credits
  • Technical Support: Polygon CDK integration for custom rollup
  • Marketing: Feature in Polygon ecosystem showcases

πŸ“– Documentation

Document Description
README.md This file - Overview & Quick Start
MIGRATION_GUIDE.md Step-by-step migration from Google/Authy
API.md Full SDK API reference
CONTRACTS.md Smart contract documentation

🀝 Contributing

# Clone repo
git clone https://github.com/polygon/immortal-auth.git

# Install dependencies
npm install

# Run tests
npm test

# Build for production
npm run build

# Deploy to IPFS
npm run deploy:ipfs

πŸ“„ License

MIT License - see LICENSE for details.


Resource URL
Website https://immortal-auth.polygon.technology
Dashboard https://dashboard.biconomy.io
Polygon https://polygon.technology
IPFS https://ipfs.tech
Documentation https://docs.immortal-auth.polygon.technology

πŸ“ž Contact


πŸ›‘οΈ Polygon Immortal Auth β€” Your Keys. Your Identity. Immortal Security.

Built with ❀️ for the Polygon Village Grants Program.

zametkikostik/Polygon-Immortal-Auth-SDK | GitHunt