Skip to content

Commit dd96b2f

Browse files
Another update
1 parent 4735f75 commit dd96b2f

File tree

10 files changed

+193
-93
lines changed

10 files changed

+193
-93
lines changed

POSEIDON_MIGRATION_PLAN.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,20 @@ Remove the local `poseidon` crate and standardize all hashing (Pure and Witness-
6767

6868
- [x] Delete `poseidon` directory.
6969

70-
- [ ] **Final Verification:**
70+
- [x] **Final Verification:**
7171

72-
- [ ] `mina-p2p-messages` fixed and compiling.
72+
- [x] `mina-p2p-messages` fixed and compiling.
7373

74-
- [ ] `mina-core` fixed and compiling.
74+
- [x] `hash_input.rs` tests fixed and passing (7/7).
75+
76+
- [x] `mina-core` fixed and compiling.
7577

7678
- [x] `mina-tree` fixed and compiling.
7779

78-
- [ ] `mina-snark` pending fixes for `MerkleTreeNode` and `DomainParameter`.
80+
- [ ] `mina-snark` fixes in progress (pending `MerkleTreeNode`, `usize` domain parameter, and `Clone` bounds).
81+
82+
- [ ] Full workspace build (`cargo check --workspace` passes).
83+
84+
85+
7986

80-
- [ ] Full workspace build and test.

crates/ledger/src/account/account.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl VerificationKey {
545545
}
546546

547547
pub fn hash(&self) -> Fp {
548-
self.hash_with_param(&MINA_SIDELOADED_VK)
548+
self.hash_with_param(MINA_SIDELOADED_VK)
549549
}
550550

551551
pub fn gen() -> Self {
@@ -596,7 +596,7 @@ fn default_zkapp_uri_hash() -> Fp {
596596
let mut inputs = Inputs::new();
597597
inputs.append(&Fp::zero());
598598
inputs.append(&Fp::zero());
599-
hash_with_kimchi(&MINA_ZKAPP_URI, &inputs.to_fields())
599+
hash_with_kimchi(MINA_ZKAPP_URI, &inputs.to_fields())
600600
});
601601
*HASH
602602
}
@@ -627,7 +627,7 @@ impl ZkAppUri {
627627
}
628628
}
629629
inputs.append_bool(true);
630-
hash_with_kimchi(&MINA_ZKAPP_URI, &inputs.to_fields())
630+
hash_with_kimchi(MINA_ZKAPP_URI, &inputs.to_fields())
631631
}
632632
}
633633

@@ -890,12 +890,12 @@ impl Default for ZkAppAccount {
890890

891891
impl ZkAppAccount {
892892
pub fn hash(&self) -> Fp {
893-
self.hash_with_param(&MINA_ZKAPP_ACCOUNT)
893+
self.hash_with_param(MINA_ZKAPP_ACCOUNT)
894894
}
895895

896896
/// empty_state_element
897897
pub fn empty_action_state() -> Fp {
898-
hash_noinputs(&NO_INPUT_ZKAPP_ACTION_STATE_EMPTY_ELT)
898+
hash_noinputs(NO_INPUT_ZKAPP_ACTION_STATE_EMPTY_ELT)
899899
}
900900

901901
pub fn is_default(&self) -> bool {
@@ -1055,7 +1055,7 @@ impl AccountId {
10551055
};
10561056

10571057
TokenId(hash_with_kimchi(
1058-
&MINA_DERIVE_TOKEN_ID,
1058+
MINA_DERIVE_TOKEN_ID,
10591059
&[self.public_key.x, self.token_id.0, is_odd_field],
10601060
))
10611061
}
@@ -1623,15 +1623,15 @@ impl Account {
16231623
}
16241624

16251625
pub fn hash(&self) -> Fp {
1626-
self.hash_with_param(&MINA_ACCOUNT)
1626+
self.hash_with_param(MINA_ACCOUNT)
16271627
}
16281628

16291629
pub fn checked_hash(&self, w: &mut Witness<Fp>) -> Fp {
16301630
use crate::proofs::transaction::transaction_snark::checked_hash;
16311631

16321632
let inputs = self.to_inputs_owned();
16331633

1634-
checked_hash(&MINA_ACCOUNT, &inputs.to_fields(), w)
1634+
checked_hash(MINA_ACCOUNT, &inputs.to_fields(), w)
16351635
}
16361636

16371637
pub fn rand() -> Self {

crates/ledger/src/proofs/block.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ fn checked_hash_protocol_state(
223223

224224
let mut inputs = Inputs::new();
225225
body.to_inputs(&mut inputs);
226-
let body_hash = checked_hash(&MINA_PROTO_STATE_BODY, &inputs.to_fields(), w);
226+
let body_hash = checked_hash(MINA_PROTO_STATE_BODY, &inputs.to_fields(), w);
227227

228228
let mut inputs = Inputs::new();
229229
inputs.append_field(*previous_state_hash);
230230
inputs.append_field(body_hash);
231-
let hash = checked_hash(&MINA_PROTO_STATE, &inputs.to_fields(), w);
231+
let hash = checked_hash(MINA_PROTO_STATE, &inputs.to_fields(), w);
232232

233233
Ok((hash, body_hash))
234234
}
@@ -245,12 +245,12 @@ fn checked_hash_protocol_state2(
245245

246246
let mut inputs = Inputs::new();
247247
body.to_inputs(&mut inputs);
248-
let body_hash = checked_hash(&MINA_PROTO_STATE_BODY, &inputs.to_fields(), w);
248+
let body_hash = checked_hash(MINA_PROTO_STATE_BODY, &inputs.to_fields(), w);
249249

250250
let mut inputs = Inputs::new();
251251
inputs.append_field(*previous_state_hash);
252252
inputs.append_field(body_hash);
253-
let hash = checked_hash(&MINA_PROTO_STATE, &inputs.to_fields(), w);
253+
let hash = checked_hash(MINA_PROTO_STATE, &inputs.to_fields(), w);
254254

255255
(hash, body_hash)
256256
}
@@ -654,7 +654,7 @@ mod vrf {
654654

655655
fn hash_to_group(m: &Message, w: &mut Witness<Fp>) -> GroupAffine<Fp> {
656656
let inputs = m.to_inputs_owned().to_fields();
657-
let hash = checked_hash(&MINA_VRF_MESSAGE, &inputs, w);
657+
let hash = checked_hash(MINA_VRF_MESSAGE, &inputs, w);
658658
crate::proofs::group_map::to_group(hash, w)
659659
}
660660

@@ -690,7 +690,7 @@ mod vrf {
690690
inputs.append_field(x);
691691
inputs.append_field(y);
692692

693-
checked_hash(&MINA_VRF_OUTPUT, &inputs.to_fields(), w)
693+
checked_hash(MINA_VRF_OUTPUT, &inputs.to_fields(), w)
694694
}
695695

696696
fn eval_and_check_public_key(
@@ -1398,7 +1398,7 @@ pub mod consensus {
13981398
};
13991399

14001400
fn epoch_seed_update_var(seed: Fp, vrf_result: Fp, w: &mut Witness<Fp>) -> Fp {
1401-
checked_hash(&MINA_EPOCH_SEED, &[seed, vrf_result], w)
1401+
checked_hash(MINA_EPOCH_SEED, &[seed, vrf_result], w)
14021402
}
14031403

14041404
let next_epoch_data = {

crates/ledger/src/proofs/transaction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4535,7 +4535,6 @@ pub(super) mod tests {
45354535
use core::panic;
45364536
use std::path::Path;
45374537

4538-
use crate::hash::params::MINA_ZKAPP_EVENT;
45394538
use mina_p2p_messages::binprot::{
45404539
self,
45414540
macros::{BinProtRead, BinProtWrite},

crates/ledger/src/scan_state/pending_coinbase.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl CoinbaseStack {
156156
inputs.append(&CoinbaseData::of_coinbase(cb));
157157
inputs.append_field(self.0);
158158

159-
let hash = hash_with_kimchi(&COINBASE_STACK, &inputs.to_fields());
159+
let hash = hash_with_kimchi(COINBASE_STACK, &inputs.to_fields());
160160
Self(hash)
161161
}
162162

@@ -166,7 +166,7 @@ impl CoinbaseStack {
166166
inputs.append(&CoinbaseData::of_coinbase(cb));
167167
inputs.append_field(self.0);
168168

169-
let hash = checked_hash(&COINBASE_STACK, &inputs.to_fields(), w);
169+
let hash = checked_hash(COINBASE_STACK, &inputs.to_fields(), w);
170170
Self(hash)
171171
}
172172

@@ -180,7 +180,7 @@ impl CoinbaseStack {
180180

181181
/// <https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/mina_base/pending_coinbase.ml#L188>
182182
pub fn empty() -> Self {
183-
Self(hash_noinputs(&NO_INPUT_COINBASE_STACK))
183+
Self(hash_noinputs(NO_INPUT_COINBASE_STACK))
184184
}
185185

186186
/// Used for tests/debug only
@@ -227,7 +227,7 @@ impl StateStack {
227227
inputs.append_field(state_body_hash);
228228
inputs.append_field(global_slot.to_field());
229229

230-
let hash = hash_with_kimchi(&MINA_PROTO_STATE, &inputs.to_fields());
230+
let hash = hash_with_kimchi(MINA_PROTO_STATE, &inputs.to_fields());
231231

232232
Self {
233233
init: self.init,
@@ -247,7 +247,7 @@ impl StateStack {
247247
inputs.append_field(state_body_hash);
248248
inputs.append_field(global_slot.to_field());
249249

250-
let hash = checked_hash(&MINA_PROTO_STATE, &inputs.to_fields(), w);
250+
let hash = checked_hash(MINA_PROTO_STATE, &inputs.to_fields(), w);
251251

252252
Self {
253253
init: self.init,
@@ -458,7 +458,7 @@ impl Stack {
458458
}
459459

460460
fn hash_var(&self, w: &mut Witness<Fp>) -> Fp {
461-
checked_hash(&COINBASE_STACK, &self.to_inputs_owned().to_fields(), w)
461+
checked_hash(COINBASE_STACK, &self.to_inputs_owned().to_fields(), w)
462462
}
463463
}
464464

crates/ledger/src/scan_state/transaction_logic/local_state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl StackFrame {
208208
};
209209
inputs.append_field(field);
210210

211-
hash_with_kimchi(&MINA_ACCOUNT_UPDATE_STACK_FRAME, &inputs.to_fields())
211+
hash_with_kimchi(MINA_ACCOUNT_UPDATE_STACK_FRAME, &inputs.to_fields())
212212
}
213213

214214
pub fn digest(&self) -> Fp {
@@ -253,10 +253,10 @@ impl StackFrameCheckedFrame {
253253

254254
if self.is_default {
255255
use crate::proofs::transaction::transaction_snark::checked_hash3;
256-
checked_hash3(&MINA_ACCOUNT_UPDATE_STACK_FRAME, &fields, w)
256+
checked_hash3(MINA_ACCOUNT_UPDATE_STACK_FRAME, &fields, w)
257257
} else {
258258
use crate::proofs::transaction::transaction_snark::checked_hash;
259-
checked_hash(&MINA_ACCOUNT_UPDATE_STACK_FRAME, &fields, w)
259+
checked_hash(MINA_ACCOUNT_UPDATE_STACK_FRAME, &fields, w)
260260
}
261261
}
262262
}

crates/ledger/src/scan_state/transaction_logic/zkapp_command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ impl<AccUpdate: Clone + AccountUpdateRef> Tree<AccUpdate> {
22722272
};
22732273
let account_update_digest = self.account_update_digest.get().unwrap();
22742274
hash_with_kimchi(
2275-
&MINA_ACCOUNT_UPDATE_NODE,
2275+
MINA_ACCOUNT_UPDATE_NODE,
22762276
&[account_update_digest, stack_hash],
22772277
)
22782278
}
@@ -2384,7 +2384,7 @@ impl<AccUpdate: Clone + AccountUpdateRef> CallForest<AccUpdate> {
23842384
let hash = tree.digest();
23852385
let h_tl = self.hash();
23862386

2387-
let stack_hash = hash_with_kimchi(&MINA_ACCOUNT_UPDATE_CONS, &[hash, h_tl]);
2387+
let stack_hash = hash_with_kimchi(MINA_ACCOUNT_UPDATE_CONS, &[hash, h_tl]);
23882388
let node = WithStackHash::<AccUpdate> {
23892389
elt: tree,
23902390
stack_hash: MutableFp::new(stack_hash),
@@ -2591,7 +2591,7 @@ impl<AccUpdate: Clone + AccountUpdateRef> CallForest<AccUpdate> {
25912591
pub fn accumulate_hashes(&self) {
25922592
/// <https://github.com/MinaProtocol/mina/blob/3fe924c80a4d01f418b69f27398f5f93eb652514/src/lib/mina_base/zkapp_command.ml#L293>
25932593
fn cons(hash: Fp, h_tl: Fp) -> Fp {
2594-
hash_with_kimchi(&MINA_ACCOUNT_UPDATE_CONS, &[hash, h_tl])
2594+
hash_with_kimchi(MINA_ACCOUNT_UPDATE_CONS, &[hash, h_tl])
25952595
}
25962596

25972597
/// <https://github.com/MinaProtocol/mina/blob/3fe924c80a4d01f418b69f27398f5f93eb652514/src/lib/mina_base/zkapp_command.ml#L561>

crates/ledger/src/zkapps/snark.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl ZkappHandler for SnarkHandler {
183183
let account2 = account.clone();
184184
let account = WithLazyHash::new(account, move |w: &mut Witness<Fp>| {
185185
let zkapp = MyCow::borrow_or_default(&account2.zkapp);
186-
zkapp.checked_hash_with_param(&MINA_ZKAPP_ACCOUNT, w);
186+
zkapp.checked_hash_with_param(MINA_ZKAPP_ACCOUNT, w);
187187
account2.checked_hash(w)
188188
});
189189
account
@@ -306,8 +306,8 @@ impl CallForestInterface for SnarkCallForest {
306306
[x, ..] => x.stack_hash.get().unwrap(), // Never fail, it was already hashed
307307
});
308308
let tree_hash = [account_update.hash, subforest.hash]
309-
.checked_hash_with_param(&MINA_ACCOUNT_UPDATE_NODE, w);
310-
let _hash_cons = [tree_hash, tl_hash].checked_hash_with_param(&MINA_ACCOUNT_UPDATE_CONS, w);
309+
.checked_hash_with_param(MINA_ACCOUNT_UPDATE_NODE, w);
310+
let _hash_cons = [tree_hash, tl_hash].checked_hash_with_param(MINA_ACCOUNT_UPDATE_CONS, w);
311311
let account = Self::AccountUpdate {
312312
body: account_update,
313313
authorization: auth.clone(),
@@ -417,7 +417,7 @@ impl StackFrameInterface for StackFrameChecked {
417417

418418
/// Call_stack_digest.Checked.cons
419419
fn call_stack_digest_checked_cons(h: Fp, t: Fp, w: &mut Witness<Fp>) -> Fp {
420-
checked_hash(&MINA_ACCOUNT_UPDATE_STACK_FRAME_CONS, &[h, t], w)
420+
checked_hash(MINA_ACCOUNT_UPDATE_STACK_FRAME_CONS, &[h, t], w)
421421
}
422422

423423
impl StackInterface for WithHash<Vec<WithStackHash<WithHash<StackFrame>>>> {
@@ -881,7 +881,7 @@ impl AccountInterface for SnarkAccount {
881881
.as_ref()
882882
.unwrap();
883883
let vk = w.exists(vk.vk());
884-
vk.checked_hash_with_param(&MINA_SIDELOADED_VK, w);
884+
vk.checked_hash_with_param(MINA_SIDELOADED_VK, w);
885885
}
886886
Signature | NoneGiven => {}
887887
}
@@ -1029,7 +1029,7 @@ impl LedgerInterface for LedgerWithHash {
10291029
let account2 = account.0.clone();
10301030
let account = WithLazyHash::new(account.0, move |w: &mut Witness<Fp>| {
10311031
let zkapp = MyCow::borrow_or_default(&account2.zkapp);
1032-
zkapp.checked_hash_with_param(&MINA_ZKAPP_ACCOUNT, w);
1032+
zkapp.checked_hash_with_param(MINA_ZKAPP_ACCOUNT, w);
10331033
account2.checked_hash(w)
10341034
});
10351035
let inclusion = w.exists(
@@ -1112,7 +1112,7 @@ impl AccountIdInterface for SnarkAccountId {
11121112
type W = Witness<Fp>;
11131113

11141114
fn derive_token_id(account_id: &AccountId, w: &mut Self::W) -> TokenId {
1115-
TokenId(account_id.checked_hash_with_param(&MINA_DERIVE_TOKEN_ID, w))
1115+
TokenId(account_id.checked_hash_with_param(MINA_DERIVE_TOKEN_ID, w))
11161116
}
11171117
}
11181118

@@ -1220,8 +1220,7 @@ impl TransactionCommitmentInterface for SnarkTransactionCommitment {
12201220
) -> Fp {
12211221
let fee_payer_hash = account_updates.body.hash;
12221222

1223-
[memo_hash, fee_payer_hash, commitment]
1224-
.checked_hash_with_param(&MINA_ACCOUNT_UPDATE_CONS, w)
1223+
[memo_hash, fee_payer_hash, commitment].checked_hash_with_param(MINA_ACCOUNT_UPDATE_CONS, w)
12251224
}
12261225
}
12271226

@@ -1373,7 +1372,7 @@ impl ActionsInterface for SnarkActions {
13731372

13741373
fn push_events(event: Fp, actions: &zkapp_command::Actions, w: &mut Self::W) -> Fp {
13751374
let hash = zkapp_command::events_to_field(actions);
1376-
checked_hash(&MINA_ZKAPP_SEQ_EVENTS, &[event, hash], w)
1375+
checked_hash(MINA_ZKAPP_SEQ_EVENTS, &[event, hash], w)
13771376
}
13781377
}
13791378

@@ -1393,7 +1392,7 @@ impl ReceiptChainHashInterface for SnarkReceiptChainHash {
13931392
inputs.append_field(element);
13941393
inputs.append(&other);
13951394

1396-
ReceiptChainHash(checked_hash(&CODA_RECEIPT_UC, &inputs.to_fields(), w))
1395+
ReceiptChainHash(checked_hash(CODA_RECEIPT_UC, &inputs.to_fields(), w))
13971396
}
13981397
}
13991398

0 commit comments

Comments
 (0)