Skip to content

Commit 43edfe5

Browse files
committed
fix calc merkle root
1 parent 7c5abd9 commit 43edfe5

File tree

9 files changed

+115
-44
lines changed

9 files changed

+115
-44
lines changed

circuits/app/proof_of_reserve/coins/provers/Prover1.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
const_message_hash = [49, 95, 91, 219, 118, 208, 120, 196, 59, 138, 192, 6, 78, 74, 1, 100, 97, 43, 31, 206, 119, 200, 105, 52, 91, 252, 148, 199, 88, 148, 237, 211]
2+
finalize_mr = false
23

34
[[coins_database]]
45
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
5-
amount = 8651008
6+
amount = 2601774
67

78
[[coins_database]]
89
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
9-
amount = 7299269
10+
amount = 8930174
1011

1112
[[coins_database]]
1213
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
13-
amount = 2193795
14+
amount = 2581082
1415

1516
[[coins_database]]
1617
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
17-
amount = 8517520
18+
amount = 6915709
1819

1920
[[coins_database]]
2021
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
21-
amount = 6174260
22+
amount = 6884780
2223

2324
[[coins_database]]
2425
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
25-
amount = 9936895
26+
amount = 9754249
2627

2728
[[coins_database]]
2829
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
29-
amount = 3330723
30+
amount = 8451177
3031

3132
[[coins_database]]
3233
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
33-
amount = 5061920
34+
amount = 4004444
3435

3536
[[own_utxos]]
3637
witness = [48, 69, 2, 33, 0, 176, 13, 195, 19, 255, 73, 45, 45, 108, 64, 66, 69, 250, 68, 134, 160, 179, 250, 237, 127, 30, 197, 101, 2, 107, 209, 142, 13, 184, 235, 138, 56, 2, 32, 120, 103, 36, 158, 33, 198, 151, 26, 30, 56, 250, 37, 73, 202, 33, 166, 26, 253, 114, 192, 163, 252, 223, 56, 48, 150, 15, 48, 27, 224, 6, 63, 0]

circuits/app/proof_of_reserve/coins/provers/Prover2.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
const_message_hash = [49, 95, 91, 219, 118, 208, 120, 196, 59, 138, 192, 6, 78, 74, 1, 100, 97, 43, 31, 206, 119, 200, 105, 52, 91, 252, 148, 199, 88, 148, 237, 211]
2+
finalize_mr = true
23

34
[[coins_database]]
45
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
5-
amount = 8798295
6+
amount = 7971045
67

78
[[coins_database]]
8-
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
9-
amount = 8965247
9+
script_pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
10+
amount = 0
1011

1112
[[coins_database]]
12-
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
13-
amount = 2620697
13+
script_pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
14+
amount = 0
1415

1516
[[coins_database]]
16-
script_pub_key = [118, 169, 20, 121, 176, 0, 136, 118, 38, 178, 148, 169, 20, 80, 26, 76, 210, 38, 181, 139, 35, 89, 131, 136, 172]
17-
amount = 2779613
17+
script_pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
18+
amount = 0
1819

1920
[[coins_database]]
2021
script_pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
@@ -37,16 +38,16 @@ witness = [48, 69, 2, 33, 0, 176, 13, 195, 19, 255, 73, 45, 45, 108, 64, 66, 69,
3738
pub_key = [3, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186, 5, 101, 215, 30, 24, 52, 96, 72, 25, 255, 156, 23, 245, 233, 213, 221, 7, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
3839

3940
[[own_utxos]]
40-
witness = [48, 69, 2, 33, 0, 176, 13, 195, 19, 255, 73, 45, 45, 108, 64, 66, 69, 250, 68, 134, 160, 179, 250, 237, 127, 30, 197, 101, 2, 107, 209, 142, 13, 184, 235, 138, 56, 2, 32, 120, 103, 36, 158, 33, 198, 151, 26, 30, 56, 250, 37, 73, 202, 33, 166, 26, 253, 114, 192, 163, 252, 223, 56, 48, 150, 15, 48, 27, 224, 6, 63, 0]
41-
pub_key = [3, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186, 5, 101, 215, 30, 24, 52, 96, 72, 25, 255, 156, 23, 245, 233, 213, 221, 7, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
41+
witness = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
42+
pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
4243

4344
[[own_utxos]]
44-
witness = [48, 69, 2, 33, 0, 176, 13, 195, 19, 255, 73, 45, 45, 108, 64, 66, 69, 250, 68, 134, 160, 179, 250, 237, 127, 30, 197, 101, 2, 107, 209, 142, 13, 184, 235, 138, 56, 2, 32, 120, 103, 36, 158, 33, 198, 151, 26, 30, 56, 250, 37, 73, 202, 33, 166, 26, 253, 114, 192, 163, 252, 223, 56, 48, 150, 15, 48, 27, 224, 6, 63, 0]
45-
pub_key = [3, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186, 5, 101, 215, 30, 24, 52, 96, 72, 25, 255, 156, 23, 245, 233, 213, 221, 7, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
45+
witness = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
46+
pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
4647

4748
[[own_utxos]]
48-
witness = [48, 69, 2, 33, 0, 176, 13, 195, 19, 255, 73, 45, 45, 108, 64, 66, 69, 250, 68, 134, 160, 179, 250, 237, 127, 30, 197, 101, 2, 107, 209, 142, 13, 184, 235, 138, 56, 2, 32, 120, 103, 36, 158, 33, 198, 151, 26, 30, 56, 250, 37, 73, 202, 33, 166, 26, 253, 114, 192, 163, 252, 223, 56, 48, 150, 15, 48, 27, 224, 6, 63, 0]
49-
pub_key = [3, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186, 5, 101, 215, 30, 24, 52, 96, 72, 25, 255, 156, 23, 245, 233, 213, 221, 7, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
49+
witness = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
50+
pub_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
5051

5152
[[own_utxos]]
5253
witness = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

circuits/app/proof_of_reserve/coins/src/main.nr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn main(
2727
const_message_hash: pub [u8; SHA256_HASH_SIZE],
2828
coins_database: [CoinsDatabaseElement; MAX_COINS_DATABASE_AMOUNT],
2929
own_utxos: [Spending; MAX_COINS_DATABASE_AMOUNT],
30+
finalize_mr: bool,
3031
) -> pub ([u8; SHA256_HASH_SIZE], u64) {
3132
let mut owned_amount = 0;
3233
let mut coins_hashes = [[0; SHA256_HASH_SIZE]; MAX_COINS_DATABASE_AMOUNT];
@@ -84,5 +85,8 @@ fn main(
8485
};
8586
}
8687

87-
(merkle_root::<MAX_COINS_DATABASE_AMOUNT, MAX_MERKLE_TREE_LEVELS>(coins_hashes), owned_amount)
88+
(
89+
merkle_root::<MAX_COINS_DATABASE_AMOUNT, MAX_MERKLE_TREE_LEVELS>(coins_hashes, finalize_mr),
90+
owned_amount,
91+
)
8892
}

circuits/app/proof_of_reserve/utxos_tree/provers/Prover_0_1.toml

Lines changed: 7 additions & 6 deletions
Large diffs are not rendered by default.

circuits/app/proof_of_reserve/utxos_tree/src/main.nr

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ fn main(
1616
verification_key: UltraHonkVerificationKey,
1717
key_hash: Field,
1818
node_proofs: [NodeProof; MAX_NODES_AMOUNT],
19-
) -> pub ([u8; SHA256_HASH_SIZE], u64) {
19+
finalize_mr: bool,
20+
) -> pub ([u8; SHA256_HASH_SIZE], [u8; SHA256_HASH_SIZE], u64) {
2021
let mut nodes = [[0; SHA256_HASH_SIZE]; MAX_NODES_AMOUNT];
2122
let mut owned_amount = 0;
2223

@@ -34,11 +35,18 @@ fn main(
3435
}
3536

3637
owned_amount += node_proofs[i].public_inputs[64] as u64;
37-
}
38-
else {
38+
} else {
3939
nodes[i] = [0; 32];
4040
}
4141
}
4242

43-
(merkle_root::<MAX_NODES_AMOUNT, MAX_MERKLE_TREE_LEVELS>(nodes), owned_amount)
43+
let mut const_message = [0; 32];
44+
for i in 0..32 {
45+
const_message[i] = node_proofs[0].public_inputs[i] as u8;
46+
}
47+
48+
(
49+
const_message, merkle_root::<MAX_NODES_AMOUNT, MAX_MERKLE_TREE_LEVELS>(nodes, finalize_mr),
50+
owned_amount,
51+
)
4452
}

circuits/crates/utils/src/merkle_root.nr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn hash(leaf1: [u8; 32], leaf2: [u8; 32]) -> [u8; 32] {
66

77
pub fn merkle_root<let N: u32, let MAX_MERKLE_TREE_LEVELS: u32>(
88
mut leafs: [[u8; 32]; N],
9+
finalize_mr: bool,
910
) -> [u8; 32] {
1011
assert((N as Field).lt(2.pow_32(MAX_MERKLE_TREE_LEVELS as Field)));
1112
let mut mtree = [[0; 32]; MAX_MERKLE_TREE_LEVELS];
@@ -28,11 +29,12 @@ pub fn merkle_root<let N: u32, let MAX_MERKLE_TREE_LEVELS: u32>(
2829
}
2930

3031
let mut tmp_node = [0; 32];
31-
for i in 0..MAX_MERKLE_TREE_LEVELS {
32+
for i in 0..(MAX_MERKLE_TREE_LEVELS - 1) {
3233
if (
3334
(i < last_level & tmp_node.all(|e| e == 0))
3435
| (i <= last_level & !tmp_node.all(|e| e == 0))
35-
) {
36+
)
37+
| finalize_mr {
3638
if !mtree[i].all(|e| e == 0) {
3739
let right = if tmp_node.all(|e| e == 0) {
3840
mtree[i]

utxo_indexer/proof_of_reserve/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ hex = "0.4"
1313
sha2 = "0.10.9"
1414
k256 = { version = "0.11", features = ["ecdsa"] }
1515
tokio = { version = "1.48.0", features = ["full"] }
16-
futures = "0.3.31"
16+
futures = "0.3.31"
17+
bitcoin = "0.32.7"

utxo_indexer/proof_of_reserve/src/main.rs

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::{Ok, Result};
2+
use bitcoin::hashes::{Hash, sha256};
23
use futures::future::join_all;
34
use k256::{ecdsa::SigningKey, elliptic_curve::sec1::ToEncodedPoint};
45
use serde::{Deserialize, Serialize};
@@ -31,6 +32,7 @@ struct LeafsToml {
3132
const_message_hash: Vec<u8>,
3233
coins_database: Vec<CoinsDatabaseElement>,
3334
own_utxos: Vec<Spending>,
35+
finalize_mr: bool,
3436
}
3537

3638
#[derive(Serialize, Deserialize)]
@@ -44,13 +46,16 @@ struct NodeToml {
4446
verification_key: Vec<String>,
4547
key_hash: String,
4648
node_proofs: Vec<NodeProof>,
49+
finalize_mr: bool,
4750
}
4851

4952
#[tokio::main]
5053
async fn main() {
5154
let message = "Hello, world!";
5255
let priv_key = [1; 32];
53-
let utxos = generate_test_utxos(12, message.as_ref(), &priv_key).unwrap();
56+
let utxos = generate_test_utxos(9, message.as_ref(), &priv_key).unwrap();
57+
58+
let total_amount: u64 = utxos.iter().map(|u| u.amount).sum();
5459

5560
let sk = SigningKey::from_bytes(&priv_key).unwrap();
5661
let pk = sk.verifying_key();
@@ -60,14 +65,36 @@ async fn main() {
6065

6166
let rounded_leafs = (utxos.len() + MAX_COINS_DATABASE_AMOUNT - 1) / MAX_COINS_DATABASE_AMOUNT;
6267

63-
// run first proof
64-
leafs_tomls(utxos, message_hash.as_ref(), pub_key.as_bytes()).unwrap();
68+
//run first proof
69+
leafs_tomls(utxos.clone(), message_hash.as_ref(), pub_key.as_bytes()).unwrap();
6570
prove_leafs(rounded_leafs).await;
6671

6772
// run second proof
6873
let (mr, amount) = prove_nodes(rounded_leafs).await;
6974

7075
println!("Merkle root: {}, Amount: {}", mr, amount);
76+
get_merkle_root(utxos);
77+
println!("Expected amount: {}", total_amount)
78+
}
79+
80+
fn get_merkle_root(utxos: Vec<TestUtxo>) {
81+
let mut hashes = Vec::new();
82+
83+
for i in utxos {
84+
let mut data = i.amount.to_le_bytes().to_vec();
85+
data.append(&mut hex::decode(i.script_pub_key).unwrap());
86+
87+
let hash = Sha256::digest(data);
88+
hashes.push(hash.to_vec());
89+
}
90+
91+
let hashes: Vec<sha256::Hash> = hashes
92+
.into_iter()
93+
.map(|h| sha256::Hash::from_slice(&h).unwrap())
94+
.collect();
95+
96+
let merkle_root = bitcoin::merkle_tree::calculate_root(hashes.iter().cloned()).unwrap();
97+
println!("Expected merkle root: {merkle_root}");
7198
}
7299

73100
fn leafs_tomls(utxos: Vec<TestUtxo>, message_hash: &[u8; 32], public_key: &[u8]) -> Result<()> {
@@ -131,6 +158,7 @@ fn leafs_tomls(utxos: Vec<TestUtxo>, message_hash: &[u8; 32], public_key: &[u8])
131158
own_utxos: own_utxos
132159
[(i * MAX_COINS_DATABASE_AMOUNT)..((i + 1) * MAX_COINS_DATABASE_AMOUNT)]
133160
.to_vec(),
161+
finalize_mr: i != 0,
134162
};
135163

136164
let mut file = File::create(format!(
@@ -178,8 +206,9 @@ async fn prove_leafs(chunks: usize) {
178206
let status = Command::new("bash")
179207
.arg("-c")
180208
.arg(format!(
181-
"nargo execute -p ./provers/Prover1.toml ./coins/witness/coins{}.gz",
182-
i + 1
209+
"nargo execute -p ./provers/Prover{}.toml ./coins/witness/coins{}.gz",
210+
i + 1,
211+
i + 1,
183212
))
184213
.current_dir("../circuits/app/proof_of_reserve/coins")
185214
.status()
@@ -266,6 +295,7 @@ fn tree_tomls(nodes: usize, vk_path: String, proof_path: String, level: usize) -
266295
verification_key: vk_strings.clone(),
267296
key_hash: key_hash.clone(),
268297
node_proofs,
298+
finalize_mr: i != 0,
269299
};
270300

271301
let mut file = File::create(format!(
@@ -280,6 +310,26 @@ fn tree_tomls(nodes: usize, vk_path: String, proof_path: String, level: usize) -
280310
}
281311

282312
async fn prove_nodes(mut chunks: usize) -> (String, u64) {
313+
if chunks == 1 {
314+
// Get output data
315+
let pi = fs::read("../circuits/target/coins/proofs/proof_0_1/public_inputs").unwrap();
316+
317+
let mut idx = 1055;
318+
319+
let mut mr = [0; 32];
320+
for i in 0..32 {
321+
mr[i] = pi[idx];
322+
idx += 32;
323+
}
324+
325+
let mut amount = [0; 8];
326+
for i in 0..8 {
327+
amount[i] = pi[idx - (7 - i)];
328+
}
329+
330+
return (hex::encode(mr), u64::from_be_bytes(amount));
331+
}
332+
283333
let status = Command::new("bash")
284334
.arg("-c")
285335
.arg("nargo compile")
@@ -356,21 +406,24 @@ async fn prove_nodes(mut chunks: usize) -> (String, u64) {
356406
i += 1;
357407
}
358408

359-
// Get merkle root
409+
// Get output data
360410
let pi = fs::read(format!(
361411
"../circuits/target/tree/proofs/proof_{}_1/public_inputs",
362412
i
363413
))
364414
.unwrap();
365415

416+
let mut idx = 1055;
417+
366418
let mut mr = [0; 32];
367419
for i in 0..32 {
368-
mr[i] = pi[i * 32 + 31];
420+
mr[i] = pi[idx];
421+
idx += 32;
369422
}
370423

371424
let mut amount = [0; 8];
372425
for i in 0..8 {
373-
amount[i] = pi[1024 + 32 - (8 - i)];
426+
amount[i] = pi[idx - (7 - i)];
374427
}
375428

376429
(hex::encode(mr), u64::from_be_bytes(amount))

utxo_indexer/utxo_test_data_generator/src/test_data_gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
1313
use sha2::{Digest, Sha256};
1414

1515
#[allow(dead_code)]
16-
#[derive(Serialize, Deserialize)]
16+
#[derive(Serialize, Deserialize, Clone)]
1717
pub struct TestUtxo {
1818
pub amount: u64,
1919
pub script_pub_key: String,

0 commit comments

Comments
 (0)