shp

module
v2.0.20251124073228+in... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2025 License: MIT

README ΒΆ

SHP v2.0 - Signed Hypertext Protocol

Electronic Document Management for the World in 600 Lines of Code

🌍 Replace PDFs with signed HTML | πŸš€ Zero complexity | πŸ”’ Maximum security | πŸ‡ΊπŸ‡¦ Built in Ukraine


The Problem

Every day, billions of documents need digital signatures:

  • πŸ›οΈ Government certificates and statements
  • πŸ₯ Medical prescriptions and records
  • πŸ’° Invoices and payment orders
  • πŸ“¦ Shipping documents and receipts
  • βš–οΈ Contracts and legal documents

Current solution: PDF + Adobe signatures = Heavy, expensive, proprietary, difficult

SHP solution: XHTML + cryptographic signature = Light, free, open, automatic


The Revolution

Traditional approach (20+ years):
β”œβ”€ Parse HTML to DOM
β”œβ”€ Canonicalize DOM structure  
β”œβ”€ Sign canonicalized form
β”œβ”€ Parse again on client
β”œβ”€ Reconstruct canonical form
└─ Verify signature
   Result: Complex, fragile, 1000+ lines of code

SHP v2.0 approach:
β”œβ”€ Generate valid XHTML
β”œβ”€ Sign raw bytes (as is!)
β”œβ”€ Verify raw bytes
└─ Browser enforces strict parsing
   Result: Simple, reliable, 600 lines of code

The insight: XHTML strict mode already guarantees structure consistency. Just sign the bytes!


Quick Start

# 1. Run server
./shp_simple -serve -port 8080

# 2. Open demo
http://localhost:8080/demo.html

# 3. See automatic verification
[SHP] βœ… Valid signature - strict XHTML mode

That's it. No complex setup, no libraries, no dependencies.


Real World Impact

πŸ“Š Statistics
Metric PDF + Signature SHP v2.0
File size 500KB - 5MB 2-10KB
Load time 3-10 seconds <100ms
Software cost $100-500/year $0
Verification Manual Automatic
Mobile friendly ⚠️ Poor βœ… Perfect
Open standard ❌ No βœ… Yes
πŸ’° Economic Impact

Global document management market: $5.55 billion/year (2024)

SHP v2.0 makes it: Free, open, automatic


Use Cases

πŸ›οΈ E-Government
<!-- Citizen requests certificate -->
GET /certificate/birth/12345

<!-- Government responds with signed XHTML -->
HTTP/1.1 200 OK
Content-Type: application/xhtml+xml
SHP-Signature: iQIzBAABCAAdFiEE...

<!-- Browser automatically verifies -->
βœ… Signature valid: Ministry of Interior
βœ… Document authentic
βœ… Can be shown anywhere, anytime
πŸ₯ Healthcare
<!-- Doctor issues prescription -->
<prescription>
  <patient>John Doe</patient>
  <medication>Amoxicillin 500mg</medication>
  <signature>Dr. Smith</signature>
</prescription>

<!-- Pharmacy receives signed XHTML -->
βœ… Doctor signature valid
βœ… Prescription authentic
βœ… Dispense medication
πŸ’° Finance
<!-- Bank issues invoice -->
<invoice>
  <amount>1000.00 USD</amount>
  <recipient>Acme Corp</recipient>
  <bank-signature>PrivatBank</bank-signature>
</invoice>

<!-- Client opens in browser -->
βœ… Bank signature valid
βœ… Amount guaranteed
βœ… Payment secure

Technical Specification

Architecture
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Server    │────────▢│    Service   │────────▢│ Browser β”‚
β”‚   (Go)      β”‚  XHTML  β”‚    Worker    β”‚  Verify β”‚ (XHTML) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  +Sig   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    βœ…   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚                        β”‚                       β”‚
      β–Ό                        β–Ό                       β–Ό
Generate XHTML           Verify bytes          Strict parse
Sign raw bytes          Block if invalid       Perfect render
Cryptography
  • Algorithm: RSA PKCS#1 v1.5
  • Hash: SHA-256
  • Key size: 2048 bits
  • Format: PEM (PKCS#1 private, SPKI public)
HTTP Headers
Content-Type: application/xhtml+xml
SHP-Signature: <base64-encoded-signature>
SHP-Algorithm: SHA256-RSA2048
SHP-Version: 2.0
SHP-Timestamp: 2025-11-24T06:24:24Z
Security Guarantees

βœ… Content integrity - Cryptographic proof that content is unmodified
βœ… Structure validity - XHTML strict mode ensures valid structure
βœ… CDN injection protection - Any modification invalidates signature
βœ… Automatic verification - Service Worker checks every request
βœ… Browser enforcement - Invalid XML = error page


Code Examples

Server (Go) - 260 lines
// Generate valid XHTML
xhtml := fmt.Sprintf(`<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head><title>%s</title></head>
  <body>%s</body>
</html>`, title, content)

// Sign raw bytes (no parsing!)
hash := sha256.Sum256([]byte(xhtml))
signature, _ := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, hash[:])

// Send with headers
w.Header().Set("SHP-Signature", base64.StdEncoding.EncodeToString(signature))
w.Header().Set("Content-Type", "application/xhtml+xml")
w.Write([]byte(xhtml))
Client (JavaScript) - 343 lines
// Service Worker intercepts response
const response = await fetch(request);
const signature = response.headers.get('SHP-Signature');

// Verify signature on raw bytes (no DOM!)
const htmlBytes = await response.arrayBuffer();
const valid = await crypto.subtle.verify(
    'RSASSA-PKCS1-v1_5',
    publicKey,
    base64ToArrayBuffer(signature),
    htmlBytes
);

// Block if invalid, pass if valid
if (valid) {
    return new Response(htmlBytes, {
        headers: {'Content-Type': 'application/xhtml+xml'}
    });
} else {
    return createBlockedResponse();
}

Total: 603 lines of code replaces multi-billion dollar industry.


Installation

Requirements
  • Go 1.22+ (server)
  • Modern browser with Service Worker support (client)
  • HTTPS or localhost (for Service Worker)
Build
# Clone repository
git clone https://github.com/ruslano69/SHP
cd SHP

# Generate keys
go run server/go/shp_simple.go -genkeys

# Run server
go run server/go/shp_simple.go -serve -port 8080

# Open browser
open http://localhost:8080/demo.html

Documentation

  • πŸ“˜ Architecture - How it works
  • πŸ”’ Security - Threat model and guarantees
  • πŸ“Š Comparison - SHP vs PDF vs other solutions
  • πŸš€ Deployment - Production setup guide
  • πŸ§ͺ Testing - Attack scenarios and verification
  • πŸ’Ό Use Cases - Real world applications

Examples


Why This Matters

For Citizens
  • βœ… Access documents anywhere, anytime
  • βœ… Automatic verification - no special software
  • βœ… Works on any device - phone, tablet, computer
  • βœ… Free - no subscription fees
For Organizations
  • βœ… Zero infrastructure cost
  • βœ… 600 lines of code - minimal maintenance
  • βœ… No vendor lock-in
  • βœ… Standards-based approach
For Developers
  • βœ… Simple implementation
  • βœ… No complex canonicalization
  • βœ… Battle-tested cryptography
  • βœ… Open source
For Society
  • βœ… Reduces paper waste
  • βœ… Accelerates bureaucracy
  • βœ… Increases transparency
  • βœ… Enables innovation

Comparison

vs PDF + Signatures
Feature PDF SHP v2.0
Complexity High (1000+ lines) Low (600 lines)
Dependencies Adobe, proprietary Browser, open
File size MB KB
Mobile Poor Perfect
Verification Manual Automatic
Cost $$$ Free
vs Blockchain "solutions"
Feature Blockchain SHP v2.0
Speed Slow (minutes) Fast (<1ms)
Cost Gas fees Free
Complexity Very high Low
Centralization Depends Standard web
Verification Complex Browser-native

Roadmap

βœ… Phase 1 (Complete)
  • v2.0 Protocol design
  • Proof of concept implementation
  • Server (Go)
  • Service Worker (JavaScript)
  • Demo page
🚧 Phase 2 (Q1 2026)
  • Academic paper
  • W3C standardization proposal
  • Pilot with Ukrainian government
  • Security audit
  • Performance benchmarks
🎯 Phase 3 (Q2-Q3 2026)
  • Government sector adoption
  • Healthcare sector adoption
  • Finance sector adoption
  • Browser vendor engagement
🌍 Phase 4 (Q4 2026+)
  • International adoption
  • Native browser support
  • Global standardization
  • Industry transformation

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Areas for contribution:

  • Server implementations (Python, Node.js, Rust, C#)
  • Additional use cases and examples
  • Documentation and translations
  • Security analysis and testing
  • Performance optimization

License

MIT License - Free for everyone, everywhere


Contact


Acknowledgments

Built during challenging times in Ukraine, proving that innovation thrives even under pressure.

Special thanks to everyone who believes that technology should be:

  • Simple - Not complicated
  • Open - Not proprietary
  • Free - Not expensive
  • Useful - Not theoretical

The Big Picture

20 years ago: "Let's make HTML signable by complex canonicalization!"
Today: "Let's just sign XHTML bytes!"

Sometimes the best solution is the simplest one.

SHP v2.0 is not just a protocol. It's a statement that web standards can solve real-world problems without complexity.


πŸš€ Star this repository if you believe in simple solutions to complex problems!

πŸ‡ΊπŸ‡¦ Made in Ukraine | 🌍 For the World | πŸ’ͺ 600 lines that matter

Directories ΒΆ

Path Synopsis
examples
government command
server
go command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL