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
0f51ee6c
Commit
0f51ee6c
authored
Jun 04, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto: return common.Address rather than raw bytes
parent
dcdb4554
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
transaction_test.go
core/types/transaction_test.go
+3
-3
crypto.go
crypto/crypto.go
+4
-4
key.go
crypto/key.go
+1
-1
No files found.
core/types/transaction_test.go
View file @
0f51ee6c
...
...
@@ -64,7 +64,7 @@ func decodeTx(data []byte) (*Transaction, error) {
return
&
tx
,
rlp
.
Decode
(
bytes
.
NewReader
(
data
),
&
tx
)
}
func
defaultTestKey
()
(
*
ecdsa
.
PrivateKey
,
[]
byte
)
{
func
defaultTestKey
()
(
*
ecdsa
.
PrivateKey
,
common
.
Address
)
{
key
:=
crypto
.
ToECDSA
(
common
.
Hex2Bytes
(
"45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
))
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
return
key
,
addr
...
...
@@ -85,7 +85,7 @@ func TestRecipientEmpty(t *testing.T) {
t
.
FailNow
()
}
if
!
bytes
.
Equal
(
addr
,
from
.
Bytes
())
{
if
addr
!=
from
{
t
.
Error
(
"derived address doesn't match"
)
}
}
...
...
@@ -105,7 +105,7 @@ func TestRecipientNormal(t *testing.T) {
t
.
FailNow
()
}
if
!
bytes
.
Equal
(
addr
,
from
.
Bytes
())
{
if
addr
!=
from
{
t
.
Error
(
"derived address doesn't match"
)
}
}
crypto/crypto.go
View file @
0f51ee6c
...
...
@@ -201,7 +201,7 @@ func ImportBlockTestKey(privKeyBytes []byte) error {
ecKey
:=
ToECDSA
(
privKeyBytes
)
key
:=
&
Key
{
Id
:
uuid
.
NewRandom
(),
Address
:
common
.
BytesToAddress
(
PubkeyToAddress
(
ecKey
.
PublicKey
)
),
Address
:
PubkeyToAddress
(
ecKey
.
PublicKey
),
PrivateKey
:
ecKey
,
}
err
:=
ks
.
StoreKey
(
key
,
""
)
...
...
@@ -247,7 +247,7 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
ecKey
:=
ToECDSA
(
ethPriv
)
key
=
&
Key
{
Id
:
nil
,
Address
:
common
.
BytesToAddress
(
PubkeyToAddress
(
ecKey
.
PublicKey
)
),
Address
:
PubkeyToAddress
(
ecKey
.
PublicKey
),
PrivateKey
:
ecKey
,
}
derivedAddr
:=
hex
.
EncodeToString
(
key
.
Address
.
Bytes
())
// needed because .Hex() gives leading "0x"
...
...
@@ -305,7 +305,7 @@ func PKCS7Unpad(in []byte) []byte {
return
in
[
:
len
(
in
)
-
int
(
padding
)]
}
func
PubkeyToAddress
(
p
ecdsa
.
PublicKey
)
[]
byte
{
func
PubkeyToAddress
(
p
ecdsa
.
PublicKey
)
common
.
Address
{
pubBytes
:=
FromECDSAPub
(
&
p
)
return
Sha3
(
pubBytes
[
1
:
])[
12
:
]
return
common
.
BytesToAddress
(
Sha3
(
pubBytes
[
1
:
])[
12
:
])
}
crypto/key.go
View file @
0f51ee6c
...
...
@@ -124,7 +124,7 @@ func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
id
:=
uuid
.
NewRandom
()
key
:=
&
Key
{
Id
:
id
,
Address
:
common
.
BytesToAddress
(
PubkeyToAddress
(
privateKeyECDSA
.
PublicKey
)
),
Address
:
PubkeyToAddress
(
privateKeyECDSA
.
PublicKey
),
PrivateKey
:
privateKeyECDSA
,
}
return
key
...
...
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