zcash / orchard

Implementation of the Zcash Orchard Protocol
https://zcash.github.io/orchard/
Other
54 stars 39 forks source link

Add a `Circuit` constructor #347

Open krnak opened 2 years ago

krnak commented 2 years ago

According to the #287 I need some Circuit constructor.

I prefer this API:

    /// Constructs a `Circuit` from the following components:
    /// - `merkle_path`: a merkle path witness of the `input_note`
    /// - `input_note`: a note spent in scope of of the action
    /// - `output_note`: a note created in scope of the action
    /// - `fvk`: full viewing key owning the `input_note`
    /// - `alpha`: a scalar used for randomization of the action spend validating key
    /// - `rcv`: trapdoor of the action value commitment
    ///
    /// Returns `None` if the `input_note` is not owned by the `fvk`.
    pub fn from_action_context(
        merkle_path: tree::MerklePath,
        input_note: Note,
        output_note: Note,
        fvk: FullViewingKey,
        alpha: pallas::Scalar,
        rcv: ValueCommitTrapdoor,
    ) -> Option<Circuit>;

Also some ValueCommitTrapdoor and Note constructors will be necessary.

I will add ValueCommitTrapdoor::from_bytes([u8; 32]) -> CtOption<Self>.

Note constructor can be resolved via https://github.com/zcash/orchard/pull/344

krnak commented 2 years ago

Please also consider

I didn't modify changelog in these PRs, so there will not be conflicts after merges. I will update the changelog afterwards.