Quick start
Every language does the same thing: one request, a policy (default hybrid), and a result that tells you the negotiated key exchange and
whether it was post-quantum. Pick your language once; the tabs stay in sync across the site.
-
Build the library and start the demo server.
Terminal window cd mvpcargo build --release./target/release/unicomm server --demo-insecure # :8443 hybrid, :8446 pq-required, :8444 classical (demo only), :8088 plain (demo only)The first run creates a local CA in
mvp/certs/ca.pem. The examples below pass it asca.pem. Or skip the local server and use the public demo at muthuishere.website, which has a real certificate (leave the CA out). -
Make a request.
// Cargo.toml: unicomm_core = { package = "pq-mvp", path = "../unicomm/mvp" }fn main() {// Same options and result as the C ABI's uni_request_json. Blocking call.let r = unicomm_core::ffi::request_value(r#"{"url":"https://localhost:8443/","policy":"hybrid","ca_path":"certs/ca.pem"}"#,);println!("{} {} post_quantum={}", r["status"], r["key_exchange"], r["post_quantum"]);// on failure r["ok"] is false and r["error_code"] is one of the stable codes}// Pure Go, no cgo, no shared library. Go 1.24+ ships X25519MLKEM768 in crypto/tls.// go get github.com/muthuishere/unicomm/mvp/relay/goclientimport ("crypto/tls"; "crypto/x509"; "fmt"; "net/http"; "os""github.com/muthuishere/unicomm/mvp/relay/goclient")func main() {cfg, _ := goclient.TLSConfig(goclient.PQRequired) // Hybrid | PQRequired | Classical (no cnsa2 in Go)roots, _ := x509.SystemCertPool()pem, _ := os.ReadFile("ca.pem")roots.AppendCertsFromPEM(pem)cfg.RootCAs = rootshc := &http.Client{Transport: &http.Transport{TLSClientConfig: cfg}}res, err := hc.Get("https://localhost:8443/")if err != nil { fmt.Println("refused:", err); return }defer res.Body.Close()kx, pq := goclient.KeyExchange(*res.TLS)fmt.Println(res.StatusCode, kx, pq)}// Loads libunicomm_core through purego (no cgo). All four policies, HTTP/3.// go get github.com/muthuishere/unicomm/mvp/bindings/goimport "github.com/muthuishere/unicomm/mvp/bindings/go/unicomm"c := &unicomm.Client{CAPath: "ca.pem"} // zero value = OS trust, policy hybridr, err := c.Get("https://localhost:8443/")var ue *unicomm.Errorif errors.As(err, &ue) { log.Fatal(ue.Code, ": ", ue.Hint) }fmt.Println(r.Status, r.KeyExchange, r.PostQuantum, r.Text())// Node 24+, koffi. Package name in the repo: @deemwar/unicomm (bindings/ts).import { Client, UniCommError } from "@deemwar/unicomm";const c = new Client({ caPath: "ca.pem" }); // policy hybridtry {const r = await c.get("https://localhost:8443/");console.log(r.status, r.keyExchange, r.json());} catch (e) {if (e instanceof UniCommError) console.error(e.code, e.hint);}# Python 3.9+, ctypes. pip install ./mvp/bindings/pythonimport unicommc = unicomm.Client(ca_path="ca.pem") # policy hybrid; or policy=unicomm.PQ_REQUIREDtry:r = c.get("https://localhost:8443/")print(r.status, r.key_exchange, r.post_quantum, r.json())except unicomm.PQRequiredError as e:print("server is not post-quantum (pq-required):", e.hint)except unicomm.UniCommError as e:print(e.code, e.hint)// .NET 10, LibraryImport. dotnet pack mvp/bindings/csharp/UniCommusing Deemwar.UniComm;var c = new UniCommClient { CaPath = "ca.pem", Policy = Policy.Hybrid };try {var r = await c.GetAsync("https://localhost:8443/");Console.WriteLine($"{r.Status} {r.KeyExchange}");} catch (UniCommException e) when (e.Code == ErrorCodes.PqRequired) {Console.WriteLine(e.Hint);}// JDK 22+, FFM. Run with --enable-native-access=ALL-UNNAMEDUniComm c = UniComm.builder().caPath("ca.pem").policy(UniComm.Policy.HYBRID).build();try {UniComm.Response r = c.get("https://localhost:8443/");System.out.println(r.status() + " " + r.keyExchange());} catch (UniComm.UniCommException e) {System.err.println(e.code() + ": " + e.hint());}Terminal window # unicomm curl: curl-like, always prints key_exchange and post_quantum./target/release/unicomm curl --cacert certs/ca.pem https://localhost:8443/ # hybrid (default)./target/release/unicomm curl --require-pq https://localhost:8446/ # pq-required, fails closed./target/release/unicomm curl --http3 https://localhost:8443/ # HTTP/3./target/release/unicomm curl --policy classical https://localhost:8444/ # explicit opt-in./target/release/unicomm curl --policy cnsa2 https://localhost:8445/ # needs unicomm server --profile cnsa2 -
Read the result. Every response carries
key_exchange(for exampleX25519MLKEM768),cipher,protocol(HTTP/1.1,HTTP/2orHTTP/3), thepolicyandpost_quantum. Underhybrida classical fallback givespost_quantum = false. Underpq-requiredit is an error (PQ_REQUIRED) instead. HTTP 4xx and 5xx are not errors; they come back as responses.
- Pick the strictness you need: TLS policies.
- Bindings in detail, with the same options in every language: Bindings and errors.
- A relay or tunnel for an app behind NAT: Protocols.