good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
open
bor
Commits
558683d1
Commit
558683d1
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Plain Diff
Merge pull request #678 from bas-vk/feature_635
Support for import/export hex encoded keys
parents
79cc3cc9
ef393da9
Loading
Loading
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/geth/main.go
+1
-2
1 addition, 2 deletions
cmd/geth/main.go
crypto/crypto.go
+10
-3
10 additions, 3 deletions
crypto/crypto.go
with
11 additions
and
5 deletions
cmd/geth/main.go
+
1
−
2
View file @
558683d1
...
...
@@ -149,8 +149,7 @@ password to file or expose in any other way.
Imports an unencrypted private key from <keyfile> and creates a new account.
Prints the address.
The keyfile is assumed to contain an unencrypted private key in canonical EC
raw bytes format.
The keyfile is assumed to contain an unencrypted private key in hexadecimal format.
The account is saved in encrypted format, you are prompted for a passphrase.
...
...
This diff is collapsed.
Click to expand it.
crypto/crypto.go
+
10
−
3
View file @
558683d1
...
...
@@ -121,7 +121,7 @@ func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error) {
// LoadECDSA loads a secp256k1 private key from the given file.
func
LoadECDSA
(
file
string
)
(
*
ecdsa
.
PrivateKey
,
error
)
{
buf
:=
make
([]
byte
,
32
)
buf
:=
make
([]
byte
,
64
)
fd
,
err
:=
os
.
Open
(
file
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -130,13 +130,20 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
if
_
,
err
:=
io
.
ReadFull
(
fd
,
buf
);
err
!=
nil
{
return
nil
,
err
}
return
ToECDSA
(
buf
),
nil
key
,
err
:=
hex
.
DecodeString
(
string
(
buf
))
if
err
!=
nil
{
return
nil
,
err
}
return
ToECDSA
(
key
),
nil
}
// SaveECDSA saves a secp256k1 private key to the given file with restrictive
// permissions
func
SaveECDSA
(
file
string
,
key
*
ecdsa
.
PrivateKey
)
error
{
return
ioutil
.
WriteFile
(
file
,
FromECDSA
(
key
),
0600
)
k
:=
hex
.
EncodeToString
(
FromECDSA
(
key
))
return
ioutil
.
WriteFile
(
file
,
[]
byte
(
k
),
0600
)
}
func
GenerateKey
()
(
*
ecdsa
.
PrivateKey
,
error
)
{
...
...
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