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
25314313
Commit
25314313
authored
Jun 29, 2014
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Mnemonic() and AsStrings() methods, added memoization for address
parent
a8be0d9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
keypair.go
ethcrypto/keypair.go
+18
-2
No files found.
ethcrypto/keypair.go
View file @
25314313
...
@@ -3,12 +3,14 @@ package ethcrypto
...
@@ -3,12 +3,14 @@ package ethcrypto
import
(
import
(
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
"github.com/obscuren/secp256k1-go"
"strings"
)
)
type
KeyPair
struct
{
type
KeyPair
struct
{
PrivateKey
[]
byte
PrivateKey
[]
byte
PublicKey
[]
byte
PublicKey
[]
byte
address
[]
byte
mnemonic
string
// The associated account
// The associated account
// account *StateObject
// account *StateObject
}
}
...
@@ -29,7 +31,21 @@ func NewKeyPairFromSec(seckey []byte) (*KeyPair, error) {
...
@@ -29,7 +31,21 @@ func NewKeyPairFromSec(seckey []byte) (*KeyPair, error) {
}
}
func
(
k
*
KeyPair
)
Address
()
[]
byte
{
func
(
k
*
KeyPair
)
Address
()
[]
byte
{
return
Sha3Bin
(
k
.
PublicKey
[
1
:
])[
12
:
]
if
k
.
address
==
nil
{
k
.
address
=
Sha3Bin
(
k
.
PublicKey
[
1
:
])[
12
:
]
}
return
k
.
address
}
func
(
k
*
KeyPair
)
Mnemonic
()
string
{
if
k
.
mnemonic
==
""
{
k
.
mnemonic
=
strings
.
Join
(
MnemonicEncode
(
ethutil
.
Bytes2Hex
(
k
.
PrivateKey
)),
" "
)
}
return
k
.
mnemonic
}
func
(
k
*
KeyPair
)
AsStrings
()
(
string
,
string
,
string
,
string
)
{
return
k
.
Mnemonic
(),
ethutil
.
Bytes2Hex
(
k
.
Address
()),
ethutil
.
Bytes2Hex
(
k
.
PrivateKey
),
ethutil
.
Bytes2Hex
(
k
.
PublicKey
)
}
}
func
(
k
*
KeyPair
)
RlpEncode
()
[]
byte
{
func
(
k
*
KeyPair
)
RlpEncode
()
[]
byte
{
...
...
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