Skip to content

isitraghav/railgun

Repository files navigation

Railgun

License Version

A decentralized, encrypted, peer-to-peer database with cryptographic identity and deterministic conflict resolution.

Railgun provides a secure, distributed storage layer for decentralized applications. It combines cryptographic identity (Ed25519), content-addressable storage (Merkle Tries), and peer-to-peer networking (WebRTC) into a simple, easy-to-use API.

Documentation

Comprehensive documentation is available in the docs/ directory:

Features

  • Cryptographic Identity: Secure user accounts using Ed25519 keypairs.
  • Suffix-Based Handles: Human-readable display names with deterministic suffixes (e.g., alice#K9FQ).
  • Merkle Trie Storage: Verifiable, content-addressable data structure.
  • P2P Sync: Real-time synchronization between peers using WebRTC.
  • Data Spaces: Granular control over data visibility and mutability (all, frozen, user).
  • Platform Agnostic: Runs in Node.js (File System) and Browsers (IndexedDB).

Installation

npm install railgundb

Quick Start

import { Railgun } from 'railgundb';

// 1. Initialize
const db = await Railgun.create();

// 2. Create Identity
const { handle } = await db.signup('alice', 'my-secure-password');
console.log(`Signed up as ${handle}`);

// 3. Store Data (Encrypted)
await db.put('notes/secret', 'This is private', { space: 'user' });

// 4. Connect to Network
await db.connect('http://localhost:3000');

Signalling Server

Railgun includes a built-in signalling server for P2P discovery.

Basic Usage

npm run server
# Running on 0.0.0.0:3000

Secure WebSocket (WSS) Support

To enable WSS (required for HTTPS web deployments), provide SSL certificates via environment variables:

Option A: File Paths

export SSL_KEY_PATH="/path/to/privkey.pem"
export SSL_CERT_PATH="/path/to/fullchain.pem"
npm run server

Option B: Direct Content

export SSL_KEY="-----BEGIN PRIVATE KEY-----..."
export SSL_CERT="-----BEGIN CERTIFICATE-----..."
npm run server

License

MIT

About

A secure, distributed storage layer for decentralized applications. Platform-agnostic (Node.js & Browser).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors