Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
G1lib.js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libs
G1lib.js
Commits
bef67c11
Commit
bef67c11
authored
3 years ago
by
Millicent Billette
Browse files
Options
Downloads
Patches
Plain Diff
vanityLike.mjs improved to find perfect debugSeed
parent
6f3ec9aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CI/vanityLike.mjs
+52
-26
52 additions, 26 deletions
CI/vanityLike.mjs
README.md
+3
-1
3 additions, 1 deletion
README.md
src/crypto.mjs
+8
-5
8 additions, 5 deletions
src/crypto.mjs
src/crypto.test.mjs
+3
-0
3 additions, 0 deletions
src/crypto.test.mjs
with
66 additions
and
32 deletions
CI/vanityLike.mjs
+
52
−
26
View file @
bef67c11
import
*
as
app
from
"
../src/crypto.mjs
"
;
// For thread use : https://github.com/darionco/WebCPU
const
fillChr
=
'
'
;
function
f
(
size
,
str
){
// format
const
toFill
=
size
-
str
.
length
;
if
(
toFill
>
0
)
return
fillChr
.
substring
(
0
,
toFill
)
+
str
;
return
str
;
}
function
main
()
{
for
(
let
x
=
1
;
true
;
x
++
)
{
const
strX
=
(
''
+
x
).
replace
(
/0/g
,
''
);
if
(
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
)
!==
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
,
false
,
true
)
&&
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
,
true
)
!==
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
,
true
,
true
)
/*&&
app.pubKey2checksum('pubKey'+strX).includes('11')
&&
app.pubKey2checksum('pubKey'+strX,true).includes('11')
*/
)
{
console
.
log
(
'
pubKey
'
+
strX
,
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
),
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
,
false
,
true
),
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
,
true
),
app
.
pubKey2checksum
(
'
pubKey
'
+
strX
,
true
,
true
)
);
console
.
log
(
'
11111111111111111111111pubKey49311
'
,
app
.
pubKey2checksum
(
'
11111111111111111111111pubKey49311
'
),
app
.
pubKey2checksum
(
'
11111111111111111111111pubKey49311
'
,
false
,
true
),
app
.
pubKey2checksum
(
'
11111111111111111111111pubKey49311
'
,
true
),
app
.
pubKey2checksum
(
'
11111111111111111111111pubKey49311
'
,
true
,
true
)
);
return
'
pubKey
'
+
strX
;
let
PARALLEL_INDEX
=
0
;
if
(
process
.
argv
[
2
])
PARALLEL_INDEX
=
parseInt
(
process
.
argv
[
2
]);
const
PARALLEL_THREAD
=
4
;
const
startTime
=
Date
.
now
();
// performance.now()
let
partialLevel
=
0
;
for
(
let
x
=
PARALLEL_INDEX
;
true
;
x
+=
PARALLEL_THREAD
)
{
const
strX
=
(
'
vanityDebugSeed
'
+
x
).
replace
(
/0/g
,
'
z
'
);
const
keys
=
app
.
raw2b58
(
app
.
seed2keyPair
(
app
.
b58pubKey2bin
(
strX
)));
let
pubKey
=
keys
.
publicKey
;
if
(
pubKey
[
0
]
===
'
1
'
){
pubKey
=
app
.
b58
.
encode
(
app
.
sliceInitialsZero
(
app
.
b58pubKey2bin
(
pubKey
)));
const
now
=
Date
.
now
();
// performance.now()
const
elapsed
=
f
(
7
,
''
+
Math
.
trunc
((
now
-
startTime
)
/
1000
));
const
speed
=
f
(
5
,
''
+
Math
.
trunc
((
x
/
PARALLEL_THREAD
)
/
((
now
-
startTime
)
/
1000
)));
if
(
partialLevel
<
2
){
partialLevel
=
1
;
console
.
log
(
`
${
speed
}
/s écoulé:
${
elapsed
}
s seed:
${
f
(
44
,
strX
)}
pubKey:
${
f
(
44
,
pubKey
)}
`
);
}
if
(
pubKey
.
length
===
42
){
if
(
partialLevel
<
3
){
partialLevel
=
2
;
console
.
log
(
`
${
speed
}
/s écoulé:
${
elapsed
}
s seed:
${
f
(
44
,
strX
)}
pubKey:
${
f
(
44
,
pubKey
)}
`
);
}
if
(
app
.
pubKey2checksum
(
pubKey
)[
0
]
===
'
1
'
){
if
(
partialLevel
<
4
){
partialLevel
=
3
;
console
.
log
(
`
${
speed
}
/s écoulé:
${
elapsed
}
s seed:
${
f
(
44
,
strX
)}
pubKey:
${
f
(
44
,
pubKey
)}
chk:
${
app
.
pubKey2checksum
(
pubKey
)}
${
app
.
pubKey2checksum
(
pubKey
,
false
,
true
)}
`
);
}
if
(
app
.
pubKey2checksum
(
pubKey
,
true
)[
0
]
===
'
1
'
){
console
.
log
(
`
${
speed
}
/s écoulé:
${
elapsed
}
s seed:
${
f
(
44
,
strX
)}
pubKey:
${
f
(
44
,
pubKey
)
}
chk:
${
app
.
pubKey2checksum
(
pubKey
)}
${
app
.
pubKey2checksum
(
pubKey
,
false
,
true
)
}
${
app
.
pubKey2checksum
(
pubKey
,
true
)}
${
app
.
pubKey2checksum
(
pubKey
,
true
,
true
)}
`
);
return
;
}
}
}
}
if
(
strX
.
includes
(
'
99999
'
))
console
.
log
(
'
pubKey
'
+
strX
);
}
}
main
();
// 111111111111111111111111111194999 BswTw MRTt8 6WCPk P3g1N 3kVZx 29cPB oTPUq 8rk41 gup
// 111111111111111111111111111111451 12rxvfozNLMgzH5j8sQZUCZKSMh5NGBYqaqXiSq5ifCE 7T5 7T5 7T5 7T5
// 161/s écoulé: 105s seed:171z8 pubKey:MKZWhcbCVoxLrUyZGKTQQDJwkg3CyxDJEf1NFfUdgk
// 161/s écoulé: 105s seed:171z8 pubKey: MKZWh cbCVo xLrUy ZGKTQ QDJwk g3Cyx DJEf1 NFfUd gk
This diff is collapsed.
Click to expand it.
README.md
+
3
−
1
View file @
bef67c11
...
...
@@ -19,7 +19,9 @@ An ubiquitous static javascript lib for Ǧ1 / Duniter ecosystem with reliability
-
[x] Unit tested
-
[x] Tracked quality metrics
-
[x] Static package with no-dependency
-
[x] modern esm import/export
-
[x] import only what you need
*
*
modern esm import/export & high modularity improve tree-shaking
## Usage
...
...
This diff is collapsed.
Click to expand it.
src/crypto.mjs
+
8
−
5
View file @
bef67c11
...
...
@@ -21,7 +21,7 @@ export async function idSecPass2rawAll(idSec, pass) {
};
}
function
raw2b58
(
raws
)
{
export
function
raw2b58
(
raws
)
{
const
result
=
{};
for
(
const
r
in
raws
)
result
[
r
]
=
b58
.
encode
(
raws
[
r
]);
return
result
;
...
...
@@ -60,15 +60,18 @@ export function pubKey2checksum(b58pubKey, b58viewDependant = false, checksumWit
else
binPubKey
=
b58pubKey2bin
(
b58pubKey
);
const
hash
=
sha256
.
digest
(
sha256
.
digest
(
binPubKey
));
if
(
checksumWithoutLeadingZero
)
{
let
zero
=
0
while
(
hash
[
zero
]
===
0
)
zero
++
;
const
shorterHash
=
hash
.
slice
(
zero
);
const
shorterHash
=
sliceInitialsZero
(
hash
);
return
b58
.
encode
(
shorterHash
).
substr
(
0
,
3
);
}
return
b58
.
encode
(
hash
).
substr
(
0
,
3
);
}
export
function
sliceInitialsZero
(
array
){
let
zero
=
0
while
(
array
[
zero
]
===
0
)
zero
++
;
return
array
.
slice
(
zero
);
}
function
b58pubKey2bin
(
b58pubKey
)
{
export
function
b58pubKey2bin
(
b58pubKey
)
{
const
binPubKey
=
new
Uint8Array
(
32
);
const
decoded
=
b58
.
decode
(
b58pubKey
);
binPubKey
.
set
(
decoded
,
32
-
decoded
.
length
);
...
...
This diff is collapsed.
Click to expand it.
src/crypto.test.mjs
+
3
−
0
View file @
bef67c11
...
...
@@ -71,3 +71,6 @@ test('checkKey false 11111111111111111111111pubKey49311:2p7', t => t.throws(() =
test
(
'
checkKey false pubKey49311:111
'
,
t
=>
t
.
throws
(()
=>
app
.
checkKey
(
'
pubKey49311:111
'
)));
test
(
'
checkKey false 0pubKey49311:any
'
,
t
=>
t
.
throws
(()
=>
app
.
checkKey
(
'
0pubKey49311:any
'
)));
test
(
'
pubKey2checksum 11111111111111111111111pubKey49311 : 14R
'
,
t
=>
t
.
is
(
app
.
pubKey2checksum
(
'
11111111111111111111111pubKey49311
'
),
'
14R
'
));
test
(
'
pubKey2checksum pubKey49311 : 14R
'
,
t
=>
t
.
is
(
app
.
pubKey2checksum
(
'
pubKey49311
'
),
'
14R
'
));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment