|
| 1 | +Zcash ledger, first connect: |
| 2 | +- Address generation |
| 3 | +- Sharing address with host |
| 4 | +- Sharing IVK with host |
| 5 | +//TODO: change to APDU API |
| 6 | +```mermaid |
| 7 | + sequenceDiagram |
| 8 | + participant LF as Ledger flash storage |
| 9 | + participant LC as Ledger computation |
| 10 | + participant H as Host |
| 11 | + participant N as Network |
| 12 | + H ->> LC: compute_address(path: u32) |
| 13 | + activate LC |
| 14 | + LC -->> LF: store_ivk(ivk) ? |
| 15 | + Note over LF: potentially store (path, IVK) |
| 16 | + LC ->> H: address: (diversifier, pk_d) |
| 17 | + LC ->> H: incoming viewing key: ivk |
| 18 | + deactivate LC |
| 19 | + Note over H,LC: show address on both screens? |
| 20 | +``` |
| 21 | + |
| 22 | +Zcash ledger, syncing |
| 23 | +- Sharing IVK with host |
| 24 | +- Decrypt incoming notes and verification note commitments |
| 25 | +- TODO: what to do with matching notes? |
| 26 | +```mermaid |
| 27 | + sequenceDiagram |
| 28 | + participant LF as Ledger flash storage |
| 29 | + participant LC as Ledger computation |
| 30 | + participant H as Host |
| 31 | + participant N as Network |
| 32 | + H ->> LC: get_ivk(path: u32) |
| 33 | + #add minor confirmation |
| 34 | + activate LC |
| 35 | + LC -->> LF: retrieve_ivk(path) ? |
| 36 | + LF -->> LC: ivk ? |
| 37 | + Note over LC: compute_ivk(path) |
| 38 | + LC ->> H: ivk |
| 39 | + deactivate LC |
| 40 | + activate H |
| 41 | + H ->> N: get_unspend_notes() |
| 42 | + N ->> H: [unspend_notes] |
| 43 | + Note over H: [matching_notes] = decrypt_all_unspend_notes(ivk, [unspend_notes]) |
| 44 | + Note over H: store [matching_notes] (d, pk_d, v, rcm) |
| 45 | + deactivate H |
| 46 | +``` |
| 47 | + |
| 48 | +Zcash ledger, make shielded transaction phase 1 |
| 49 | +- Verify outputs on screen |
| 50 | + |
| 51 | +```mermaid |
| 52 | + sequenceDiagram |
| 53 | + participant LF as Ledger flash storage |
| 54 | + participant LC as Ledger computation |
| 55 | + participant H as Host |
| 56 | + participant N as Network |
| 57 | +
|
| 58 | + Note over H: show amount, address, memo-fields per output |
| 59 | + Note over H: validate amount <= total_amount |
| 60 | + H ->> LC: initiate_transaction() |
| 61 | +N ->> H: anchor of note? |
| 62 | +N ->> H: metadata |
| 63 | +Note over H: input note selection (path, note) |
| 64 | +
|
| 65 | + activate LC |
| 66 | + loop Every output note |
| 67 | + H ->> LC: verify_output(d, pk_d, value, memo) |
| 68 | + Note over H,LC: approve amount and address and verify on screens |
| 69 | + Note over H,LC: approve hash of memo and verify on screens |
| 70 | + LC ->> H: approval of output |
| 71 | + LC ->> LF: store_output_data(d,pk_d,value,memo) |
| 72 | + end |
| 73 | + deactivate LC |
| 74 | + #compute value balance and approve |
| 75 | + Note over LC,H: continue if all approved |
| 76 | + ``` |
| 77 | + |
| 78 | + Zcash ledger, make shielded transaction phase 2 |
| 79 | +- Process outputs and store in flash |
| 80 | +- Compute hash of all outputs |
| 81 | + |
| 82 | +```mermaid |
| 83 | + sequenceDiagram |
| 84 | + participant LF as Ledger flash storage |
| 85 | + participant LC as Ledger computation |
| 86 | + participant H as Host |
| 87 | + participant N as Network |
| 88 | + activate LC |
| 89 | + loop Every output note |
| 90 | + H ->> LC: make_transaction(path) #TODO: which path??? fixed one makes sense?? |
| 91 | + Note over LC: compute random rcm |
| 92 | + LC ->> LF: update_rcmnew(rcm) |
| 93 | + LF ->> LC: (d,pk_d,value) |
| 94 | + Note over LC: compute value/note commitments |
| 95 | + LC ->> LF: update_valuecommitsum(vc) |
| 96 | + LC ->> LF: value/note commitments |
| 97 | + LC ->> H: value/note commitments |
| 98 | + LF ->> LC: d,pk_d, value, memo |
| 99 | + Note over LC: compute eph, c_out, c_enc |
| 100 | + LC ->> LF: eph, c_out, c_enc |
| 101 | + LC ->> H: eph, c_out, c_enc |
| 102 | + deactivate LC |
| 103 | + activate H |
| 104 | + H -->> LC: get_proof_key(path) #is this necessary? |
| 105 | + LC -->> H: proof_key |
| 106 | + Note over H: ZK proof of output note |
| 107 | + H ->> LC: zk_proof |
| 108 | + deactivate H |
| 109 | + activate LC |
| 110 | + LC ->> LF: zk_proof |
| 111 | + end |
| 112 | + Note over LC: perform shieldedoutput_hash |
| 113 | + LC ->> H: shielded_output_hash |
| 114 | + LC ->> LF: shielded_output_hash |
| 115 | + deactivate LC |
| 116 | + ``` |
| 117 | + |
| 118 | +Zcash ledger, make shielded transaction phase 3 |
| 119 | +- Process spends and store in flash |
| 120 | +- Store RCM values in flash |
| 121 | +- Compute hash of all outputs |
| 122 | + |
| 123 | +```mermaid |
| 124 | + sequenceDiagram |
| 125 | + participant LF as Ledger flash storage |
| 126 | + participant LC as Ledger computation |
| 127 | + participant H as Host |
| 128 | + participant N as Network |
| 129 | + loop Every spend note |
| 130 | + N ->> H: anchor of note? |
| 131 | + H ->> LC: spend_this_note(path, valuecommit, rcm, anchor) # Do we need to verify here that rcm is correct? Is the zkproof of the spend the old one in the blockchain? #what about the valuecommit? |
| 132 | + LC ->> LF: (path, valuecommit, anchor) |
| 133 | + LC -->> H: proof_gen_key(path) ? #is this needed |
| 134 | +
|
| 135 | + activate LC |
| 136 | + LC ->> LF: update_rcmvalue(rcm) |
| 137 | + LC ->> LF: update_valuecommitsum(vc) #??? |
| 138 | +
|
| 139 | + note over LC: compute nullifier |
| 140 | + LC ->> H: nullifier |
| 141 | + LC ->> LF: nullifier |
| 142 | +
|
| 143 | + note over LC: compute randomized verification key |
| 144 | + LC ->> H: randomized verification key |
| 145 | + LC ->> LF: (path, randomizer value, randomized verification key) |
| 146 | + deactivate LC |
| 147 | +
|
| 148 | + Note over H: ZK proof of spend note |
| 149 | + H ->> LC: zk_proof |
| 150 | + LC ->> LF: zk_proof |
| 151 | +
|
| 152 | + end |
| 153 | + Note over LC: perform shieldedspend_hash |
| 154 | + LC ->> LF: shieldedspend_hash #does the host actually need this? |
| 155 | + LC ->> H: shieldedspend_hash |
| 156 | +``` |
| 157 | + |
| 158 | +Zcash ledger, make shielded transaction phase 4 |
| 159 | +- Host gives all remaining transaction (meta) data |
| 160 | +- Ledger does the complete TX_HASH_ALL |
| 161 | +- Final approval of transaction? |
| 162 | +- Ledger signs the necessary parts and shares with host |
| 163 | +- Host sends transaction blob to network |
| 164 | + |
| 165 | +```mermaid |
| 166 | + sequenceDiagram |
| 167 | + participant LF as Ledger flash storage |
| 168 | + participant LC as Ledger computation |
| 169 | + participant H as Host |
| 170 | + participant N as Network |
| 171 | + |
| 172 | + H -->> N: retrieve meta_data from network? |
| 173 | + N -->> H: meta_data |
| 174 | +
|
| 175 | + H ->> LC: meta_data transaction |
| 176 | + LC ->> LF: meta_data transaction |
| 177 | +
|
| 178 | + Note over LC: compute valuebalance and commitment |
| 179 | + LC ->> LF: valuebalance and commitment |
| 180 | + Note over LF,LC: verify rcm_secretkey/publickey |
| 181 | +
|
| 182 | + Note over LF,LC: perform_tx_hash_all over all data in flash |
| 183 | +
|
| 184 | + LC ->> H: tx_hash_all |
| 185 | +
|
| 186 | + Note over LC,H: final verification/approval of tx before signing? |
| 187 | +
|
| 188 | + LC ->> H: sign(rcm_secretkey, tx_hash_all) |
| 189 | + loop Every spend note |
| 190 | + LF ->> LC: randomized value |
| 191 | + Note over LC: get_secret_key(path) |
| 192 | + Note over LC: sign(sk, randomized value, tx_hash_all) |
| 193 | + LC ->> H: spend_auth_sign |
| 194 | + end |
| 195 | +
|
| 196 | + Note over H: make raw transaction blob |
| 197 | + H ->> N: raw_transaction_blob |
| 198 | +
|
| 199 | +``` |
0 commit comments