Add Sp1 Feature with deserialization methods #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔄 Pull Request
📝 Description
This PR introduces the
sp1-v3
feature tosindri-rs
which adds convenience methods for transforming structs between Sindri's proof request and response types and those in thesp1-sdk
package.The main new methods of interest to SP1 users are demonstrated in
examples/sp1-proof/main.rs
. These will automatically transform anSP1Stdin
struct into Sindri proof input. Once a proof is generated, methods are introduced to turn that Sindri proof response into theSP1ProofWithPublicValues
struct or help with clientside verification.In more generality, this PR is the start of several features which make Sindri proof responses/requests more natively compatible with the rust ZK-framework a user might be interested in:
sindri_rs::types::ProofInfo
:get_proof_as_serde_json
: The proof field of aProofInfoResponse
hasOption<Option<Value>>
type. This double_option type is used to distinguish certain cases like "a proof could exist but is not ready yet, a proof exists and is null, etc." But for most processing cases, you'd like to grab the proof or an error immediately. That's what this method does.get_proof_as_bytes
: Proofs for a few rust-based frameworks are naturally stored as bytes (withbincode
handling the packing/unpacking), but the API returns another format. For those frameworks, this method will automatically call the correct conversion back into avec<u8>
.extract_single_value
(internal): this method introduces a unified way of handling API proof responses that may consist of a single key-value pair. For some frameworks, a proof value may be interpretable on its own, but due to some initial API constraints, we added an identifying key. This method strips the key away without having to know what it was🔗 Related Tickets & Documents
📋 Type of PR (check all applicable)
💭 Developer Notes
We have found
sp1-sdk
to be very faithful in semver compatibility. While our backend supports3.0.0
and sindri-rs imports3.0.0
, we have spot checked a few other minor versions successfully. Moreover, Cargo wont let us have two simultaneous minor versions of Sp1 in our crate (even for different features).🧪 Testing Instructions
The CI workflow has been modified to test the new SP1 v3 integration feature. In the future when we have incompatible versions, we may have to test separately (and refactor default feature tests to avoid redundancy).
The new example in
examples/sp1-proof
does not yet have automated testing. We choose to punt on that until a more permanent GHA workflow is created for integration and example testing (requiring Sindri key secrets)✅ Testing Status