The method KeyExchange(ArraySegment<byte>, ArraySegment<byte>, ArraySegment<byte>) defined in the file Chaos.NaCl/Ed25519.cs performs an unnecessary ScalarOperations.sc_clamp(byte[], int) operation (link with details: Chaos.NaCl/Ed25519.cs on Line 140).
This is beacuse the following line calls MontgomeryOperations.scalarmult(out sharedMontgomeryX, h, 0, ref montgomeryX), which in turn will end calling the very same sc_clamp operation on Chaos.NaCl/Internal/Ed25519Ref10/scalarmult.cs on Line 39.
Simple fix (for a very small performance gain) is to simply remove the unnecessary ScalarOperations.sc_clamp(byte[], int) operation. Already tested and KeyExchange keeps working as expected after removing Chaos.NaCl/Ed25519.cs on Line 140).
The method
KeyExchange(ArraySegment<byte>, ArraySegment<byte>, ArraySegment<byte>)
defined in the fileChaos.NaCl/Ed25519.cs
performs an unnecessaryScalarOperations.sc_clamp(byte[], int)
operation (link with details:Chaos.NaCl/Ed25519.cs
on Line 140).This is beacuse the following line calls
MontgomeryOperations.scalarmult(out sharedMontgomeryX, h, 0, ref montgomeryX)
, which in turn will end calling the very samesc_clamp
operation on Chaos.NaCl/Internal/Ed25519Ref10/scalarmult.cs on Line 39.Simple fix (for a very small performance gain) is to simply remove the unnecessary
ScalarOperations.sc_clamp(byte[], int)
operation. Already tested andKeyExchange
keeps working as expected after removingChaos.NaCl/Ed25519.cs
on Line 140).