@@ -32,6 +32,7 @@ test('Bits using total, risk', t => {
3232 t . is ( round ( Entropy . bits ( 100000 , 100000 ) ) , 49 )
3333} )
3434
35+ // CxTBD Remove bitsWithRiskPower in next release
3536test ( 'Bits using total, risk power' , t => {
3637 t . is ( round ( Entropy . bitsWithRiskPower ( 10 , 3 ) ) , 15 )
3738 t . is ( round ( Entropy . bitsWithRiskPower ( 10 , 4 ) ) , 19 )
@@ -53,6 +54,7 @@ test('Bits using total, risk power', t => {
5354 t . is ( round ( Entropy . bitsWithRiskPower ( 100000 , 5 ) ) , 49 )
5455} )
5556
57+ // CxTBD Remove bitsWithPowers in next release
5658test ( 'Bits using total power, risk power' , t => {
5759 t . is ( round ( Entropy . bitsWithPowers ( 1 , 3 ) ) , 15 )
5860 t . is ( round ( Entropy . bitsWithPowers ( 1 , 4 ) ) , 19 )
@@ -77,105 +79,96 @@ test('Bits using total power, risk power', t => {
7779
7880// preshing.com tests come from table at http://preshing.com/20110504/hash-collision-probabilities/
7981test ( 'preshing.com, 32-bit column' , t => {
80- t . is ( round ( Entropy . bits ( 30084 , 10 ) ) , 32 )
81- t . is ( round ( Entropy . bits ( 9292 , 100 ) ) , 32 )
82- t . is ( round ( Entropy . bits ( 2932 , 1000 ) ) , 32 )
83- t . is ( round ( Entropy . bits ( 927 , 10000 ) ) , 32 )
84- t . is ( round ( Entropy . bits ( 294 , 100000 ) ) , 32 )
85- t . is ( round ( Entropy . bits ( 93 , 1000000 ) ) , 32 )
86- t . is ( round ( Entropy . bits ( 30 , 10000000 ) ) , 32 )
87- t . is ( round ( Entropy . bits ( 10 , 100000000 ) ) , 32 )
88-
89- t . is ( round ( Entropy . bitsWithRiskPower ( 30084 , 1 ) ) , 32 )
90- t . is ( round ( Entropy . bitsWithRiskPower ( 9292 , 2 ) ) , 32 )
91- t . is ( round ( Entropy . bitsWithRiskPower ( 2932 , 3 ) ) , 32 )
92- t . is ( round ( Entropy . bitsWithRiskPower ( 927 , 4 ) ) , 32 )
93- t . is ( round ( Entropy . bitsWithRiskPower ( 294 , 5 ) ) , 32 )
94- t . is ( round ( Entropy . bitsWithRiskPower ( 93 , 6 ) ) , 32 )
95- t . is ( round ( Entropy . bitsWithRiskPower ( 30 , 7 ) ) , 32 )
96- t . is ( round ( Entropy . bitsWithRiskPower ( 10 , 8 ) ) , 32 )
82+ t . is ( round ( Entropy . bits ( 30084 , 10 ) ) , 32 )
83+ t . is ( round ( Entropy . bits ( 9292 , 100 ) ) , 32 )
84+ t . is ( round ( Entropy . bits ( 2932 , 1e3 ) ) , 32 )
85+ t . is ( round ( Entropy . bits ( 927 , 1e4 ) ) , 32 )
86+ t . is ( round ( Entropy . bits ( 294 , 1e5 ) ) , 32 )
87+ t . is ( round ( Entropy . bits ( 93 , 1e6 ) ) , 32 )
88+ t . is ( round ( Entropy . bits ( 30 , 1e7 ) ) , 32 )
89+ t . is ( round ( Entropy . bits ( 10 , 1e8 ) ) , 32 )
9790} )
9891
9992test ( 'preshing.com, 64-bit column' , t => {
100- t . is ( round ( Entropy . bitsWithRiskPower ( 1970000000 , 1 ) ) , 64 )
101- t . is ( round ( Entropy . bitsWithRiskPower ( 609000000 , 2 ) ) , 64 )
102- t . is ( round ( Entropy . bitsWithRiskPower ( 192000000 , 3 ) ) , 64 )
103- t . is ( round ( Entropy . bitsWithRiskPower ( 60700000 , 4 ) ) , 64 )
104- t . is ( round ( Entropy . bitsWithRiskPower ( 19200000 , 5 ) ) , 64 )
105- t . is ( round ( Entropy . bitsWithRiskPower ( 6070000 , 6 ) ) , 64 )
106- t . is ( round ( Entropy . bitsWithRiskPower ( 1920000 , 7 ) ) , 64 )
107- t . is ( round ( Entropy . bitsWithRiskPower ( 607401 , 8 ) ) , 64 )
108- t . is ( round ( Entropy . bitsWithRiskPower ( 192077 , 9 ) ) , 64 )
109- t . is ( round ( Entropy . bitsWithRiskPower ( 60704 , 10 ) ) , 64 )
110- t . is ( round ( Entropy . bitsWithRiskPower ( 19208 , 11 ) ) , 64 )
111- t . is ( round ( Entropy . bitsWithRiskPower ( 6074 , 12 ) ) , 64 )
112- t . is ( round ( Entropy . bitsWithRiskPower ( 1921 , 13 ) ) , 64 )
113- t . is ( round ( Entropy . bitsWithRiskPower ( 608 , 14 ) ) , 64 )
114- t . is ( round ( Entropy . bitsWithRiskPower ( 193 , 15 ) ) , 64 )
115- t . is ( round ( Entropy . bitsWithRiskPower ( 61 , 16 ) ) , 64 )
116- t . is ( round ( Entropy . bitsWithRiskPower ( 20 , 17 ) ) , 64 )
117- t . is ( round ( Entropy . bitsWithRiskPower ( 7 , 18 ) ) , 64 )
93+ t . is ( round ( Entropy . bits ( 1.97e9 , 10 ) ) , 64 )
94+ t . is ( round ( Entropy . bits ( 6.09e8 , 100 ) ) , 64 )
95+ t . is ( round ( Entropy . bits ( 1.92e8 , 1e3 ) ) , 64 )
96+ t . is ( round ( Entropy . bits ( 6.07e7 , 1e4 ) ) , 64 )
97+ t . is ( round ( Entropy . bits ( 1.92e7 , 1e5 ) ) , 64 )
98+ t . is ( round ( Entropy . bits ( 6.07e6 , 1e6 ) ) , 64 )
99+ t . is ( round ( Entropy . bits ( 1.92e6 , 1e7 ) ) , 64 )
100+ t . is ( round ( Entropy . bits ( 607401 , 1e8 ) ) , 64 )
101+ t . is ( round ( Entropy . bits ( 192077 , 1e9 ) ) , 64 )
102+ t . is ( round ( Entropy . bits ( 60704 , 1e10 ) ) , 64 )
103+ t . is ( round ( Entropy . bits ( 19208 , 1e11 ) ) , 64 )
104+ t . is ( round ( Entropy . bits ( 6074 , 1e12 ) ) , 64 )
105+ t . is ( round ( Entropy . bits ( 1921 , 1e13 ) ) , 64 )
106+ t . is ( round ( Entropy . bits ( 608 , 1e14 ) ) , 64 )
107+ t . is ( round ( Entropy . bits ( 193 , 1e15 ) ) , 64 )
108+ t . is ( round ( Entropy . bits ( 61 , 1e16 ) ) , 64 )
109+ t . is ( round ( Entropy . bits ( 20 , 1e17 ) ) , 64 )
110+ t . is ( round ( Entropy . bits ( 7 , 1e18 ) ) , 64 )
118111} )
119112
120113test ( 'preshing.com, 160-bit column, modified and extended' , t => {
121- t . is ( round ( Entropy . bitsWithPowers ( 24 , 1 ) ) , 162 )
122- t . is ( round ( Entropy . bitsWithPowers ( 23 , 1 ) ) , 155 )
123- t . is ( round ( Entropy . bitsWithPowers ( 24 , 2 ) ) , 165 )
124- t . is ( round ( Entropy . bitsWithPowers ( 23 , 2 ) ) , 158 )
125- t . is ( round ( Entropy . bitsWithPowers ( 23 , 3 ) ) , 162 )
126- t . is ( round ( Entropy . bitsWithPowers ( 22 , 3 ) ) , 155 )
127- t . is ( round ( Entropy . bitsWithPowers ( 23 , 4 ) ) , 165 )
128- t . is ( round ( Entropy . bitsWithPowers ( 22 , 4 ) ) , 158 )
129- t . is ( round ( Entropy . bitsWithPowers ( 22 , 5 ) ) , 162 )
130- t . is ( round ( Entropy . bitsWithPowers ( 21 , 5 ) ) , 155 )
131- t . is ( round ( Entropy . bitsWithPowers ( 22 , 6 ) ) , 165 )
132- t . is ( round ( Entropy . bitsWithPowers ( 21 , 6 ) ) , 158 )
133- t . is ( round ( Entropy . bitsWithPowers ( 21 , 7 ) ) , 162 )
134- t . is ( round ( Entropy . bitsWithPowers ( 20 , 7 ) ) , 155 )
135- t . is ( round ( Entropy . bitsWithPowers ( 21 , 8 ) ) , 165 )
136- t . is ( round ( Entropy . bitsWithPowers ( 20 , 8 ) ) , 158 )
137- t . is ( round ( Entropy . bitsWithPowers ( 20 , 9 ) ) , 162 )
138- t . is ( round ( Entropy . bitsWithPowers ( 19 , 9 ) ) , 155 )
139- t . is ( round ( Entropy . bitsWithPowers ( 20 , 10 ) ) , 165 )
140- t . is ( round ( Entropy . bitsWithPowers ( 19 , 10 ) ) , 158 )
141- t . is ( round ( Entropy . bitsWithPowers ( 19 , 11 ) ) , 162 )
142- t . is ( round ( Entropy . bitsWithPowers ( 18 , 11 ) ) , 155 )
143- t . is ( round ( Entropy . bitsWithPowers ( 19 , 12 ) ) , 165 )
144- t . is ( round ( Entropy . bitsWithPowers ( 18 , 12 ) ) , 158 )
145- t . is ( round ( Entropy . bitsWithPowers ( 18 , 13 ) ) , 162 )
146- t . is ( round ( Entropy . bitsWithPowers ( 17 , 13 ) ) , 155 )
147- t . is ( round ( Entropy . bitsWithPowers ( 18 , 14 ) ) , 165 )
148- t . is ( round ( Entropy . bitsWithPowers ( 17 , 14 ) ) , 158 )
149- t . is ( round ( Entropy . bitsWithPowers ( 17 , 15 ) ) , 162 )
150- t . is ( round ( Entropy . bitsWithPowers ( 16 , 15 ) ) , 155 )
151- t . is ( round ( Entropy . bitsWithPowers ( 17 , 16 ) ) , 165 )
152- t . is ( round ( Entropy . bitsWithPowers ( 16 , 16 ) ) , 158 )
153- t . is ( round ( Entropy . bitsWithPowers ( 16 , 17 ) ) , 162 )
154- t . is ( round ( Entropy . bitsWithPowers ( 15 , 17 ) ) , 155 )
155- t . is ( round ( Entropy . bitsWithPowers ( 16 , 18 ) ) , 165 )
156- t . is ( round ( Entropy . bitsWithPowers ( 15 , 18 ) ) , 158 )
157- t . is ( round ( Entropy . bitsWithPowers ( 15 , 19 ) ) , 162 )
158- t . is ( round ( Entropy . bitsWithPowers ( 14 , 19 ) ) , 155 )
159- t . is ( round ( Entropy . bitsWithPowers ( 15 , 20 ) ) , 165 )
160- t . is ( round ( Entropy . bitsWithPowers ( 14 , 20 ) ) , 158 )
161- t . is ( round ( Entropy . bitsWithPowers ( 14 , 21 ) ) , 162 )
162- t . is ( round ( Entropy . bitsWithPowers ( 13 , 21 ) ) , 155 )
163- t . is ( round ( Entropy . bitsWithPowers ( 14 , 22 ) ) , 165 )
164- t . is ( round ( Entropy . bitsWithPowers ( 13 , 22 ) ) , 158 )
165- t . is ( round ( Entropy . bitsWithPowers ( 13 , 23 ) ) , 162 )
166- t . is ( round ( Entropy . bitsWithPowers ( 12 , 23 ) ) , 155 )
167- t . is ( round ( Entropy . bitsWithPowers ( 13 , 24 ) ) , 165 )
168- t . is ( round ( Entropy . bitsWithPowers ( 12 , 24 ) ) , 158 )
169- t . is ( round ( Entropy . bitsWithPowers ( 12 , 25 ) ) , 162 )
170- t . is ( round ( Entropy . bitsWithPowers ( 11 , 25 ) ) , 155 )
171- t . is ( round ( Entropy . bitsWithPowers ( 12 , 26 ) ) , 165 )
172- t . is ( round ( Entropy . bitsWithPowers ( 11 , 26 ) ) , 158 )
173- t . is ( round ( Entropy . bitsWithPowers ( 11 , 27 ) ) , 162 )
174- t . is ( round ( Entropy . bitsWithPowers ( 10 , 27 ) ) , 155 )
175- t . is ( round ( Entropy . bitsWithPowers ( 11 , 28 ) ) , 165 )
176- t . is ( round ( Entropy . bitsWithPowers ( 10 , 28 ) ) , 158 )
177- t . is ( round ( Entropy . bitsWithPowers ( 10 , 29 ) ) , 162 )
178- t . is ( round ( Entropy . bitsWithPowers ( 9 , 29 ) ) , 155 )
179- t . is ( round ( Entropy . bitsWithPowers ( 10 , 30 ) ) , 165 )
180- t . is ( round ( Entropy . bitsWithPowers ( 9 , 30 ) ) , 158 )
114+ t . is ( round ( Entropy . bits ( 1e24 , 10 ) ) , 162 )
115+ t . is ( round ( Entropy . bits ( 1e23 , 10 ) ) , 155 )
116+ t . is ( round ( Entropy . bits ( 1e24 , 100 ) ) , 165 )
117+ t . is ( round ( Entropy . bits ( 1e23 , 100 ) ) , 158 )
118+ t . is ( round ( Entropy . bits ( 1e23 , 1e3 ) ) , 162 )
119+ t . is ( round ( Entropy . bits ( 1e22 , 1e3 ) ) , 155 )
120+ t . is ( round ( Entropy . bits ( 1e23 , 1e4 ) ) , 165 )
121+ t . is ( round ( Entropy . bits ( 1e22 , 1e4 ) ) , 158 )
122+ t . is ( round ( Entropy . bits ( 1e22 , 1e5 ) ) , 162 )
123+ t . is ( round ( Entropy . bits ( 1e21 , 1e5 ) ) , 155 )
124+ t . is ( round ( Entropy . bits ( 1e22 , 1e6 ) ) , 165 )
125+ t . is ( round ( Entropy . bits ( 1e21 , 1e6 ) ) , 158 )
126+ t . is ( round ( Entropy . bits ( 1e21 , 1e7 ) ) , 162 )
127+ t . is ( round ( Entropy . bits ( 1e20 , 1e7 ) ) , 155 )
128+ t . is ( round ( Entropy . bits ( 1e21 , 1e8 ) ) , 165 )
129+ t . is ( round ( Entropy . bits ( 1e20 , 1e8 ) ) , 158 )
130+ t . is ( round ( Entropy . bits ( 1e20 , 1e9 ) ) , 162 )
131+ t . is ( round ( Entropy . bits ( 1e19 , 1e9 ) ) , 155 )
132+ t . is ( round ( Entropy . bits ( 1e20 , 1e10 ) ) , 165 )
133+ t . is ( round ( Entropy . bits ( 1e19 , 1e10 ) ) , 158 )
134+ t . is ( round ( Entropy . bits ( 1e19 , 1e11 ) ) , 162 )
135+ t . is ( round ( Entropy . bits ( 1e18 , 1e11 ) ) , 155 )
136+ t . is ( round ( Entropy . bits ( 1e19 , 1e12 ) ) , 165 )
137+ t . is ( round ( Entropy . bits ( 1e18 , 1e12 ) ) , 158 )
138+ t . is ( round ( Entropy . bits ( 1e18 , 1e13 ) ) , 162 )
139+ t . is ( round ( Entropy . bits ( 1e17 , 1e13 ) ) , 155 )
140+ t . is ( round ( Entropy . bits ( 1e18 , 1e14 ) ) , 165 )
141+ t . is ( round ( Entropy . bits ( 1e17 , 1e14 ) ) , 158 )
142+ t . is ( round ( Entropy . bits ( 1e17 , 1e15 ) ) , 162 )
143+ t . is ( round ( Entropy . bits ( 1e16 , 1e15 ) ) , 155 )
144+ t . is ( round ( Entropy . bits ( 1e17 , 1e16 ) ) , 165 )
145+ t . is ( round ( Entropy . bits ( 1e16 , 1e16 ) ) , 158 )
146+ t . is ( round ( Entropy . bits ( 1e16 , 1e17 ) ) , 162 )
147+ t . is ( round ( Entropy . bits ( 1e15 , 1e17 ) ) , 155 )
148+ t . is ( round ( Entropy . bits ( 1e16 , 1e18 ) ) , 165 )
149+ t . is ( round ( Entropy . bits ( 1e15 , 1e18 ) ) , 158 )
150+ t . is ( round ( Entropy . bits ( 1e15 , 1e19 ) ) , 162 )
151+ t . is ( round ( Entropy . bits ( 1e14 , 1e19 ) ) , 155 )
152+ t . is ( round ( Entropy . bits ( 1e15 , 1e20 ) ) , 165 )
153+ t . is ( round ( Entropy . bits ( 1e14 , 1e20 ) ) , 158 )
154+ t . is ( round ( Entropy . bits ( 1e14 , 1e21 ) ) , 162 )
155+ t . is ( round ( Entropy . bits ( 1e13 , 1e21 ) ) , 155 )
156+ t . is ( round ( Entropy . bits ( 1e14 , 1e22 ) ) , 165 )
157+ t . is ( round ( Entropy . bits ( 1e13 , 1e22 ) ) , 158 )
158+ t . is ( round ( Entropy . bits ( 1e13 , 1e23 ) ) , 162 )
159+ t . is ( round ( Entropy . bits ( 1e12 , 1e23 ) ) , 155 )
160+ t . is ( round ( Entropy . bits ( 1e13 , 1e24 ) ) , 165 )
161+ t . is ( round ( Entropy . bits ( 1e12 , 1e24 ) ) , 158 )
162+ t . is ( round ( Entropy . bits ( 1e12 , 1e25 ) ) , 162 )
163+ t . is ( round ( Entropy . bits ( 1e11 , 1e25 ) ) , 155 )
164+ t . is ( round ( Entropy . bits ( 1e12 , 1e26 ) ) , 165 )
165+ t . is ( round ( Entropy . bits ( 1e11 , 1e26 ) ) , 158 )
166+ t . is ( round ( Entropy . bits ( 1e11 , 1e27 ) ) , 162 )
167+ t . is ( round ( Entropy . bits ( 1e10 , 1e27 ) ) , 155 )
168+ t . is ( round ( Entropy . bits ( 1e11 , 1e28 ) ) , 165 )
169+ t . is ( round ( Entropy . bits ( 1e10 , 1e28 ) ) , 158 )
170+ t . is ( round ( Entropy . bits ( 1e10 , 1e29 ) ) , 162 )
171+ t . is ( round ( Entropy . bits ( 1e9 , 1e29 ) ) , 155 )
172+ t . is ( round ( Entropy . bits ( 1e10 , 1e30 ) ) , 165 )
173+ t . is ( round ( Entropy . bits ( 1e9 , 1e30 ) ) , 158 )
181174} )
0 commit comments