Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
a791dddb
Commit
a791dddb
authored
4 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#176
: Get rid of base58 code
parent
a01ddfd4
No related branches found
No related tags found
1 merge request
!149
#176: Get rid of PyNaCl and use base58 module
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
silkaj/crypto_tools.py
+0
-57
0 additions, 57 deletions
silkaj/crypto_tools.py
with
0 additions
and
57 deletions
silkaj/crypto_tools.py
+
0
−
57
View file @
a791dddb
...
@@ -82,60 +82,3 @@ def gen_checksum(pubkey):
...
@@ -82,60 +82,3 @@ def gen_checksum(pubkey):
pubkey_byte
=
base58
.
b58decode
(
pubkey
)
pubkey_byte
=
base58
.
b58decode
(
pubkey
)
hash
=
hashlib
.
sha256
(
hashlib
.
sha256
(
pubkey_byte
).
digest
()).
digest
()
hash
=
hashlib
.
sha256
(
hashlib
.
sha256
(
pubkey_byte
).
digest
()).
digest
()
return
base58
.
b58encode
(
hash
)[:
3
].
decode
(
"
utf-8
"
)
return
base58
.
b58encode
(
hash
)[:
3
].
decode
(
"
utf-8
"
)
b58_digits
=
"
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
"
def
b58_encode
(
b
):
# Convert big-endian bytes to integer
n
=
int
(
"
0x0
"
+
encoding
.
HexEncoder
.
encode
(
b
).
decode
(
"
utf8
"
),
16
)
# Divide that integer into base58
res
=
[]
while
n
>
0
:
n
,
r
=
divmod
(
n
,
58
)
res
.
append
(
b58_digits
[
r
])
res
=
""
.
join
(
res
[::
-
1
])
# Encode leading zeros as base58 zeros
czero
=
0
pad
=
0
for
c
in
b
:
if
c
==
czero
:
pad
+=
1
else
:
break
return
b58_digits
[
0
]
*
pad
+
res
def
b58_decode
(
s
):
if
not
s
:
return
b
""
# Convert the string to an integer
n
=
0
for
c
in
s
:
n
*=
58
if
c
not
in
b58_digits
:
raise
InvalidBase58Error
(
"
Character %r is not a
"
+
"
valid base58 character
"
%
c
)
digit
=
b58_digits
.
index
(
c
)
n
+=
digit
# Convert the integer to bytes
h
=
"
%x
"
%
n
if
len
(
h
)
%
2
:
h
=
"
0
"
+
h
res
=
encoding
.
HexEncoder
.
decode
(
h
.
encode
(
"
utf8
"
))
# Add padding back.
pad
=
0
for
c
in
s
[:
-
1
]:
if
c
==
b58_digits
[
0
]:
pad
+=
1
else
:
break
return
b
"
\x00
"
*
pad
+
res
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