powerdlz23 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/package.json +1 -1
  2. package/pto/CryptoNoter/.gitattributes +2 -0
  3. package/pto/CryptoNoter/CryptoNight.md +444 -0
  4. package/pto/CryptoNoter/CryptoNight.txt +364 -0
  5. package/pto/CryptoNoter/LICENSE +21 -0
  6. package/pto/CryptoNoter/README.md +178 -0
  7. package/pto/CryptoNoter/banner +4 -0
  8. package/pto/CryptoNoter/config.json +8 -0
  9. package/pto/CryptoNoter/install.sh +60 -0
  10. package/pto/CryptoNoter/package-lock.json +33 -0
  11. package/pto/CryptoNoter/package.json +16 -0
  12. package/pto/CryptoNoter/server.js +225 -0
  13. package/pto/CryptoNoter/web/demo.html +81 -0
  14. package/pto/CryptoNoter/web/index.html +1 -0
  15. package/pto/CryptoNoter/web/lib/cryptonight-asmjs.min.js +16891 -0
  16. package/pto/CryptoNoter/web/lib/cryptonight-asmjs.min.js.mem +0 -0
  17. package/pto/CryptoNoter/web/lib/cryptonight.wasm +0 -0
  18. package/pto/CryptoNoter/web/processor.js +496 -0
  19. package/pto/CryptoNoter/web/worker.js +5549 -0
  20. package/pto/crypto/README.md +1 -0
  21. package/pto/crypto/aes256cbc/README.md +59 -0
  22. package/pto/crypto/aes256cbc/aes256cbc.go +172 -0
  23. package/pto/crypto/aes256cbc/aes256cbc_test.go +105 -0
  24. package/pto/crypto/aes256cbc/examples_test.go +30 -0
  25. package/pto/crypto/dh64/README.md +84 -0
  26. package/pto/crypto/dh64/c/dh64.c +75 -0
  27. package/pto/crypto/dh64/c/dh64.h +12 -0
  28. package/pto/crypto/dh64/c/dh64_test.c +30 -0
  29. package/pto/crypto/dh64/csharp/dh64.cs +77 -0
  30. package/pto/crypto/dh64/csharp/dh64_test.cs +1074 -0
  31. package/pto/crypto/dh64/go/dh64.go +72 -0
  32. package/pto/crypto/dh64/go/dh64_test.go +1064 -0
  33. package/pto/crypto/mt19937/README.md +30 -0
  34. package/pto/crypto/mt19937/c/mt19937-64.c +180 -0
  35. package/pto/crypto/mt19937/c/mt19937-64.h +96 -0
  36. package/pto/crypto/mt19937/c/mt19937-64.out.txt +401 -0
  37. package/pto/crypto/mt19937/c/mt19937-64test.c +78 -0
  38. package/pto/crypto/mt19937/csharp/mt19937.cs +139 -0
  39. package/pto/crypto/mt19937/csharp/mt19937_test.cs +574 -0
  40. package/pto/crypto/mt19937/go/COPYING +674 -0
  41. package/pto/crypto/mt19937/go/README.rst +103 -0
  42. package/pto/crypto/mt19937/go/doc.go +35 -0
  43. package/pto/crypto/mt19937/go/example.go +32 -0
  44. package/pto/crypto/mt19937/go/mt19937.go +149 -0
  45. package/pto/crypto/mt19937/go/mt19937_test.go +614 -0
  46. package/pto/crypto/rc4/README.md +14 -0
  47. package/pto/crypto/rc4/csharp/rc4.cs +119 -0
  48. package/pto/crypto/rc4/csharp/rc4_echo_client.cs +78 -0
  49. package/pto/crypto/rc4/go/rc4_echo_client.go +102 -0
  50. package/pto/crypto/rc4/go/rc4_echo_server.go +110 -0
@@ -0,0 +1,103 @@
1
+ The Mersenne Twister in Go
2
+ ==========================
3
+
4
+ An implementation of Takuji Nishimura's and Makoto Matsumoto's
5
+ `Mersenne Twister`_ pseudo random number generator in Go.
6
+
7
+ Copyright (C) 2013 Jochen Voss
8
+
9
+ This program is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ The homepage of this package is at <http://www.seehuhn.de/pages/mt19937>.
15
+ Please send any comments or bug reports to the program's author,
16
+ Jochen Voss <voss@seehuhn.de>.
17
+
18
+ .. _Mersenne Twister: http://en.wikipedia.org/wiki/Mersenne_twister
19
+
20
+ Overview
21
+ --------
22
+
23
+ The Mersenne Twister is a pseudo random number generator (PRNG),
24
+ developed by Takuji Nishimura and Makoto Matsumoto. The Mersenne
25
+ Twister is, for example, commonly used in Monte Carlo simulations and
26
+ is the default random number generator for many programming languages,
27
+ e.g. Python_ and R_. This package implements the `64bit version`_ of the
28
+ algorithm.
29
+
30
+ .. _Python: http://www.python.org/
31
+ .. _R: http://www.r-project.org/
32
+ .. _64bit version: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html
33
+
34
+
35
+ Installation
36
+ ------------
37
+
38
+ This package can be installed using the ``go get`` command::
39
+
40
+ go get github.com/seehuhn/mt19937
41
+
42
+
43
+ Usage
44
+ -----
45
+
46
+ Detailed usage instructions are available via the package's online
47
+ help, either on godoc.org_ or on the command line::
48
+
49
+ go doc github.com/seehuhn/mt19937
50
+
51
+ .. _godoc.org: http://godoc.org/github.com/seehuhn/mt19937
52
+
53
+ The class ``MT19937`` represents instances of the Mersenne Twister.
54
+ New instances can be allocated using the ``mt19937.New()`` function.
55
+ A seed can be set using the .Seed() or .SeedFromSlice() methods.
56
+ ``MT19937`` implements the ``rand.Source`` interface from the
57
+ ``math/rand`` package. Typically the PRNG is wrapped in a rand.Rand
58
+ object as in the following example::
59
+
60
+ rng := rand.New(mt19937.New())
61
+ rng.Seed(time.Now().UnixNano())
62
+
63
+ Comparison to the Go Default PRNG
64
+ ---------------------------------
65
+
66
+ Go has a built-in PRNG provided by the math/rand package. I did not
67
+ find any information about this built-in PRNG except for a comment in
68
+ the source code which says "algorithm by DP Mitchell and JA Reeds".
69
+ In contrast, the MT19737 generator provided in this package is a
70
+ well-understood random number generator. Relevant references include
71
+ [Ni2000]_ and [MatNi1998]_.
72
+
73
+ .. [Ni2000] T. Nishimura, *Tables of 64-bit Mersenne Twisters*, ACM
74
+ Transactions on Modeling and Computer Simulation 10, 2000, pages
75
+ 348-357.
76
+ .. [MatNi1998] M. Matsumoto and T. Nishimura, *Mersenne Twister: a
77
+ 623-dimensionally equidistributed uniform pseudorandom number
78
+ generator*, ACM Transactions on Modeling and Computer Simulation
79
+ 8, 1998, pages 3--30.
80
+
81
+ The unit tests for the mt19937 package verify that the output of the
82
+ Go implementation coincides with the output of the references
83
+ implementation.
84
+
85
+ The mt19937 generator is slightly slower than the Go default PRNG.
86
+ A speed comparison can be performed using the following command::
87
+
88
+ go test -bench=. github.com/seehuhn/mt19937
89
+
90
+ On my (64bit) system I get the following results:
91
+
92
+ +----------------+---------------+----------------+
93
+ | method | time per call | thoughput |
94
+ +================+===============+================+
95
+ | MT19937.Uint64 | 14.9 ns/op | 537.48 MB/s |
96
+ +----------------+---------------+----------------+
97
+ | MT19937.Int63 | 15.0 ns/op | 533.54 MB/s |
98
+ +----------------+---------------+----------------+
99
+ | builtin Int63 | 11.9 ns/op | 674.07 MB/s |
100
+ +----------------+---------------+----------------+
101
+
102
+ This shows that, on my system, a call to the ``Int63()`` method of the
103
+ built-in PRNG takes about 80% of the time that MT19937.Int63() takes.
@@ -0,0 +1,35 @@
1
+ // doc.go - package documentation for github.com/seehuhn/mt19937
2
+ // Copyright (C) 2013 Jochen Voss <voss@seehuhn.de>
3
+ //
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ //
9
+ // This program is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ // Package mt19937 is a pure-go implementation of the 64bit Mersenne
18
+ // Twister pseudo random number generator (PRNG). The Mersenne
19
+ // Twister, developed by Takuji Nishimura and Makoto Matsumoto, is,
20
+ // for example, commonly used in Monte Carlo simulations. The
21
+ // implementation in the mt19937 package closely follows the reference
22
+ // implementation from
23
+ //
24
+ // http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html
25
+ //
26
+ // and, for identical seeds, gives identical output to the reference
27
+ // implementation.
28
+ //
29
+ // The PRNG from the mt19937 package implements the rand.Source
30
+ // interface from the math/rand package. Typically the PRNG is
31
+ // wrapped in a rand.Rand object as in the following example:
32
+ //
33
+ // rng := rand.New(mt19937.New())
34
+ // rng.Seed(time.Now().UnixNano())
35
+ package mt19937
@@ -0,0 +1,32 @@
1
+ // example.go - a test program for the mt19937 package
2
+ // Copyright (C) 2013 Jochen Voss <voss@seehuhn.de>
3
+ //
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ //
9
+ // This program is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ // +build ignore
18
+
19
+ package main
20
+
21
+ import (
22
+ "fmt"
23
+ "github.com/funny/mt19937/go"
24
+ "math/rand"
25
+ "time"
26
+ )
27
+
28
+ func main() {
29
+ rng := rand.New(mt19937.New())
30
+ rng.Seed(time.Now().UnixNano())
31
+ fmt.Println(rng.NormFloat64())
32
+ }
@@ -0,0 +1,149 @@
1
+ // mt19937.go - an implementation of the 64bit Mersenne Twister PRNG
2
+ // Copyright (C) 2013 Jochen Voss <voss@seehuhn.de>
3
+ //
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ //
9
+ // This program is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ package mt19937
18
+
19
+ const (
20
+ n = 312
21
+ m = 156
22
+ notSeeded = n + 1
23
+
24
+ hiMask uint64 = 0xffffffff80000000
25
+ loMask uint64 = 0x000000007fffffff
26
+
27
+ matrixA uint64 = 0xB5026F5AA96619E9
28
+ )
29
+
30
+ // MT19937 is the structure to hold the state of one instance of the
31
+ // Mersenne Twister PRNG. New instances can be allocated using the
32
+ // mt19937.New() function. MT19937 implements the rand.Source
33
+ // interface and rand.New() from the math/rand package can be used to
34
+ // generate different distributions from a MT19937 PRNG.
35
+ //
36
+ // This class is not safe for concurrent accesss by different
37
+ // goroutines. If more than one goroutine accesses the PRNG, the
38
+ // callers must synchronise access using sync.Mutex or similar.
39
+ type MT19937 struct {
40
+ state []uint64
41
+ index int
42
+ }
43
+
44
+ // New allocates a new instance of the 64bit Mersenne Twister.
45
+ // A seed can be set using the .Seed() or .SeedFromSlice() methods.
46
+ func New() *MT19937 {
47
+ res := &MT19937{
48
+ state: make([]uint64, n),
49
+ index: notSeeded,
50
+ }
51
+ return res
52
+ }
53
+
54
+ // Seed uses the given 64bit value to initialise the generator state.
55
+ // This method is part of the rand.Source interface.
56
+ func (mt *MT19937) Seed(seed int64) {
57
+ x := mt.state
58
+ x[0] = uint64(seed)
59
+ for i := uint64(1); i < n; i++ {
60
+ x[i] = 6364136223846793005*(x[i-1]^(x[i-1]>>62)) + i
61
+ }
62
+ mt.index = n
63
+ }
64
+
65
+ // SeedFromSlice uses the given slice of 64bit values to set the
66
+ // generator state.
67
+ func (mt *MT19937) SeedFromSlice(key []uint64) {
68
+ mt.Seed(19650218)
69
+
70
+ x := mt.state
71
+ i := uint64(1)
72
+ j := 0
73
+ k := len(key)
74
+ if n > k {
75
+ k = n
76
+ }
77
+ for k > 0 {
78
+ x[i] = (x[i] ^ ((x[i-1] ^ (x[i-1] >> 62)) * 3935559000370003845) + key[j] + uint64(j))
79
+ i++
80
+ if i >= n {
81
+ x[0] = x[n-1]
82
+ i = 1
83
+ }
84
+ j++
85
+ if j >= len(key) {
86
+ j = 0
87
+ }
88
+ k--
89
+ }
90
+ for j := uint64(0); j < n-1; j++ {
91
+ x[i] = x[i] ^ ((x[i-1] ^ (x[i-1] >> 62)) * 2862933555777941757) - i
92
+ i++
93
+ if i >= n {
94
+ x[0] = x[n-1]
95
+ i = 1
96
+ }
97
+ }
98
+ x[0] = 1 << 63
99
+ }
100
+
101
+ // Uint64 generates a (pseudo-)random 64bit value. The output can be
102
+ // used as a replacement for a sequence of independent, uniformly
103
+ // distributed samples in the range 0, 1, ..., 2^64-1.
104
+ func (mt *MT19937) Uint64() uint64 {
105
+ x := mt.state
106
+ if mt.index >= n {
107
+ if mt.index == notSeeded {
108
+ mt.Seed(5489) // default seed, as in mt19937-64.c
109
+ }
110
+ for i := 0; i < n-m; i++ {
111
+ y := (x[i] & hiMask) | (x[i+1] & loMask)
112
+ x[i] = x[i+m] ^ (y >> 1) ^ ((y & 1) * matrixA)
113
+ }
114
+ for i := n - m; i < n-1; i++ {
115
+ y := (x[i] & hiMask) | (x[i+1] & loMask)
116
+ x[i] = x[i+(m-n)] ^ (y >> 1) ^ ((y & 1) * matrixA)
117
+ }
118
+ y := (x[n-1] & hiMask) | (x[0] & loMask)
119
+ x[n-1] = x[m-1] ^ (y >> 1) ^ ((y & 1) * matrixA)
120
+ mt.index = 0
121
+ }
122
+ y := x[mt.index]
123
+ y ^= (y >> 29) & 0x5555555555555555
124
+ y ^= (y << 17) & 0x71D67FFFEDA60000
125
+ y ^= (y << 37) & 0xFFF7EEE000000000
126
+ y ^= (y >> 43)
127
+ mt.index++
128
+ return y
129
+ }
130
+
131
+ // Int63 generates a (pseudo-)random 63bit value. The output can be
132
+ // used as a replacement for a sequence of independent, uniformly
133
+ // distributed samples in the range 0, 1, ..., 2^63-1. This method is
134
+ // part of the rand.Source interface.
135
+ func (mt *MT19937) Int63() int64 {
136
+ return int64(mt.Uint64() >> 1)
137
+ }
138
+
139
+ func (mt *MT19937) Real1() float64 {
140
+ return float64(mt.Uint64()>>11) * (1.0 / 9007199254740991.0)
141
+ }
142
+
143
+ func (mt *MT19937) Real2() float64 {
144
+ return float64(mt.Uint64()>>11) * (1.0 / 9007199254740992.0)
145
+ }
146
+
147
+ func (mt *MT19937) Real3() float64 {
148
+ return (float64(mt.Uint64()>>12) + 0.5) * (1.0 / 4503599627370496.0)
149
+ }