Use more intuitive local var numbering
In test code we use multiple pub/sec keys. It is more intuitive if the 'secret 1' is generated by the owner of secret key 1. Refactor only, no logic changes.
This commit is contained in:
parent
834f63c26c
commit
d5eeb099ad
|
@ -34,8 +34,8 @@ use secp256k1_sys::types::{c_int, c_uchar, c_void};
|
||||||
/// let s = Secp256k1::new();
|
/// let s = Secp256k1::new();
|
||||||
/// let (sk1, pk1) = s.generate_keypair(&mut thread_rng());
|
/// let (sk1, pk1) = s.generate_keypair(&mut thread_rng());
|
||||||
/// let (sk2, pk2) = s.generate_keypair(&mut thread_rng());
|
/// let (sk2, pk2) = s.generate_keypair(&mut thread_rng());
|
||||||
/// let sec1 = SharedSecret::new(&pk1, &sk2);
|
/// let sec1 = SharedSecret::new(&pk2, &sk1);
|
||||||
/// let sec2 = SharedSecret::new(&pk2, &sk1);
|
/// let sec2 = SharedSecret::new(&pk1, &sk2);
|
||||||
/// assert_eq!(sec1, sec2);
|
/// assert_eq!(sec1, sec2);
|
||||||
/// # }
|
/// # }
|
||||||
// ```
|
// ```
|
||||||
|
@ -200,8 +200,8 @@ mod tests {
|
||||||
let (sk1, pk1) = s.generate_keypair(&mut thread_rng());
|
let (sk1, pk1) = s.generate_keypair(&mut thread_rng());
|
||||||
let (sk2, pk2) = s.generate_keypair(&mut thread_rng());
|
let (sk2, pk2) = s.generate_keypair(&mut thread_rng());
|
||||||
|
|
||||||
let sec1 = SharedSecret::new(&pk1, &sk2);
|
let sec1 = SharedSecret::new(&pk2, &sk1);
|
||||||
let sec2 = SharedSecret::new(&pk2, &sk1);
|
let sec2 = SharedSecret::new(&pk1, &sk2);
|
||||||
let sec_odd = SharedSecret::new(&pk1, &sk1);
|
let sec_odd = SharedSecret::new(&pk1, &sk1);
|
||||||
assert_eq!(sec1, sec2);
|
assert_eq!(sec1, sec2);
|
||||||
assert!(sec_odd != sec2);
|
assert!(sec_odd != sec2);
|
||||||
|
|
Loading…
Reference in New Issue