Remove unintentional formatting changes and add .editorconfig

This commit is contained in:
Johannes Leupold committed 2024-08-14 23:06:41 +02:00
1 parent 989d671c41
commit 2887ae2535
12 files changed
+2329 -2321

No files matched your search

@@ -4,133 +4,133 @@ import com.ionspin.kotlin.crypto.GeneralLibsodiumException.Companion.ensureLibso
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
actual abstract class Ed25519LowLevel actual constructor() {
actual fun isValidPoint(encoded: UByteArray): Boolean =
sodiumJna.crypto_core_ed25519_is_valid_point(encoded.asByteArray()) == 1
actual fun isValidPoint(encoded: UByteArray): Boolean =
sodiumJna.crypto_core_ed25519_is_valid_point(encoded.asByteArray()) == 1
actual fun addPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun addPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_core_ed25519_add(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_core_ed25519_add(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_core_ed25519_sub(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_core_ed25519_sub(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun encodedPointFromUniform(uniform: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun encodedPointFromUniform(uniform: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_core_ed25519_from_uniform(result.asByteArray(), uniform.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_core_ed25519_from_uniform(result.asByteArray(), uniform.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun randomEncodedPoint(): UByteArray = UByteArray(crypto_core_ed25519_BYTES).also {
sodiumJna.crypto_core_ed25519_random(it.asByteArray())
}
actual fun randomEncodedPoint(): UByteArray = UByteArray(crypto_core_ed25519_BYTES).also {
sodiumJna.crypto_core_ed25519_random(it.asByteArray())
}
actual fun randomEncodedScalar(): UByteArray = UByteArray(crypto_core_ed25519_SCALARBYTES).also {
sodiumJna.crypto_core_ed25519_scalar_random(it.asByteArray())
}
actual fun randomEncodedScalar(): UByteArray = UByteArray(crypto_core_ed25519_SCALARBYTES).also {
sodiumJna.crypto_core_ed25519_scalar_random(it.asByteArray())
}
actual fun invertScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun invertScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_invert(result.asByteArray(), scalar.asByteArray()).ensureLibsodiumSuccess()
sodiumJna.crypto_core_ed25519_scalar_invert(result.asByteArray(), scalar.asByteArray()).ensureLibsodiumSuccess()
return result
}
return result
}
actual fun negateScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun negateScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_negate(result.asByteArray(), scalar.asByteArray())
sodiumJna.crypto_core_ed25519_scalar_negate(result.asByteArray(), scalar.asByteArray())
return result
}
return result
}
actual fun complementScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun complementScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_complement(result.asByteArray(), scalar.asByteArray())
sodiumJna.crypto_core_ed25519_scalar_complement(result.asByteArray(), scalar.asByteArray())
return result
}
return result
}
actual fun addScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun addScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_add(result.asByteArray(), x.asByteArray(), y.asByteArray())
sodiumJna.crypto_core_ed25519_scalar_add(result.asByteArray(), x.asByteArray(), y.asByteArray())
return result
}
return result
}
actual fun subtractScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun subtractScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_sub(result.asByteArray(), x.asByteArray(), y.asByteArray())
sodiumJna.crypto_core_ed25519_scalar_sub(result.asByteArray(), x.asByteArray(), y.asByteArray())
return result
}
return result
}
actual fun multiplyScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun multiplyScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_mul(result.asByteArray(), x.asByteArray(), y.asByteArray())
sodiumJna.crypto_core_ed25519_scalar_mul(result.asByteArray(), x.asByteArray(), y.asByteArray())
return result
}
return result
}
actual fun reduceScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
actual fun reduceScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_SCALARBYTES)
sodiumJna.crypto_core_ed25519_scalar_reduce(result.asByteArray(), scalar.asByteArray())
sodiumJna.crypto_core_ed25519_scalar_reduce(result.asByteArray(), scalar.asByteArray())
return result
}
return result
}
actual fun scalarMultiplication(n: UByteArray, p: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun scalarMultiplication(n: UByteArray, p: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_scalarmult_ed25519(result.asByteArray(), n.asByteArray(), p.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_scalarmult_ed25519(result.asByteArray(), n.asByteArray(), p.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun scalarMultiplicationNoClamp(n: UByteArray, p: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun scalarMultiplicationNoClamp(n: UByteArray, p: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_scalarmult_ed25519_noclamp(result.asByteArray(), n.asByteArray(), p.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_scalarmult_ed25519_noclamp(result.asByteArray(), n.asByteArray(), p.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun scalarMultiplicationBase(n: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun scalarMultiplicationBase(n: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_scalarmult_ed25519_base(result.asByteArray(), n.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_scalarmult_ed25519_base(result.asByteArray(), n.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun scalarMultiplicationBaseNoClamp(n: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
actual fun scalarMultiplicationBaseNoClamp(n: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ed25519_BYTES)
sodiumJna.crypto_scalarmult_ed25519_base_noclamp(result.asByteArray(), n.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_scalarmult_ed25519_base_noclamp(result.asByteArray(), n.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
}
@@ -4,114 +4,115 @@ import com.ionspin.kotlin.crypto.GeneralLibsodiumException.Companion.ensureLibso
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
actual abstract class Ristretto255LowLevel actual constructor() {
actual fun isValidPoint(encoded: UByteArray): Boolean =
sodiumJna.crypto_core_ristretto255_is_valid_point(encoded.asByteArray()) == 1
actual fun isValidPoint(encoded: UByteArray): Boolean =
sodiumJna.crypto_core_ristretto255_is_valid_point(encoded.asByteArray()) == 1
actual fun addPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
actual fun addPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
sodiumJna.crypto_core_ristretto255_add(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_core_ristretto255_add(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
actual fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
sodiumJna.crypto_core_ristretto255_sub(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_core_ristretto255_sub(result.asByteArray(), p.asByteArray(), q.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun encodedPointFromHash(hash: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
actual fun encodedPointFromHash(hash: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
sodiumJna.crypto_core_ristretto255_from_hash(result.asByteArray(), hash.asByteArray())
sodiumJna.crypto_core_ristretto255_from_hash(result.asByteArray(), hash.asByteArray())
return result
}
return result
}
actual fun randomEncodedPoint(): UByteArray = UByteArray(crypto_core_ristretto255_BYTES).also {
sodiumJna.crypto_core_ristretto255_random(it.asByteArray())
}
actual fun randomEncodedPoint(): UByteArray = UByteArray(crypto_core_ristretto255_BYTES).also {
sodiumJna.crypto_core_ristretto255_random(it.asByteArray())
}
actual fun randomEncodedScalar(): UByteArray = UByteArray(crypto_core_ristretto255_SCALARBYTES).also {
sodiumJna.crypto_core_ristretto255_scalar_random(it.asByteArray())
}
actual fun randomEncodedScalar(): UByteArray = UByteArray(crypto_core_ristretto255_SCALARBYTES).also {
sodiumJna.crypto_core_ristretto255_scalar_random(it.asByteArray())
}
actual fun invertScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun invertScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_invert(result.asByteArray(), scalar.asByteArray()).ensureLibsodiumSuccess()
sodiumJna.crypto_core_ristretto255_scalar_invert(result.asByteArray(), scalar.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun negateScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun negateScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_negate(result.asByteArray(), scalar.asByteArray())
sodiumJna.crypto_core_ristretto255_scalar_negate(result.asByteArray(), scalar.asByteArray())
return result
}
return result
}
actual fun complementScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun complementScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_complement(result.asByteArray(), scalar.asByteArray())
sodiumJna.crypto_core_ristretto255_scalar_complement(result.asByteArray(), scalar.asByteArray())
return result
}
return result
}
actual fun addScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun addScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_add(result.asByteArray(), x.asByteArray(), y.asByteArray())
sodiumJna.crypto_core_ristretto255_scalar_add(result.asByteArray(), x.asByteArray(), y.asByteArray())
return result
}
return result
}
actual fun subtractScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun subtractScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_sub(result.asByteArray(), x.asByteArray(), y.asByteArray())
sodiumJna.crypto_core_ristretto255_scalar_sub(result.asByteArray(), x.asByteArray(), y.asByteArray())
return result
}
return result
}
actual fun multiplyScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun multiplyScalars(x: UByteArray, y: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_mul(result.asByteArray(), x.asByteArray(), y.asByteArray())
sodiumJna.crypto_core_ristretto255_scalar_mul(result.asByteArray(), x.asByteArray(), y.asByteArray())
return result
}
return result
}
actual fun reduceScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
actual fun reduceScalar(scalar: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_SCALARBYTES)
sodiumJna.crypto_core_ristretto255_scalar_reduce(result.asByteArray(), scalar.asByteArray())
sodiumJna.crypto_core_ristretto255_scalar_reduce(result.asByteArray(), scalar.asByteArray())
return result
}
return result
}
actual fun scalarMultiplication(n: UByteArray, p: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
actual fun scalarMultiplication(n: UByteArray, p: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
sodiumJna.crypto_scalarmult_ristretto255(result.asByteArray(), n.asByteArray(), p.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_scalarmult_ristretto255(result.asByteArray(), n.asByteArray(), p.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
actual fun scalarMultiplicationBase(n: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
actual fun scalarMultiplicationBase(n: UByteArray): UByteArray {
val result = UByteArray(crypto_core_ristretto255_BYTES)
sodiumJna.crypto_scalarmult_ristretto255_base(result.asByteArray(), n.asByteArray())
.ensureLibsodiumSuccess()
sodiumJna.crypto_scalarmult_ristretto255_base(result.asByteArray(), n.asByteArray())
.ensureLibsodiumSuccess()
return result
}
return result
}
}