mirror of
https://github.com/lux-apps/papers.git
synced 2026-10-30 18:15:21 +00:00
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.
51 lines
1.8 KiB
TeX
51 lines
1.8 KiB
TeX
\section{Testing Methodology}
|
|
|
|
|
|
\subsection{Four-Level Testing}
|
|
|
|
\begin{enumerate}
|
|
\item \textbf{Known-Answer Tests (KATs)}: Test against NIST/standard test vectors.
|
|
Verifies correctness for specific inputs.
|
|
\item \textbf{Fuzz Tests}: Random inputs to find panics, incorrect results, and
|
|
non-determinism.
|
|
\item \textbf{Integration Tests}: Call precompiles from Solidity via Foundry. Verifies
|
|
the full path from Solidity through the EVM to the native code and back.
|
|
\item \textbf{Cross-Platform Tests}: Run identical tests on AMD64, ARM64, and WASM.
|
|
Any output difference is a critical bug.
|
|
\end{enumerate}
|
|
|
|
\begin{lstlisting}[language=Solidity,caption={Integration test for post-quantum verification}]
|
|
function test_dilithiumVerifyFromSolidity() public {
|
|
// Known-good signature from NIST test vectors
|
|
bytes memory input = abi.encodePacked(
|
|
dilithiumPubKey,
|
|
dilithiumSignature,
|
|
testMessage
|
|
);
|
|
|
|
(bool success, bytes memory result) = address(0x0230).staticcall(input);
|
|
assertTrue(success, "precompile call failed");
|
|
|
|
uint256 verified = abi.decode(result, (uint256));
|
|
assertEq(verified, 1, "valid signature should verify");
|
|
}
|
|
|
|
function test_dilithiumRejectsInvalidSig() public {
|
|
bytes memory invalidSig = new bytes(dilithiumSignature.length);
|
|
// Zero signature should not verify
|
|
bytes memory input = abi.encodePacked(
|
|
dilithiumPubKey,
|
|
invalidSig,
|
|
testMessage
|
|
);
|
|
|
|
(bool success, bytes memory result) = address(0x0230).staticcall(input);
|
|
assertTrue(success, "precompile should not revert on invalid sig");
|
|
|
|
uint256 verified = abi.decode(result, (uint256));
|
|
assertEq(verified, 0, "invalid signature should not verify");
|
|
}
|
|
\end{lstlisting}
|
|
|
|
%% ============================================================
|