From 0e0801328bc1c5409acc1426ea62946c802d0ca9 Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Wed, 19 Feb 2020 17:36:20 +0100 Subject: [PATCH 1/2] chore: bump kotlin to 1.3.61 and use jdk8 & gradle 6.1.1 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- knacl/build.gradle | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 047858b..3efa32d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.11' + ext.kotlin_version = '1.3.61' repositories { jcenter() } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1543dbb..2289d15 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/knacl/build.gradle b/knacl/build.gradle index 2938bad..e7aa48a 100644 --- a/knacl/build.gradle +++ b/knacl/build.gradle @@ -1,7 +1,10 @@ apply plugin: "kotlin" apply plugin: "maven" +compileKotlin.kotlinOptions.jvmTarget = "1.8" +compileTestKotlin.kotlinOptions.jvmTarget = "1.8" + dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" testImplementation "junit:junit:4.12" } \ No newline at end of file From 5852066814227a8745becff1bf76e45fc7d86ac4 Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Thu, 20 Feb 2020 14:21:22 +0100 Subject: [PATCH 2/2] fix: potential overflow see https://github.com/dchest/tweetnacl-js/issues/187 --- knacl/src/main/kotlin/me/uport/knacl/NaClLowLevel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/knacl/src/main/kotlin/me/uport/knacl/NaClLowLevel.kt b/knacl/src/main/kotlin/me/uport/knacl/NaClLowLevel.kt index e249150..587845e 100644 --- a/knacl/src/main/kotlin/me/uport/knacl/NaClLowLevel.kt +++ b/knacl/src/main/kotlin/me/uport/knacl/NaClLowLevel.kt @@ -5,6 +5,8 @@ import java.security.SecureRandom import kotlin.experimental.and import kotlin.experimental.or import kotlin.experimental.xor +import kotlin.math.floor +import kotlin.math.roundToLong /** * This is a port of the TweetNaCl library @@ -817,7 +819,7 @@ internal object NaClLowLevel { carry = 0 for (j in (i - 32) until (i - 12)) { x[j] += carry - 16 * x[i] * L[j - (i - 32)] - carry = (x[j] + 128) shr 8 + carry = floor((x[j].toDouble() + 128.0) / 256.0).roundToLong() x[j] -= carry shl 8 } ///XXX: check index arithmetic