tana-auth
Authentication and JWT utilities for Tana with Ed25519 signatures.
Status: ✅ TypeScript implementation complete (8/8 tests passing) | ⚙️ Rust implementation ready for WASM compilation
Features
- User-signed JWTs - Unlike traditional JWTs signed by servers, Tana JWTs are signed by users with their private keys
- Ed25519 signatures - Same crypto as Tana transactions, compatible with existing key infrastructure
- Blockchain verification - JWTs are verified against public keys stored on the blockchain (trustless)
- Dual implementation - Available for both Rust (native) and TypeScript/Bun (WASM)
Architecture
Traditional JWTs use server secrets (HS256) or server keypairs (RS256). Tana uses a different model:
┌─────────────┐ ┌──────────────┐
│ User │ │ Blockchain │
│ │ │ (Ledger) │
│ Private Key │──┐ │ │
│ Public Key │ │ │ Public Key │
└─────────────┘ │ └──────────────┘
│ ▲
│ Sign JWT │ Verify
│ with private key │ against public key
▼ │
┌────────────────┐ │
│ JWT │────────────────┘
│ (self-signed) │
└────────────────┘
This creates a git-like trust model where:
- Users sign their own credentials
- The blockchain is the source of truth for identity
- No central authority can forge JWTs
Installation
Rust
[]
= "0.1"
TypeScript/Bun
# or
Usage
TypeScript/Bun
import { create_jwt, verify_jwt } from '@tananetwork/auth'
// Create JWT signed by user's private key
const jwt = create_jwt(
"ed25519_a1b2c3...", // user's private key
"@alice", // username
90 // days until expiration
)
// Verify JWT against user's public key from blockchain
const result = verify_jwt(jwt, "ed25519_d4e5f6...")
if (result.valid) {
console.log(`JWT valid for user: ${result.username}`)
console.log(`Expires: ${new Date(result.expires_at * 1000)}`)
} else {
console.error(`JWT invalid: ${result.error}`)
}
Rust
use ;
// Create JWT signed by user's private key
let jwt = create_jwt?;
// Verify JWT
let result = verify_jwt?;
if result.valid else
Integration with Tana CLI
The Tana CLI manages user keys in ~/.config/tana/users/:
# Show current user
# Switch active user
# Generate JWT for git authentication
The CLI reads the active user's private key from config and creates a JWT that lasts 90 days. This JWT is then used for:
- Git push/pull authentication
- API access
- Build triggers
- Other automated workflows
JWT Format
Tana JWTs follow standard JWT format with EdDSA algorithm:
{header}.{payload}.{signature}
Header:
Payload:
Signature:
- Ed25519 signature of SHA-256 hash of
{header}.{payload} - Signed with user's private key
- Verified against user's public key from blockchain
Building from Source
Build Rust library
Build WASM for Node.js/Bun
# or
Build WASM for browsers
# or
Run tests
# Rust tests
# WASM tests
Publishing
Publish Rust crate
Publish NPM package
License
Dual-licensed under MIT OR Apache-2.0