• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The bare minimum for high performance, fully-encrypted bidirectional RPC over TCP in Go with zero memory allocations.

monte

MIT License go.dev reference Discord Chat

The bare minimum for high performance, fully-encrypted RPC over TCP in Go.

Features

  1. Send requests, receive responses, or send messages without waiting for a response.
  2. Send from 50MiB/s to 1500MiB/s, with zero allocations per sent message or RPC call.
  3. Gracefully establish multiple client connections to a single endpoint up to a configurable limit.
  4. Set the total number of connections that may concurrently be accepted and handled by a single endpoint.
  5. Configure read/write timeouts, dial timeouts, handshake timeouts, or customize the handshaking protocol.
  6. All messages, once the handshake protocol is complete, are encrypted and non-distinguishable from each other.
  7. Supports graceful shutdowns for both client and server, with extensive tests for highly-concurrent scenarios.

Protocol

Handshake

  1. Send X25519 curve point (32 bytes) to peer.
  2. Receive X25519 curve point (32 bytes) from our peer.
  3. Multiply X25519 curve scalar with X25519 curve point received from our peer.
  4. Derive a shared key by using BLAKE-2b as a key derivation function over our scalar point multiplication result.
  5. Encrypt further communication with AES 256-bit GCM using our shared key, with a nonce counter increasing for every incoming/outgoing message.

Message Format

  1. Encrypted messages are prefixed with an unsigned 32-bit integer denoting the message's length.
  2. The decoded message content is prefixed with an unsigned 32-bit integer designating a sequence number.
  3. The sequence number is used as an identifier to identify requests/responses from one another.
  4. The sequence number 0 is reserved for requests that do not expect a response.

Benchmarks

$ cat /proc/cpuinfo | grep 'model name' | uniq
model name : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz

$ go test -bench=. -benchtime=10s
goos: linux
goarch: amd64
pkg: github.com/lithdew/monte
BenchmarkSend-8                          1814391              6690 ns/op         209.27 MB/s         115 B/op          0 allocs/op
BenchmarkSendNoWait-8                   10638730              1153 ns/op        1214.19 MB/s         141 B/op          0 allocs/op
BenchmarkRequest-8                        438381             28556 ns/op          49.03 MB/s         140 B/op          0 allocs/op
BenchmarkParallelSend-8                  4917001              2876 ns/op         486.70 MB/s         115 B/op          0 allocs/op
BenchmarkParallelSendNoWait-8           10317255              1291 ns/op        1084.78 MB/s         150 B/op          0 allocs/op
BenchmarkParallelRequest-8               1341444              8520 ns/op         164.32 MB/s         140 B/op          0 allocs/op

More Repositories

1

flatend

Quickly build microservices using p2p networking in NodeJS/Go.
TypeScript
650
star
2

rheia

A blockchain written in Zig.
Zig
246
star
3

quickjs

Go bindings to QuickJS: a fast, small, and embeddable ES2020 JavaScript interpreter.
C
147
star
4

reliable

A reliability layer for UDP connections in Go.
Go
138
star
5

pike

Async I/O for Zig
Zig
118
star
6

alon

Remix for Solana.
JavaScript
100
star
7

casso

A Go implementation of the Cassowary constraint solving algorithm.
Go
75
star
8

youtube

A library for executing search queries, retrieving metadata, and obtaining direct links to video-only/audio-only/muxed versions of videos on YouTube in Go.
Go
68
star
9

lmdb-zig

Lightweight, fully-featured, idiomatic cross-platform Zig bindings to Lightning Memory-Mapped Database (LMDB).
Zig
65
star
10

hyperia

Zig
45
star
11

snow

A small, fast, cross-platform, async Zig networking framework built on top of lithdew/pike.
Zig
36
star
12

hello

Multi-threaded cross-platform HTTP/1.1 web server example in Zig.
Zig
33
star
13

solana-zig

Write Solana programs in Zig.
Zig
24
star
14

cuckoo

A fast, vectorized Cuckoo filter implementation in Go. Zero allocations in hot paths with zero-copy binary representation.
Go
15
star
15

borsh-zig

A Zig implementation of the Borsh binary format specification.
Zig
15
star
16

kademlia-go

S/Kademlia in Go. Heavy WIP.
Go
11
star
17

nicehttp

Helper utilities for downloading files/making requests with valyala/fasthttp.
Go
9
star
18

flatlang

An embeddable human-friendly configuration language with zero keywords in Go. Heavily inspired by Google Starlark and CUE.
Go
8
star
19

usockets-zig

A fork of uSockets packaged for Zig.
Zig
8
star
20

seq

A fast implementation of sequence buffers in Go with 100% unit test coverage.
Go
7
star
21

oauth2-go

What does it take to write a minimal security-first OAuth 2.0 Server w/ OpenID Connect support in Go?
Go
6
star
22

bincode-zig

A Zig implementation of the Bincode binary format specification.
Zig
6
star
23

bytesutil

Utilities for reducing memory allocations in Go w/ 100% unit test coverage.
Go
5
star
24

boringssl-zig

A fork of boringssl packaged for Zig.
Assembly
4
star
25

recaptcha

Quickly verify reCAPTCHA v2/v3 submissions in Go.
Go
4
star
26

libuv-zig

A fork of libuv packaged for Zig.
Zig
3
star
27

rhh-ts

Robin-hood hashing vs. B+Trees in TypeScript.
TypeScript
3
star
28

uwebsockets-zig

A fork of uWebSockets packaged for Zig.
Zig
2
star
29

asciigraph

Go package to make lightweight ASCII line graph ╭┈╯ in command line apps. Mindful fork of guptarohit/asciigraph.
Go
1
star
30

ed25519-donna-zig

Minimal Zig bindings to ed25519-donna.
Zig
1
star
31

alon-sysroot

Sysroot for Alon.
C
1
star
32

sqlutil

Utilities for working with SQL in Go.
Go
1
star
33

slept

Research on reliable, high-peformance transport protocols for p2p networking.
Go
1
star