fix: handle Sapling entropy failures without aborting checked calls

FE
3d ago
+675-254

The rand 0.4 OS RNG can panic while reading entropy after construction has succeeded. In a release native library (panic = 'abort'), that can terminate the calling JVM.

Seed an operation-local ChaCha20 generator through the fallible getrandom API before Sapling scalar generation, signing, or proving. Reject failed and partially written seeds without falling back to predictable bytes. Subsequent randomness comes from the seeded generator without further OS reads. Proof and signature entry points return false on entropy failure before changing context or outputs.

Add librustzcash_sapling_generate_r_checked and its C declaration. The existing void scalar ABI is retained and still aborts on failure; consumers must migrate to the checked entry point to handle failure. The companion JNI change translates false into a Java exception and preserves the Java output array. Sprout and the release panic policy are unchanged.

Validation of this branch:

  • Rust library tests: 10 passed; the parameter-dependent test is ignored by default.
  • Separately ran entropy_tests::proof_entropy_errors_with_parameters with the SDK parameter fixtures: passed, checking errors after 0/16/32 seed bytes and unchanged proof context/output.
  • Built the macOS x86_64 release static library and relinked the companion JNI source: 37 Java tests passed, including actual OS entropy-read fault injection, output preservation, and retry.
  • Rust tests also check the legacy RNG adapter against ChaCha20 and reject partial seed failures. The lockfile adds the entropy/generator dependencies and is regenerated in current Cargo format.

This is independently based on release_vm_zksnarks_4.1 at 45f8049; it does not include the ZIP32 and proof-state changes in #12. Both PRs touch proof RNG initialization, so preserve this generator when reconciling them. Linux and native macOS arm64 JNI builds were not validated in this run. This PR addresses entropy failures, not every possible native panic.

Companion integration: zksnark-java-sdk #20 pins this Rust commit and migrates scalar generation to the checked entry point. That PR is a draft until its four bundled native libraries are rebuilt and validated.