WIP: Fix build/test issues
This commit is contained in:
1 parent
338c1f0012
commit
9a4a776bbd
14 files changed
+1378
-1152
No files matched your search
+12
-4
@@ -17,11 +17,17 @@ const val crypto_core_ed25519_NONREDUCEDSCALARBYTES = 64
|
||||
const val crypto_scalarmult_ed25519_BYTES = 32U
|
||||
const val crypto_scalarmult_ed25519_SCALARBYTES = 32U
|
||||
|
||||
enum class HashToCurveAlgorithm(val id: Int) {
|
||||
SHA256(1),
|
||||
SHA512(2),
|
||||
}
|
||||
|
||||
expect abstract class Ed25519LowLevel() {
|
||||
fun isValidPoint(encoded: UByteArray): Boolean
|
||||
fun addPoints(p: UByteArray, q: UByteArray): UByteArray
|
||||
fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray
|
||||
fun encodedPointFromHash(hash: UByteArray): UByteArray
|
||||
fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray
|
||||
fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray
|
||||
fun encodedPointFromUniform(uniform: UByteArray): UByteArray
|
||||
fun randomEncodedPoint(): UByteArray
|
||||
fun randomEncodedScalar(): UByteArray
|
||||
@@ -45,7 +51,11 @@ object Ed25519 : Ed25519LowLevel() {
|
||||
fun subtract(p: Point, q: Point): Point =
|
||||
Point(subtractPoints(p.encoded, q.encoded))
|
||||
|
||||
fun pointFromHash(hash: UByteArray): Point = Point(encodedPointFromHash(hash))
|
||||
fun pointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point =
|
||||
Point(encodedPointFromString(ctx, msg, hashAlg))
|
||||
|
||||
fun pointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point =
|
||||
Point(encodedPointFromStringRo(ctx, msg, hashAlg))
|
||||
|
||||
fun pointFromUniform(uniform: UByteArray): Point = Point(encodedPointFromUniform(uniform))
|
||||
|
||||
@@ -103,8 +113,6 @@ object Ed25519 : Ed25519LowLevel() {
|
||||
val IDENTITY: Point = Point(UByteArray(crypto_core_ed25519_BYTES))
|
||||
val BASE: Point = scalarMultiplicationBaseNoClamp(Scalar.ONE)
|
||||
|
||||
fun fromHash(hash: UByteArray): Point = pointFromHash(hash)
|
||||
|
||||
fun fromUniform(uniform: UByteArray): Point = pointFromUniform(uniform)
|
||||
|
||||
fun random(): Point = randomPoint()
|
||||
|
||||
+9
@@ -1,5 +1,6 @@
|
||||
package com.ionspin.kotlin.crypto.ristretto255
|
||||
|
||||
import com.ionspin.kotlin.crypto.ed25519.HashToCurveAlgorithm
|
||||
import com.ionspin.kotlin.crypto.util.LibsodiumUtil
|
||||
import kotlin.UByteArray
|
||||
|
||||
@@ -22,6 +23,8 @@ expect abstract class Ristretto255LowLevel() {
|
||||
fun addPoints(p: UByteArray, q: UByteArray): UByteArray
|
||||
fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray
|
||||
fun encodedPointFromHash(hash: UByteArray): UByteArray
|
||||
fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray
|
||||
fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray
|
||||
fun randomEncodedPoint(): UByteArray
|
||||
fun randomEncodedScalar(): UByteArray
|
||||
fun invertScalar(scalar: UByteArray): UByteArray
|
||||
@@ -44,6 +47,12 @@ object Ristretto255 : Ristretto255LowLevel() {
|
||||
|
||||
fun pointFromHash(hash: UByteArray): Point = Point(encodedPointFromHash(hash))
|
||||
|
||||
fun pointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point =
|
||||
Point(encodedPointFromString(ctx, msg, hashAlg))
|
||||
|
||||
fun pointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point =
|
||||
Point(encodedPointFromStringRo(ctx, msg, hashAlg))
|
||||
|
||||
fun randomPoint(): Point = Point(randomEncodedPoint())
|
||||
|
||||
fun randomScalar(): Scalar = Scalar(randomEncodedScalar())
|
||||
|
||||
Reference in new issue
Block a user