Move ecdh derivation up to prevent Scalar::one() * ecdh

This commit is contained in:
Luke Parker
2023-03-11 10:51:40 -05:00
parent 5e62072a0f
commit 36034c2f72
3 changed files with 10 additions and 19 deletions

View File

@@ -59,12 +59,11 @@ pub(crate) fn uniqueness(inputs: &[Input]) -> [u8; 32] {
#[allow(non_snake_case)]
pub(crate) fn shared_key(
uniqueness: Option<[u8; 32]>,
s: &Zeroizing<Scalar>,
P: &EdwardsPoint,
ecdh: EdwardsPoint,
o: usize,
) -> (u8, Scalar, [u8; 8]) {
// 8Ra
let mut output_derivation = (s.deref() * P).mul_by_cofactor().compress().to_bytes().to_vec();
let mut output_derivation = ecdh.mul_by_cofactor().compress().to_bytes().to_vec();
let mut payment_id_xor = [0; 8];
payment_id_xor