|
@@ -9,14 +9,14 @@ use darkfi::{
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/// The state machine, held in memory.
|
|
/// The state machine, held in memory.
|
|
|
-struct State {
|
|
|
|
|
|
|
+pub struct State {
|
|
|
/// The entire Merkle tree state
|
|
/// The entire Merkle tree state
|
|
|
- tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
|
|
|
|
|
|
+ pub tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
|
|
/// List of all previous and the current Merkle roots.
|
|
/// List of all previous and the current Merkle roots.
|
|
|
/// This is the hashed value of all the children.
|
|
/// This is the hashed value of all the children.
|
|
|
- merkle_roots: Vec<MerkleNode>,
|
|
|
|
|
|
|
+ pub merkle_roots: Vec<MerkleNode>,
|
|
|
/// Nullifiers prevent double spending
|
|
/// Nullifiers prevent double spending
|
|
|
- nullifiers: Vec<Nullifier>,
|
|
|
|
|
|
|
+ pub nullifiers: Vec<Nullifier>,
|
|
|
/// Verifying key for the mint zk circuit.
|
|
/// Verifying key for the mint zk circuit.
|
|
|
mint_vk: VerifyingKey,
|
|
mint_vk: VerifyingKey,
|
|
|
/// Verifying key for the burn zk circuit.
|
|
/// Verifying key for the burn zk circuit.
|
|
@@ -54,20 +54,3 @@ impl ProgramState for State {
|
|
|
&self.burn_vk
|
|
&self.burn_vk
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-impl State {
|
|
|
|
|
- fn apply(&mut self, mut update: StateUpdate) {
|
|
|
|
|
- // Extend our list of nullifiers with the ones from the update
|
|
|
|
|
- self.nullifiers.append(&mut update.nullifiers);
|
|
|
|
|
-
|
|
|
|
|
- // Update merkle tree and witnesses
|
|
|
|
|
- for (coin, enc_note) in update.coins.into_iter().zip(update.enc_notes.into_iter()) {
|
|
|
|
|
- // Add the new coins to the Merkle tree
|
|
|
|
|
- let node = MerkleNode(coin.0);
|
|
|
|
|
- self.tree.append(&node);
|
|
|
|
|
-
|
|
|
|
|
- // Keep track of all Merkle roots that have existed
|
|
|
|
|
- self.merkle_roots.push(self.tree.root(0).unwrap());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|