✨ New: Go Implementation Post-Quantum Secure Defense-in-Depth

kMOSAIC

Multi-Oracle Structured Algebraic Intractability Composition.
The next generation of post-quantum cryptography, combining Lattices, Tensors, and Graphs.

🛡️

Triple Hardness

Combines Sparse Lattice Subset Sum, Tensor Decomposition, and Expander Graph Random Walk problems for unmatched security.

Go Gopher

High Performance

Optimized Go implementation for blazing fast key generation, encapsulation, and signing operations.

Node.js Logo Bun Logo

Cross-Platform

Available as a high-performance Go module and a flexible Node.js/Bun library for web integration.

Documentation

In-depth resources to understand the mathematics and implementation.

Getting Started

Choose your preferred language to begin.

main.go go get github.com/BackendStack21/k-mosaic-go
package main

import (
    "fmt"
    "log"
    "github.com/BackendStack21/k-mosaic-go"
    "github.com/BackendStack21/k-mosaic-go/kem"
)

func main() {
    // 1. Generate Key Pair (MOS_128)
    kp, err := kem.GenerateKeyPair(kmosaic.MOS_128)
    if err != nil {
        log.Fatal(err)
    }

    // 2. Encapsulate (Sender)
    result, _ := kem.Encapsulate(&kp.PublicKey)
    fmt.Printf("Shared Secret: %x\n", result.SharedSecret[:16])

    // 3. Decapsulate (Receiver)
    secret, _ := kem.Decapsulate(&kp.SecretKey, &kp.PublicKey, &result.Ciphertext)
    fmt.Printf("Recovered:     %x\n", secret[:16])
}
index.ts npm install k-mosaic
import { 
  kemGenerateKeyPair, 
  encapsulate, 
  decapsulate, 
  SecurityLevel 
} from 'k-mosaic';

async function main() {
  // 1. Generate Key Pair
  const { publicKey, secretKey } = await kemGenerateKeyPair(SecurityLevel.MOS_128);

  // 2. Encapsulate (Sender)
  const { ciphertext, sharedSecret } = await encapsulate(publicKey);
  console.log('Shared Secret:', sharedSecret);

  // 3. Decapsulate (Receiver)
  const recovered = await decapsulate(ciphertext, secretKey, publicKey);
  console.log('Recovered:', recovered);
}

main();

Performance Benchmarks

Comparison of core operations (MOS-128 Security Level)

Operation Go Gopher Implementation FASTEST Node.js Logo Node.js Implementation
KEM Key Generation 6.29 ms 19.70 ms
KEM Encapsulate 0.32 ms 0.52 ms
KEM Decapsulate 0.38 ms 6.32 ms
Sign Key Generation 6.22 ms 19.63 ms
Sign Message 0.012 ms 0.038 ms
Verify Signature 2.44 ms 1.45 ms

* Benchmarks run on Apple M2 Pro. Go implementation is recommended for high-performance applications.

Powerful CLI

Manage keys and operations directly from your terminal using the Go-based CLI.

go install github.com/BackendStack21/k-mosaic-go/cmd/k-mosaic-cli@latest

k-mosaic-cli kem keygen -l 128 -o keys.json
Generated MOS-128 key pair in 6.5ms. Saved to keys.json k-mosaic-cli kem encrypt -pk keys.json -m "Top Secret" -o enc.json
Message encrypted. Ciphertext saved to enc.json k-mosaic-cli sign sign -sk keys.json -pk keys.json -i contract.pdf -o sig.json
File signed successfully. Signature saved to sig.json