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
14e7192d
Commit
14e7192d
authored
9 years ago
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto/sha3: pull in latest keccak from go crypto (45% speed increase)
parent
9085b105
master
v1.10.12
v1.10.12-modified
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
409 additions
and
173 deletions
+409
-173
keccakf.go
crypto/sha3/keccakf.go
+401
-162
sha3.go
crypto/sha3/sha3.go
+8
-11
No files found.
crypto/sha3/keccakf.go
View file @
14e7192d
This diff is collapsed.
Click to expand it.
crypto/sha3/sha3.go
View file @
14e7192d
...
...
@@ -38,13 +38,10 @@ const stateSize = laneSize * numLanes
// O(2^{outputSize/2}) computations (the birthday lower bound). Future standards may modify the
// capacity/outputSize ratio to allow for more output with lower cryptographic security.
type
digest
struct
{
a
[
numLanes
]
uint64
// main state of the hash
b
[
numLanes
]
uint64
// intermediate states
c
[
sliceSize
]
uint64
// intermediate states
d
[
sliceSize
]
uint64
// intermediate states
outputSize
int
// desired output size in bytes
capacity
int
// number of bytes to leave untouched during squeeze/absorb
absorbed
int
// number of bytes absorbed thus far
a
[
numLanes
]
uint64
// main state of the hash
outputSize
int
// desired output size in bytes
capacity
int
// number of bytes to leave untouched during squeeze/absorb
absorbed
int
// number of bytes absorbed thus far
}
// minInt returns the lesser of two integer arguments, to simplify the absorption routine.
...
...
@@ -116,7 +113,7 @@ func (d *digest) Write(p []byte) (int, error) {
// For every rate() bytes absorbed, the state must be permuted via the F Function.
if
(
d
.
absorbed
)
%
d
.
rate
()
==
0
{
d
.
keccakF
(
)
keccakF1600
(
&
d
.
a
)
}
}
...
...
@@ -134,7 +131,7 @@ func (d *digest) Write(p []byte) (int, error) {
d
.
absorbed
+=
(
lastLane
-
firstLane
)
*
laneSize
// For every rate() bytes absorbed, the state must be permuted via the F Function.
if
(
d
.
absorbed
)
%
d
.
rate
()
==
0
{
d
.
keccakF
(
)
keccakF1600
(
&
d
.
a
)
}
offset
=
0
...
...
@@ -167,7 +164,7 @@ func (d *digest) pad() {
// finalize prepares the hash to output data by padding and one final permutation of the state.
func
(
d
*
digest
)
finalize
()
{
d
.
pad
()
d
.
keccakF
(
)
keccakF1600
(
&
d
.
a
)
}
// squeeze outputs an arbitrary number of bytes from the hash state.
...
...
@@ -192,7 +189,7 @@ func (d *digest) squeeze(in []byte, toSqueeze int) []byte {
out
=
out
[
laneSize
:
]
}
if
len
(
out
)
>
0
{
d
.
keccakF
(
)
keccakF1600
(
&
d
.
a
)
}
}
return
in
[
:
len
(
in
)
+
toSqueeze
]
// Re-slice in case we wrote extra data.
...
...
This diff is collapsed.
Click to expand it.
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