Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 3bc3087

Browse files
authored
Rename caller_address to commitment (#96)
1 parent df31437 commit 3bc3087

File tree

8 files changed

+27
-33
lines changed

8 files changed

+27
-33
lines changed

crates/shielder-circuits/src/circuits/deposit/chip.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ use crate::{
1010
deposit::knowledge::DepositProverKnowledge,
1111
merkle::{MerkleChip, MerkleProverKnowledge},
1212
},
13-
deposit::DepositInstance::{
14-
self, CallerAddress, DepositValue, HashedNewNote, HashedOldNullifier,
15-
},
13+
deposit::DepositInstance::{self, Commitment, DepositValue, HashedNewNote, HashedOldNullifier},
1614
instance_wrapper::InstanceWrapper,
1715
poseidon::circuit::{hash, PoseidonChip},
1816
synthesizer::Synthesizer,
@@ -115,14 +113,12 @@ impl DepositChip {
115113
Ok(())
116114
}
117115

118-
pub fn check_caller_address(
116+
pub fn check_commitment(
119117
&self,
120118
synthesizer: &mut impl Synthesizer,
121119
knowledge: &DepositProverKnowledge<AssignedCell>,
122120
) -> Result<(), Error> {
123-
self.public_inputs.constrain_cells(
124-
synthesizer,
125-
[(knowledge.caller_address.clone(), CallerAddress)],
126-
)
121+
self.public_inputs
122+
.constrain_cells(synthesizer, [(knowledge.commitment.clone(), Commitment)])
127123
}
128124
}

crates/shielder-circuits/src/circuits/deposit/circuit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Circuit<Fr> for DepositCircuit {
5757
main_chip.check_old_nullifier(&mut synthesizer, &knowledge)?;
5858
main_chip.check_new_note(&mut synthesizer, &knowledge)?;
5959
main_chip.check_mac(&mut synthesizer, &knowledge)?;
60-
main_chip.check_caller_address(&mut synthesizer, &knowledge)
60+
main_chip.check_commitment(&mut synthesizer, &knowledge)
6161
}
6262
}
6363

@@ -188,7 +188,7 @@ mod tests {
188188
// Important note: there is no range check in the circuit for DepositValue, however there is an external constraint
189189
// (in the smart contract) guaranteeing that this never exceeds MAX_CONTRACT_BALANCE = 2^{112} - 1.
190190
DepositValue => pk.deposit_value,
191-
CallerAddress => pk.caller_address,
191+
Commitment => pk.commitment,
192192
TokenAddress => pk.token_address,
193193
MacSalt => pk.mac_salt,
194194
MacCommitment => hash(&[pk.mac_salt, off_circuit::derive_viewing_key(pk.id)]),
@@ -266,9 +266,9 @@ mod tests {
266266
}
267267

268268
#[test]
269-
fn fails_if_caller_address_is_incorrect() {
269+
fn fails_if_commitment_is_incorrect() {
270270
let pk = DepositProverKnowledge::random_correct_example(&mut OsRng);
271-
let pub_input = pk.with_substitution(CallerAddress, |s| s + Fr::ONE);
271+
let pub_input = pk.with_substitution(Commitment, |s| s + Fr::ONE);
272272

273273
assert!(
274274
expect_prover_success_and_run_verification(pk.create_circuit(), &pub_input).is_err()

crates/shielder-circuits/src/circuits/deposit/knowledge.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct DepositProverKnowledge<T> {
4141
pub mac_salt: T,
4242

4343
pub deposit_value: T,
44-
pub caller_address: T,
44+
pub commitment: T,
4545
}
4646

4747
impl ProverKnowledge for DepositProverKnowledge<Fr> {
@@ -73,7 +73,7 @@ impl ProverKnowledge for DepositProverKnowledge<Fr> {
7373
nullifier_new: Fr::random(&mut *rng),
7474
deposit_value: Fr::ONE,
7575
mac_salt: Fr::random(&mut *rng),
76-
caller_address: Fr::random(rng),
76+
commitment: Fr::random(rng),
7777
}
7878
}
7979

@@ -87,7 +87,7 @@ impl ProverKnowledge for DepositProverKnowledge<Fr> {
8787
path: self.path.map(|level| level.map(Value::known)),
8888
deposit_value: Value::known(self.deposit_value),
8989
mac_salt: Value::known(self.mac_salt),
90-
caller_address: Value::known(self.caller_address),
90+
commitment: Value::known(self.commitment),
9191
})
9292
}
9393
}
@@ -107,7 +107,7 @@ impl PublicInputProvider<DepositInstance> for DepositProverKnowledge<Fr> {
107107
token_address: self.token_address,
108108
}),
109109
DepositInstance::DepositValue => self.deposit_value,
110-
DepositInstance::CallerAddress => self.caller_address,
110+
DepositInstance::Commitment => self.commitment,
111111
DepositInstance::TokenAddress => self.token_address,
112112
DepositInstance::MacSalt => self.mac_salt,
113113
DepositInstance::MacCommitment => hash(&[self.mac_salt, viewing_key]),

crates/shielder-circuits/src/circuits/deposit/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum DepositInstance {
1717
HashedOldNullifier,
1818
HashedNewNote,
1919
DepositValue,
20-
CallerAddress,
20+
Commitment,
2121
TokenAddress,
2222
MacSalt,
2323
MacCommitment,
@@ -73,7 +73,7 @@ mod tests {
7373
HashedOldNullifier,
7474
HashedNewNote,
7575
DepositValue,
76-
CallerAddress,
76+
Commitment,
7777
TokenAddress,
7878
MacSalt,
7979
MacCommitment,

crates/shielder-circuits/src/circuits/new_account/chip.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,12 @@ impl NewAccountChip {
151151
Ok(())
152152
}
153153

154-
pub fn check_caller_address(
154+
pub fn check_commitment(
155155
&self,
156156
synthesizer: &mut impl Synthesizer,
157157
knowledge: &NewAccountProverKnowledge<AssignedCell>,
158158
) -> Result<(), Error> {
159-
self.public_inputs.constrain_cells(
160-
synthesizer,
161-
[(knowledge.caller_address.clone(), CallerAddress)],
162-
)
159+
self.public_inputs
160+
.constrain_cells(synthesizer, [(knowledge.commitment.clone(), Commitment)])
163161
}
164162
}

crates/shielder-circuits/src/circuits/new_account/circuit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Circuit<Fr> for NewAccountCircuit {
6666
main_chip.constrain_prenullifier(&mut synthesizer, &knowledge)?;
6767
main_chip.constrain_encrypting_viewing_key(&mut synthesizer, &knowledge)?;
6868
main_chip.check_mac(&mut synthesizer, &knowledge)?;
69-
main_chip.check_caller_address(&mut synthesizer, &knowledge)
69+
main_chip.check_commitment(&mut synthesizer, &knowledge)
7070
}
7171
}
7272

@@ -173,9 +173,9 @@ mod tests {
173173
}
174174

175175
#[test]
176-
fn fails_if_caller_address_is_incorrect() {
176+
fn fails_if_commitment_is_incorrect() {
177177
let pk = NewAccountProverKnowledge::random_correct_example(&mut OsRng);
178-
let pub_input = pk.with_substitution(CallerAddress, |s| s + Fr::ONE);
178+
let pub_input = pk.with_substitution(Commitment, |s| s + Fr::ONE);
179179

180180
assert!(
181181
expect_prover_success_and_run_verification(pk.create_circuit(), &pub_input).is_err()

crates/shielder-circuits/src/circuits/new_account/knowledge.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct NewAccountProverKnowledge<T> {
2727
pub id: T,
2828
pub nullifier: T,
2929
pub initial_deposit: T,
30-
pub caller_address: T,
30+
pub commitment: T,
3131
pub token_address: T,
3232
pub encryption_salt: [T; FIELD_BITS],
3333
pub anonymity_revoker_public_key: GrumpkinPointAffine<T>,
@@ -40,7 +40,7 @@ impl<T: Default + Copy> Default for NewAccountProverKnowledge<T> {
4040
id: T::default(),
4141
nullifier: T::default(),
4242
initial_deposit: T::default(),
43-
caller_address: T::default(),
43+
commitment: T::default(),
4444
token_address: T::default(),
4545
encryption_salt: [T::default(); FIELD_BITS],
4646
anonymity_revoker_public_key: GrumpkinPointAffine::default(),
@@ -58,7 +58,7 @@ impl ProverKnowledge for NewAccountProverKnowledge<Fr> {
5858
id: curve_arithmetic::generate_user_id(Fr::random(&mut *rng).to_bytes()),
5959
nullifier: Fr::random(&mut *rng),
6060
initial_deposit: Fr::ONE,
61-
caller_address: Fr::random(&mut *rng),
61+
commitment: Fr::random(&mut *rng),
6262
token_address: Fr::ZERO,
6363
encryption_salt: field_element_to_le_bits(grumpkin::Fr::ONE),
6464
anonymity_revoker_public_key: GrumpkinPointAffine::random(rng),
@@ -71,7 +71,7 @@ impl ProverKnowledge for NewAccountProverKnowledge<Fr> {
7171
id: Value::known(self.id),
7272
nullifier: Value::known(self.nullifier),
7373
initial_deposit: Value::known(self.initial_deposit),
74-
caller_address: Value::known(self.caller_address),
74+
commitment: Value::known(self.commitment),
7575
token_address: Value::known(self.token_address),
7676
encryption_salt: self.encryption_salt.map(Value::known),
7777
anonymity_revoker_public_key: GrumpkinPointAffine::new(
@@ -111,7 +111,7 @@ impl PublicInputProvider<NewAccountInstance> for NewAccountProverKnowledge<Fr> {
111111
}),
112112
NewAccountInstance::Prenullifier => hash(&[self.id]),
113113
NewAccountInstance::InitialDeposit => self.initial_deposit,
114-
NewAccountInstance::CallerAddress => self.caller_address,
114+
NewAccountInstance::Commitment => self.commitment,
115115
NewAccountInstance::TokenAddress => self.token_address,
116116
NewAccountInstance::AnonymityRevokerPublicKeyX => self.anonymity_revoker_public_key.x,
117117
NewAccountInstance::AnonymityRevokerPublicKeyY => self.anonymity_revoker_public_key.y,

crates/shielder-circuits/src/circuits/new_account/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum NewAccountInstance {
1414
HashedNote,
1515
Prenullifier,
1616
InitialDeposit,
17-
CallerAddress,
17+
Commitment,
1818
TokenAddress,
1919
AnonymityRevokerPublicKeyX,
2020
AnonymityRevokerPublicKeyY,
@@ -64,7 +64,7 @@ mod tests {
6464
HashedNote,
6565
Prenullifier,
6666
InitialDeposit,
67-
CallerAddress,
67+
Commitment,
6868
TokenAddress,
6969
AnonymityRevokerPublicKeyX,
7070
AnonymityRevokerPublicKeyY,

0 commit comments

Comments
 (0)