Parallelism cleanup and preaparations
This commit is contained in:
parent
aaaa5c176b
commit
799a9bb74e
@ -17,7 +17,7 @@ org.gradle.parallel=true
|
|||||||
|
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
|
||||||
kotlin.js.compiler=both
|
kotlin.js.compiler=ir
|
||||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
|
|
||||||
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m
|
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m
|
||||||
|
@ -250,13 +250,13 @@ kotlin {
|
|||||||
val jsMain by getting {
|
val jsMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin(Deps.Js.stdLib))
|
implementation(kotlin(Deps.Js.stdLib))
|
||||||
implementation(kotlin(Deps.Js.test))
|
|
||||||
implementation(Deps.Js.coroutines)
|
implementation(Deps.Js.coroutines)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jsTest by getting {
|
val jsTest by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("test-js"))
|
implementation(Deps.Js.coroutines)
|
||||||
|
implementation(kotlin(Deps.Js.test))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val linuxMain by getting {
|
val linuxMain by getting {
|
||||||
@ -400,21 +400,20 @@ tasks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsIrNodeTest by getting(KotlinJsTest::class) {
|
val jsNodeTest by getting(KotlinJsTest::class) {
|
||||||
|
|
||||||
testLogging {
|
testLogging {
|
||||||
events("PASSED", "FAILED", "SKIPPED")
|
events("PASSED", "FAILED", "SKIPPED")
|
||||||
showStandardStreams = true
|
showStandardStreams = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val legacyjsNodeTest by getting(KotlinJsTest::class) {
|
// val legacyjsNodeTest by getting(KotlinJsTest::class) {
|
||||||
|
//
|
||||||
testLogging {
|
// testLogging {
|
||||||
events("PASSED", "FAILED", "SKIPPED")
|
// events("PASSED", "FAILED", "SKIPPED")
|
||||||
showStandardStreams = true
|
// showStandardStreams = true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// val jsIrBrowserTest by getting(KotlinJsTest::class) {
|
// val jsIrBrowserTest by getting(KotlinJsTest::class) {
|
||||||
// testLogging {
|
// testLogging {
|
||||||
|
@ -44,6 +44,13 @@ data class SegmentPosition(
|
|||||||
val slice: Int
|
val slice: Int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class ArgonResult(
|
||||||
|
val hashBytes: Array<UByte>
|
||||||
|
) {
|
||||||
|
val hashString by lazy { hashBytes.map { it.toString(16).padStart(2, '0') }.joinToString(separator = "") }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ExperimentalStdlibApi
|
@ExperimentalStdlibApi
|
||||||
class Argon2(
|
class Argon2(
|
||||||
private val password: Array<UByte>,
|
private val password: Array<UByte>,
|
||||||
@ -57,6 +64,17 @@ class Argon2(
|
|||||||
private val argonType: ArgonType = ArgonType.Argon2id
|
private val argonType: ArgonType = ArgonType.Argon2id
|
||||||
) : KeyDerivationFunction {
|
) : KeyDerivationFunction {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun derive(
|
||||||
|
password: String,
|
||||||
|
parallelism: Int = 16,
|
||||||
|
memory : Int = 4096,
|
||||||
|
numberOfIterations : Int = 10
|
||||||
|
) : ArgonResult {
|
||||||
|
return ArgonResult(emptyArray())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
password: String,
|
password: String,
|
||||||
salt: String = "",
|
salt: String = "",
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Ugljesa Jovanovic
|
||||||
|
*
|
||||||
|
* 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 License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.ionspin.kotlin.crypto.parallelization
|
||||||
|
|
||||||
|
import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
import kotlin.time.ExperimentalTime
|
||||||
|
import kotlin.time.measureTime
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ugljesa Jovanovic
|
||||||
|
* ugljesa.jovanovic@ionspin.com
|
||||||
|
* on 17-May-2020
|
||||||
|
*/
|
||||||
|
@ExperimentalTime
|
||||||
|
object Coroutines14 {
|
||||||
|
fun argonParallel() : Array<UByte> {
|
||||||
|
val argon = Argon2()
|
||||||
|
argon
|
||||||
|
println("Placeholder")
|
||||||
|
return emptyArray()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Ugljesa Jovanovic
|
||||||
|
*
|
||||||
|
* 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 License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.ionspin.kotlin.crypto.parallelization
|
||||||
|
|
||||||
|
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.time.ExperimentalTime
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ugljesa Jovanovic
|
||||||
|
* ugljesa.jovanovic@ionspin.com
|
||||||
|
* on 17-May-2020
|
||||||
|
*/
|
||||||
|
@ExperimentalTime
|
||||||
|
class CoroutinesDebugTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun debugTest() = testBlocking {
|
||||||
|
GlobalScope.launch {
|
||||||
|
Coroutines14.argonParallel()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -23,4 +23,4 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
* ugljesa.jovanovic@ionspin.com
|
* ugljesa.jovanovic@ionspin.com
|
||||||
* on 20-Jul-2019
|
* on 20-Jul-2019
|
||||||
*/
|
*/
|
||||||
expect fun testBlocking(block : suspend (scope : CoroutineScope) -> Unit)
|
expect fun testBlocking(block : suspend () -> Unit)
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.ionspin.kotlin.crypto
|
package com.ionspin.kotlin.crypto
|
||||||
|
|
||||||
|
import kotlin.browser.window
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ugljesa Jovanovic
|
* Created by Ugljesa Jovanovic
|
||||||
* ugljesa.jovanovic@ionspin.com
|
* ugljesa.jovanovic@ionspin.com
|
||||||
@ -25,15 +27,7 @@ actual object SRNG {
|
|||||||
var counter = 0
|
var counter = 0
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
actual fun getRandomBytes(amount: Int): Array<UByte> {
|
actual fun getRandomBytes(amount: Int): Array<UByte> {
|
||||||
val runningOnNode = js(
|
val runningOnNode = jsTypeOf(window) == "undefined"
|
||||||
"var isNode = false;\n" +
|
|
||||||
"if (typeof window === 'undefined') {\n" +
|
|
||||||
" isNode = true;\n" +
|
|
||||||
" } else {\n" +
|
|
||||||
" isNode = false;\n" +
|
|
||||||
" }\n" +
|
|
||||||
"return isNode;"
|
|
||||||
)
|
|
||||||
val randomBytes = if (runningOnNode) {
|
val randomBytes = if (runningOnNode) {
|
||||||
js("require('crypto')").randomBytes(amount).toJSON().data
|
js("require('crypto')").randomBytes(amount).toJSON().data
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
package com.ionspin.kotlin.crypto.util
|
package com.ionspin.kotlin.crypto.util
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.promise
|
import kotlinx.coroutines.promise
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ugljesa Jovanovic
|
* Created by Ugljesa Jovanovic
|
||||||
* ugljesa.jovanovic@ionspin.com
|
* ugljesa.jovanovic@ionspin.com
|
||||||
* on 20-Jul-2019
|
* on 20-Jul-2019
|
||||||
*/
|
*/
|
||||||
actual fun testBlocking(block: suspend (scope: CoroutineScope) -> Unit) : dynamic = GlobalScope.promise { block(this) }
|
actual fun testBlocking(block: suspend ()-> Unit) : dynamic = GlobalScope.promise { block() }
|
@ -24,4 +24,4 @@ import kotlinx.coroutines.runBlocking
|
|||||||
* ugljesa.jovanovic@ionspin.com
|
* ugljesa.jovanovic@ionspin.com
|
||||||
* on 20-Jul-2019
|
* on 20-Jul-2019
|
||||||
*/
|
*/
|
||||||
actual fun testBlocking(block: suspend (scope: CoroutineScope) -> Unit) = runBlocking { block(this) }
|
actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
@ -24,4 +24,4 @@ import kotlinx.coroutines.runBlocking
|
|||||||
* ugljesa.jovanovic@ionspin.com
|
* ugljesa.jovanovic@ionspin.com
|
||||||
* on 20-Jul-2019
|
* on 20-Jul-2019
|
||||||
*/
|
*/
|
||||||
actual fun testBlocking(block: suspend (scope: CoroutineScope) -> Unit) = runBlocking { block(this) }
|
actual fun testBlocking(block: suspend () -> Unit) = runBlocking { block() }
|
Loading…
x
Reference in New Issue
Block a user