The CuSVC Investigation: Systematic Exploration of a Proof-of-Work Challenge Generator
Introduction
In the course of a deep debugging session targeting an intermittent PSProve PoRep (Proof-of-Replication) verification failure in the Filecoin proof pipeline, a critical sub-investigation was launched. The hypothesis was that the CuSVC (ProofShare/proof service)—a proof marketplace where clients outsource SNARK computation to providers—might be generating cryptographic challenges differently from the standard proving path. If CuSVC computed SealCommitPhase1Output using different seeds, tickets, or replica_id constructions, that could explain why proofs generated through the service failed verification while standard proofs succeeded.
This article synthesizes the CuSVC exploration sub-session, a methodical investigation that spanned over twenty messages of code reading, grep searches, data inspection, and cross-codebase comparison. The investigation traced the entire challenge generation pipeline from the powsrv PoW server through the FFI boundary into the Rust cryptographic core, compared implementations across two codebases, and ultimately produced a comprehensive understanding of how CuSVC generates its proof-of-work challenges.
The Mandate: A Systematic Exploration Request
The investigation began with a detailed task assignment from the parent session ([msg 0]). The user's instructions were explicit: thoroughly explore the CuSVC challenge generation code, compare it with the standard C1 path in the curio codebase, and identify any differences in seed values, tickets, replica IDs, registered proof types, or vanilla proof construction [2]. The message was structured as a six-phase exploration blueprint, starting with locating the codebase and ending with a comprehensive comparison against known reference implementations.
The mandate reflected a sophisticated understanding of where bugs hide in distributed proof systems. Rather than asking a vague "find the problem," the user specified five concrete parameters to compare—seed, ticket, replica_id, registered_proof, and vanilla proof assembly—each of which could produce a different byte stream in the serialized SealCommitPhase1Output and cause downstream verification failures [2]. This targeted approach would prove essential in narrowing the investigation.
Finding the Target: Locating CuSVC
The first step was locating the CuSVC codebase. The assistant launched three parallel searches: ls commands on likely paths (/root/cusvc/, /home/theuser/cusvc/, ~/cusvc/), a find command sweeping the filesystem to depth 5, and a glob pattern for files within a cusvc directory [3]. This belt-and-suspenders approach reflected a methodical philosophy: use multiple independent probes, cross-validate results, and never rely on a single search method.
The searches converged on /home/theuser/cusvc/, a Go service (module github.com/curiostorage/cusvc, go 1.24.7) with a rich directory structure including cmd/ (entry points), proofs/ (proof-related logic), srv/ (HTTP server), db/ (database), ledger/ (payment tracking), and a vendored filecoin-ffi/ submodule [1]. The presence of c1.json and c1o-inner.json files in the repository root immediately signaled that C1 output data was being stored or tested locally.
Mapping the Architecture: A Proof Marketplace
The assistant's exploration of the CuSVC directory structure revealed a three-component architecture:
- cusvc (
cmd/cusvc/main.go): The main HTTP service running on port 9834, hosting client and provider APIs for the proof marketplace. - powsrv (
cmd/powsrv/main.go): A standalone HTTP server on port 2337 that continuously generates C1 (SealCommitPhase1) data using worker goroutines. - provider (
cmd/provider/): The GPU worker that connects to cusvc, fetches proof data, computes SNARKs (C2), and submits results. The architecture follows a market model: clients uploadProofData(C1 output / vanilla proofs) and request SNARK computation; providers poll for work, download proof data, compute SNARKs, and upload results. The PoW challenges serve as a sybil-resistance mechanism—providers must solve C1-based challenges before gaining work slots [1][7]. Theproofs/package contained the core business logic:provider.go(server-side proof handling),client.go(client interaction),routes.go(HTTP API),config.go(configuration), andvanillastore/(filesystem-backed vanilla proof storage). Background workers handled balance settling (bg_balance_settler.go), node watching (bg_nodewatcher.go), and work watching (bg_workwatch.go) [1].
The Heart of the System: powsrv Challenge Generation
The critical discovery came when the assistant read cmd/powsrv/main.go ([msg 4]). The generateC1Data() function (lines 41-74) revealed the exact parameters used for PoW challenge generation:
- Proof type: Hardcoded to
StackedDrg32GiBV1_1(32 GiB v1.1) - Sealed CID: A hardcoded bench sector CID (
bagboea4b5abcbx3jccdohrttzfneleehcpkmle4oltwuh4q3rcf5tpdodaoj6mtl) - Unsealed CID: A hardcoded bench sector CID (
baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq) - Ticket: Fixed to
[0x01, 0x01, ..., 0x01](32 bytes of 0x01), with the comment "match bench" - Seed: Random—generated fresh each time via
crypto/rand.Read - Miner ID: Fixed to
1000 - Sector Number: Fixed to
1 - Cache and seal paths: Pointed to a pre-sealed bench sector on disk The function calls
ffi.SealCommitPhase1with these parameters, invoking the exact same Rust cryptographic code as the standard proving path [4][7]. The powsrv runs with 5 workers (configurable viaNUM_WORKERSenv) and buffers 30 C1 outputs in a channel, continuously generating new challenges against the pre-sealed bench sector. This was a significant finding: CuSVC was not using a custom challenge derivation algorithm. It was calling the standardSealCommitPhase1Rust function with fixed (bench) sector data but a random seed. The PoW challenge was essentially a real C1 computation against a dummy sector, with the randomness of the seed providing the variability needed for proof-of-work.
Comparing Against the Standard Path
With the CuSVC challenge generation understood, the assistant pivoted to the curio codebase at /tmp/czk/ for comparison ([msg 5]). The standard GeneratePoRepVanillaProof function in /tmp/czk/lib/paths/local.go (line 1270) follows the same pattern: it acquires sector paths, checks for supraseal batch metadata, and falls through to ffi.SealCommitPhase1 with the sector's real parameters [5][7].
The proofshare client upload path in /tmp/czk/tasks/proofshare/task_client_upload_porep.go showed the standard flow for outsourced proof generation: the client gets sector info from the database, retrieves randomness from the chain beacon, calls GeneratePoRepVanillaProof with the real sector's sealed CID, unsealed CID, ticket, and seed, then wraps the result in common.ProofData and uploads it to CuSVC [5].
The comparison revealed that both paths use the same Rust FFI function. The only differences were in the input parameters:
| Parameter | CuSVC PoW | Standard Path | |-----------|-----------|---------------| | Purpose | Sybil-resistance challenge | Real on-chain proof | | Sealed CID | Hardcoded bench CID | Real sector's sealed CID | | Unsealed CID | Hardcoded bench CID | Real sector's unsealed CID | | Ticket | Fixed [1,...,1] | Chain-derived randomness | | Seed | Random (crypto/rand) | Chain beacon randomness | | Miner ID | Fixed 1000 | Real miner actor ID | | Sector Number | Fixed 1 | Real sector number |
This comparison ruled out the hypothesis that CuSVC used a different cryptographic algorithm. The divergence, if any, would have to be in the byte-level serialization or in how the Rust implementation handled the specific parameter values.
The FFI Boundary: Verifying Structural Parity
A critical step was verifying that the CuSVC fork of filecoin-ffi had not diverged from the upstream version used by curio. The assistant ran parallel grep searches for func SealCommitPhase1 across both codebases ([msg 8]), finding two matches in each: the higher-level Go wrapper in proofs.go (line 350) and the CGo binding in cgo/proofs.go (line 165) [9].
The CGo binding signatures were textually identical:
func SealCommitPhase1(registeredProof RegisteredSealProof, commR *ByteArray32, commD *ByteArray32, cacheDirPath SliceRefUint8, replicaPath SliceRefUint8, sectorId uint64, proverId *ByteArray32, ticket *ByteArray32, seed *ByteArray32, pieces SliceRefPublicPieceInfo) ([]byte, error)
Both at line 165, with the same ten parameters in the same order. This was strong evidence that the FFI layer had not been modified in the CuSVC fork [9].
A subsequent diff of the two cgo/proofs.go files ([msg 14]) confirmed that the only differences were in ClearCache and ClearSyntheticProofs signatures—unrelated utility functions. The SealCommitPhase1 implementation was identical [8].
This narrowed the investigation further: if the FFI signatures matched and the Rust code was the same (as confirmed by diffing the Rust api.rs files), then any byte-level discrepancy in C1 output must originate in the parameters passed by the caller or in the serialization format of the output.
Ground Truth: Inspecting C1 JSON Data
To validate its understanding against real artifacts, the assistant inspected the C1 JSON files in the repository root ([msg 17], [msg 18]). The c1.json file (51 MB) was a thin wrapper with three fields: SectorNum (integer), Phase1Out (string containing the inner JSON), and SectorSize (integer). The inner c1o-inner.json file (38 MB) contained the actual proof payload with seven fields: registered_proof, vanilla_proofs, comm_r, comm_d, replica_id, seed, and ticket [6][11].
The registered_proof field contained "StackedDrg32GiBV1_1", confirming the proof type. The vanilla_proofs field was a dictionary mapping proof type strings to arrays of proof components, mirroring the Rust serialization format. The cryptographic commitments (comm_r, comm_d, replica_id, seed, ticket) were all 32-byte arrays, consistent with the [32]byte types used in the Filecoin FFI [6].
This data inspection was a crucial methodological step. Source code can be misleading—comments may be outdated, types may be used differently than documented, and serialization formats may drift from their declared schemas. By inspecting actual C1 output files, the assistant grounded its understanding in empirical reality [11].
The Seed-Ticket Reversal Discovery
One of the most interesting findings came from comparing the c1o-inner.json data with the powsrv source code ([msg 19]). The JSON file showed seed: [1,1,1,...,1] and ticket: [1,1,1,...,1]—both all-0x01 bytes. But the powsrv code generated a random seed and a fixed ticket of all-0x01 bytes.
This discrepancy was explained by the provenance of the JSON files: c1o-inner.json was from a previous bench run where both seed and ticket were fixed to 0x01, while the powsrv code had been updated to use a random seed. The ticket remained fixed at 0x01 to "match bench" [4].
The assistant also investigated the user's hint about fr32 seed masking—the standard Filecoin practice of truncating seed[31] &= 0x3f to ensure the seed fits within the Fr field modulus. The assistant discovered that powsrv did not apply this truncation. However, analysis of the Rust challenge derivation code showed that the seed is used as raw bytes for SHA256, not directly as an Fr element, ruling this out as the root cause of the intermittent failure (though it remains a correctness issue in powsrv) [9].
The Supraseal Path: A Specialized Branch
The investigation also explored the supraseal batch proving path ([msg 12]). The GeneratePoRepVanillaProof function in local.go has a special branch at line 1290: if a BatchMetaFile exists in the cache directory, it delegates to supraPoRepVanillaProof instead of the standard FFI call. This path handles sectors that were sealed as part of a supraseal batch, where multiple sectors share cached data [4].
The supraPoRepVanillaProof function signature notably omits the sealed, unsealed, ticket, and seed parameters—it derives these from the batch metadata file. A supraC1Token channel (a buffered channel of size 1) acts as a synchronization primitive, serializing C1 generation for suprasealed sectors to prevent concurrent access to shared batch resources [4].
This path was relevant to the CuSVC investigation because the proof service might encounter suprasealed sectors from clients, and understanding how their C1 data is generated was essential for a complete picture.
Synthesizing the Findings
By the end of the exploration, the assistant had constructed a comprehensive understanding of CuSVC's challenge generation system:
- CuSVC uses the standard
ffi.SealCommitPhase1Rust function for generating PoW challenges, not a custom algorithm. - The FFI bindings are identical between the CuSVC fork and the upstream curio codebase, ruling out FFI-level divergence.
- The only differences are in input parameters: CuSVC uses a pre-sealed bench sector with a fixed ticket and random seed, while the standard path uses real sector data with chain-derived randomness.
- The C1 output format is standard JSON with seven fields:
registered_proof,vanilla_proofs,comm_r,comm_d,replica_id,seed, andticket. - The supraseal batch path provides an alternative C1 generation mechanism for sectors sealed in batches, with its own synchronization and parameter derivation logic. The investigation ruled out several potential causes of the PSProve PoRep failure: the FFI signatures matched, the Rust implementation was identical, the serialization format was standard, and the challenge derivation algorithm was the same. The search for the byte-level discrepancy would need to continue in other areas—perhaps in the specific parameter values passed for PSProve proof types, or in the JSON serialization/deserialization logic that wraps the C1 output for transmission between services.
Conclusion
The CuSVC exploration sub-session exemplifies methodical codebase investigation at its best. Starting from a vague hypothesis ("maybe CuSVC generates challenges differently"), the assistant systematically traced the entire challenge generation pipeline—from the Go service architecture through the FFI boundary into the Rust cryptographic core, across two codebases, and validated against real serialized data. Each step narrowed the investigation, ruling out entire categories of potential causes and focusing attention on the remaining possibilities.
The investigation demonstrated several principles of effective debugging: use multiple independent probes to locate the target, follow the code's own control flow rather than jumping randomly, compare against a known reference implementation, verify assumptions against real artifacts, and maintain awareness of the broader system architecture. These principles, applied systematically, transformed an open-ended exploration into a structured forensic analysis that produced definitive answers about how CuSVC generates its proof-of-work challenges.## References
[1] "Mapping the Territory: The First Deep Dive into CuSVC's Proof Generation Code" — Article analyzing message 3, which explored the CuSVC proofs/ package structure.
[2] "The CuSVC Exploration Mandate: A Subagent Task Message in the PSProve PoRep Investigation" — Article analyzing message 0, the task assignment that launched the CuSVC investigation.
[3] "The First Step: Systematic Discovery in the CuSVC Exploration" — Article analyzing message 1, the initial search for the cusvc directory.
[4] "Drilling into the Supraseal Path: A Focused Code Exploration in CuSVC Challenge Generation" — Article analyzing message 12, which read the supraPoRepVanillaProof function.
[5] "Reading the Standard Path: A Pivotal Data-Gathering Step in CuSVC Challenge Generation Analysis" — Article analyzing message 7, which read the standard C1 path files.
[6] "Peering into the C1 Proof Structure: A Data Inspection in the CuSVC Investigation" — Article analyzing message 18, which inspected the c1o-inner.json file structure.
[7] "The Pivot Point: Tracing C1 Challenge Generation Across CuSVC and Curio" — Article analyzing message 5, the pivot from CuSVC exploration to curio comparison.
[8] "Comparing SealCommitPhase1 Across Two Codebases: A Forensic Read in the CuSVC Investigation" — Article analyzing message 9, which compared SealCommitPhase1 implementations.
[9] "Tracing the SealCommitPhase1 Boundary: A Forensic Comparison of FFI Signatures in CuSVC" — Article analyzing message 8, which traced FFI signatures across codebases.
[10] "The Methodical Explorer: Deciphering CuSVC Through Systematic Codebase Reconnaissance" — Article analyzing message 13, which explored build infrastructure and pricing.
[11] "Grounding Code Investigation in Concrete Data: Inspecting C1 JSON Fixtures in the CuSVC Codebase" — Article analyzing message 17, which inspected the c1.json wrapper structure.