File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -421,8 +421,9 @@ Point.prototype.getY = function getY() {
421
421
422
422
Point . prototype . mul = function mul ( k ) {
423
423
k = new BN ( k , 16 ) ;
424
-
425
- if ( this . _hasDoubles ( k ) )
424
+ if ( this . isInfinity ( ) )
425
+ return this ;
426
+ else if ( this . _hasDoubles ( k ) )
426
427
return this . curve . _fixedNafMul ( this , k ) ;
427
428
else if ( this . curve . endo )
428
429
return this . curve . _endoWnafMulAdd ( [ this ] , [ k ] ) ;
Original file line number Diff line number Diff line change @@ -253,6 +253,13 @@ describe('Curve', function() {
253
253
var neg2 = neg . neg ( true ) ;
254
254
assert ( p . eq ( neg2 ) ) ;
255
255
} ) ;
256
+
257
+ it ( 'should correctly handle scalar multiplication of zero' , function ( ) {
258
+ var curve = elliptic . curves . secp256k1 . curve ;
259
+ var p1 = curve . g . mul ( '0' ) ;
260
+ var p2 = p1 . mul ( '2' ) ;
261
+ assert ( p1 . eq ( p2 ) ) ;
262
+ } ) ;
256
263
} ) ;
257
264
258
265
describe ( 'Point codec' , function ( ) {
You can’t perform that action at this time.
0 commit comments