Table of Contents
Zcash
Anonymous transfer, sender address, recipient address, and amount all invisible.
Transactions example:
Zero knowledge proof
The verifier could confirm that the prover computes some functions ‘F(w) = y’ correctly even without knowing the input ‘w’.
Algorithms
CreateAddress
Mint
mint the public coin to a cm,the hide , , so that we don’t know the owner of the coin. the allow us to verify the value of the corresponding coin is v.
Pour
The new coin is tied to the . Without the corresponding private key, it cannot be spent. also does not display how the value of new coin is allocated, nor does it display the corresponding public key.
Proof
instance:
witness:
- why need a? Ensure the correctness of cm and prevent the creation of non-existent cm.
 - why b? Ensure that the prover have the private key of the coin’s pk.
 - why c? Ensure that the serial number of the coin correct.
 - why d? Ensure that the coin information is legitimate and can be associated with cm.
 - why e? Same to d.
 - why f? Ensure that the is indeed the signture public key and has not been changed.
 
VerifyTransaction
Receive
Summary
Orchard
Rust Implementation of the Zcash Orchard Protocol
Key&Address
Class
mermaid
classDiagramdirection LR    class Action {        -Nullifier nf        -redpallas::VerificationKey rk        -ExtractedNoteCommitment cmx        -TransmittedNoteCiphertext encrypted_note        -ValueCommitment cv_net        -T authorization    }
    class Builder {        -Vec[SpendInfo] spends        -Vec[RecipientInfo] recipients        -Flags flags        -Anchor anchor    }
    class Bundle {        -NonEmpty[Action] actions        -Flags flags        -V value_balance        -Anchor anchor        -T authorization    }
    class Note {        -Address recipient        -NoteValue value        -Nullifier rho        -RandomSeed rseed    }
    class ActionInfo {        -SpendInfo spend        -RecipientInfo output        -ValueCommitTrapdoor rcv    }
    class RecipientInfo {        -Option[OutgoingViewingKey] ovk        -Address recipient        -NoteValue value        -Option [u8; 512] memo    }
    class SpendInfo {        -Option[SpendingKey] dummy_sk        -FullViewingKey fvk        -Scope scope        -Note note        -MerklePath merkle_path    }
    Builder *-- RecipientInfo    Builder *-- SpendInfo    SpendInfo *-- Note
    Builder --> ActionInfo : create    RecipientInfo --* ActionInfo    SpendInfo --* ActionInfo
    ActionInfo --> Action : create    Action --> Bundle : createTranscation
let shielding_bundle: Bundle<_, i64> = {        // Use the empty tree.        let anchor = MerkleHashOrchard::empty_root(32.into()).into();
        let mut builder = Builder::new(Flags::from_parts(false, true), anchor);        assert_eq!(            builder.add_recipient(None, recipient, NoteValue::from_raw(5000), None),            Ok(())        );        let unauthorized = builder.build(&mut rng).unwrap();        let sighash = unauthorized.commitment().into();        let proven = unauthorized.create_proof(&pk, &mut rng).unwrap();        proven.apply_signatures(rng, sighash, &[]).unwrap()    };
fn verify_bundle(bundle: &Bundle<Authorized, i64>, vk: &VerifyingKey) {    assert!(matches!(bundle.verify_proof(vk), Ok(())));    let sighash: [u8; 32] = bundle.commitment().into();    let bvk = bundle.binding_validating_key();    for action in bundle.actions() {        assert_eq!(action.rk().verify(&sighash, action.authorization()), Ok(()));    }    assert_eq!(        bvk.verify(&sighash, bundle.authorization().binding_signature()),        Ok(())    );}
mermaid
sequenceDiagram    participant user as User    participant BuildFn as Build Function    participant SpendInfo as SpendInfo    participant RecipientInfo as RecipientInfo    participant ActionInfo as ActionInfo    participant Bundle as Bundle
    user->>BuildFn: Call build()    activate BuildFn
    BuildFn->>SpendInfo: Extend with dummy spends    activate SpendInfo    SpendInfo-->>BuildFn: Dummy spends    deactivate SpendInfo
    BuildFn->>RecipientInfo: Extend with dummy recipients    activate RecipientInfo    RecipientInfo-->>BuildFn: Dummy recipients    deactivate RecipientInfo
    BuildFn->>BuildFn: Shuffle spends and recipients    BuildFn->>ActionInfo: Pair up spends and recipients    activate ActionInfo    ActionInfo-->>BuildFn: pre_actions (Vec<ActionInfo>)    deactivate ActionInfo
    BuildFn->>BuildFn: Calculate value_balance
    loop Build Action and Circuit        BuildFn->>ActionInfo: build()        activate ActionInfo        ActionInfo-->>BuildFn: Action, Circuit        deactivate ActionInfo    end
    BuildFn->>Bundle: Create Bundle    activate Bundle    Bundle-->>BuildFn: Bundle instance    deactivate Bundle
    deactivate BuildFn    BuildFn-->>user: Return Result<Bundle, BuildError>
    user->>Bundle: create_proof    activate Bundle    Bundle-->>user: Proven Bundle    deactivate Bundle
    user->>Bundle: apply_signatures    activate Bundle    Bundle-->>user: Signed Bundle    deactivate Bundle