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:
Tobin Harding 2022-02-21 13:11:30 +00:00
parent 834f63c26c
commit d5eeb099ad
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 4 additions and 4 deletions

View File

@ -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);