Skip to content

Commit b935ff4

Browse files
Add an extra check in UInt256_8x32 and clarify xml doc
1 parent 7c9bd67 commit b935ff4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/UInt256_8x32.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file LICENCE or http://www.opensource.org/licenses/mit-license.php.
55

6+
using System.Diagnostics;
67
using System.Runtime.CompilerServices;
78

89
namespace Autarkysoft.Bitcoin.Cryptography.EllipticCurve
@@ -62,13 +63,18 @@ public UInt256_8x32(in UInt256_10x26 u26)
6263
/// <summary>
6364
/// Conditional move. Sets <paramref name="r"/> equal to <paramref name="a"/> if flag is true (=1).
6465
/// </summary>
65-
/// <param name="r"></param>
66-
/// <param name="a"></param>
66+
/// <remarks>
67+
/// This method is constant time.
68+
/// </remarks>
69+
/// <param name="r">Destination</param>
70+
/// <param name="a">Source</param>
6771
/// <param name="flag">Zero or one. Sets <paramref name="r"/> equal to <paramref name="a"/> if flag is one.</param>
68-
/// <returns>Result</returns>
72+
/// <returns><paramref name="a"/> if flag was one; otherwise r.</returns>
6973
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7074
public static UInt256_8x32 CMov(in UInt256_8x32 r, in UInt256_8x32 a, uint flag)
7175
{
76+
Debug.Assert(flag == 0 || flag == 1);
77+
7278
uint mask0 = flag + ~0U;
7379
uint mask1 = ~mask0;
7480
return new UInt256_8x32(

0 commit comments

Comments
 (0)