Sfoglia il codice sorgente

kdf_sapling(): add comment about non-constant function call edge case.

zero 2 anni fa
parent
commit
36a36b1728
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      src/sdk/src/crypto/diffie_hellman.rs

+ 3 - 0
src/sdk/src/crypto/diffie_hellman.rs

@@ -36,6 +36,9 @@ pub fn sapling_ka_agree(esk: &SecretKey, pk_d: &PublicKey) -> PublicKey {
 
 
 /// Sapling KDF for note encryption.
 /// Sapling KDF for note encryption.
 pub fn kdf_sapling(dhsecret: &PublicKey, epk: &PublicKey) -> Blake2bHash {
 pub fn kdf_sapling(dhsecret: &PublicKey, epk: &PublicKey) -> Blake2bHash {
+    // The P.to_bytes() for P ∈ ℙₚ function used on affine curves it not perfectly constant time,
+    // but it's close enough. The function returns 0 when P = ∞ is the identity which is the
+    // edge case but almost never occurs.
     Blake2bParams::new()
     Blake2bParams::new()
         .hash_length(32)
         .hash_length(32)
         .personal(KDF_SAPLING_PERSONALIZATION)
         .personal(KDF_SAPLING_PERSONALIZATION)