Skip to content

Commit 1af2b73

Browse files
committed
misc fixes
1 parent 8ef8512 commit 1af2b73

68 files changed

Lines changed: 330 additions & 83 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ ark-dlog-gadget = { package = "ark-dlog-gadget", git = "https://github.com/Polym
2525

2626
#dock_crypto_utils = { path = "../crypto/utils" }
2727
#schnorr_pok = { path = "../crypto/schnorr_pok" }
28-
dock_crypto_utils = { git = "https://github.com/PolymeshAssociation/crypto", branch = "patch30" }
29-
schnorr_pok = { git = "https://github.com/PolymeshAssociation/crypto", branch = "patch30" }
28+
dock_crypto_utils = { git = "https://github.com/PolymeshAssociation/crypto", branch = "main" }
29+
schnorr_pok = { git = "https://github.com/PolymeshAssociation/crypto", branch = "main" }
3030

3131
# Polymesh changes.
3232
#ark-serialize = { path = "../arkworks-algebra/serialize" }

dart-bp/docs/5.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,13 @@ with $r_{\mathrm{old},D} + r_{\mathrm{old},H} = b_0$ (so old partials sum to $\m
279279
$$T_{P_{\mathrm{new},D}} = \mathrm{sk}_r \cdot G_{\mathrm{Aff}} + \mathrm{ek}_r \cdot G_{\mathrm{Enc}} + r_{\mathrm{new},D_r} \cdot H_0$$
280280
2. **D-relation** (replaces the $\mathrm{ek} \cdot \mathrm{ek}^{-1} = 1$ BP constraint). Pick fresh $r \in \mathbb{Z}_p$ and compute
281281
$$D = G_{\mathrm{Enc}} \cdot \mathrm{ek} + H_0 \cdot r$$
282-
Since $G_{\mathrm{Enc}} = D \cdot \mathrm{ek}^{-1} + H_0 \cdot (-r \cdot \mathrm{ek}^{-1})$, the device proves knowledge of $(\mathrm{ek}^{-1}, -r \cdot \mathrm{ek}^{-1})$ in this relation. Pick blindings $(\mathrm{ek}^{-1})_r, (-r \cdot \mathrm{ek}^{-1})_r$:
283-
$$T_D = D \cdot (\mathrm{ek}^{-1})_r + H_0 \cdot (-r \cdot \mathrm{ek}^{-1})_r$$
284-
The blinding $r$ hides $\mathrm{ek}$ in $D$. This Sigma proof binds $\mathrm{ek}^{-1}$ to the true inverse of $\mathrm{ek}$ in $D$, and the $\mathrm{ek}^{-1}$ response is reused as the bridging element in all per-leg ciphertext checks below.
282+
The blinding $r$ hides $\mathrm{ek}$ in $D$. The device proves two things about $D$:
283+
- **$D$ opening.** Knowledge of $(\mathrm{ek}, r)$ in $D = G_{\mathrm{Enc}} \cdot \mathrm{ek} + H_0 \cdot r$, reusing the account partials' $\mathrm{ek}_r$ (step 1) so the $\mathrm{ek}$ response $s_{\mathrm{ek}}$ is shared. Pick a blinding $r_r$:
284+
$$T_D = G_{\mathrm{Enc}} \cdot \mathrm{ek}_r + H_0 \cdot r_r$$
285+
The shared $s_{\mathrm{ek}}$ binds the $\mathrm{ek}$ inside $D$ to the account's $\mathrm{ek}$; without it the device could open $D$ with an arbitrary key.
286+
- **Inverse relation.** Since $G_{\mathrm{Enc}} = D \cdot \mathrm{ek}^{-1} + H_0 \cdot (-r \cdot \mathrm{ek}^{-1})$, knowledge of $(\mathrm{ek}^{-1}, -r \cdot \mathrm{ek}^{-1})$ in it. Pick blindings $(\mathrm{ek}^{-1})_r, (-r \cdot \mathrm{ek}^{-1})_r$:
287+
$$T_{G_{\mathrm{Enc}}} = D \cdot (\mathrm{ek}^{-1})_r + H_0 \cdot (-r \cdot \mathrm{ek}^{-1})_r$$
288+
Given $D$ opens to the account's $\mathrm{ek}$, this forces $\mathrm{ek} \cdot \mathrm{ek}^{-1} = 1$, so $\mathrm{ek}^{-1}$ is the true inverse. The $\mathrm{ek}^{-1}$ response is reused as the bridging element in all per-leg ciphertext checks below.
285289
3. **Per-leg amount partial** (when the asset-id is revealed in this leg, or the balance changes). Pick fresh $k_{\mathrm{amt}} \in \mathbb{Z}_p$ and a blinding $k_{\mathrm{amt},r}$, publish
286290
$$P_{\mathrm{ct}_{\mathrm{amt}},D} = H_0 \cdot k_{\mathrm{amt}} + \mathrm{eph\_pk}_{\mathrm{amt}} \cdot \mathrm{ek}^{-1}$$
287291
$$T_{P_{\mathrm{ct}_{\mathrm{amt}},D}} = H_0 \cdot k_{\mathrm{amt},r} + \mathrm{eph\_pk}_{\mathrm{amt}} \cdot (\mathrm{ek}^{-1})_r$$
@@ -295,9 +299,10 @@ with $r_{\mathrm{old},D} + r_{\mathrm{old},H} = b_0$ (so old partials sum to $\m
295299
5. Device hashes its transcript — containing $\mathrm{nonce}$, $P_{\mathrm{old},D}, P_{\mathrm{new},D}, D$, the per-leg partials $P_{\mathrm{ct}_{\mathrm{amt}},D}, P_{\mathrm{ct\_at},D}$, the leg encryptions, and all $T$ values above — to derive challenge $c$.
296300
6. Device responses:
297301
- $s_{\mathrm{sk}} = \mathrm{sk}_r + \mathrm{sk} \cdot c$ (shared across both account partials)
298-
- $s_{\mathrm{ek}} = \mathrm{ek}_r + \mathrm{ek} \cdot c$ (shared across both account partials)
302+
- $s_{\mathrm{ek}} = \mathrm{ek}_r + \mathrm{ek} \cdot c$ (shared across both account partials and the $D$ opening)
299303
- $s_{r_{\mathrm{old},D}} = r_{\mathrm{old},D_r} + r_{\mathrm{old},D} \cdot c$, $\quad s_{r_{\mathrm{new},D}} = r_{\mathrm{new},D_r} + r_{\mathrm{new},D} \cdot c$
300-
- $s_{\mathrm{ek}^{-1}} = (\mathrm{ek}^{-1})_r + \mathrm{ek}^{-1} \cdot c$ (shared across the D-relation, the per-leg amount partial, and the per-leg asset-id)
304+
- $s_r = r_r + r \cdot c$ (for the $D$ opening)
305+
- $s_{\mathrm{ek}^{-1}} = (\mathrm{ek}^{-1})_r + \mathrm{ek}^{-1} \cdot c$ (shared across the inverse relation, the per-leg amount partial, and the per-leg asset-id)
301306
- $s_{-r \cdot \mathrm{ek}^{-1}} = (-r \cdot \mathrm{ek}^{-1})_r + (-r \cdot \mathrm{ek}^{-1}) \cdot c$
302307
- Per leg with a $\mathrm{ct}_{\mathrm{amt}}$ partial: $s_{k_{\mathrm{amt}}} = k_{\mathrm{amt},r} + k_{\mathrm{amt}} \cdot c$
303308
- Per leg with hidden asset-id: $s_{k_{\mathrm{at}}} = k_{\mathrm{at},r} + k_{\mathrm{at}} \cdot c$
@@ -307,7 +312,8 @@ with $r_{\mathrm{old},D} + r_{\mathrm{old},H} = b_0$ (so old partials sum to $\m
307312
The verifier recomputes $c$ from the device's transcript and checks each Sigma relation. Each check has the standard structure $\text{(linear combination of responses)} \stackrel{?}{=} T + \text{(committed value)}.c$:
308313
- $s_{\mathrm{sk}} \cdot G_{\mathrm{Aff}} + s_{\mathrm{ek}} \cdot G_{\mathrm{Enc}} + s_{r_{\mathrm{old},D}} \cdot H_0 \stackrel{?}{=} T_{P_{\mathrm{old},D}} + P_{\mathrm{old},D} \cdot c$
309314
- $s_{\mathrm{sk}} \cdot G_{\mathrm{Aff}} + s_{\mathrm{ek}} \cdot G_{\mathrm{Enc}} + s_{r_{\mathrm{new},D}} \cdot H_0 \stackrel{?}{=} T_{P_{\mathrm{new},D}} + P_{\mathrm{new},D} \cdot c$
310-
- $s_{\mathrm{ek}^{-1}} \cdot D + s_{-r \cdot \mathrm{ek}^{-1}} \cdot H_0 \stackrel{?}{=} T_D + G_{\mathrm{Enc}} \cdot c$
315+
- $D$ opening: $s_{\mathrm{ek}} \cdot G_{\mathrm{Enc}} + s_r \cdot H_0 \stackrel{?}{=} T_D + D \cdot c$
316+
- Inverse relation: $s_{\mathrm{ek}^{-1}} \cdot D + s_{-r \cdot \mathrm{ek}^{-1}} \cdot H_0 \stackrel{?}{=} T_{G_{\mathrm{Enc}}} + G_{\mathrm{Enc}} \cdot c$
311317
- Per leg with a $\mathrm{ct}_{\mathrm{amt}}$ partial (asset-id revealed in this leg, or balance changes): $s_{\mathrm{ek}^{-1}} \cdot \mathrm{eph\_pk}_{\mathrm{amt}} + s_{k_{\mathrm{amt}}} \cdot H_0 \stackrel{?}{=} T_{P_{\mathrm{ct}_{\mathrm{amt}},D}} + P_{\mathrm{ct}_{\mathrm{amt}},D} \cdot c$
312318
- Per leg with hidden asset-id: $s_{\mathrm{ek}^{-1}} \cdot \mathrm{eph\_pk}_{\mathrm{asset\_id}} + s_{k_{\mathrm{at}}} \cdot H_0 \stackrel{?}{=} T_{P_{\mathrm{ct\_at},D}} + P_{\mathrm{ct\_at},D} \cdot c$
313319
- Per leg with asset-id revealed elsewhere: $s_{\mathrm{ek}^{-1}} \cdot \mathrm{eph\_pk}_{\mathrm{asset\_id}} \stackrel{?}{=} T_{\mathrm{at},\mathrm{DL}} + (\mathrm{CT}_{\mathrm{at}} - \mathrm{at} \cdot H) \cdot c$

dart-bp/src/account/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<
838838
);
839839
}
840840

841-
let (nullifier, comm_bp, comm_bp_blinding, t_null, t_bp) = create_bp_and_null_t_values(
841+
let (nullifier, comm_bp, comm_bp_blinding, t_null, t_bp, _) = create_bp_and_null_t_values(
842842
rng,
843843
false, // include_sk: host mode
844844
account.rho(),

dart-bp/src/account/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,12 @@ macro_rules! impl_txn_proof {
355355
rng: &mut R,
356356
rmc: Option<&mut RandomizedMultChecker<Affine<G0>>>,
357357
) -> Result<(VerificationTuple<Affine<G0>>, VerificationTuple<Affine<G1>>)> {
358+
let (leg_enc_core, eph_pk) = leg_enc;
358359
let mut verifier = StateChangeVerifier::init::<Parameters0, Parameters1>(
359360
&self.common_proof,
360361
vec![LegVerifierConfig {
361-
encryption: leg_enc.0.clone(),
362-
party_eph_pk: PartyEphemeralPublicKey::$EphPkVariant(leg_enc.1.clone()),
362+
encryption: leg_enc_core,
363+
party_eph_pk: PartyEphemeralPublicKey::$EphPkVariant(eph_pk),
363364
has_balance_decreased: $ver_bal_dec,
364365
has_counter_decreased: $ver_ctr_dec,
365366
}],

dart-bp/src/account/tests.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10685,6 +10685,7 @@ fn send_txn_split_proof() {
1068510685
);
1068610686
println!("split proof size = {}", split_proof.compressed_size());
1068710687

10688+
let clock = Instant::now();
1068810689
let (even_tuple, odd_tuple) = verify_split_proof!(
1068910690
proof: split_proof,
1069010691
party: Sender,
@@ -10702,11 +10703,7 @@ fn send_txn_split_proof() {
1070210703
rng: &mut rng,
1070310704
);
1070410705
verify_given_verification_tuples(even_tuple, odd_tuple, &account_tree_params).unwrap();
10705-
10706-
println!(
10707-
"reveal_asset_id={}, full verification passed!",
10708-
reveal_asset_id
10709-
);
10706+
let verifier_time = clock.elapsed();
1071010707

1071110708
// Sequential flow
1071210709
let (split_proof_seq, nullifier_seq, _) = gen_split_proof!(
@@ -10733,6 +10730,7 @@ fn send_txn_split_proof() {
1073310730
b_blinding: b_blinding,
1073410731
reveal_asset_id: reveal_asset_id,
1073510732
);
10733+
let clock = Instant::now();
1073610734
let (even_tuple_seq, odd_tuple_seq) = verify_split_proof!(
1073710735
sequential;
1073810736
proof: split_proof_seq,
@@ -10752,6 +10750,12 @@ fn send_txn_split_proof() {
1075210750
);
1075310751
verify_given_verification_tuples(even_tuple_seq, odd_tuple_seq, &account_tree_params)
1075410752
.unwrap();
10753+
let verifier_time_seq = clock.elapsed();
10754+
10755+
println!(
10756+
"total prover time = {:?}, total verifier time (parallel W2) = {:?}, verifier time (sequential W3) = {:?}",
10757+
host_proof_time, verifier_time, verifier_time_seq
10758+
);
1075510759
};
1075610760

1075710761
// asset-id hidden
@@ -10839,6 +10843,7 @@ fn receive_txn_split_proof() {
1083910843
);
1084010844
println!("split proof size = {}", split_proof.compressed_size());
1084110845

10846+
let clock = Instant::now();
1084210847
let (even_tuple, odd_tuple) = verify_split_proof!(
1084310848
proof: split_proof,
1084410849
party: Receiver,
@@ -10856,11 +10861,7 @@ fn receive_txn_split_proof() {
1085610861
rng: &mut rng,
1085710862
);
1085810863
verify_given_verification_tuples(even_tuple, odd_tuple, &account_tree_params).unwrap();
10859-
10860-
println!(
10861-
"reveal_asset_id={}, full verification passed!",
10862-
reveal_asset_id
10863-
);
10864+
let verifier_time = clock.elapsed();
1086410865

1086510866
// Sequential flow
1086610867
let (split_proof_seq, nullifier_seq, _) = gen_split_proof!(
@@ -10887,6 +10888,7 @@ fn receive_txn_split_proof() {
1088710888
b_blinding: b_blinding,
1088810889
reveal_asset_id: reveal_asset_id,
1088910890
);
10891+
let clock = Instant::now();
1089010892
let (even_tuple_seq, odd_tuple_seq) = verify_split_proof!(
1089110893
sequential;
1089210894
proof: split_proof_seq,
@@ -10906,6 +10908,12 @@ fn receive_txn_split_proof() {
1090610908
);
1090710909
verify_given_verification_tuples(even_tuple_seq, odd_tuple_seq, &account_tree_params)
1090810910
.unwrap();
10911+
let verifier_time_seq = clock.elapsed();
10912+
10913+
println!(
10914+
"total prover time = {:?}, total verifier time (parallel W2) = {:?}, verifier time (sequential W3) = {:?}",
10915+
host_proof_time, verifier_time, verifier_time_seq
10916+
);
1090910917
};
1091010918

1091110919
// asset-id hidden

0 commit comments

Comments
 (0)