#!/bin/bash # Vendor pinned libsodium source. Verifies size + sha256 before use. # Pin provenance: docs/research/v2-crypto-2026-10-31.md (S3). set -u ROOT="$(cd "$(dirname "$0")/.." && pwd)" URL="https://github.com/jedisct1/libsodium/releases/download/1.0.22-RELEASE/libsodium-1.0.22.tar.gz" WANT_SHA="adbdd8f16149e81ac6078a03aca6fc03b592b89ef7b5ed83841c086191be3349" WANT_SIZE=2008529 DEST="$ROOT/third_party/libsodium.tar.gz" mkdir -p "$ROOT/third_party" if [ ! -f "$DEST" ]; then curl -sL -f -o "$DEST" "$URL" || { echo "download failed" >&2; exit 1; } fi SIZE=$(stat -c%s "$DEST") [ "$SIZE" = "$WANT_SIZE" ] || { echo "size mismatch: $SIZE want $WANT_SIZE" >&2; exit 1; } GOT_SHA=$(sha256sum "$DEST" | cut -d' ' -f1) [ "$GOT_SHA" = "$WANT_SHA" ] || { echo "sha256 mismatch: $GOT_SHA" >&2; exit 1; } echo "VENDOR-OK libsodium-1.0.22 size=$SIZE sha256=$GOT_SHA"