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
ad78db4d
Commit
ad78db4d
authored
Mar 17, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto: fix Sha3Hash and add a test for it
parent
8ce6a364
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
crypto.go
crypto/crypto.go
+1
-1
crypto_test.go
crypto/crypto_test.go
+7
-1
No files found.
crypto/crypto.go
View file @
ad78db4d
...
@@ -42,7 +42,7 @@ func Sha3Hash(data ...[]byte) (h common.Hash) {
...
@@ -42,7 +42,7 @@ func Sha3Hash(data ...[]byte) (h common.Hash) {
for
_
,
b
:=
range
data
{
for
_
,
b
:=
range
data
{
d
.
Write
(
b
)
d
.
Write
(
b
)
}
}
d
.
Sum
(
h
[
:
])
d
.
Sum
(
h
[
:
0
])
return
h
return
h
}
}
...
...
crypto/crypto_test.go
View file @
ad78db4d
...
@@ -7,8 +7,8 @@ import (
...
@@ -7,8 +7,8 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
)
)
// These tests are sanity checks.
// These tests are sanity checks.
...
@@ -21,6 +21,12 @@ func TestSha3(t *testing.T) {
...
@@ -21,6 +21,12 @@ func TestSha3(t *testing.T) {
checkhash
(
t
,
"Sha3-256"
,
func
(
in
[]
byte
)
[]
byte
{
return
Sha3
(
in
)
},
msg
,
exp
)
checkhash
(
t
,
"Sha3-256"
,
func
(
in
[]
byte
)
[]
byte
{
return
Sha3
(
in
)
},
msg
,
exp
)
}
}
func
TestSha3Hash
(
t
*
testing
.
T
)
{
msg
:=
[]
byte
(
"abc"
)
exp
,
_
:=
hex
.
DecodeString
(
"4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45"
)
checkhash
(
t
,
"Sha3-256-array"
,
func
(
in
[]
byte
)
[]
byte
{
h
:=
Sha3Hash
(
in
);
return
h
[
:
]
},
msg
,
exp
)
}
func
TestSha256
(
t
*
testing
.
T
)
{
func
TestSha256
(
t
*
testing
.
T
)
{
msg
:=
[]
byte
(
"abc"
)
msg
:=
[]
byte
(
"abc"
)
exp
,
_
:=
hex
.
DecodeString
(
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
)
exp
,
_
:=
hex
.
DecodeString
(
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
)
...
...
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