7
7
8
8
namespace Org . BouncyCastle . Crypto . Tests
9
9
{
10
- public class NistEccTest
10
+ [ TestFixture ]
11
+ public class NistEccTest : SimpleTest
11
12
{
13
+ public override string Name { get ; } = "NistEcc" ;
14
+
15
+ public override void PerformTest ( )
16
+ {
17
+ foreach ( var testVector in CollectTestVectors ( ) )
18
+ {
19
+ TestMultiply (
20
+ curve : testVector [ 0 ] as string ,
21
+ k : testVector [ 1 ] as BigInteger ,
22
+ expectedX : testVector [ 2 ] as BigInteger ,
23
+ expectedY : testVector [ 3 ] as BigInteger
24
+ ) ;
25
+ }
26
+ }
27
+
12
28
public IEnumerable < object [ ] > CollectTestVectors ( )
13
29
{
14
30
string curve = null ;
@@ -55,7 +71,6 @@ public IEnumerable<object[]> CollectTestVectors()
55
71
}
56
72
}
57
73
58
- [ TestCaseSource ( nameof ( CollectTestVectors ) ) ]
59
74
public void TestMultiply ( string curve , BigInteger k , BigInteger expectedX , BigInteger expectedY )
60
75
{
61
76
// Arrange
@@ -65,8 +80,21 @@ public void TestMultiply(string curve, BigInteger k, BigInteger expectedX, BigIn
65
80
var ecPoint = x9EcParameters . G . Multiply ( k ) . Normalize ( ) ;
66
81
67
82
// Assert
68
- Assert . AreEqual ( expectedX , ecPoint . XCoord . ToBigInteger ( ) , "Unexpected X Coordinate" ) ;
69
- Assert . AreEqual ( expectedY , ecPoint . YCoord . ToBigInteger ( ) , "Unexpected Y Coordinate" ) ;
83
+ IsEquals ( "Unexpected X Coordinate" , expectedX , ecPoint . AffineXCoord . ToBigInteger ( ) ) ;
84
+ IsEquals ( "Unexpected Y Coordinate" , expectedY , ecPoint . AffineYCoord . ToBigInteger ( ) ) ;
85
+ }
86
+
87
+ public static void Main ( string [ ] args )
88
+ {
89
+ RunTest ( new NistEccTest ( ) ) ;
90
+ }
91
+
92
+ [ Test ]
93
+ public void TestFunction ( )
94
+ {
95
+ string resultText = Perform ( ) . ToString ( ) ;
96
+
97
+ Assert . AreEqual ( Name + ": Okay" , resultText ) ;
70
98
}
71
99
}
72
100
}
0 commit comments