nim-chat-poc/scripts/fetch_mix_librln_dylib.sh
Prem Chaitanya Prathi c9dfefa498
feat(mix): mixnet sender-anonymity for Logos Chat (static RLN, no LEZ)
Global, restart-based Required/None anonymity mode: route chat messages through the
libp2p mixnet for sender anonymity, on the logos-delivery (efafdfdc2) nwaku stack.
Static RLN spam protection; no on-chain LEZ gifter / dynamic membership.

Delivery (src/chat/delivery/waku_client.nim):
- WakuConfig.mixEnabled/mixNodes/minMixPoolSize; parseMixNodes, waitForMixPool,
  getMixPoolSize, mixReady.
- Required mode: sendBytes -> lightpushPublish(mixify=true) over the mix pool,
  fail-fast below minMixPoolSize (no relay fallback). None mode: relay publish.
  Errors propagate up to chat_send_message.
- Receive via WakuFilter (subscribe to static peers; no relay mounted), refreshed
  by a 60s keep-alive.
- Static RLN: pre-populated rln_tree.db + per-peer keystore; nodekey config to adopt
  a provisioned identity. No per-send root-convergence wait (static membership).

API / build:
- chat_get_mix_status FFI -> {mixEnabled,mixReady,mixPoolSize,minPoolSize}.
- Reproducible nix build: librln consumed as a cdylib (avoids the two-Rust-staticlib
  symbol collision); -d:libp2p_mix_experimental_exit_is_dest.
- vendor/nwaku -> efafdfdc2; vendor/nim-protobuf-serialization -> 38d24eb (0.4.0).
2026-06-25 21:45:41 +05:30

46 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Stage the mix-RLN shared library (librln.dylib / librln.so) for the host
# platform.
#
# liblogoschat also statically links libchat's Rust bundle; linking librln
# statically too puts two copies of the Rust runtime in one image and collides
# at link time (`_rust_eh_personality`, `_ffi_c_string_free`). Consuming librln
# as a cdylib keeps its runtime in its own image — nothing collides and no
# symbol surgery is needed. We pull the prebuilt shared lib from zerokit's
# stateless release (the same asset build_rln.sh uses for the static archive)
# and give it an @rpath install name so liblogoschat.dylib loads it from beside
# itself at runtime.
set -euo pipefail
out="${1:?usage: fetch_mix_librln_dylib.sh <out-path> [rln-version]}"
rln_version="${2:-v2.0.2}"
case "$(uname -s)" in
Darwin) ext="dylib" ;;
*) ext="so" ;;
esac
# Host target triple, e.g. aarch64-apple-darwin / x86_64-unknown-linux-gnu.
host_triplet="$(rustc --version --verbose | awk '/host:/{print $2}')"
tarball="${host_triplet}-stateless-rln.tar.gz"
url="https://github.com/vacp2p/zerokit/releases/download/${rln_version}/${tarball}"
work="$(mktemp -d)"
trap 'rm -rf "${work}"' EXIT
echo "Fetching mix RLN shared lib: ${url}"
curl --silent --fail-with-body -L "${url}" -o "${work}/${tarball}"
tar -xzf "${work}/${tarball}" -C "${work}"
mkdir -p "$(dirname "${out}")"
cp "${work}/release/librln.${ext}" "${out}"
chmod +w "${out}"
# Repoint the install name to @rpath so the consuming library finds it via its
# own @loader_path (we ship librln.dylib beside liblogoschat.dylib).
if [ "${ext}" = "dylib" ]; then
install_name_tool -id "@rpath/$(basename "${out}")" "${out}"
fi
echo "Staged $(basename "${out}") at ${out}"