Skip to content

Commit

Permalink
Fix OutputProver::prepare_circuit API to be usable outside the crate
Browse files Browse the repository at this point in the history
The public APIs that produced `esk` all used the `EphemeralSecretKey`
type, but that could only be converted to a `jubjub::Scalar` inside the
crate. We now use the type-safe wrapper consistently.
  • Loading branch information
str4d committed Oct 12, 2024
1 parent 0de2402 commit eacc5a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Changed
- `sapling_crypto::prover::OutputProver::prepare_circuit` now takes `esk` as an
`sapling_crypto::keys::EphemeralSecretKey`, matching the existing public APIs
that expose it.

## [0.3.0] - 2024-10-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl PreparedOutputInfo {

// Prepare the circuit that will be used to construct the proof.
let zkproof = Pr::prepare_circuit(
encryptor.esk().0,
encryptor.esk(),
self.note.recipient(),
self.note.rcm(),
self.note.value(),
Expand Down
12 changes: 7 additions & 5 deletions src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rand_core::RngCore;
use crate::{
bundle::GrothProofBytes,
circuit::{self, GROTH_PROOF_SIZE},
keys::EphemeralSecretKey,
value::{NoteValue, ValueCommitTrapdoor},
MerklePath,
};
Expand Down Expand Up @@ -56,7 +57,7 @@ pub trait OutputProver {
///
/// Returns `None` if `diversifier` is not a valid Sapling diversifier.
fn prepare_circuit(
esk: jubjub::Fr,
esk: &EphemeralSecretKey,
payment_address: PaymentAddress,
rcm: jubjub::Fr,
value: NoteValue,
Expand Down Expand Up @@ -136,7 +137,7 @@ impl OutputProver for OutputParameters {
type Proof = Proof<Bls12>;

fn prepare_circuit(
esk: jubjub::Fr,
esk: &EphemeralSecretKey,
payment_address: PaymentAddress,
rcm: jubjub::Fr,
value: NoteValue,
Expand All @@ -153,7 +154,7 @@ impl OutputProver for OutputParameters {
value_commitment_opening: Some(value_commitment_opening),
payment_address: Some(payment_address),
commitment_randomness: Some(rcm),
esk: Some(esk),
esk: Some(esk.0),
}
}

Expand All @@ -179,6 +180,7 @@ pub mod mock {
use crate::{
bundle::GrothProofBytes,
circuit::{self, ValueCommitmentOpening, GROTH_PROOF_SIZE},
keys::EphemeralSecretKey,
value::{NoteValue, ValueCommitTrapdoor},
Diversifier, MerklePath, PaymentAddress, ProofGenerationKey, Rseed,
};
Expand Down Expand Up @@ -235,7 +237,7 @@ pub mod mock {
type Proof = GrothProofBytes;

fn prepare_circuit(
esk: jubjub::Fr,
esk: &EphemeralSecretKey,
payment_address: PaymentAddress,
rcm: jubjub::Fr,
value: NoteValue,
Expand All @@ -248,7 +250,7 @@ pub mod mock {
}),
payment_address: Some(payment_address),
commitment_randomness: Some(rcm),
esk: Some(esk),
esk: Some(esk.0),
}
}

Expand Down

0 comments on commit eacc5a4

Please sign in to comment.