arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
Fix missing postprocess script and clean conversion warnings
Pau Escrich p4u@dabax.net
Fri, 27 Feb 2026 13:03:22 +0100
commit

c177ce3cabe0a8a6b4200cbe97225e35e83c8808

parent

5e2e15f9ffb5f13dd08dcf052c4dcf1c9bd34c82

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
M scripts/prepare-flattened-tex.sh → scripts/prepare-flattened-tex.sh

@@ -61,7 +61,7 @@ fi

( cd "$TMP_TEX_ROOT/build" - latexpand main.tex > "$ROOT_DIR/build/flat/flattened.tex" + latexpand --makeatletter main.tex > "$ROOT_DIR/build/flat/flattened.tex" ) # Preserve references as readable labels when TeX crossrefs are unresolved.
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}. -