-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SHA3 implementation #7
Conversation
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
==========================================
+ Coverage 85.45% 86.28% +0.82%
==========================================
Files 16 17 +1
Lines 770 853 +83
Branches 98 109 +11
==========================================
+ Hits 658 736 +78
- Misses 89 93 +4
- Partials 23 24 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Thanks! |
I know you merged it, but any better ideas for the names of the sha3 functions, or no? because having names with an underscore feels kinda icky, though I'm not sure if there's a better alternative. although, I guess something like class SHA3 internal constructor(digestSize: Int) : Hasher(
chunkSize = 200 - 2 * digestSize,
digestSize = digestSize,
name = "SHA3-${digestSize * 8}"
) {
// ...
object Digest224 : HasherFactory("SHA3-512", { SHA3(224 / Byte.SIZE_BITS) })
object Digest256 : HasherFactory("SHA3-256", { SHA3(256 / Byte.SIZE_BITS) })
object Digest384 : HasherFactory("SHA3-384", { SHA3(384 / Byte.SIZE_BITS) })
object Digest512 : HasherFactory("SHA3-512", { SHA3(512 / Byte.SIZE_BITS) })
} could work, however it does not match the existing naming conventions and I'm unsure if it's any better. (also, I did only just realize that |
public static final field KECCAKF_ROUNDS I | ||
public static final field SHA3_KECCAK_SPONGE_WORDS I |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
public final fun getKECCAKF_PI_LANE ()[I | ||
public final fun getKECCAKF_ROTATION_OFFSETS ()[I | ||
public final fun getKECCAKF_ROUND_CONSTANTS-Y2RjT0g ()[J |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
@@ -250,6 +250,45 @@ public final class korlibs/crypto/SHA256Kt { | |||
public static final fun sha256 ([B)Lkorlibs/crypto/Hash; | |||
} | |||
|
|||
public class korlibs/crypto/SHA3 : korlibs/crypto/Hasher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it final
public static final field KECCAKF_ROUNDS I | ||
public static final field SHA3_KECCAK_SPONGE_WORDS I |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
public final fun getKECCAKF_PI_LANE ()[I | ||
public final fun getKECCAKF_ROTATION_OFFSETS ()[I | ||
public final fun getKECCAKF_ROUND_CONSTANTS-Y2RjT0g ()[J |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
@solonovamax Feel free to make another PR. Regarding names I'm okay with the current ones. There is a mistake here:
You can remove the |
oops, must have missed that when copying things around. |
Adds a SHA3 implementation.
I currently just have
Is there perhaps a better way that these could be named?
Also, I chose to just make them
object
s instead of doing