Przeglądaj źródła

update leadcoin in state

mohab metwally 3 lat temu
rodzic
commit
fcc5fa05fd
2 zmienionych plików z 4 dodań i 3 usunięć
  1. 3 3
      src/consensus/leadcoin.rs
  2. 1 0
      src/consensus/state.rs

+ 3 - 3
src/consensus/leadcoin.rs

@@ -107,7 +107,7 @@ impl LeadCoin {
         // Merkle root of the `coin_1` secret key in the Merkle tree of secret keys
         coin1_sk_root: MerkleNode,
         // sk pos
-        coin1_sk_pos: u32,
+        coin1_sk_pos: usize,
         // Merkle path to the secret key of `coin_1` in the Merkle tree of secret keys
         coin1_sk_merkle_path: [MerkleNode; MERKLE_DEPTH_LEADCOIN],
         // what's seed supposed to be?
@@ -203,7 +203,7 @@ impl LeadCoin {
             sn: c_sn,
             coin1_commitment_root,
             coin1_sk_root,
-            coin1_sk_pos,
+            coin1_sk_pos: u32::try_from(usize::from(coin1_sk_pos )).unwrap(),
             coin1_commitment_merkle_path: coin1_commitment_merkle_path.try_into().unwrap(),
             coin1_sk_merkle_path,
             coin1_blind,
@@ -243,7 +243,7 @@ impl LeadCoin {
         let pk_msg = [prefix_pk, self.coin1_sk_root.inner(), self.tau, zero];
         let pk = poseidon_hash(pk_msg);
         // rho
-        let rho_msg = [prefix_evl, self.coin1_sk_root.inner(), nonce, zero];
+        let rho_msg = [prefix_evl, self.coin1_sk_root.inner(), self.nonce, zero];
         let c2_rho = poseidon_hash(rho_msg);
         // coin 1-2 cm/commitment
         let c1_cm = self.coin1_commitment.to_affine().coordinates().unwrap();

+ 1 - 0
src/consensus/state.rs

@@ -393,6 +393,7 @@ impl ValidatorState {
                 LOTTERY_HEAD_START, // TODO: TESTNET: Why is this constant being used?
                 i,
                 epoch_secrets.merkle_roots[i],
+                i, //TODO same as idx now for simplicity.
                 epoch_secrets.merkle_paths[i],
                 seeds[i],
                 epoch_secrets.secret_keys[i],