Skip to content

Commit ddb8780

Browse files
committed
domain separation updates as per dep
1 parent 175cbcf commit ddb8780

80 files changed

Lines changed: 977 additions & 380 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: 4 additions & 4 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 = "main" }
29-
schnorr_pok = { git = "https://github.com/PolymeshAssociation/crypto", branch = "main" }
28+
dock_crypto_utils = { git = "https://github.com/PolymeshAssociation/crypto", branch = "patch30" }
29+
schnorr_pok = { git = "https://github.com/PolymeshAssociation/crypto", branch = "patch30" }
3030

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

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::account::AccountState;
2+
use crate::dst;
23
use crate::util::{
34
create_balance_bp_t_values, enforce_balance_change_prover,
45
generate_schnorr_responses_for_balance_change, generate_sigma_t_values_for_balance_change,
@@ -32,8 +33,8 @@ pub struct BalanceChangeProofPartial<
3233
> {
3334
/// Commitment to old and new balances and amounts used in BP
3435
pub comm_bp_bal: Affine<G0>,
35-
/// For the sigma protocol for above commitment
36-
pub t_comm_bp_bal: Affine<G0>,
36+
/// Response for the sigma protocol for above commitment. Carries the commitment to
37+
/// randomness `t` from step 1.
3738
pub resp_comm_bp_bal: PartialSchnorrResponse<Affine<G0>>,
3839
}
3940

@@ -140,7 +141,6 @@ impl<F0: PrimeField, G0: SWCurveConfig<ScalarField = F0> + Clone + Copy>
140141
}
141142

142143
pub fn gen_proof(self, challenge: &F0) -> Result<BalanceChangeProof<F0, G0>> {
143-
let t_comm_bp_bal = self.t_comm_bp_bal.t;
144144
let resp_comm_bp_bal = generate_schnorr_responses_for_balance_change(
145145
self.comm_bp_bal_blinding,
146146
self.t_comm_bp_bal.clone(),
@@ -149,7 +149,6 @@ impl<F0: PrimeField, G0: SWCurveConfig<ScalarField = F0> + Clone + Copy>
149149
Ok(BalanceChangeProof {
150150
partial: BalanceChangeProofPartial {
151151
comm_bp_bal: self.comm_bp_bal,
152-
t_comm_bp_bal,
153152
resp_comm_bp_bal,
154153
},
155154
})
@@ -252,7 +251,7 @@ impl<F0: PrimeField, G0: SWCurveConfig<ScalarField = F0> + Clone + Copy>
252251

253252
{
254253
let mut transcript = even_prover.transcript();
255-
t_comm_bp_bal.challenge_contribution(&mut transcript)?;
254+
t_comm_bp_bal.challenge_contribution(dst::BP_BALANCE, &mut transcript)?;
256255
}
257256

258257
Ok(Self {
@@ -263,15 +262,13 @@ impl<F0: PrimeField, G0: SWCurveConfig<ScalarField = F0> + Clone + Copy>
263262
}
264263

265264
pub fn gen_proof(self, challenge: &F0) -> Result<BalanceChangeProofPartial<F0, G0>> {
266-
let t_comm_bp_bal = self.t_comm_bp_bal.t;
267265
let resp_comm_bp_bal = generate_schnorr_responses_for_balance_change(
268266
self.comm_bp_bal_blinding,
269267
self.t_comm_bp_bal.clone(),
270268
challenge,
271269
)?;
272270
Ok(BalanceChangeProofPartial {
273271
comm_bp_bal: self.comm_bp_bal,
274-
t_comm_bp_bal,
275272
resp_comm_bp_bal,
276273
})
277274
}

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub mod verifier;
55
use crate::account::state::NUM_GENERATORS;
66
use crate::account::{AccountCommitmentKeyTrait, AccountState, AccountStateCommitment};
77
use crate::auth_proofs::account::AuthProofAffirmation;
8+
use crate::dst;
89
use crate::leg::{LegEncryptionCore, PartyEphemeralPublicKey};
910
use crate::util::{
1011
BPProof, generate_sigma_responses_for_common_state_change,
@@ -82,9 +83,8 @@ pub struct CommonStateChangeProofPartial<
8283
pub resp_null: PartialPokDiscreteLog<Affine<G0>>,
8384
/// Commitment to initial rho, old and current rho, old and current randomness
8485
pub comm_bp_randomness_relations: Affine<G0>,
85-
/// Commitment to randomness for proving knowledge of rho and commitment randomness (step 1 of Schnorr)
86-
pub t_bp_randomness_relations: Affine<G0>,
87-
/// Response for proving knowledge of rho and commitment randomness (step 3 of Schnorr)
86+
/// Response for proving knowledge of rho and commitment randomness (step 3 of Schnorr).
87+
/// Carries the commitment to randomness `t` from step 1.
8888
pub resp_bp_randomness_relations: PartialSchnorrResponse<Affine<G0>>,
8989
}
9090

@@ -98,13 +98,11 @@ pub struct CommonStateChangeProof<
9898
G1: SWCurveConfig<ScalarField = F1, BaseField = F0> + Clone + Copy,
9999
> {
100100
pub partial: CommonStateChangeProofPartial<F0, F1, G0, G1, { L }>,
101-
/// Commitment to randomness for proving knowledge of re-randomized leaf using Schnorr protocol (step 1 of Schnorr)
102-
pub t_acc_old: Affine<G0>,
103-
/// Commitment to randomness for proving knowledge of new account commitment (which becomes new leaf) using Schnorr protocol (step 1 of Schnorr)
104-
pub t_acc_new: Affine<G0>,
105-
/// Response for proving knowledge of re-randomized account commitment (leaf) using Schnorr protocol (step 3 of Schnorr)
101+
/// Response for proving knowledge of re-randomized account commitment (leaf) using Schnorr
102+
/// protocol (step 3 of Schnorr). Carries the commitment to randomness `t` from step 1.
106103
pub resp_acc_old: SchnorrResponse<Affine<G0>>,
107-
/// Response for proving knowledge of new account commitment using Schnorr protocol (step 3 of Schnorr)
104+
/// Response for proving knowledge of new account commitment using Schnorr protocol (step 3
105+
/// of Schnorr). Carries the commitment to randomness `t` from step 1.
108106
pub resp_acc_new: PartialSchnorrResponse<Affine<G0>>,
109107
pub resp_leg_link: Vec<LegAccountLink<G0>>,
110108
}
@@ -532,11 +530,8 @@ impl<
532530
re_randomized_path: self.re_randomized_path.clone(),
533531
resp_null,
534532
comm_bp_randomness_relations: self.comm_bp_randomness_relations,
535-
t_bp_randomness_relations: self.t_bp_randomness_relations.t,
536533
resp_bp_randomness_relations,
537534
},
538-
t_acc_old: self.t_acc_old.t,
539-
t_acc_new: self.t_acc_new.t,
540535
resp_acc_old,
541536
resp_acc_new,
542537
resp_leg_link,
@@ -548,18 +543,18 @@ impl<
548543
/// Does NOT include sk or sk_enc.
549544
#[derive(Clone, Debug, CanonicalSerialize, CanonicalDeserialize)]
550545
pub struct AccountCommitmentsHostProof<G: SWCurveConfig + Clone + Copy> {
551-
pub t_acc_old: Affine<G>,
552-
pub t_acc_new: Affine<G>,
553-
/// Full response for old re-randomized account
546+
/// Full response for old re-randomized account (carries its commitment `t`)
554547
pub resp_acc_old: SchnorrResponse<Affine<G>>,
555-
/// Partial response for new account
548+
/// Partial response for new account (carries its commitment `t`)
556549
pub resp_acc_new: PartialSchnorrResponse<Affine<G>>,
557550
}
558551

559552
impl<G: SWCurveConfig + Clone + Copy> AccountCommitmentsHostProof<G> {
560553
pub fn challenge_contribution<W: Write>(&self, writer: &mut W) -> Result<()> {
561-
self.t_acc_old.serialize_compressed(&mut *writer)?;
562-
self.t_acc_new.serialize_compressed(writer)?;
554+
self.resp_acc_old
555+
.challenge_contribution(dst::ACCOUNT_COMM_OLD, &mut *writer)?;
556+
self.resp_acc_new
557+
.challenge_contribution(dst::ACCOUNT_COMM_NEW, writer)?;
563558
Ok(())
564559
}
565560
}
@@ -658,8 +653,10 @@ impl<G: SWCurveConfig + Clone + Copy> AccountCommitmentsHostProtocol<G> {
658653
}
659654

660655
pub fn challenge_contribution<W: Write>(&self, writer: &mut W) -> Result<()> {
661-
self.t_acc_old.challenge_contribution(&mut *writer)?;
662-
self.t_acc_new.challenge_contribution(writer)?;
656+
self.t_acc_old
657+
.challenge_contribution(dst::ACCOUNT_COMM_OLD, &mut *writer)?;
658+
self.t_acc_new
659+
.challenge_contribution(dst::ACCOUNT_COMM_NEW, writer)?;
663660
Ok(())
664661
}
665662

@@ -688,8 +685,6 @@ impl<G: SWCurveConfig + Clone + Copy> AccountCommitmentsHostProtocol<G> {
688685
)?;
689686

690687
Ok(AccountCommitmentsHostProof {
691-
t_acc_old: self.t_acc_old.t,
692-
t_acc_new: self.t_acc_new.t,
693688
resp_acc_old,
694689
resp_acc_new,
695690
})
@@ -897,7 +892,6 @@ impl<
897892
re_randomized_path: self.re_randomized_path.take(),
898893
resp_null,
899894
comm_bp_randomness_relations: self.comm_bp,
900-
t_bp_randomness_relations: self.t_bp.t,
901895
resp_bp_randomness_relations: resp_bp,
902896
}
903897
}
@@ -1217,13 +1211,18 @@ impl<
12171211
let mut transcript = even_prover.transcript();
12181212
acc_host_proto
12191213
.t_acc_old
1220-
.challenge_contribution(&mut transcript)?;
1214+
.challenge_contribution(dst::ACCOUNT_COMM_OLD, &mut transcript)?;
12211215
acc_host_proto
12221216
.t_acc_new
1223-
.challenge_contribution(&mut transcript)?;
1224-
t_bp.challenge_contribution(&mut transcript)?;
1217+
.challenge_contribution(dst::ACCOUNT_COMM_NEW, &mut transcript)?;
1218+
t_bp.challenge_contribution(dst::BP_RANDOMNESS_RELATIONS, &mut transcript)?;
12251219
let null_gen = account_comm_key.current_rho_gen();
1226-
t_null.challenge_contribution(&null_gen, &nullifier, &mut transcript)?;
1220+
t_null.challenge_contribution(
1221+
&null_gen,
1222+
&nullifier,
1223+
dst::NULLIFIER,
1224+
&mut transcript,
1225+
)?;
12271226
}
12281227

12291228
let mut ct_asset_id_2_protos = Vec::new();
@@ -1244,6 +1243,7 @@ impl<
12441243
&enc_gen,
12451244
&b_blinding,
12461245
ct_asset_id_2,
1246+
dst::HOST_CT_ASSET_ID_2,
12471247
&mut transcript,
12481248
)?;
12491249
}
@@ -1269,6 +1269,7 @@ impl<
12691269
&enc_gen,
12701270
&b_blinding,
12711271
ct_amount_2,
1272+
dst::HOST_CT_AMOUNT_2,
12721273
&mut transcript,
12731274
)?;
12741275
}
@@ -1489,7 +1490,6 @@ impl<
14891490
re_randomized_path,
14901491
resp_null,
14911492
comm_bp_randomness_relations: comm_bp,
1492-
t_bp_randomness_relations: t_bp.t,
14931493
resp_bp_randomness_relations: resp_bp,
14941494
};
14951495

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::util::{
1515
};
1616
use crate::{
1717
Error, LEG_ENC_LABEL, NONCE_LABEL, RE_RANDOMIZED_PATH_LABEL, ROOT_LABEL, TXN_EVEN_LABEL,
18-
TXN_ODD_LABEL, UPDATED_ACCOUNT_COMMITMENT_LABEL, add_to_transcript, error::Result,
18+
TXN_ODD_LABEL, UPDATED_ACCOUNT_COMMITMENT_LABEL, add_to_transcript, dst, error::Result,
1919
};
2020
use ark_dlog_gadget::dlog::DiscreteLogParameters;
2121
use ark_ec::short_weierstrass::{Affine, SWCurveConfig};
@@ -347,9 +347,9 @@ impl<
347347
asset_id,
348348
&nullifier,
349349
proof.partial.comm_bp_randomness_relations,
350-
&proof.t_acc_old,
351-
&proof.t_acc_new,
352-
&proof.partial.t_bp_randomness_relations,
350+
&proof.resp_acc_old,
351+
&proof.resp_acc_new,
352+
&proof.partial.resp_bp_randomness_relations,
353353
&proof.partial.resp_null,
354354
&proof.resp_leg_link,
355355
&needs_ct_amount,
@@ -392,7 +392,7 @@ impl<
392392
// ct_amount challenge contributions are written in the leg-link (common) phase now;
393393
// the balance phase only contributes the balance BP t-value.
394394
take_challenge_contrib_of_balance_bp(
395-
&proof.partial.t_comm_bp_bal,
395+
&proof.partial.resp_comm_bp_bal,
396396
&mut verifier_transcript,
397397
)?;
398398
Ok(())
@@ -441,9 +441,6 @@ impl<
441441
&common_state_change_proof
442442
.partial
443443
.comm_bp_randomness_relations,
444-
&common_state_change_proof.t_acc_old,
445-
&common_state_change_proof.t_acc_new,
446-
&common_state_change_proof.partial.t_bp_randomness_relations,
447444
&common_state_change_proof.resp_acc_old,
448445
&common_state_change_proof.resp_acc_new,
449446
&common_state_change_proof.partial.resp_null,
@@ -483,7 +480,6 @@ impl<
483480
verify_sigma_for_balance_change(
484481
&balance_resp_amounts,
485482
&balance_change_proof.partial.comm_bp_bal,
486-
&balance_change_proof.partial.t_comm_bp_bal,
487483
&balance_change_proof.partial.resp_comm_bp_bal,
488484
challenge,
489485
*common_state_change_proof
@@ -729,12 +725,13 @@ impl<
729725
.challenge_contribution(&mut transcript)?;
730726
proof
731727
.partial
732-
.t_bp_randomness_relations
733-
.serialize_compressed(&mut transcript)?;
728+
.resp_bp_randomness_relations
729+
.challenge_contribution(dst::BP_RANDOMNESS_RELATIONS, &mut transcript)?;
734730
let null_gen = account_comm_key.current_rho_gen();
735731
proof.partial.resp_null.challenge_contribution(
736732
&null_gen,
737733
&nullifier,
734+
dst::NULLIFIER,
738735
&mut transcript,
739736
)?;
740737
}
@@ -758,6 +755,7 @@ impl<
758755
&enc_gen,
759756
&B_blinding,
760757
&ct_asset_id_2,
758+
dst::HOST_CT_ASSET_ID_2,
761759
&mut transcript,
762760
)?;
763761
asset_id_idx += 1;
@@ -779,6 +777,7 @@ impl<
779777
&enc_gen,
780778
&B_blinding,
781779
&ct_amount_2,
780+
dst::HOST_CT_AMOUNT_2,
782781
&mut transcript,
783782
)?;
784783
amount_idx += 1;
@@ -881,8 +880,8 @@ impl<
881880
let mut transcript = even_verifier.transcript();
882881
balance_proof
883882
.partial
884-
.t_comm_bp_bal
885-
.serialize_compressed(&mut transcript)?;
883+
.resp_comm_bp_bal
884+
.challenge_contribution(dst::BP_BALANCE, &mut transcript)?;
886885
}
887886

888887
Ok(())
@@ -1001,7 +1000,6 @@ impl<
10011000
common_proof.host_commitment_proof.resp_acc_old,
10021001
gens_acc_old,
10031002
y_old,
1004-
common_proof.host_commitment_proof.t_acc_old,
10051003
challenge,
10061004
);
10071005

@@ -1046,7 +1044,6 @@ impl<
10461044
common_proof.host_commitment_proof.resp_acc_new,
10471045
gens_acc_new,
10481046
y_new,
1049-
common_proof.host_commitment_proof.t_acc_new,
10501047
challenge,
10511048
missing_resps_acc_new,
10521049
);
@@ -1120,7 +1117,6 @@ impl<
11201117
common_proof.partial.resp_bp_randomness_relations,
11211118
bp_gens_vec,
11221119
common_proof.partial.comm_bp_randomness_relations,
1123-
common_proof.partial.t_bp_randomness_relations,
11241120
challenge,
11251121
missing_resps_bp,
11261122
);
@@ -1196,7 +1192,6 @@ impl<
11961192
balance_proof.partial.resp_comm_bp_bal,
11971193
bp_bal_gens,
11981194
balance_proof.partial.comm_bp_bal,
1199-
balance_proof.partial.t_comm_bp_bal,
12001195
challenge,
12011196
missing_resps_bal,
12021197
);

0 commit comments

Comments
 (0)