mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-03-10 22:23:33 +00:00
fix: removed redundant logging
This commit is contained in:
parent
cf92157728
commit
fa406e7a86
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4253,6 +4253,7 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
"secp256k1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
@ -23,3 +23,4 @@ bip39.workspace = true
|
||||
hmac-sha512.workspace = true
|
||||
thiserror.workspace = true
|
||||
itertools.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@ -79,6 +79,7 @@ mod tests {
|
||||
use rand::RngCore;
|
||||
|
||||
use super::*;
|
||||
use crate::key_management::ephemeral_key_holder::EphemeralKeyHolder;
|
||||
|
||||
#[test]
|
||||
fn test_new_os_random() {
|
||||
@ -151,4 +152,201 @@ mod tests {
|
||||
hex::encode(viewing_public_key.to_bytes())
|
||||
);
|
||||
}
|
||||
|
||||
fn account_with_chain_index_2_for_tests() -> KeyChain {
|
||||
let key_chain_raw = r#"
|
||||
{
|
||||
"secret_spending_key": [
|
||||
208,
|
||||
155,
|
||||
82,
|
||||
128,
|
||||
101,
|
||||
206,
|
||||
20,
|
||||
95,
|
||||
241,
|
||||
147,
|
||||
159,
|
||||
231,
|
||||
207,
|
||||
78,
|
||||
152,
|
||||
28,
|
||||
114,
|
||||
111,
|
||||
61,
|
||||
69,
|
||||
254,
|
||||
51,
|
||||
242,
|
||||
28,
|
||||
28,
|
||||
195,
|
||||
170,
|
||||
242,
|
||||
160,
|
||||
24,
|
||||
47,
|
||||
189
|
||||
],
|
||||
"private_key_holder": {
|
||||
"nullifier_secret_key": [
|
||||
142,
|
||||
76,
|
||||
154,
|
||||
157,
|
||||
42,
|
||||
40,
|
||||
174,
|
||||
199,
|
||||
151,
|
||||
63,
|
||||
2,
|
||||
216,
|
||||
52,
|
||||
103,
|
||||
81,
|
||||
42,
|
||||
200,
|
||||
177,
|
||||
189,
|
||||
49,
|
||||
81,
|
||||
39,
|
||||
166,
|
||||
139,
|
||||
203,
|
||||
154,
|
||||
156,
|
||||
166,
|
||||
88,
|
||||
159,
|
||||
11,
|
||||
151
|
||||
],
|
||||
"viewing_secret_key": [
|
||||
122,
|
||||
94,
|
||||
159,
|
||||
21,
|
||||
28,
|
||||
49,
|
||||
169,
|
||||
79,
|
||||
12,
|
||||
156,
|
||||
171,
|
||||
90,
|
||||
41,
|
||||
216,
|
||||
203,
|
||||
75,
|
||||
251,
|
||||
192,
|
||||
204,
|
||||
217,
|
||||
18,
|
||||
49,
|
||||
28,
|
||||
219,
|
||||
213,
|
||||
147,
|
||||
244,
|
||||
194,
|
||||
205,
|
||||
237,
|
||||
134,
|
||||
36
|
||||
]
|
||||
},
|
||||
"nullifer_public_key": [
|
||||
235,
|
||||
24,
|
||||
62,
|
||||
99,
|
||||
243,
|
||||
236,
|
||||
137,
|
||||
35,
|
||||
153,
|
||||
149,
|
||||
6,
|
||||
10,
|
||||
118,
|
||||
239,
|
||||
117,
|
||||
188,
|
||||
64,
|
||||
8,
|
||||
33,
|
||||
52,
|
||||
220,
|
||||
231,
|
||||
11,
|
||||
39,
|
||||
180,
|
||||
117,
|
||||
1,
|
||||
22,
|
||||
62,
|
||||
199,
|
||||
164,
|
||||
169
|
||||
],
|
||||
"viewing_public_key": [
|
||||
2,
|
||||
253,
|
||||
204,
|
||||
5,
|
||||
212,
|
||||
86,
|
||||
249,
|
||||
156,
|
||||
132,
|
||||
143,
|
||||
1,
|
||||
172,
|
||||
80,
|
||||
61,
|
||||
18,
|
||||
185,
|
||||
233,
|
||||
36,
|
||||
221,
|
||||
58,
|
||||
64,
|
||||
110,
|
||||
89,
|
||||
242,
|
||||
202,
|
||||
230,
|
||||
154,
|
||||
66,
|
||||
45,
|
||||
252,
|
||||
138,
|
||||
174,
|
||||
37
|
||||
]
|
||||
}
|
||||
"#;
|
||||
|
||||
serde_json::from_str(key_chain_raw).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_trivial_chain_index() {
|
||||
let keys = account_with_chain_index_2_for_tests();
|
||||
|
||||
let eph_key_holder = EphemeralKeyHolder::new(&keys.nullifer_public_key);
|
||||
|
||||
let key_sender = eph_key_holder.calculate_shared_secret_sender(&keys.viewing_public_key);
|
||||
let key_receiver = keys.calculate_shared_secret_receiver(
|
||||
eph_key_holder.generate_ephemeral_public_key(),
|
||||
Some(2),
|
||||
);
|
||||
|
||||
assert_eq!(key_sender.0, key_receiver.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,19 +368,6 @@ impl WalletCore {
|
||||
.map(|keys| keys.ssk)
|
||||
.collect();
|
||||
|
||||
// ["dbfa57c178c287057c94f2fa8caaf78649d1dcac8d4eec0759264a22ebc788b4",
|
||||
// "e3aa7298c9cc409f001e425caf139d0f5d627201fa60c0868d68f200c9044825"]
|
||||
// ["dbfa57c178c287057c94f2fa8caaf78649d1dcac8d4eec0759264a22ebc788b4",
|
||||
// "17a5070917903d5213db9ce9442ba472d8682af318fb5369e5c784c3980cacc9"]
|
||||
|
||||
info!(
|
||||
"shared secrets is {:?}",
|
||||
shared_secrets
|
||||
.iter()
|
||||
.map(|secret| hex::encode(secret.0))
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
Ok((
|
||||
self.sequencer_client.send_tx_private(tx).await?,
|
||||
shared_secrets,
|
||||
@ -494,205 +481,3 @@ impl WalletCore {
|
||||
&self.config_overrides
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use key_protocol::key_management::{KeyChain, ephemeral_key_holder::EphemeralKeyHolder};
|
||||
|
||||
fn account_for_tests() -> KeyChain {
|
||||
let key_chain_raw = r#"
|
||||
{
|
||||
"secret_spending_key": [
|
||||
208,
|
||||
155,
|
||||
82,
|
||||
128,
|
||||
101,
|
||||
206,
|
||||
20,
|
||||
95,
|
||||
241,
|
||||
147,
|
||||
159,
|
||||
231,
|
||||
207,
|
||||
78,
|
||||
152,
|
||||
28,
|
||||
114,
|
||||
111,
|
||||
61,
|
||||
69,
|
||||
254,
|
||||
51,
|
||||
242,
|
||||
28,
|
||||
28,
|
||||
195,
|
||||
170,
|
||||
242,
|
||||
160,
|
||||
24,
|
||||
47,
|
||||
189
|
||||
],
|
||||
"private_key_holder": {
|
||||
"nullifier_secret_key": [
|
||||
142,
|
||||
76,
|
||||
154,
|
||||
157,
|
||||
42,
|
||||
40,
|
||||
174,
|
||||
199,
|
||||
151,
|
||||
63,
|
||||
2,
|
||||
216,
|
||||
52,
|
||||
103,
|
||||
81,
|
||||
42,
|
||||
200,
|
||||
177,
|
||||
189,
|
||||
49,
|
||||
81,
|
||||
39,
|
||||
166,
|
||||
139,
|
||||
203,
|
||||
154,
|
||||
156,
|
||||
166,
|
||||
88,
|
||||
159,
|
||||
11,
|
||||
151
|
||||
],
|
||||
"viewing_secret_key": [
|
||||
122,
|
||||
94,
|
||||
159,
|
||||
21,
|
||||
28,
|
||||
49,
|
||||
169,
|
||||
79,
|
||||
12,
|
||||
156,
|
||||
171,
|
||||
90,
|
||||
41,
|
||||
216,
|
||||
203,
|
||||
75,
|
||||
251,
|
||||
192,
|
||||
204,
|
||||
217,
|
||||
18,
|
||||
49,
|
||||
28,
|
||||
219,
|
||||
213,
|
||||
147,
|
||||
244,
|
||||
194,
|
||||
205,
|
||||
237,
|
||||
134,
|
||||
36
|
||||
]
|
||||
},
|
||||
"nullifer_public_key": [
|
||||
235,
|
||||
24,
|
||||
62,
|
||||
99,
|
||||
243,
|
||||
236,
|
||||
137,
|
||||
35,
|
||||
153,
|
||||
149,
|
||||
6,
|
||||
10,
|
||||
118,
|
||||
239,
|
||||
117,
|
||||
188,
|
||||
64,
|
||||
8,
|
||||
33,
|
||||
52,
|
||||
220,
|
||||
231,
|
||||
11,
|
||||
39,
|
||||
180,
|
||||
117,
|
||||
1,
|
||||
22,
|
||||
62,
|
||||
199,
|
||||
164,
|
||||
169
|
||||
],
|
||||
"viewing_public_key": [
|
||||
2,
|
||||
253,
|
||||
204,
|
||||
5,
|
||||
212,
|
||||
86,
|
||||
249,
|
||||
156,
|
||||
132,
|
||||
143,
|
||||
1,
|
||||
172,
|
||||
80,
|
||||
61,
|
||||
18,
|
||||
185,
|
||||
233,
|
||||
36,
|
||||
221,
|
||||
58,
|
||||
64,
|
||||
110,
|
||||
89,
|
||||
242,
|
||||
202,
|
||||
230,
|
||||
154,
|
||||
66,
|
||||
45,
|
||||
252,
|
||||
138,
|
||||
174,
|
||||
37
|
||||
]
|
||||
}
|
||||
"#;
|
||||
|
||||
serde_json::from_str(key_chain_raw).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_1() {
|
||||
let keys = account_for_tests();
|
||||
|
||||
let eph_key_holder = EphemeralKeyHolder::new(&keys.nullifer_public_key);
|
||||
|
||||
let key_sender = eph_key_holder.calculate_shared_secret_sender(&keys.viewing_public_key);
|
||||
let key_receiver = keys.calculate_shared_secret_receiver(
|
||||
eph_key_holder.generate_ephemeral_public_key(),
|
||||
Some(2),
|
||||
);
|
||||
|
||||
assert_eq!(key_sender.0, key_receiver.0);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user