Skip to content

ergo-nipopow: validate proof structure and extension-root binding - #917

Open
a-shannon wants to merge 12 commits into
ergoplatform:v0.30.0from
a-shannon:fix/nipopow-interlink-canonicality
Open

ergo-nipopow: validate proof structure and extension-root binding#917
a-shannon wants to merge 12 commits into
ergoplatform:v0.30.0from
a-shannon:fix/nipopow-interlink-canonicality

Conversation

@a-shannon

@a-shannon a-shannon commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • Retain canonical interlink-run validation before proof selection.
  • Authenticate disclosed interlinks against the full header extension root.
  • Reject invalid proof parameters before comparison.
  • Add complete JVM-produced proof fixtures for cross-runtime verification.
  • Match the JVM logarithm arithmetic shape when truncating superblock levels at floating-point boundaries.

Invariant

A disclosed interlink is accepted only when its Merkle proof reconstructs the full extension root committed by the header, and proof comparison is entered only with valid structural parameters.

Superblock-level calculation uses ln(x) / LN_2, matching the JVM reference arithmetic shape at the known integer boundary. This is deliberately not a claim of general bit-exact parity across math-library implementations.

Boundary parity note

For the measured requiredTarget = 2^256, realTarget = 2^251 vector, OpenJDK 17 evaluates the level as 4.999999999999972 and truncates it to 4. Native Rust f64::log2 evaluates it as exactly 5. The regression pins both outcomes.

This boundary was surfaced by Muad'Dib through SANTA conformance work and independently reproduced before adaptation to this branch.

Public API behavior note

The corrective update restores the historical exhaustive NipopowProofError variant set. Detailed proof-local validation outcomes are exposed separately through the #[non_exhaustive] NipopowValidationError returned by NipopowProof::validate.

  • valid_proof.is_better_than(&invalid_proof) returns Ok(true), preserving the historical base comparison behavior.
  • Comparing two valid proofs with different (m, k) values returns Ok(false).
  • At the stateful boundary, NipopowVerifier::process reports a valid challenger parameter mismatch as the legacy AutolykosPowSchemeError::OutOfBounds before mutation; the incumbent remains unchanged.
  • An invalid mismatched challenger is ignored with Ok(()) and cannot replace the incumbent.

Coordination

Validation

At exact head 1196317c0445ef44635e7390879c7ae973fc1f56:

  • ergo-nipopow: 61/61 passed (60 unit tests plus 1 public-error compatibility test).
  • ergo-chain-generation: 34/34 passed.
  • The boundary regression passes; replacing the helper with the prior native log2 behavior makes it fail on 251.0 != 251.00000000000003.
  • Full-root fixture matrix: 8/8.
  • JVM interoperability fixture matrix: 9/9.
  • rustfmt and strict Clippy passed for the affected targets.
  • Publication guard passed on the exact commit range.

Upstream rustfmt is green. The observed build jobs stop during dependency resolution, before compiling this change, because the v0.30.0 base still selects the yanked core2 0.4.0; #916 carries the CI/dependency migration on develop. Independent review of this new exact head remains pending.

Downstream consumer

@a-shannon a-shannon changed the title ergo-nipopow: reject non-canonical interlink runs ergo-nipopow: validate proof structure and extension-root binding Aug 6, 2026
@a-shannon
a-shannon marked this pull request as draft August 6, 2026 12:27
@a-shannon
a-shannon marked this pull request as ready for review August 6, 2026 22:39
@a-shannon

Copy link
Copy Markdown
Author

Review acknowledgement: many thanks to Muadib for the thorough initial security review, the reproducible test cases, and the independent re-audit of this exact head (bb24b1c2). The re-audit reports the prior P0/P1 findings for this surface remediated and gives this revision an APPROVE (residual nit) verdict. Formal maintainer review and applicable CI remain separate gates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant