Skip to content

Commit

Permalink
Update the docs for Secret Key to Shared Secret Key
Browse files Browse the repository at this point in the history
* This matches the name in the NIST FIPS 203 document to reduce confusion
  • Loading branch information
ronhombre committed Aug 30, 2024
1 parent 8187ba1 commit dee09f0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/commonMain/kotlin/asia/hombre/kyber/KyberAgreement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class KyberAgreement(private val decapsulationKey: KyberDecapsulationKey) {
*
* @param kyberEncapsulationKey [KyberEncapsulationKey] of the second party.
* @param plainText [ByteArray] The Plain Text to use.
* @return [KyberEncapsulationResult] - Contains the Cipher Text and the generated Secret Key.
* @return [KyberEncapsulationResult] - Contains the Cipher Text and the generated Shared Secret Key.
*/
@JvmSynthetic
internal fun encapsulate(kyberEncapsulationKey: KyberEncapsulationKey, plainText: ByteArray): KyberEncapsulationResult {
Expand All @@ -221,7 +221,7 @@ class KyberAgreement(private val decapsulationKey: KyberDecapsulationKey) {
*
* @param decapsulationKey [KyberDecapsulationKey] from yourself.
* @param kyberCipherText [KyberCipherText] received from sender.
* @return [ByteArray] - The generated Secret Key, which is the same one generated by the sender.
* @return [ByteArray] - The generated Shared Secret Key, which is the same one generated by the sender.
*/
@JvmSynthetic
internal fun decapsulate(decapsulationKey: KyberDecapsulationKey, kyberCipherText: KyberCipherText): ByteArray {
Expand Down Expand Up @@ -259,12 +259,12 @@ class KyberAgreement(private val decapsulationKey: KyberDecapsulationKey) {
}

/**
* Encapsulates a [KyberEncapsulationKey] into a [KyberCipherText] and generates a Secret Key.
* Encapsulates a [KyberEncapsulationKey] into a [KyberCipherText] and generates a Shared Secret Key.
*
* This method is the ML-KEM.Encaps() specified in NIST FIPS 203.
*
* @param kyberEncapsulationKey [KyberEncapsulationKey] received from sender.
* @return [KyberEncapsulationResult] - Contains the Cipher Text and the generated Secret Key.
* @return [KyberEncapsulationResult] - Contains the Cipher Text and the generated Shared Secret Key.
*/
@JvmStatic
@JsName("encapsulate")
Expand All @@ -278,12 +278,12 @@ class KyberAgreement(private val decapsulationKey: KyberDecapsulationKey) {
}

/**
* Decapsulates a [KyberCipherText] and recovers the Secret Key.
* Decapsulates a [KyberCipherText] and recovers the Shared Secret Key.
*
* This method is the ML-KEM.Decaps() specified in NIST FIPS 203.
*
* @param kyberCipherText [KyberCipherText] received from sender.
* @return [ByteArray] - The generated Secret Key, which is the same one generated by the sender.
* @return [ByteArray] - The generated Shared Secret Key, which is the same one generated by the sender.
*/
@JsName("decapsulate")
@Deprecated("KyberAgreement is a redundant class.",
Expand Down
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/asia/hombre/kyber/KyberCipherText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ class KyberCipherText internal constructor( //TODO: Copy parameter variables
}

/**
* Decapsulates this [KyberCipherText] and recovers the Secret Key.
* Decapsulates this [KyberCipherText] and recovers the Shared Secret Key.
*
* This method is the ML-KEM.Decaps() specified in NIST FIPS 203.
*
* @param decapsulationKey your [KyberDecapsulationKey].
* @return [ByteArray] - The generated Secret Key, which is the same one generated by the sender.
* @return [ByteArray] - The generated Shared Secret Key, which is the same one generated by the sender.
*/
fun decapsulate(decapsulationKey: KyberDecapsulationKey): ByteArray {
return KyberAgreement.decapsulate(decapsulationKey, this)
Expand Down
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/asia/hombre/kyber/KyberConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object KyberConstants {
const val MONT_R2: Short = 1353 //MONT_R.toLong() shl 16 <- mod Q = 1353 //Basically R^2 mod Q

/**
* The length of the Secret Key in bytes.
* The length of the Shared Secret Key in bytes.
*/
const val SECRET_KEY_LENGTH: Int = N_BYTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ class KyberEncapsulationKey internal constructor(
}

/**
* Encapsulates this [KyberEncapsulationKey] into a [KyberCipherText] and generates a Secret Key.
* Encapsulates this [KyberEncapsulationKey] into a [KyberCipherText] and generates a Shared Secret Key.
*
* This method is the ML-KEM.Encaps() specified in NIST FIPS 203.
*
* @return [KyberEncapsulationResult] - Contains the Cipher Text and the generated Secret Key.
* @return [KyberEncapsulationResult] - Contains the Cipher Text and the generated Shared Secret Key.
*/
fun encapsulate(): KyberEncapsulationResult {
return KyberAgreement.encapsulate(this, SecureRandom().nextBytesOf(KyberConstants.N_BYTES))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import kotlin.jvm.JvmName
/**
* A class for ML-KEM Encapsulation Results.
*
* This class contains the Secret Key and the Cipher Text.
* This class contains the Shared Secret Key and the Cipher Text.
*
* @constructor Stores the Secret Key and the Cipher Text.
* @constructor Stores the Shared Secret Key and the Cipher Text.
* @author Ron Lauren Hombre
*/
@OptIn(ExperimentalJsExport::class)
Expand All @@ -37,7 +37,7 @@ class KyberEncapsulationResult internal constructor(
private val cipherText_: KyberCipherText
) {
/**
* The Secret Key generated by the Encapsulation.
* The Shared Secret Key generated by the Encapsulation.
*
* @return [ByteArray] - 32 Bytes.
*/
Expand Down

0 comments on commit dee09f0

Please sign in to comment.