Files
papers/lux-evm-precompiles/sections/10-hash-function-precompiles.tex
zeekay abf99d05fc papers: reorganize into per-paper dirs, add Antje Worring as co-author
Restructured from flat .tex/.pdf files into per-paper subdirectories.
Added Antje Worring as co-author on all papers.
Synced PDFs to pdfs/ for download site.
2026-04-18 21:50:07 -07:00

47 lines
1.5 KiB
TeX

\section{Hash Function Precompiles}
\label{sec:hash}
\subsection{BLAKE2b-256}
In addition to the standard Keccak-256 and SHA-256, Lux provides BLAKE2b-256 as a precompile for applications requiring BLAKE2b compatibility (e.g., Zcash interoperability, Substrate chains):
\begin{table}[H]
\centering
\caption{Hash function precompile comparison.}
\label{tab:hash}
\begin{tabular}{lrrr}
\toprule
\textbf{Hash Function} & \textbf{Output (B)} & \textbf{Gas (64 B input)} & \textbf{Speed (ns/byte)} \\
\midrule
Keccak-256 (native) & 32 & 30 + 6/word & 3.2 \\
SHA-256 (EIP-2) & 32 & 60 + 12/word & 2.8 \\
BLAKE2b-256 (Lux) & 32 & 25 + 5/word & 1.9 \\
BLAKE2f (EIP-152) & Variable & 1/round & 1.5 \\
\bottomrule
\end{tabular}
\end{table}
BLAKE2b is approximately 40\% faster than Keccak-256 for the same input size, reflected in lower gas costs.
\subsection{Poseidon Hash}
For zero-knowledge applications, we provide a Poseidon hash precompile that is dramatically cheaper than computing Poseidon in Solidity:
\begin{table}[H]
\centering
\caption{Poseidon precompile vs.\ Solidity implementation.}
\label{tab:poseidon}
\begin{tabular}{lrr}
\toprule
\textbf{Operation} & \textbf{Solidity Gas} & \textbf{Precompile Gas} \\
\midrule
Poseidon hash (2 inputs) & 45,000 & 3,000 \\
Poseidon hash (4 inputs) & 85,000 & 5,000 \\
Poseidon hash (8 inputs) & 165,000 & 9,000 \\
\bottomrule
\end{tabular}
\end{table}
This 15x gas reduction makes on-chain Merkle tree operations for privacy protocols and ZK rollups significantly more practical.