arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
Merge branch 'main' of github-account2:vocdoni/davinci-paper
bellesmarta belles.mm@gmail.com
Sat, 28 Feb 2026 20:27:58 +0100
commit

1fd4c6893db082d8ed4ade55aaf47dbcaf16d72b

parent

10b2c75e2aa8f2cefd364d47b4942d2f2d275756

A .github/workflows/build-and-deploy.yml

@@ -0,0 +1,254 @@

+name: Build & Deploy Paper + +on: + push: + branches: ["main"] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install tools + run: | + sudo apt-get update + sudo apt-get install -y pandoc texlive-latex-recommended texlive-latex-extra texlive-bibtex-extra texlive-extra-utils poppler-utils + + - name: Build LaTeX HTML site + run: | + ./scripts/build-latex-html.sh docs ./md/ + + - name: Build final PDF + run: | + ./scripts/build-paper-pdf.sh docs/paper.pdf + + - name: Convert LaTeX to Markdown + run: | + ./scripts/convert-paper.sh docs/md + + - name: Build Markdown preview page (/md) + run: | + touch docs/.nojekyll + mkdir -p docs/md + cat << 'EOF' > docs/md/index.html + <!DOCTYPE html> + <html lang="en" data-color-mode="light" data-light-theme="light" data-dark-theme="light"> + <head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>DaVinci Paper (Markdown)</title> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.8.1/github-markdown.min.css"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css"> + <style> + :root { + color-scheme: light; + --fgColor-default: #1f2328; + --fgColor-muted: #57606a; + --fgColor-accent: #0969da; + --bgColor-default: #ffffff; + --bgColor-muted: #f6f8fa; + --borderColor-default: #d0d7de; + } + body { + margin: 0; + background: linear-gradient(180deg, #eef2f7 0%, #f6f8fa 30%, #f6f8fa 100%); + color: #1f2328; + } + .topbar { + position: sticky; + top: 0; + z-index: 2; + display: flex; + gap: 12px; + align-items: center; + padding: 12px 16px; + border-bottom: 1px solid #d0d7de; + background: rgba(255, 255, 255, 0.95); + backdrop-filter: blur(4px); + } + .topbar a { + text-decoration: none; + border: 1px solid #d0d7de; + border-radius: 6px; + padding: 6px 10px; + color: #1f2328; + background: #f6f8fa; + font: 600 14px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; + } + .markdown-body { + box-sizing: border-box; + min-width: 200px; + max-width: 980px; + margin: 14px auto 24px; + padding: 30px 28px 40px; + background: #fff; + border: 1px solid #d0d7de; + border-radius: 10px; + box-shadow: 0 10px 24px rgba(31, 35, 40, 0.07); + color: #1f2328 !important; + font-size: 17px; + line-height: 1.72; + } + .markdown-body p, + .markdown-body li, + .markdown-body blockquote, + .markdown-body td, + .markdown-body th { + color: #1f2328 !important; + } + .markdown-body h1, + .markdown-body h2, + .markdown-body h3, + .markdown-body h4, + .markdown-body h5, + .markdown-body h6 { + color: #0f172a !important; + letter-spacing: -0.01em; + } + .markdown-body a { + color: #0969da !important; + } + .markdown-body code { + color: #0550ae; + background: #f6f8fa; + } + .markdown-body pre { + background: #f6f8fa; + border: 1px solid #d0d7de; + border-radius: 8px; + } + .markdown-body img, + .markdown-body object, + .markdown-body embed { + max-width: 100% !important; + width: 100% !important; + height: auto !important; + display: block; + margin: 0 auto; + border-radius: 6px; + } + .markdown-body figure { + margin: 1.2rem 0; + max-width: 100%; + } + .markdown-body figure > img { + width: 100% !important; + } + .markdown-body figcaption { + color: #57606a !important; + font-size: 0.95rem; + } + #status { + margin-left: auto; + font: 500 13px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; + color: #57606a; + } + @media (max-width: 767px) { + .markdown-body { + margin: 0; + border-radius: 0; + border-left: none; + border-right: none; + padding: 22px 16px 30px; + font-size: 16px; + } + } + </style> + </head> + <body> + <div class="topbar"> + <a href="../">LaTeX HTML view</a> + <a href="../paper.pdf" download>Download paper.pdf</a> + <a href="paper.md" download>Download paper.md</a> + <a href="paper.md" target="_blank" rel="noopener noreferrer">Open raw markdown</a> + <span id="status">Loading markdown...</span> + </div> + <article id="content" class="markdown-body"></article> + <script src="https://cdn.jsdelivr.net/npm/marked@15.0.12/lib/marked.umd.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/dompurify@3.1.7/dist/purify.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js"></script> + <script> + (async () => { + const status = document.getElementById('status'); + const content = document.getElementById('content'); + try { + const response = await fetch('paper.md', { cache: 'no-store' }); + if (!response.ok) { + throw new Error('HTTP ' + response.status); + } + const md = await response.text(); + marked.setOptions({ gfm: true, breaks: false }); + const html = marked.parse(md); + content.innerHTML = DOMPurify.sanitize(html); + if (window.renderMathInElement) { + window.renderMathInElement(content, { + throwOnError: false, + macros: { + "\\ensuremath": "#1", + "\\sf": "\\mathsf", + "\\tt": "\\texttt" + }, + delimiters: [ + { left: '$$', right: '$$', display: true }, + { left: '$', right: '$', display: false }, + { left: '\\\\[', right: '\\\\]', display: true }, + { left: '\\\\(', right: '\\\\)', display: false } + ] + }); + } + status.textContent = 'Loaded'; + } catch (err) { + status.textContent = 'Failed to load markdown'; + content.innerHTML = '<p>Unable to render <code>paper.md</code>.</p><p>' + err.message + '</p>'; + } + })(); + </script> + </body> + </html> + EOF + + - name: Upload paper.md artifact + uses: actions/upload-artifact@v4 + with: + name: paper-markdown + path: docs/md/paper.md + if-no-files-found: error + + - name: Upload paper.pdf artifact + uses: actions/upload-artifact@v4 + with: + name: paper-pdf + path: docs/paper.pdf + if-no-files-found: error + + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs + + deploy: + runs-on: ubuntu-latest + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4
A docker/pandoc-test/Dockerfile

@@ -0,0 +1,15 @@

+FROM ubuntu:24.04 + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + pandoc \ + poppler-utils \ + texlive-latex-recommended \ + texlive-latex-extra \ + texlive-bibtex-extra \ + texlive-extra-utils \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /workspace + +CMD ["bash"]
A scripts/build-latex-html.sh

@@ -0,0 +1,56 @@

+#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT_DIR" + +OUTPUT_DIR="${1:-docs}" +MD_PATH="${2:-./md/}" +mkdir -p "$OUTPUT_DIR" + +./scripts/prepare-flattened-tex.sh + +FLAT_TEX="$ROOT_DIR/build/flat/flattened.tex" +RESOURCE_PATH="$ROOT_DIR/build/flat:$ROOT_DIR/build/flat/texsrc/build:$ROOT_DIR/build/flat/texsrc/sections:$ROOT_DIR/build/flat/texsrc/figures:$ROOT_DIR/v2/build:$ROOT_DIR/v2/sections:$ROOT_DIR/v2/figures:$ROOT_DIR/v2/bibliography" + +( + cd "$OUTPUT_DIR" + pandoc "$FLAT_TEX" \ + --from=latex+raw_tex \ + --to=html5 \ + --standalone \ + --mathjax=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js \ + --resource-path="$RESOURCE_PATH" \ + --citeproc \ + --bibliography="$ROOT_DIR/v2/bibliography/bibtex.bib" \ + --extract-media=media \ + --metadata title="DaVinci Paper" \ + -o index.html +) + +perl -0777 -i -pe " + s~</head>~<style> + :root { color-scheme: light; } + body { margin: 0 auto; max-width: 980px; padding: 26px 18px 48px; color: #1f2328; line-height: 1.72; background: #f6f8fa; } + .paper-nav { position: sticky; top: 0; z-index: 10; margin: -26px -18px 20px; padding: 10px 14px; border-bottom: 1px solid #d0d7de; background: rgba(255,255,255,0.95); backdrop-filter: blur(4px); } + .paper-nav a { display: inline-block; margin-right: 8px; text-decoration: none; border: 1px solid #d0d7de; border-radius: 6px; padding: 6px 10px; color: #1f2328; background: #f6f8fa; font: 600 14px/1.2 -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif; } + p, li, td, th, blockquote { color: #1f2328; } + h1, h2, h3, h4, h5, h6 { color: #0f172a; } + img, embed, object { max-width: 100%; width: 100% !important; height: auto !important; display: block; margin: 0 auto; border-radius: 6px; } + figure { margin: 1.2rem 0; max-width: 100%; } + figure > img { width: 100% !important; } + figcaption { color: #57606a; font-size: 0.95rem; } + pre { overflow-x: auto; background: #f6f8fa; border: 1px solid #d0d7de; border-radius: 8px; padding: 10px; } + @media (max-width: 767px) { body { padding: 14px 12px 28px; } .paper-nav { margin: -14px -12px 16px; } } + </style></head>~s; + s~<body([^>]*)>~<body\\1><div class='paper-nav'><a href='paper.pdf' download>Download paper.pdf</a><a href='$MD_PATH'>Markdown View</a><a href='${MD_PATH}paper.md' download>Download paper.md</a></div>~s; +" "$OUTPUT_DIR/index.html" + +# Ensure extracted media links are relative in deployed root page. +perl -0777 -i -pe ' + s#(?:\.\./)*docs/(?:md/)?media/#media/#g; +' "$OUTPUT_DIR/index.html" + +./scripts/postprocess-web-output.sh "$OUTPUT_DIR" "$OUTPUT_DIR/index.html" + +test -s "$OUTPUT_DIR/index.html"
A scripts/build-paper-pdf.sh

@@ -0,0 +1,70 @@

+#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT_DIR" + +OUTPUT_PDF="${1:-docs/paper.pdf}" +OUTPUT_ABS="$ROOT_DIR/$OUTPUT_PDF" +WORK_DIR="$ROOT_DIR/v2/build" + +mkdir -p "$(dirname "$OUTPUT_ABS")" + +run_or_show_log() { + local log_file="$1" + shift + if ! "$@" >"$log_file" 2>&1; then + echo "Command failed: $*" >&2 + echo "Last 200 lines from $log_file:" >&2 + tail -n 200 "$log_file" >&2 || true + return 1 + fi +} + +( + cd "$WORK_DIR" + + TEX_FILE="main.tex" + BASENAME="main" + TEMP_FINAL=0 + + # Build a non-draft PDF for website downloads without changing source files. + if grep -q '^\\documentclass\[runningheads, draft\]{llncs}' main.tex; then + sed 's/^\\documentclass\[runningheads, draft\]{llncs}/\\documentclass[runningheads]{llncs}/' main.tex > main.ci-final.tex + TEX_FILE="main.ci-final.tex" + BASENAME="main.ci-final" + TEMP_FINAL=1 + fi + + run_or_show_log "${BASENAME}.pdflatex.1.log" pdflatex -interaction=nonstopmode -halt-on-error "$TEX_FILE" + run_or_show_log "${BASENAME}.bibtex.log" bibtex "$BASENAME" + run_or_show_log "${BASENAME}.pdflatex.2.log" pdflatex -interaction=nonstopmode -halt-on-error "$TEX_FILE" + run_or_show_log "${BASENAME}.pdflatex.3.log" pdflatex -interaction=nonstopmode -halt-on-error "$TEX_FILE" + + cp "${BASENAME}.pdf" "$OUTPUT_ABS" + + if [[ "$TEMP_FINAL" -eq 1 ]]; then + rm -f \ + "${BASENAME}.tex" \ + "${BASENAME}.aux" \ + "${BASENAME}.bbl" \ + "${BASENAME}.blg" \ + "${BASENAME}.log" \ + "${BASENAME}.out" \ + "${BASENAME}.pdf" \ + "${BASENAME}.toc" \ + "${BASENAME}.xref" \ + "${BASENAME}.dvi" \ + "${BASENAME}.4ct" \ + "${BASENAME}.4tc" \ + "${BASENAME}.idv" \ + "${BASENAME}.lg" \ + "${BASENAME}.tmp" \ + "${BASENAME}.bibtex.log" \ + "${BASENAME}.pdflatex.1.log" \ + "${BASENAME}.pdflatex.2.log" \ + "${BASENAME}.pdflatex.3.log" + fi +) + +test -s "$OUTPUT_ABS"
A scripts/convert-paper.sh

@@ -0,0 +1,59 @@

+#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT_DIR" + +OUTPUT_DIR="${1:-docs/md}" +mkdir -p "$OUTPUT_DIR" + +./scripts/prepare-flattened-tex.sh + +FLAT_TEX="$ROOT_DIR/build/flat/flattened.tex" +RESOURCE_PATH="$ROOT_DIR/build/flat:$ROOT_DIR/build/flat/texsrc/build:$ROOT_DIR/build/flat/texsrc/sections:$ROOT_DIR/build/flat/texsrc/figures:$ROOT_DIR/v2/build:$ROOT_DIR/v2/sections:$ROOT_DIR/v2/figures:$ROOT_DIR/v2/bibliography" + +( + cd "$OUTPUT_DIR" + pandoc "$FLAT_TEX" \ + --from=latex+raw_tex \ + --to=gfm+tex_math_dollars \ + --wrap=none \ + --markdown-headings=atx \ + --resource-path="$RESOURCE_PATH" \ + --citeproc \ + --bibliography="$ROOT_DIR/v2/bibliography/bibtex.bib" \ + --extract-media=media \ + --strip-comments \ + -o paper.md +) + +# Clean residual LaTeX wrappers that are not useful in markdown output. +perl -0777 -i -pe ' + s/\\hyperlink\{[^{}]*\}\{([^{}]*)\}/$1/g; + s/\\hypertarget\{[^{}]*\}\{([^{}]*)\}/$1/g; + s/\\ensuremath\{/\{/g; + s/\\ensuremath\{([^{}]+)\}/$1/g; + s/\\detokenize\{([^{}]+)\}/$1/g; + s/\{\\sf\{([^{}]+)\}\}/\\texttt{$1}/g; + s/\\sf\{([^{}]+)\}/\\texttt{$1}/g; + s/\{\\tt\{([^{}]+)\}\}/\\texttt{$1}/g; + s/\\tt\{([^{}]+)\}/\\texttt{$1}/g; + s/\\text\{\\tiny\s*\\sf\s*([^{}]+)\}/\\mathrm{$1}/g; + s/\\text\{\\tiny\s*\\mathsf\{([^{}]+)\}\}/\\mathrm{$1}/g; + s/\\xspace//g; + s/\\hspace\{[^}]*\}//g; + s/\\rule\{[^}]*\}\{[^}]*\}//g; + s/\\allowbreak//g; + s/\$\$\\label\{[^}]+\}\s*/\$\$/g; + s/\\:\|\|\\:/ || /g; + s/\[\]\(#\\detokenize\{([^}]*)\}\)/$1/g; +' "$OUTPUT_DIR/paper.md" + +# Ensure media links remain relative for /md hosting. +perl -0777 -i -pe ' + s#(?:\.\./)*docs/(?:md/)?media/#media/#g; +' "$OUTPUT_DIR/paper.md" + +./scripts/postprocess-web-output.sh "$OUTPUT_DIR" "$OUTPUT_DIR/paper.md" + +test -s "$OUTPUT_DIR/paper.md"
A scripts/postprocess-web-output.sh

@@ -0,0 +1,101 @@

+#!/usr/bin/env bash +set -euo pipefail + +if [[ $# -lt 2 ]]; then + echo "usage: $0 <output-dir> <file> [file...]" >&2 + exit 1 +fi + +OUTPUT_DIR="$1" +shift +MEDIA_DIR="$OUTPUT_DIR/media" + +escape_regex() { + printf '%s' "$1" | sed -e 's/[][(){}.^$*+?|\\/]/\\&/g' +} + +escape_replacement() { + printf '%s' "$1" | sed -e 's/[\\/&]/\\&/g' +} + +replace_path() { + local target_file="$1" + local from_path="$2" + local to_path="$3" + local from_escaped to_escaped + from_escaped="$(escape_regex "$from_path")" + to_escaped="$(escape_replacement "$to_path")" + perl -0777 -i -pe "s#${from_escaped}(?=[\\\"'\\)\\s>])#${to_escaped}#g" "$target_file" +} + +# Convert PDFs to PNG for browser-friendly rendering. +if [[ -d "$MEDIA_DIR" ]] && command -v pdftoppm >/dev/null 2>&1; then + while IFS= read -r -d '' pdf_file; do + png_file="${pdf_file%.pdf}.png" + if [[ ! -f "$png_file" ]]; then + pdftoppm -singlefile -png "$pdf_file" "${pdf_file%.pdf}" >/dev/null 2>&1 || true + fi + done < <(find "$MEDIA_DIR" -type f -name '*.pdf' -print0) +fi + +# Ensure extensionless media files also have stable, browser-friendly suffixes. +if [[ -d "$MEDIA_DIR" ]] && command -v file >/dev/null 2>&1; then + while IFS= read -r -d '' raw_file; do + mime_type="$(file -b --mime-type "$raw_file" || true)" + case "$mime_type" in + image/png) normalized_file="${raw_file}.png" ;; + image/jpeg) normalized_file="${raw_file}.jpg" ;; + image/webp) normalized_file="${raw_file}.webp" ;; + image/svg+xml) normalized_file="${raw_file}.svg" ;; + application/pdf) normalized_file="${raw_file}.pdf" ;; + text/plain) normalized_file="${raw_file}.txt" ;; + *) continue ;; + esac + [[ -f "$normalized_file" ]] || cp "$raw_file" "$normalized_file" + done < <(find "$MEDIA_DIR" -type f ! -name '*.*' -print0) +fi + +for target_file in "$@"; do + [[ -f "$target_file" ]] || continue + + # Replace embeds with imgs and drop hard-coded sizing attributes. + perl -0777 -i -pe ' + s#<embed\b#<img#g; + s#\sstyle="[^"]*(?:width|height):[^"]*"##g; + s#\sstyle='\''[^'\'']*(?:width|height):[^'\'']*'\''##g; + s#\swidth="[^"]*"##g; + s#\sheight="[^"]*"##g; + ' "$target_file" + + # Rewrite .pdf links to .png only where PNG counterparts exist. + if [[ -d "$MEDIA_DIR" ]]; then + while IFS= read -r -d '' png_file; do + rel_png="${png_file#"$MEDIA_DIR"/}" + rel_base="${rel_png%.png}" + replace_path "$target_file" "media/${rel_base}.pdf" "media/${rel_png}" + done < <(find "$MEDIA_DIR" -type f -name '*.png' -print0) + + # Rewrite extensionless media paths to explicit extensions. + while IFS= read -r -d '' explicit_file; do + rel_explicit="${explicit_file#"$MEDIA_DIR"/}" + rel_base="${rel_explicit%.*}" + replace_path "$target_file" "media/${rel_base}" "media/${rel_explicit}" + done < <(find "$MEDIA_DIR" -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.webp' -o -name '*.svg' -o -name '*.pdf' -o -name '*.txt' \) -print0) + + # If pandoc emitted .so payload links, redirect to PNG when possible. + while IFS= read -r -d '' so_file; do + rel_so="${so_file#"$MEDIA_DIR"/}" + base_file="${so_file%.so}" + if [[ -f "${base_file}.png" ]]; then + replace_path "$target_file" "media/${rel_so}" "media/${rel_so%.so}.png" + elif [[ -f "${base_file}.txt" ]]; then + replace_path "$target_file" "media/${rel_so}" "media/${rel_so%.so}.txt" + fi + done < <(find "$MEDIA_DIR" -type f -name '*.so' -print0) + fi +done + +# Remove stale .so blobs from published assets. They are not needed for rendering. +if [[ -d "$MEDIA_DIR" ]]; then + find "$MEDIA_DIR" -type f -name '*.so' -delete +fi
A scripts/prepare-flattened-tex.sh

@@ -0,0 +1,101 @@

+#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT_DIR" + +mkdir -p build/flat + +TMP_TEX_ROOT="build/flat/texsrc" +rm -rf "$TMP_TEX_ROOT" +cp -R v2 "$TMP_TEX_ROOT" + +# latexpand does not resolve macro-based include prefixes like \secs/, so +# normalize them to explicit relative paths in a temporary conversion tree. +while IFS= read -r -d '' tex_file; do + sed -E \ + -e 's#\\input\{\\secs/#\\input{../sections/#g' \ + -e 's#\\input\{\\figs/#\\input{../figures/#g' \ + -e 's#\\includegraphics(\[[^]]*\])?\{\\figs/#\\includegraphics\1{../figures/#g' \ + -e 's#\\bibliography\{\\bib/#\\bibliography{../bibliography/#g' \ + "$tex_file" > "${tex_file}.tmp" + mv "${tex_file}.tmp" "$tex_file" +done < <(find "$TMP_TEX_ROOT" -type f -name '*.tex' -print0) + +# Use conversion-friendly macro styles to avoid leaking complex LaTeX wrappers. +cat >> "$TMP_TEX_ROOT/build/preamble-macros.tex" <<'EOF' +\renewcommand{\hlset}[1]{#1} +\renewcommand{\hlget}[1]{#1} +\renewcommand{\circuitstyle}[1]{\texttt{#1}\xspace} +\renewcommand{\smartcontractstyle}[1]{\texttt{#1}\xspace} +\renewcommand{\blobstyle}[1]{\texttt{#1}\xspace} +\renewcommand{\methodstyle}[1]{\texttt{#1}\xspace} +\renewcommand{\vocstyle}[1]{\texttt{#1}\xspace} +\renewcommand{\blinder}[1][]{\texttt{blinder}\xspace} +\renewcommand{\msg}[1][]{\texttt{message}\xspace} +\renewcommand{\enc}[1][]{\texttt{ciphertext}\xspace} +\renewcommand{\pk}[1][]{\texttt{pk}\xspace} +\renewcommand{\sk}[1][]{\texttt{sk}\xspace} +\renewcommand{\conc}{||} +\renewcommand{\F}{\mathbb{F}\xspace} +EOF + +# Support extensionless \includegraphics{...} paths by adding safe aliases. +# Prefer true image formats and avoid source formats like .mmd/.drawio. +if [[ -d "$TMP_TEX_ROOT/figures" ]]; then + declare -A FIGURE_BASES=() + while IFS= read -r -d '' figure_file; do + FIGURE_BASES["${figure_file%.*}"]=1 + done < <(find "$TMP_TEX_ROOT/figures" -maxdepth 1 -type f -print0) + + for figure_base in "${!FIGURE_BASES[@]}"; do + [[ -e "$figure_base" ]] && continue + for ext in png jpg jpeg webp svg pdf; do + if [[ -f "${figure_base}.${ext}" ]]; then + ln -s "$(basename "${figure_base}.${ext}")" "$figure_base" + break + fi + done + done +fi + +( + cd "$TMP_TEX_ROOT/build" + latexpand --makeatletter main.tex > "$ROOT_DIR/build/flat/flattened.tex" +) + +# Preserve references as readable labels when TeX crossrefs are unresolved. +perl -0777 -i -pe ' + s#\{../figures/#\{texsrc/figures/#g; + s/\\labelcref\{([^}]+)\}/$1/g; + s/\\eqref\{([^}]+)\}/$1/g; + s/\\ref\{([^}]+)\}/$1/g; + s/\\Cref\{([^}]+)\}/$1/g; + s/\\cref\{([^}]+)\}/$1/g; + s/\{\\sf\{([^{}]+)\}\}/\\texttt{$1}/g; + s/\\sf\{([^{}]+)\}/\\texttt{$1}/g; + s/\{\\tt\{([^{}]+)\}\}/\\texttt{$1}/g; + s/\\tt\{([^{}]+)\}/\\texttt{$1}/g; +' build/flat/flattened.tex + +# Ensure extensionless figure paths point to explicit, browser-friendly files. +if [[ -d "$TMP_TEX_ROOT/figures" ]]; then + declare -A FIGURE_BASES=() + while IFS= read -r -d '' figure_file; do + FIGURE_BASES["$(basename "${figure_file%.*}")"]=1 + done < <(find "$TMP_TEX_ROOT/figures" -maxdepth 1 -type f -print0) + + for figure_base in "${!FIGURE_BASES[@]}"; do + selected_ext="" + for ext in png jpg jpeg webp svg pdf; do + if [[ -f "$TMP_TEX_ROOT/figures/${figure_base}.${ext}" ]]; then + selected_ext="$ext" + break + fi + done + [[ -n "$selected_ext" ]] || continue + + escaped_base="$(printf '%s' "texsrc/figures/${figure_base}" | sed -e 's/[][(){}.^$*+?|\\/]/\\&/g')" + perl -0777 -i -pe "s#\\{${escaped_base}\\}#\\{texsrc/figures/${figure_base}.${selected_ext}\\}#g" build/flat/flattened.tex + done +fi
M v2/sections/cryptographic-primitives.tex → v2/sections/cryptographic-primitives.tex

@@ -328,7 +328,7 @@

\subsection{Key generation schemes} \label{sec:cryptographic-primitives:dkg} -To ensure that no single entity controls the decryption key, DAVINCI employs a \ac{DKG} protocol to jointly derive the ElGamal encryption key pair used for ballots encryption~\cite{todocitaton}. Participants who contribute to the \ac{DKG} ceremony are called \emph{\keywardens}, and they are each identified by a unique index~$i$. The outcome is a collective public key (\epk) that is published on-chain and used by voters to encrypt their ballots, while the corresponding private key is secret-shared among the \keywardens. Only a threshold number $t$ out of $n$ \keywardens can later collaborate to decrypt the tally. Unlike classical \ac{DKG} protocols where shares are exchanged in the clear, our construction uses encrypted shares and \ac{ZK-SNARK} proofs of correctness. This allows the Ethereum smart contract to verify compliance without learning any of the underlying secrets, ensuring both security and verifiability in a fully decentralized setting. +To ensure that no single entity controls the decryption key, DAVINCI employs a \ac{DKG} protocol to jointly derive the ElGamal encryption key pair used for ballots encryption~\cite{todocitation}. Participants who contribute to the \ac{DKG} ceremony are called \emph{\keywardens}, and they are each identified by a unique index~$i$. The outcome is a collective public key (\epk) that is published on-chain and used by voters to encrypt their ballots, while the corresponding private key is secret-shared among the \keywardens. Only a threshold number $t$ out of $n$ \keywardens can later collaborate to decrypt the tally. Unlike classical \ac{DKG} protocols where shares are exchanged in the clear, our construction uses encrypted shares and \ac{ZK-SNARK} proofs of correctness. This allows the Ethereum smart contract to verify compliance without learning any of the underlying secrets, ensuring both security and verifiability in a fully decentralized setting. {\color{blue} Let $t$ be the threshold parameter and $n$ the number of \keywardens, with $t\leq n$. Let $G$ be a generator of the elliptic curve group of order $q$. Each participant $P_i$ runs the following procedure.

@@ -399,4 +399,3 @@

{Zero-knowledge succinct non-interactive arguments of knowledge (ZK-SNARKs)} are a crucial component in ensuring the integrity of the election. Voters generate ZK-SNARK proofs to demonstrate that their encrypted ballots comply with the rules and constraints defined by the election parameters, without revealing any information about their choices. Similarly, sequencers produce proofs to certify the correctness of vote aggregation and state transitions throughout the protocol. {\color{blue}\hlset{\PProve}(), \hlset{\PVerify}(proof, PI) -- pkey, vkey.} All ZK circuits in \davinci are compiled using the Groth16 proof system~\cite{groth2016size}, a widely adopted ZK-SNARK construction known for its succinctness, efficient verification, and minimal proof size. Although all circuits rely on the same proving system, they are instantiated with different elliptic curves depending on the cryptographic requirements of each phase. Specifically, the vote validity circuit is compiled over the BN254 curve, the census-related circuit uses BLS12-377, and the aggregation circuit is instantiated over BW6-761. Finally, the last circuit used by the sequencer—responsible for generating the final proof of correct tallying and result—is compiled over BN254 as well, since this is the proof that is verified on-chain by the smart contract using Ethereum’s native precompiles. Further details on the circuits are provided in Section~\ref{sec:vocdoni-protocol:circuits} and a summary of the instantiations can be found in Figure~\ref{fig:circuits-flow}. -