Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
2b9f71c6
Commit
2b9f71c6
authored
Aug 15, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com-obscure:ethereum/eth-go into develop
parents
d701b232
79bc6288
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1636 additions
and
1660 deletions
+1636
-1660
mnemonic.go
ethcrypto/mnemonic.go
+6
-34
mnemonic.words.lst
ethcrypto/mnemonic.words.lst
+0
-1626
mnemonic_words.go
ethcrypto/mnemonic_words.go
+1630
-0
No files found.
ethcrypto/mnemonic.go
View file @
2b9f71c6
...
@@ -2,37 +2,9 @@ package ethcrypto
...
@@ -2,37 +2,9 @@ package ethcrypto
import
(
import
(
"fmt"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strconv"
"strconv"
"strings"
)
)
func
InitWords
(
wordsPath
string
)
{
filename
:=
path
.
Join
(
wordsPath
,
"mnemonic.words.lst"
)
if
_
,
err
:=
os
.
Stat
(
filename
);
os
.
IsNotExist
(
err
)
{
dir
:=
path
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"eth-go"
,
"ethcrypto"
)
filename
=
path
.
Join
(
dir
,
"mnemonic.words.lst"
)
if
_
,
err
:=
os
.
Stat
(
filename
);
os
.
IsNotExist
(
err
)
{
dir
,
err
:=
filepath
.
Abs
(
filepath
.
Dir
(
os
.
Args
[
0
]))
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"problem getting current folder: "
,
err
))
}
filename
=
path
.
Join
(
dir
,
"mnemonic.words.lst"
)
}
}
content
,
err
:=
ioutil
.
ReadFile
(
filename
)
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"All options for finding the mnemonic word list file 'mnemonic.words.lst' failed: "
,
err
))
}
words
=
strings
.
Split
(
string
(
content
),
"
\n
"
)
}
var
words
[]
string
// TODO: See if we can refactor this into a shared util lib if we need it multiple times
// TODO: See if we can refactor this into a shared util lib if we need it multiple times
func
IndexOf
(
slice
[]
string
,
value
string
)
int64
{
func
IndexOf
(
slice
[]
string
,
value
string
)
int64
{
for
p
,
v
:=
range
slice
{
for
p
,
v
:=
range
slice
{
...
@@ -45,7 +17,7 @@ func IndexOf(slice []string, value string) int64 {
...
@@ -45,7 +17,7 @@ func IndexOf(slice []string, value string) int64 {
func
MnemonicEncode
(
message
string
)
[]
string
{
func
MnemonicEncode
(
message
string
)
[]
string
{
var
out
[]
string
var
out
[]
string
n
:=
int64
(
len
(
w
ords
))
n
:=
int64
(
len
(
MnemonicW
ords
))
for
i
:=
0
;
i
<
len
(
message
);
i
+=
(
len
(
message
)
/
8
)
{
for
i
:=
0
;
i
<
len
(
message
);
i
+=
(
len
(
message
)
/
8
)
{
x
:=
message
[
i
:
i
+
8
]
x
:=
message
[
i
:
i
+
8
]
...
@@ -53,22 +25,22 @@ func MnemonicEncode(message string) []string {
...
@@ -53,22 +25,22 @@ func MnemonicEncode(message string) []string {
w1
:=
(
bit
%
n
)
w1
:=
(
bit
%
n
)
w2
:=
((
bit
/
n
)
+
w1
)
%
n
w2
:=
((
bit
/
n
)
+
w1
)
%
n
w3
:=
((
bit
/
n
/
n
)
+
w2
)
%
n
w3
:=
((
bit
/
n
/
n
)
+
w2
)
%
n
out
=
append
(
out
,
words
[
w1
],
words
[
w2
],
w
ords
[
w3
])
out
=
append
(
out
,
MnemonicWords
[
w1
],
MnemonicWords
[
w2
],
MnemonicW
ords
[
w3
])
}
}
return
out
return
out
}
}
func
MnemonicDecode
(
wordsar
[]
string
)
string
{
func
MnemonicDecode
(
wordsar
[]
string
)
string
{
var
out
string
var
out
string
n
:=
int64
(
len
(
w
ords
))
n
:=
int64
(
len
(
MnemonicW
ords
))
for
i
:=
0
;
i
<
len
(
wordsar
);
i
+=
3
{
for
i
:=
0
;
i
<
len
(
wordsar
);
i
+=
3
{
word1
:=
wordsar
[
i
]
word1
:=
wordsar
[
i
]
word2
:=
wordsar
[
i
+
1
]
word2
:=
wordsar
[
i
+
1
]
word3
:=
wordsar
[
i
+
2
]
word3
:=
wordsar
[
i
+
2
]
w1
:=
IndexOf
(
w
ords
,
word1
)
w1
:=
IndexOf
(
MnemonicW
ords
,
word1
)
w2
:=
IndexOf
(
w
ords
,
word2
)
w2
:=
IndexOf
(
MnemonicW
ords
,
word2
)
w3
:=
IndexOf
(
w
ords
,
word3
)
w3
:=
IndexOf
(
MnemonicW
ords
,
word3
)
y
:=
(
w2
-
w1
)
%
n
y
:=
(
w2
-
w1
)
%
n
z
:=
(
w3
-
w2
)
%
n
z
:=
(
w3
-
w2
)
%
n
...
...
ethcrypto/mnemonic.words.lst
deleted
100644 → 0
View file @
d701b232
This diff is collapsed.
Click to expand it.
ethcrypto/mnemonic_words.go
0 → 100644
View file @
2b9f71c6
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment