@@ -58,7 +58,7 @@ class ECDSAUtils {
5858
5959 final jacobiSymbol = jacobi (a, p);
6060
61- if (jacobiSymbol == BigInt . from ( - 1 ) ) {
61+ if (jacobiSymbol.isNegative ) {
6262 throw SquareRootError ("$a has no square root modulo $p " );
6363 }
6464
@@ -80,7 +80,7 @@ class ECDSAUtils {
8080 }
8181
8282 for (BigInt b = BigInt .from (2 ); b < p; b += BigInt .one) {
83- if (jacobi (b * b - BigInt .from (4 ) * a, p) == BigInt . from ( - 1 ) ) {
83+ if (jacobi (b * b - BigInt .from (4 ) * a, p).isNegative ) {
8484 final quadraticForm = [a, - b, BigInt .one];
8585 final result = polynomialExponentiationMod ([BigInt .zero, BigInt .one],
8686 (p + BigInt .one) ~ / BigInt .from (2 ), quadraticForm, p);
@@ -142,20 +142,20 @@ class ECDSAUtils {
142142 ///
143143 /// Throws a JacobiError if 'n' is not an odd integer greater than or equal to 3.
144144 ///
145- static BigInt jacobi (BigInt a, BigInt n) {
145+ static int jacobi (BigInt a, BigInt n) {
146146 if (! (n >= BigInt .from (3 ))) {
147- throw const JacobiError ("n must be larger than 2" );
147+ throw const JacobiError ("n must be larger than 2. " );
148148 }
149149 if (! (n % BigInt .two == BigInt .one)) {
150- throw const JacobiError ("n must be odd" );
150+ throw const JacobiError ("n must be odd. " );
151151 }
152152
153153 a = a % n;
154154 if (a == BigInt .zero) {
155- return BigInt .zero ;
155+ return 0 ;
156156 }
157157 if (a == BigInt .one) {
158- return BigInt .one ;
158+ return 1 ;
159159 }
160160
161161 BigInt a1 = a, e = BigInt .zero;
@@ -164,14 +164,14 @@ class ECDSAUtils {
164164 e = e + BigInt .one;
165165 }
166166
167- BigInt s = BigInt .one ;
167+ int s = 1 ;
168168
169169 if (e % BigInt .two == BigInt .zero ||
170170 n % BigInt .from (8 ) == BigInt .one ||
171171 n % BigInt .from (8 ) == BigInt .from (7 )) {
172172 // s remains 1
173173 } else {
174- s = BigInt . from ( - 1 ) ;
174+ s = - 1 ;
175175 }
176176
177177 if (a1 == BigInt .one) {
0 commit comments