A production-ready ONDC BAP (Beckn Application Platform) server implementation in Rust, designed to onboard as a Network Participant in the ONDC (Open Network for Digital Commerce) ecosystem. This server provides all required endpoints for ONDC registry integration and participant onboarding.
Primary Objective: Successfully onboard as a Network Participant in the ONDC ecosystem by implementing a compliant BAP server that can:
- β Generate and serve site verification pages with Ed25519 signatures
- β Process ONDC challenge-response authentication via X25519 key exchange and AES-256-ECB decryption
- π Register with ONDC registry using
/subscribeAPI - π Support all participant types (Buyer App, Seller App, Buyer & Seller App)
- π Provide administrative endpoints for registration management
Phase 2 - Crypto Foundation: β COMPLETED
- Ed25519 signing and verification with ONDC compliance
- X25519 key exchange with secure key handling
- AES-256-ECB decryption for challenge processing
- Base64 encoding utilities and key format conversions
Phase 3 - BAP Server Core: β COMPLETED
- Axum web server with production-ready middleware stack
- Site verification endpoint (
/ondc-site-verification.html) - Challenge processing endpoint (
/on_subscribe) - Comprehensive configuration management
- Security headers, rate limiting, and error handling
Phase 4 - ONDC Protocol: π§ IN PROGRESS
- β Site verification implementation
- β Challenge processing implementation
- π Registry client implementation (Next)
- π Onboarding service orchestration
- Domain Name: Valid FQDN for your Network Participant
- SSL Certificate: Valid SSL certificate for your domain
- ONDC Whitelisting: Approval from ONDC for your subscriber_id
- Rust Environment: Rust 1.70+ with Cargo
# Clone the repository
git clone https://github.com/your-username/ondc-bap-server.git
cd ondc-bap-server
# Build the project
cargo build --release
# Run with staging configuration
ONDC_ENV=staging cargo run --bin ondc-bapCreate environment-specific configuration files:
# config/staging.toml
[server]
host = "0.0.0.0"
port = 8080
[ondc]
environment = "staging"
subscriber_id = "your-domain.com"
callback_url = "/ondc"
[keys]
signing_private_key = "base64-encoded-ed25519-private-key"
encryption_private_key = "base64-encoded-x25519-private-key"
unique_key_id = "key-1"The project follows a layered architecture with modular crates:
ondc-bap/ # Main BAP server
βββ ondc-crypto-traits/ # Core traits and error types
βββ ondc-crypto-algorithms/ # Cryptographic implementations
βββ ondc-crypto-formats/ # Encoding and format utilities
βββ ondc-crypto-cli/ # Command-line utilities
- Presentation Layer: Axum HTTP server with middleware stack
- Services Layer: Business logic for onboarding and challenge processing
- Infrastructure Layer: Configuration, logging, and external integrations
- Crypto Foundation: Secure cryptographic operations for ONDC compliance
// Generates ONDC-compliant site verification page
GET /ondc-site-verification.htmlFeatures:
- β Unique request ID generation (UUID format)
- β Ed25519 signing without hashing (ONDC requirement)
- β Proper HTML meta tag format
- β Request ID storage with TTL
// Processes ONDC challenge-response authentication
POST /on_subscribe
{
"subscriber_id": "your-domain.com",
"challenge": "base64-encoded-encrypted-challenge"
}Features:
- β X25519 key exchange with ONDC public keys
- β AES-256-ECB challenge decryption
- β Environment-specific ONDC public keys
- β Comprehensive error handling and validation
// Registry client for ONDC API integration
POST /subscribe // Participant registration
POST /v2.0/lookup // Participant lookupPlanned Features:
- π HTTP signature generation for authenticated requests
- π Retry logic with exponential backoff
- π Rate limiting compliance
- π Environment-specific registry URLs
- Memory Safety: Automatic zeroization of sensitive data
- Cryptographic Security: Ed25519/X25519/AES-256-ECB operations
- Input Validation: Comprehensive request validation
- Rate Limiting: Per-IP adaptive rate limiting
- Security Headers: Production-ready security middleware
- TLS Support: HTTPS configuration for production
- Technical Guide - Implementation details and patterns
- Architecture - System design and data flows
- Project Status - Implementation progress and roadmap
- ONDC Onboarding Guide - ONDC-specific requirements
# Build all crates
cargo build
# Build with optimizations
cargo build --release
# Run tests
cargo test
# Check code quality
cargo clippy
cargo fmt# Development environment
ONDC_ENV=staging cargo run
# Production environment
ONDC_ENV=production cargo run --release
# Custom configuration
ONDC_SUBSCRIBER_ID=your-domain.com cargo runUse the provided CLI utilities for key generation:
# Generate Ed25519 signing key pair
cargo run --bin ondc-crypto-cli -- generate-signing-keys
# Generate X25519 encryption key pair
cargo run --bin ondc-crypto-cli -- generate-encryption-keys
# Convert key formats
cargo run --bin ondc-crypto-cli -- convert-key-format# Multi-stage build for production
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bullseye-slim
COPY --from=builder /app/target/release/ondc-bap /usr/local/bin/
EXPOSE 8080
CMD ["ondc-bap"]apiVersion: apps/v1
kind: Deployment
metadata:
name: ondc-bap-server
spec:
replicas: 3
selector:
matchLabels:
app: ondc-bap-server
template:
metadata:
labels:
app: ondc-bap-server
spec:
containers:
- name: ondc-bap
image: ondc-bap-server:latest
ports:
- containerPort: 8080
env:
- name: ONDC_ENV
value: "production"- Health Checks:
/healthendpoint for system status - Metrics: Prometheus-style metrics collection
- Logging: Structured logging with tracing
- Error Tracking: Comprehensive error handling and reporting
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and ensure they pass
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
- ONDC for the specification and protocol
- Beckn Protocol for the underlying protocol
- Rust Crypto for cryptographic implementations
- Axum for the web framework
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- ONDC Support: techsupport@ondc.org
See our Project Status for detailed implementation progress.
- Registry client implementation
- Onboarding service orchestration
- Administrative API endpoints
- Integration testing with ONDC environments
- Production deployment guides
Note: This project is designed to help organizations successfully onboard as Network Participants in the ONDC ecosystem. The implementation follows ONDC specifications and best practices for secure, scalable, and maintainable BAP server development.