Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
80fe753
Bump dependencies
mattmook May 6, 2026
d2b140f
Bump more dependencies
mattmook May 7, 2026
04ba5fd
Add base for new sample app
mattmook May 7, 2026
5e0fb40
Enable new sample app
mattmook May 7, 2026
d46faa7
Fix libs.versions.toml
mattmook May 7, 2026
02e0a29
Add dependencies for new sample app
mattmook May 7, 2026
7da4811
Update dependencies
mattmook May 7, 2026
e84cd63
Remove some unused dependencies
mattmook May 7, 2026
1f15690
Fix dokka warnings
mattmook May 8, 2026
bd8dbd6
Fix Koin warnings
mattmook May 8, 2026
eb6380e
UI for first screen
mattmook May 8, 2026
dd2cc6a
Tidy up UI into separate files
mattmook May 8, 2026
e56ea66
Initial view model for cryptohash
mattmook May 8, 2026
f999d3d
cryptohash sample screen implemented
mattmook May 8, 2026
683a1de
Tidy up
mattmook May 8, 2026
050e37b
Fix text field implementation
mattmook May 8, 2026
01e81ed
Make hash selectable and tidy up design
mattmook May 8, 2026
a3ff32e
Fix edge to edge
mattmook May 8, 2026
52e38b8
Add previews
mattmook May 8, 2026
2df017b
Fix for previews
mattmook May 8, 2026
3ac7890
Ignore nothing to inline warning
mattmook May 8, 2026
28f3bfc
Fix sample app for js/wasm and add unit test
mattmook May 9, 2026
ec3bc85
Remove old sample app and add readme
mattmook May 10, 2026
11012fb
Enable desugaring in the sample app
mattmook May 10, 2026
997eb97
Fix copyright messaging
mattmook May 10, 2026
b82c3d8
Fix detekt issues
mattmook May 10, 2026
2a7fcae
Fix project copyright
mattmook May 10, 2026
2cbb430
Fix wasmWasi
mattmook May 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ language translations, unit/integration tests are welcomed.

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)

Copyright 2021-2022 Appmattus Limited
Copyright 2021-2026 Appmattus Limited

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
Expand Down
70 changes: 32 additions & 38 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2024 Appmattus Limited
* Copyright 2021-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,14 +19,17 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}")
classpath("com.google.dagger:hilt-android-gradle-plugin:${libs.versions.google.dagger.get()}")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${libs.versions.androidX.navigation.get()}")
}
}

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.kotlinMultiplatformLibrary) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.compose.hotReload) apply false
alias(libs.plugins.compose.multiplatform) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.markdownlintGradlePlugin)
alias(libs.plugins.gradleMavenPublishPlugin) apply false
alias(libs.plugins.dokkaPlugin)
Expand All @@ -35,37 +38,30 @@ plugins {

allprojects {
repositories {
//noinspection JcenterRepositoryObsolete Just needed for Groupie
@Suppress("DEPRECATION")
jcenter()
google()
mavenCentral()
maven("https://jitpack.io")
}
}

apply(from = "gradle/scripts/detekt.gradle.kts")

tasks.withType<DependencyUpdatesTask> {
resolutionStrategy {
componentSelection {
all {
fun isNonStable(version: String) = listOf(
"alpha",
"beta",
"rc",
"cr",
"m",
"preview",
"b",
"ea"
).any { qualifier ->
version.matches(Regex("(?i).*[.-]$qualifier[.\\d-+]*"))
}
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
fun isNonStable(version: String) = listOf(
"alpha",
"beta",
"rc",
"cr",
"m",
"preview",
"b",
"ea"
).any { qualifier ->
version.matches(Regex("(?i).*[.-]$qualifier[.\\d-+]*"))
}

rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}

Expand All @@ -76,19 +72,17 @@ tasks.withType<DependencyUpdatesTask> {
allprojects {
version = System.getenv("GITHUB_REF")?.substring(10) ?: System.getProperty("GITHUB_REF")?.substring(10) ?: "unknown"

plugins.withType<org.jetbrains.dokka.gradle.DokkaPlugin> {
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
dokkaSourceSets {
configureEach {
if (name.startsWith("ios")) {
displayName.set("ios")
}
pluginManager.withPlugin("org.jetbrains.dokka") {
extensions.configure<org.jetbrains.dokka.gradle.DokkaExtension> {
dokkaSourceSets.configureEach {
if (name.startsWith("ios")) {
displayName.set("ios")
}

sourceLink {
localDirectory.set(rootDir)
remoteUrl.set(java.net.URL("https://github.com/appmattus/crypto/blob/main"))
remoteLineSuffix.set("#L")
}
sourceLink {
localDirectory.set(rootDir)
remoteUrl("https://github.com/appmattus/crypto/blob/main")
remoteLineSuffix.set("#L")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cryptohash/NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Notices

Copyright &copy; 2021 Appmattus Limited.
Copyright &copy; 2021-2026 Appmattus Limited.

Portions:

Expand All @@ -9,4 +9,4 @@ Portions:
- Copyright &copy; 2007-2010 [Projet RNRT SAPHIR](https://github.com/sfuhrm/saphir-hash)
- Copyright &copy; 2012-2021 [xxHash Library](https://github.com/Cyan4973/xxHash)

Translations to Kotlin copyright &copy; 2021 Appmattus Limited.
Translations to Kotlin copyright &copy; 2021-2026 Appmattus Limited.
21 changes: 13 additions & 8 deletions cryptohash/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 Appmattus Limited
* Copyright 2022-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,8 @@
* limitations under the License.
*/

import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
id("com.vanniktech.maven.publish")
Expand All @@ -37,12 +39,20 @@ kotlin {
js {
browser()
nodejs()
binaries.executable()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
nodejs()
}
@OptIn(ExperimentalWasmDsl::class)
wasmWasi {
nodejs()
}

// Tier 1
// Apple macOS hosts only:
macosX64() // Running tests
macosArm64() // Running tests
iosSimulatorArm64() // Running tests
iosX64() // Running tests
Expand All @@ -52,11 +62,9 @@ kotlin {
linuxArm64()
// Apple macOS hosts only:
watchosSimulatorArm64() // Running tests
watchosX64() // Running tests
watchosArm32()
watchosArm64()
tvosSimulatorArm64() // Running tests
tvosX64() // Running tests
tvosArm64()
iosArm64()

Expand Down Expand Up @@ -94,16 +102,13 @@ kotlin {
mingwTest.get().dependsOn(androidAndLinuxAndMingwTest)
androidNativeTest.get().dependsOn(androidAndLinuxAndMingwTest)

val macosX64Main by getting { dependsOn(apple64Main) }
val macosArm64Main by getting { dependsOn(apple64Main) }
val iosSimulatorArm64Main by getting { dependsOn(apple64Main) }
val iosX64Main by getting { dependsOn(apple64Main) }
val watchosSimulatorArm64Main by getting { dependsOn(apple64Main) }
val watchosX64Main by getting { dependsOn(apple64Main) }
val watchosArm32Main by getting { dependsOn(apple32Main) }
val watchosArm64Main by getting { dependsOn(apple32Main) }
val tvosSimulatorArm64Main by getting { dependsOn(apple64Main) }
val tvosX64Main by getting { dependsOn(apple64Main) }
val tvosArm64Main by getting { dependsOn(apple64Main) }
val iosArm64Main by getting { dependsOn(apple64Main) }
val watchosDeviceArm64Main by getting { dependsOn(apple64Main) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 Appmattus Limited
* Copyright 2022-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,11 +53,19 @@ internal class SM3 : MDHelper<SM3>(false, 8) {
}
}

@Suppress("NOTHING_TO_INLINE")
private inline fun p0(x: Int) = x xor x.rotateLeft(9) xor x.rotateLeft(17)

@Suppress("NOTHING_TO_INLINE")
private inline fun p1(x: Int) = x xor x.rotateLeft(15) xor x.rotateLeft(23)

@Suppress("NOTHING_TO_INLINE")
private inline fun f1(x: Int, y: Int, z: Int) = x xor y xor z

@Suppress("NOTHING_TO_INLINE")
private inline fun ff(x: Int, y: Int, z: Int) = (x and y) xor (x and z) xor (y and z)

@Suppress("NOTHING_TO_INLINE")
private inline fun gg(x: Int, y: Int, z: Int) = (x and y) xor (x.inv() and z)

override fun processBlock(data: ByteArray) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 Appmattus Limited
* Copyright 2022-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,31 +44,36 @@ internal fun encodeLEInt(value: Int, buf: ByteArray, off: Int) {
* @param off the source offset
* @return the decoded value
*/
@Suppress("NOTHING_TO_INLINE")
internal inline fun decodeLEInt(buf: ByteArray, off: Int): Int {
return (buf[off + 3].toInt() and 0xFF shl 24) or
(buf[off + 2].toInt() and 0xFF shl 16) or
(buf[off + 1].toInt() and 0xFF shl 8) or
(buf[off].toInt() and 0xFF)
}

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteArray.decodeLEShort(off: Int): Short {
return ((this[off + 1].toInt() and 0xFF shl 8) or (this[off].toInt() and 0xFF)).toShort()
}

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteBuffer.decodeLEInt(off: Int): Int {
return (this[off + 3].toInt() and 0xFF shl 24) or
(this[off + 2].toInt() and 0xFF shl 16) or
(this[off + 1].toInt() and 0xFF shl 8) or
(this[off].toInt() and 0xFF)
}

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteBuffer.decodeBEInt(off: Int): Int {
return this[off].toInt() and 0xFF shl 24 or
(this[off + 1].toInt() and 0xFF shl 16) or
(this[off + 2].toInt() and 0xFF shl 8) or
(this[off + 3].toInt() and 0xFF)
}

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteBuffer.decodeLEUInt(off: Int): UInt = decodeLEInt(off).toUInt()

/**
Expand All @@ -78,6 +83,7 @@ internal inline fun ByteBuffer.decodeLEUInt(off: Int): UInt = decodeLEInt(off).t
* @param off the source offset
* @return the decoded integer
*/
@Suppress("NOTHING_TO_INLINE")
internal inline fun decodeLELong(buf: ByteArray, off: Int): Long {
return buf[off + 0].toLong() and 0xFF or
((buf[off + 1].toLong() and 0xFF) shl 8) or
Expand All @@ -89,8 +95,10 @@ internal inline fun decodeLELong(buf: ByteArray, off: Int): Long {
((buf[off + 7].toLong() and 0xFF) shl 56)
}

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteArray.decodeLEULong(off: Int): ULong = decodeLELong(this, off).toULong()

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteBuffer.decodeLELong(off: Int): Long {
return this[off + 0].toLong() and 0xFF or
((this[off + 1].toLong() and 0xFF) shl 8) or
Expand All @@ -102,6 +110,7 @@ internal inline fun ByteBuffer.decodeLELong(off: Int): Long {
((this[off + 7].toLong() and 0xFF) shl 56)
}

@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteBuffer.decodeLEULong(off: Int): ULong = decodeLELong(off).toULong()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* Translation to Kotlin:
*
* Copyright 2021-2024 Appmattus Limited
* Copyright 2021-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -158,7 +158,8 @@ internal class Hasher(
private const val DERIVE_KEY_MATERIAL = 64

@Suppress("PropertyWrapping")
internal val IV = intArrayOf(0x6A09E667, -0x4498517b, 0x3C6EF372, -0x5ab00ac6, 0x510E527F, -0x64fa9774, 0x1F83D9AB, 0x5BE0CD19)
internal val IV =
intArrayOf(0x6A09E667, -0x4498517b, 0x3C6EF372, -0x5ab00ac6, 0x510E527F, -0x64fa9774, 0x1F83D9AB, 0x5BE0CD19)
private val MSG_PERMUTATION = intArrayOf(2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8)

private fun wrappingAdd(a: Int, b: Int): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* Translation to Kotlin:
*
* Copyright 2021-2024 Appmattus Limited
* Copyright 2021-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,6 +70,7 @@ internal class BLAKE224 : BLAKESmallCore<BLAKE224>() {
companion object {
/** The initial value for BLAKE-224 */
@Suppress("PropertyWrapping")
private val initVal = intArrayOf(-0x3efa6128, 0x367CD507, 0x3070DD17, -0x8f1a6c7, -0x3ff4cf, 0x68581511, 0x64F98FA7, -0x4105b05c)
private val initVal =
intArrayOf(-0x3efa6128, 0x367CD507, 0x3070DD17, -0x8f1a6c7, -0x3ff4cf, 0x68581511, 0x64F98FA7, -0x4105b05c)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* Translation to Kotlin:
*
* Copyright 2021-2024 Appmattus Limited
* Copyright 2021-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,6 +70,7 @@ internal class BLAKE256 : BLAKESmallCore<BLAKE256>() {
companion object {
/** The initial value for BLAKE-256. */
@Suppress("PropertyWrapping")
private val initVal = intArrayOf(0x6A09E667, -0x4498517b, 0x3C6EF372, -0x5ab00ac6, 0x510E527F, -0x64fa9774, 0x1F83D9AB, 0x5BE0CD19)
private val initVal =
intArrayOf(0x6A09E667, -0x4498517b, 0x3C6EF372, -0x5ab00ac6, 0x510E527F, -0x64fa9774, 0x1F83D9AB, 0x5BE0CD19)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* Translation to Kotlin:
*
* Copyright 2021-2024 Appmattus Limited
* Copyright 2021-2026 Appmattus Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -123,10 +123,14 @@ internal abstract class BMWBigCore<D : BMWBigCore<D>> : DigestEngine<D>() {
((q[u - 3] ushr 2) xor (q[u - 3] shl 1) xor q[u - 3].rotateLeft(19) xor q[u - 3].rotateLeft(53)) +
((q[u - 2] ushr 2) xor (q[u - 2] shl 2) xor q[u - 2].rotateLeft(28) xor q[u - 2].rotateLeft(59)) +
((q[u - 1] ushr 1) xor (q[u - 1] shl 3) xor q[u - 1].rotateLeft(4) xor q[u - 1].rotateLeft(37)) +
((m[u - 16 + 0 and 15].rotateLeft((u - 16 + 0 and 15) + 1) +
(
(
m[u - 16 + 0 and 15].rotateLeft((u - 16 + 0 and 15) + 1) +
m[u - 16 + 3 and 15].rotateLeft((u - 16 + 3 and 15) + 1) -
m[u - 16 + 10 and 15].rotateLeft((u - 16 + 10 and 15) + 1) +
K[u - 16]) xor h[u - 16 + 7 and 15])
K[u - 16]
) xor h[u - 16 + 7 and 15]
)
}
for (u in 18..31) {
@Suppress("Wrapping")
Expand All @@ -139,10 +143,14 @@ internal abstract class BMWBigCore<D : BMWBigCore<D>> : DigestEngine<D>() {
q[u - 4] + q[u - 3].rotateLeft(53) +
((q[u - 2] ushr 1) xor q[u - 2]) +
((q[u - 1] ushr 2) xor q[u - 1]) +
((m[u - 16 + 0 and 15].rotateLeft((u - 16 + 0 and 15) + 1) +
(
(
m[u - 16 + 0 and 15].rotateLeft((u - 16 + 0 and 15) + 1) +
m[u - 16 + 3 and 15].rotateLeft((u - 16 + 3 and 15) + 1) -
m[u - 16 + 10 and 15].rotateLeft((u - 16 + 10 and 15) + 1) +
K[u - 16]) xor h[u - 16 + 7 and 15])
K[u - 16]
) xor h[u - 16 + 7 and 15]
)
}
val xl = q[16] xor q[17] xor q[18] xor q[19] xor q[20] xor q[21] xor q[22] xor q[23]
val xh = xl xor q[24] xor q[25] xor q[26] xor q[27] xor q[28] xor q[29] xor q[30] xor q[31]
Expand Down
Loading
Loading