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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
0f51ee6c
Commit
0f51ee6c
authored
Jun 4, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
crypto: return common.Address rather than raw bytes
parent
dcdb4554
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/types/transaction_test.go
+3
-3
3 additions, 3 deletions
core/types/transaction_test.go
crypto/crypto.go
+4
-4
4 additions, 4 deletions
crypto/crypto.go
crypto/key.go
+1
-1
1 addition, 1 deletion
crypto/key.go
with
8 additions
and
8 deletions
core/types/transaction_test.go
+
3
−
3
View file @
0f51ee6c
...
@@ -64,7 +64,7 @@ func decodeTx(data []byte) (*Transaction, error) {
...
@@ -64,7 +64,7 @@ func decodeTx(data []byte) (*Transaction, error) {
return
&
tx
,
rlp
.
Decode
(
bytes
.
NewReader
(
data
),
&
tx
)
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"
))
key
:=
crypto
.
ToECDSA
(
common
.
Hex2Bytes
(
"45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
))
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
return
key
,
addr
return
key
,
addr
...
@@ -85,7 +85,7 @@ func TestRecipientEmpty(t *testing.T) {
...
@@ -85,7 +85,7 @@ func TestRecipientEmpty(t *testing.T) {
t
.
FailNow
()
t
.
FailNow
()
}
}
if
!
bytes
.
Equal
(
addr
,
from
.
Bytes
())
{
if
addr
!=
from
{
t
.
Error
(
"derived address doesn't match"
)
t
.
Error
(
"derived address doesn't match"
)
}
}
}
}
...
@@ -105,7 +105,7 @@ func TestRecipientNormal(t *testing.T) {
...
@@ -105,7 +105,7 @@ func TestRecipientNormal(t *testing.T) {
t
.
FailNow
()
t
.
FailNow
()
}
}
if
!
bytes
.
Equal
(
addr
,
from
.
Bytes
())
{
if
addr
!=
from
{
t
.
Error
(
"derived address doesn't match"
)
t
.
Error
(
"derived address doesn't match"
)
}
}
}
}
This diff is collapsed.
Click to expand it.
crypto/crypto.go
+
4
−
4
View file @
0f51ee6c
...
@@ -201,7 +201,7 @@ func ImportBlockTestKey(privKeyBytes []byte) error {
...
@@ -201,7 +201,7 @@ func ImportBlockTestKey(privKeyBytes []byte) error {
ecKey
:=
ToECDSA
(
privKeyBytes
)
ecKey
:=
ToECDSA
(
privKeyBytes
)
key
:=
&
Key
{
key
:=
&
Key
{
Id
:
uuid
.
NewRandom
(),
Id
:
uuid
.
NewRandom
(),
Address
:
common
.
BytesToAddress
(
PubkeyToAddress
(
ecKey
.
PublicKey
)
)
,
Address
:
PubkeyToAddress
(
ecKey
.
PublicKey
),
PrivateKey
:
ecKey
,
PrivateKey
:
ecKey
,
}
}
err
:=
ks
.
StoreKey
(
key
,
""
)
err
:=
ks
.
StoreKey
(
key
,
""
)
...
@@ -247,7 +247,7 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
...
@@ -247,7 +247,7 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
ecKey
:=
ToECDSA
(
ethPriv
)
ecKey
:=
ToECDSA
(
ethPriv
)
key
=
&
Key
{
key
=
&
Key
{
Id
:
nil
,
Id
:
nil
,
Address
:
common
.
BytesToAddress
(
PubkeyToAddress
(
ecKey
.
PublicKey
)
)
,
Address
:
PubkeyToAddress
(
ecKey
.
PublicKey
),
PrivateKey
:
ecKey
,
PrivateKey
:
ecKey
,
}
}
derivedAddr
:=
hex
.
EncodeToString
(
key
.
Address
.
Bytes
())
// needed because .Hex() gives leading "0x"
derivedAddr
:=
hex
.
EncodeToString
(
key
.
Address
.
Bytes
())
// needed because .Hex() gives leading "0x"
...
@@ -305,7 +305,7 @@ func PKCS7Unpad(in []byte) []byte {
...
@@ -305,7 +305,7 @@ func PKCS7Unpad(in []byte) []byte {
return
in
[
:
len
(
in
)
-
int
(
padding
)]
return
in
[
:
len
(
in
)
-
int
(
padding
)]
}
}
func
PubkeyToAddress
(
p
ecdsa
.
PublicKey
)
[]
byte
{
func
PubkeyToAddress
(
p
ecdsa
.
PublicKey
)
common
.
Address
{
pubBytes
:=
FromECDSAPub
(
&
p
)
pubBytes
:=
FromECDSAPub
(
&
p
)
return
Sha3
(
pubBytes
[
1
:
])[
12
:
]
return
common
.
BytesToAddress
(
Sha3
(
pubBytes
[
1
:
])[
12
:
]
)
}
}
This diff is collapsed.
Click to expand it.
crypto/key.go
+
1
−
1
View file @
0f51ee6c
...
@@ -124,7 +124,7 @@ func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
...
@@ -124,7 +124,7 @@ func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
id
:=
uuid
.
NewRandom
()
id
:=
uuid
.
NewRandom
()
key
:=
&
Key
{
key
:=
&
Key
{
Id
:
id
,
Id
:
id
,
Address
:
common
.
BytesToAddress
(
PubkeyToAddress
(
privateKeyECDSA
.
PublicKey
)
)
,
Address
:
PubkeyToAddress
(
privateKeyECDSA
.
PublicKey
),
PrivateKey
:
privateKeyECDSA
,
PrivateKey
:
privateKeyECDSA
,
}
}
return
key
return
key
...
...
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