feat: add standalone zkvm guest target - #2
Conversation
defined(standalone) shims for platforms with no OS primitives: - sysrand: deterministic zero-fill stub (no OS CSPRNG; the zkVM circuit guarantees integrity, so side-channel blinding is unnecessary) - threadpool: route barriers/futexes/topology/threads to *_standalone single-hart implementations
Single-hart zkVM guest implementations: - panicoverride: trap loop instead of OS abort - barriers_standalone: N=1 barrier releases immediately - futexes_standalone: spin-wait degenerates to a fence with one worker - threads_standalone: createThread traps (spawn loop is empty at n=1) - topology_standalone: report one core / one available thread
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
…on function name to zkvm as well Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
…grams Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
Review Comments1.
|
Signed-off-by: Ivo Kubjas <ivo.kubjas@consensys.net>
Signed-off-by: Ivo Kubjas <ivo.kubjas@consensys.net>
|
Second review round. The guest build and archive checks pass locally and the freestanding plug looks minimal and correct — no findings there. One request:
The canonical-scalar checks are load-bearing here because |
…recompile fix: BN254 pairing precompile bypass
Thanks for the comments! I addressed them |
This PR adds the EVM precompiles and makes the library compilable to R5 standalone target.
Note
High Risk
Touches KZG trusted-setup loading, pairing correctness, and new cryptographic entry points for bare-metal builds; BN254 fix changes EVM pairing behavior for mixed infinity inputs.
Overview
Adds a freestanding RISC-V64 (rv64im) build path for zkVM guests: Nim
--os:standalonegates file I/O and stdio, a clang shim plus stub headers/standalone_stdio.csatisfy the runtime, andmake_lib_riscv64_freestandingproduceslibconstantine.riscv64.awith embedded KZG verification-only (CTT_EMBEDDED_KZG+CTT_KZG_VERIFICATION_ONLY), no threads, and an archive symbol check.Embedded KZG can load the full ceremony from a compile-time
.datblob (ctt_eth_kzg_context_new_embedded) or, in verification-only mode, only embed[τ]G2and strip prover/PeerDAS APIs viafullKzgContext/fullKzgApimacros and slimmer C headers.zkVM secp256k1 adds raw
eth_zkvm_secp256k1_ecrecover/eth_zkvm_secp256k1_verify(digest-in, strict scalar checks, newcttEVM_MalformedSignature) plusverifyFromDigestfor ECDSA.BN254 pairing (EIP-197) fixes a regression where seeing an infinity pair short-circuited the whole check to success; infinity pairs are now skipped in the product like the spec expects, with dedicated tests/vectors.
CI gains embedded-KZG test batches, BN254 pairing and zkVM secp256k1 suites, and
.gitattributesLF enforcement for the embedded setup file.Reviewed by Cursor Bugbot for commit ba2b28f. Bugbot is set up for automated code reviews on this repo. Configure here.