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
79f4cfac
Commit
79f4cfac
authored
Apr 02, 2019
by
Guillaume Ballet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refuse to overwrite the master key of a previously initialized card
parent
1d1bee52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
wallet.go
accounts/scwallet/wallet.go
+15
-3
No files found.
accounts/scwallet/wallet.go
View file @
79f4cfac
...
@@ -589,9 +589,8 @@ func (w *Wallet) Contains(account accounts.Account) bool {
...
@@ -589,9 +589,8 @@ func (w *Wallet) Contains(account accounts.Account) bool {
// Initialize installs a keypair generated from the provided key into the wallet.
// Initialize installs a keypair generated from the provided key into the wallet.
func
(
w
*
Wallet
)
Initialize
(
seed
[]
byte
)
error
{
func
(
w
*
Wallet
)
Initialize
(
seed
[]
byte
)
error
{
w
.
lock
.
Lock
()
// DO NOT lock at this stage, as the initialize
defer
w
.
lock
.
Unlock
()
// function relies on Status()
return
w
.
session
.
initialize
(
seed
)
return
w
.
session
.
initialize
(
seed
)
}
}
...
@@ -877,6 +876,19 @@ type initializeData struct {
...
@@ -877,6 +876,19 @@ type initializeData struct {
// initialize initializes the card with new key data.
// initialize initializes the card with new key data.
func
(
s
*
Session
)
initialize
(
seed
[]
byte
)
error
{
func
(
s
*
Session
)
initialize
(
seed
[]
byte
)
error
{
// Check that the wallet isn't currently initialized,
// otherwise the key would be overwritten.
status
,
err
:=
s
.
Wallet
.
Status
()
if
err
!=
nil
{
return
err
}
if
status
==
"Online"
{
return
fmt
.
Errorf
(
"card is already initialized, cowardly refusing to proceed"
)
}
s
.
Wallet
.
lock
.
Lock
()
defer
s
.
Wallet
.
lock
.
Unlock
()
// HMAC the seed to produce the private key and chain code
// HMAC the seed to produce the private key and chain code
mac
:=
hmac
.
New
(
sha512
.
New
,
[]
byte
(
"Bitcoin seed"
))
mac
:=
hmac
.
New
(
sha512
.
New
,
[]
byte
(
"Bitcoin seed"
))
mac
.
Write
(
seed
)
mac
.
Write
(
seed
)
...
...
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