File tree 1 file changed +9
-3
lines changed
Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 3
3
// Distributed under the MIT software license, see the accompanying
4
4
// file LICENCE or http://www.opensource.org/licenses/mit-license.php.
5
5
6
+ using System . Diagnostics ;
6
7
using System . Runtime . CompilerServices ;
7
8
8
9
namespace Autarkysoft . Bitcoin . Cryptography . EllipticCurve
@@ -62,13 +63,18 @@ public UInt256_8x32(in UInt256_10x26 u26)
62
63
/// <summary>
63
64
/// Conditional move. Sets <paramref name="r"/> equal to <paramref name="a"/> if flag is true (=1).
64
65
/// </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>
67
71
/// <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>
69
73
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
70
74
public static UInt256_8x32 CMov ( in UInt256_8x32 r , in UInt256_8x32 a , uint flag )
71
75
{
76
+ Debug . Assert ( flag == 0 || flag == 1 ) ;
77
+
72
78
uint mask0 = flag + ~ 0U ;
73
79
uint mask1 = ~ mask0 ;
74
80
return new UInt256_8x32 (
You can’t perform that action at this time.
0 commit comments