You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When scanning for one-sided outputs, the client computes a Diffie-Hellman shared secret, serializes it to bytes, and then parses the bytes using modular reduction to a scalar. This scalar is then hashed and parsed as a scalar for use in commitment mask extraction. That scalar is then hashed again, parsed as a scalar, and used as input to a KDF for value decryption.
While Diffie-Hellman exchange results are uniformly-distributed group elements, they need not be uniformly-distributed byte arrays. Performing scalar reduction prior to the other operations used for key derivation is nonstandard and could lead to collisions. A more standard and safe approach could be the following:
Use the exchange result directly as input to the value encryption KDF
If mask extraction is not guaranteed to provide its own KDF (with scalar output) for the rewind key, use the exchange result directly as input to a scalar-output KDF to produce the rewind key; otherwise, it may be safe to pass the exchange result directly to the extractor
Note that this should not apply to the method used for detecting stealth address matching. That code hashes the shared secret prior to parsing as a scalar.
The text was updated successfully, but these errors were encountered:
Currently working on a fix for this. It uses separate KDFs that each take the shared secret as input: one for the spending key, another for the rewind key, and a third for the encryption key. This also takes advantage of the new DiffieHellmanSharedSecrettype.
Description
---
Uses KDFs on ECDH shared secrets for output generation. Closes [issue 4717](#4717).
Motivation and Context
---
Several uses of ECDH shared secrets in the output manager and transaction services parse an ECDH shared secret as a scalar spending key, and use this as input to a chain of hash functions for use in rewinding and value encryption. This is non-standard.
This work uses separate KDFs to independently produce a spending key, rewind key, and value encryption key from a `DiffieHellmanSharedSecret`-type ECDH shared secret.
How Has This Been Tested?
---
Existing tests pass.
BREAKING CHANGE: Changes the way output keys are derived.
When scanning for one-sided outputs, the client computes a Diffie-Hellman shared secret, serializes it to bytes, and then parses the bytes using modular reduction to a scalar. This scalar is then hashed and parsed as a scalar for use in commitment mask extraction. That scalar is then hashed again, parsed as a scalar, and used as input to a KDF for value decryption.
The relevant code:
While Diffie-Hellman exchange results are uniformly-distributed group elements, they need not be uniformly-distributed byte arrays. Performing scalar reduction prior to the other operations used for key derivation is nonstandard and could lead to collisions. A more standard and safe approach could be the following:
Note that this should not apply to the method used for detecting stealth address matching. That code hashes the shared secret prior to parsing as a scalar.
The text was updated successfully, but these errors were encountered: