@@ -2,15 +2,17 @@ console.time('prepare');
2
2
require ( '@babel/polyfill' ) ;
3
3
const crypto = require ( 'crypto' ) ;
4
4
const ArgumentParser = require ( 'argparse' ) . ArgumentParser ;
5
- //const itertools = require('@aureooms/js-itertools');
5
+ // Const itertools = require('@aureooms/js-itertools');
6
6
const XorShift128Plus = require ( 'xorshift.js' ) . XorShift128Plus ;
7
- const { ZZ , DEFAULT_DISPLAY_BASE , DEFAULT_REPRESENTATION_BASE } = require ( '..' ) ;
8
- //const BN = require('bn.js');
7
+ const { ZZ , DEFAULT_DISPLAY_BASE , DEFAULT_REPRESENTATION_BASE } = require ( '..' ) ;
8
+ // Const BN = require('bn.js');
9
9
10
10
const parser = new ArgumentParser ( ) ;
11
11
parser . addArgument ( [ 'M' ] , { defaultValue : 1000 , nargs : '?' } ) ;
12
12
parser . addArgument ( [ '-N' ] , { defaultValue : 1000 } ) ;
13
- parser . addArgument ( [ '-s' ] , { defaultValue : process . env . SEED || crypto . randomBytes ( 16 ) . toString ( 'hex' ) } ) ;
13
+ parser . addArgument ( [ '-s' ] , {
14
+ defaultValue : process . env . SEED || crypto . randomBytes ( 16 ) . toString ( 'hex' ) ,
15
+ } ) ;
14
16
const args = parser . parseArgs ( ) ;
15
17
const M = args . M ;
16
18
const N = args . N ;
@@ -21,22 +23,25 @@ console.log('number of operations:', N);
21
23
console . log ( 'seed:' , seed ) ;
22
24
23
25
const MAX_PRINT_DIGITS = 79 ;
24
- const _show = _x => _x . length <= MAX_PRINT_DIGITS ?
25
- _x :
26
- _x . slice ( 0 , ( MAX_PRINT_DIGITS - 3 ) / 2 ) + '...' + _x . slice ( _x . length - ( MAX_PRINT_DIGITS - 3 ) / 2 ) ;
26
+ const _show = ( _x ) =>
27
+ _x . length <= MAX_PRINT_DIGITS
28
+ ? _x
29
+ : _x . slice ( 0 , ( MAX_PRINT_DIGITS - 3 ) / 2 ) +
30
+ '...' +
31
+ _x . slice ( _x . length - ( MAX_PRINT_DIGITS - 3 ) / 2 ) ;
27
32
28
33
const prng = new XorShift128Plus ( seed ) ;
29
34
const _x = prng . randomBytes ( M ) . toString ( 'hex' ) ;
30
35
console . log ( '_x:' , _show ( _x ) ) ;
31
36
const _y = prng . randomBytes ( M ) . toString ( 'hex' ) ;
32
37
console . log ( '_y:' , _show ( _y ) ) ;
33
38
34
- let x = ZZ . from ( _x , 16 ) ;
39
+ const x = ZZ . from ( _x , 16 ) ;
35
40
const y = ZZ . from ( _y , 16 ) ;
36
- //let x = BigInt('0x'+_x) ;
37
- //const y = BigInt('0x'+_y) ;
38
- //let x = new BN(_x,16) ;
39
- //const y = new BN(_y,16) ;
41
+ // Let x = BigInt('0x'+_x) ;
42
+ // const y = BigInt('0x'+_y) ;
43
+ // let x = new BN(_x,16) ;
44
+ // const y = new BN(_y,16) ;
40
45
let z = x ;
41
46
42
47
console . log ( 'limbs x:' , x . limbs . length ) ;
@@ -48,12 +53,13 @@ console.timeEnd('prepare');
48
53
49
54
console . time ( 'loop' ) ;
50
55
for ( let k = 0 ; k < N ; ++ k ) {
51
- //x *= y;
52
- z = z . add ( y ) ;
53
- z = z . sub ( y ) ;
54
- //x = x + y;
55
- // x = x - y;
56
+ // X *= y;
57
+ z = z . add ( y ) ;
58
+ z = z . sub ( y ) ;
59
+ // X = x + y;
60
+ // x = x - y;
56
61
}
62
+
57
63
console . timeEnd ( 'loop' ) ;
58
64
59
65
// eslint-disable-next-line no-self-compare
0 commit comments