Skip to content

Commit

Permalink
Pre-1.x.x Deprecation
Browse files Browse the repository at this point in the history
* These methods will be fully deprecated in the 1.0.0 release
  • Loading branch information
ronhombre committed Aug 28, 2024
1 parent 69ff060 commit 688d4f6
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/commonMain/kotlin/asia/hombre/kyber/KyberCipherText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class KyberCipherText internal constructor( //TODO: Copy parameter variables
*/
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@Deprecated("Conversion from hex values are up to the user.", level = DeprecationLevel.WARNING)
fun fromHex(hexString: String): KyberCipherText {
return fromBytes(KyberMath.decodeHex(hexString))
}
Expand All @@ -111,6 +112,13 @@ class KyberCipherText internal constructor( //TODO: Copy parameter variables
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@OptIn(ExperimentalEncodingApi::class)
@Deprecated("Conversion from base64 values are up to the user.", level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
"fromBytes(Base64.decode(base64String))",
"asia.hombre.kyber.KyberCipherText.Companion.fromBytes",
"kotlin.io.encoding.Base64"
)
)
fun fromBase64(base64String: String): KyberCipherText {
return fromBytes(Base64.decode(base64String))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class KyberDecapsulationKey internal constructor(
*/
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@Deprecated("Conversion from hex values are up to the user.", level = DeprecationLevel.WARNING)
fun fromHex(hexString: String): KyberDecapsulationKey {
return fromBytes(KyberMath.decodeHex(hexString))
}
Expand All @@ -122,6 +123,13 @@ class KyberDecapsulationKey internal constructor(
@JvmStatic
@Throws(UnsupportedKyberVariantException::class)
@OptIn(ExperimentalEncodingApi::class)
@Deprecated("Conversion from base64 values are up to the user.", level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
"fromBytes(Base64.decode(base64String))",
"asia.hombre.kyber.KyberDecapsulationKey.Companion.fromBytes",
"kotlin.io.encoding.Base64"
)
)
fun fromBase64(base64String: String): KyberDecapsulationKey {
return fromBytes(Base64.decode(base64String))
}
Expand Down
8 changes: 8 additions & 0 deletions src/commonMain/kotlin/asia/hombre/kyber/KyberDecryptionKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class KyberDecryptionKey internal constructor(
*/
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@Deprecated("Conversion from hex values are up to the user.", level = DeprecationLevel.WARNING)
fun fromHex(hexString: String): KyberDecryptionKey {
return fromBytes(KyberMath.decodeHex(hexString))
}
Expand All @@ -103,6 +104,13 @@ class KyberDecryptionKey internal constructor(
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@OptIn(ExperimentalEncodingApi::class)
@Deprecated("Conversion from base64 values are up to the user.", level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
"fromBytes(Base64.decode(base64String))",
"asia.hombre.kyber.KyberDecryptionKey.Companion.fromBytes",
"kotlin.io.encoding.Base64"
)
)
fun fromBase64(base64String: String): KyberDecryptionKey {
return fromBytes(Base64.decode(base64String))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class KyberEncapsulationKey internal constructor(
*/
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@Deprecated("Conversion from hex values are up to the user.", level = DeprecationLevel.WARNING)
fun fromHex(hexString: String): KyberEncapsulationKey {
return KyberEncapsulationKey(KyberEncryptionKey.fromHex(hexString))
}
Expand All @@ -89,6 +90,12 @@ class KyberEncapsulationKey internal constructor(
*/
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@Deprecated("Conversion from base64 values are up to the user.", level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
"KyberEncapsulationKey(KyberEncryptionKey.fromBase64(base64String))",
"asia.hombre.kyber.KyberEncapsulationKey"
)
)
fun fromBase64(base64String: String): KyberEncapsulationKey {
return KyberEncapsulationKey(KyberEncryptionKey.fromBase64(base64String))
}
Expand Down
8 changes: 8 additions & 0 deletions src/commonMain/kotlin/asia/hombre/kyber/KyberEncryptionKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class KyberEncryptionKey internal constructor(
*/
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@Deprecated("Conversion from hex values are up to the user.", level = DeprecationLevel.WARNING)
fun fromHex(hexString: String): KyberEncryptionKey {
return fromBytes(KyberMath.decodeHex(hexString))
}
Expand All @@ -117,6 +118,13 @@ class KyberEncryptionKey internal constructor(
@JvmStatic
@Throws(UnsupportedKyberVariantException::class, IllegalArgumentException::class)
@OptIn(ExperimentalEncodingApi::class)
@Deprecated("Conversion from base64 values are up to the user.", level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
"fromBytes(Base64.decode(base64String))",
"asia.hombre.kyber.KyberEncryptionKey.Companion.fromBytes",
"kotlin.io.encoding.Base64"
)
)
fun fromBase64(base64String: String): KyberEncryptionKey {
return fromBytes(Base64.decode(base64String))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ package asia.hombre.kyber.exceptions
/**
* When a key fails a validity check.
*/
class InvalidKyberKeyException(override val message: String): Exception("This may not be a Kyber Key! Reason: $message")
class InvalidKyberKeyException(override val message: String): Exception("This may not be an ML-KEM Key! Reason: $message")
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ package asia.hombre.kyber.exceptions
/**
* When an unsupported ML-KEM variant was attempted to be used.
*/
class UnsupportedKyberVariantException(override val message: String): Exception("This Kyber variant is not yet supported! Reason: $message")
class UnsupportedKyberVariantException(override val message: String): Exception("This ML-KEM variant is not yet supported! Reason: $message")
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import kotlin.js.JsExport
@OptIn(ExperimentalJsExport::class)
@JsExport
internal interface Convertible {
@Deprecated("Conversion to hex values are up to the user.", level = DeprecationLevel.WARNING)
fun toHex(isUppercase: Boolean = true): String
@Deprecated("Conversion to base64 values are up to the user.", level = DeprecationLevel.WARNING)
fun toBase64(): String
}

0 comments on commit 688d4f6

Please sign in to comment.