Features
Golang

Why Go for DERO?

Golang

DERO was built from scratch in Go (Golang) - a deliberate choice that enables the unique features other blockchains can't achieve. Not a fork, not a copy - original code leveraging Go's strengths.

Written from scratch: DERO is NOT a fork. Every line of code designed specifically for homomorphic encryption, ring signatures, and private smart contracts.


Why Go Was Chosen

ReasonHow DERO Uses It
ConcurrencyThousands of P2P connections simultaneously
PerformanceFast cryptographic operations (bulletproofs, ElGamal)
Memory SafetyPrevents exploits in consensus code
Cross-PlatformRuns on Linux/Windows/Mac from same codebase
Fast CompilationQuick development iterations

Real DERO Examples

1. Concurrent P2P Connections

From source (p2p/controller.go:542-545):

// Handle thousands of connections concurrently
go func() {
    time.Sleep(2 * time.Second)
    connection.dispatch_test_handshake()
}()

Each connection runs in its own goroutine - DERO can handle 10,000+ concurrent peers effortlessly

2. Parallel Transaction Validation

From source (blockchain/transaction_verify.go):

// Validate multiple transactions in parallel
for t := range tx.Payloads {
    go func(payload_index int) {
        // Verify bulletproofs
        // Check ring signatures  
        // Validate homomorphic operations
    }(t)
}

Go's goroutines make parallel validation fast

3. Cryptographic Performance

ElGamal operations (cryptography/crypto/algebra_elgamal.go:69-74):

func (e *ElGamal) Add(addendum *ElGamal) *ElGamal {
    return ConstructElGamal(
        new(bn256.G1).Add(e.Left, addendum.Left),
        new(bn256.G1).Add(e.Right, addendum.Right))
}

Go's performance enables fast homomorphic balance updates (under 25ms)


Go vs Other Blockchain Languages

LanguageUsed ByDERO Couldn't Use Because
C++BitcoinMemory unsafe, harder to maintain
RustPolkadotSlower development, steep learning curve
SolidityEthereumSmart contract language only, not for core
Python(tools only)Too slow for blockchain consensus
GoDERO✅ Perfect fit

Key Go Features DERO Leverages

Goroutines (Lightweight Threads)

// Launch 10,000 goroutines - no problem
for i := 0; i < 10000; i++ {
    go handleConnection(conn)
}
 
// Each uses only ~2KB memory
// Total: ~20MB for 10,000 connections

Enables: Massive P2P scalability

Channels (Safe Communication)

// Thread-safe message passing
Exit_Event := make(chan bool)
 
// Signal all goroutines to stop
close(Exit_Event)

Enables: Clean shutdown, no race conditions

Built-in Crypto Libraries

import "crypto/sha256"
import "crypto/ecdsa"  
import "crypto/tls"
 
// Fast, battle-tested implementations

Enables: Secure P2P, fast hashing

Memory Safety

// Go prevents:
// - Buffer overflows
// - Use-after-free
// - Null pointer dereferences (with panic recovery)
 
// Critical for consensus code

Enables: Secure blockchain operations


DERO's Go Stack

Go version: 1.17+ (check go.mod)

Key packages used:

import "crypto/tls"           // P2P encryption
import "crypto/ecdsa"         // Certificates
import "github.com/xtaci/kcp-go/v5"  // UDP reliability
import "github.com/deroproject/derohe/cryptography/bn256"  // ElGamal

Performance Benefits

Real Measurements

OperationTimeEnabled By
Transaction validationunder 25msGo's speed + goroutines
TLS handshakes20,000/secECDSA in Go
ElGamal operations~10msOptimized Go math
P2P connections10,000+ simultaneousGoroutines

Source: README.md - Performance claims, verified in codebase


Development Advantages

Cross-Platform Compilation

# Build for all platforms from one codebase
GOOS=linux GOARCH=amd64 go build      # Linux
GOOS=windows GOARCH=amd64 go build    # Windows  
GOOS=darwin GOARCH=amd64 go build     # Mac Intel
GOOS=darwin GOARCH=arm64 go build     # Mac M1/M2

Result: Single codebase, multiple platforms

Fast Iteration

# Compile entire DERO daemon
go build cmd/derod/*.go
 
# Takes seconds, not minutes

Enables: Quick bug fixes and feature additions


DERO-Specific Examples

Homomorphic Encryption in Go

// From cryptography/crypto/algebra_elgamal.go
type ElGamal struct {
    Left  *bn256.G1  // Elliptic curve point
    Right *bn256.G1  // Elliptic curve point
}
 
// Add encrypted values (homomorphic!)
func (e *ElGamal) Add(other *ElGamal) *ElGamal {
    return ConstructElGamal(
        new(bn256.G1).Add(e.Left, other.Left),
        new(bn256.G1).Add(e.Right, other.Right))
}

Go makes complex crypto operations readable and maintainable

Concurrent Mining

// Multiple miners can connect simultaneously
for {
    conn, _ := listener.Accept()
    go handleMiner(conn)  // Each in own goroutine
}

Go's goroutines enable 10,000+ miner connections per daemon


Key Takeaways

Go enables DERO's unique features:

  • Fast cryptography - Homomorphic encryption, bulletproofs
  • Massive P2P - 10,000+ concurrent connections
  • Safe consensus - Memory safety prevents exploits
  • Quick development - Fast compilation, easy maintenance
  • Cross-platform - One codebase, all platforms

DERO wouldn't be possible in most other languages

Want to contribute? DERO's Go codebase is open source and readable. No complex macros, no manual memory management - just clean, concurrent code.


Further Reading