ML-KEM's Kotlin Implementation
APACHE-2.0 License
Bot releases are hidden (Show)
OPTIMIZED/MASTER VERSION
dependencies {
implementation("asia.hombre:kyber:0.8.1")
}
Extract kyber-0.8.1-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 6 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation("asia.hombre:kyber:0.8.0")
}
Extract kyber-0.8.0-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 6 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation("asia.hombre:kyber:0.7.1")
}
Extract kyber-0.7.1-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 6 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation("asia.hombre:kyber:0.7.0")
}
Extract kyber-0.7.0-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 6 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) //kyber-0.6.1-full.jar
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.6.1")
}
Extract kyber-0.6.1-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 6 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) //kyber-0.6.0-full.jar
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.6.0")
}
Extract kyber-0.6.0-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 7 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) //kyber-0.5.1-full.jar
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.5.1")
}
Extract kyber-0.5.1-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i [email protected]
Published by ronhombre 7 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) //kyber-0.5.0-full.jar
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.5.0")
}
Extract kyber-0.4.10-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i kyberkotlin
Published by ronhombre 7 months ago
OPTIMIZED/MASTER VERSION
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) //kyber-0.4.10-full.jar
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.10")
}
Extract kyber-0.4.10-native-mingw-windows.zip
and copy the contents inside your C# project.
npm i kyberkotlin
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
C#
using System.Runtime.InteropServices;
//Use absolute path if relative does not work.
const string dllName = "KyberKotlin.dll";
//Declare methods from the DLL.
[DllImport(dllName, EntryPoint = "generateKeyPair")]
static extern IntPtr generateKeyPair(int parameterId);
[DllImport(dllName, EntryPoint = "getEncapsulationKeySize")]
static extern int getEncapsulationKeySize(int parameterId);
[DllImport(dllName, EntryPoint = "getDecapsulationKeySize")]
static extern int getDecapsulationKeySize(int parameterId);
[DllImport(dllName, EntryPoint = "getCipherTextSize")]
static extern int getCipherTextSize(int parameterId);
[DllImport(dllName, EntryPoint = "getSecretKeySize")]
static extern int getSecretKeySize();
[DllImport(dllName, EntryPoint = "encapsulate")]
static extern IntPtr encapsulate(byte[] encapsulationKey, int parameterId);
[DllImport(dllName, EntryPoint = "decapsulate")]
static extern IntPtr decapsulate(byte[] decapsulationKey, byte[] cipherText, int parameterId);
//Get sizes
int encapsulationKeySize = getEncapsulationKeySize(0); //0 = 512, 1 = 768, 2 = 1024
int decapsulationKeySize = getDecapsulationKeySize(0);
int cipherTextSize = getCipherTextSize(0);
//Generate Key Pair
IntPtr keysPtr = generateKeyPair(0);
byte[] encapsulationKey = new byte[encapsulationKeySize];
byte[] decapsulationKey = new byte[decapsulationKeySize];
Marshal.Copy(keysPtr, encapsulationKey, 0, encapsulationKey.Length);
Marshal.Copy(keysPtr + encapsulationKey.Length, decapsulationKey, 0, decapsulationKey.Length);
//Send encapsulation key to Bob
//Bob encapsulates using it
IntPtr cipherPtr = encapsulate(encapsulationKey, 0);
//Bob receives the Secret Key
byte[] secretKey = new byte[getSecretKeySize()];
byte[] cipherText = new byte[cipherTextSize];
Marshal.Copy(cipherPtr, secretKey, 0, secretKey.Length);
Marshal.Copy(cipherPtr + secretKey.Length, cipherText, 0, cipherText.Length);
//Bob sends the Cipher Text to Alice
//Alice uses it to get a copy of the Secret Key
IntPtr secretKeyPtr = decapsulate(decapsulationKey, cipherText, 0);
//Alice's Copy of the Secret Key
byte[] secretKey2 = new byte[getSecretKeySize()];
Marshal.Copy(secretKeyPtr, secretKey2, 0, secretKey2.Length);
//Use the debugger to see the values.
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.8")
}
Extract kyber-0.4.8-native-mingw-windows.zip
and copy the contents inside your C# project.
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
C#
using System.Runtime.InteropServices;
//Use absolute path if relative does not work.
const string dllName = "KyberKotlin.dll";
//Declare methods from the DLL.
[DllImport(dllName, EntryPoint = "generateKeyPair")]
static extern IntPtr generateKeyPair(int parameterId);
[DllImport(dllName, EntryPoint = "getEncapsulationKeySize")]
static extern int getEncapsulationKeySize(int parameterId);
[DllImport(dllName, EntryPoint = "getDecapsulationKeySize")]
static extern int getDecapsulationKeySize(int parameterId);
[DllImport(dllName, EntryPoint = "getCipherTextSize")]
static extern int getCipherTextSize(int parameterId);
[DllImport(dllName, EntryPoint = "getSecretKeySize")]
static extern int getSecretKeySize();
[DllImport(dllName, EntryPoint = "encapsulate")]
static extern IntPtr encapsulate(byte[] encapsulationKey, int parameterId);
[DllImport(dllName, EntryPoint = "decapsulate")]
static extern IntPtr decapsulate(byte[] decapsulationKey, byte[] cipherText, int parameterId);
//Get sizes
int encapsulationKeySize = getEncapsulationKeySize(0); //0 = 512, 1 = 768, 2 = 1024
int decapsulationKeySize = getDecapsulationKeySize(0);
int cipherTextSize = getCipherTextSize(0);
//Generate Key Pair
IntPtr keysPtr = generateKeyPair(0);
byte[] encapsulationKey = new byte[encapsulationKeySize];
byte[] decapsulationKey = new byte[decapsulationKeySize];
Marshal.Copy(keysPtr, encapsulationKey, 0, encapsulationKey.Length);
Marshal.Copy(keysPtr + encapsulationKey.Length, decapsulationKey, 0, decapsulationKey.Length);
//Send encapsulation key to Bob
//Bob encapsulates using it
IntPtr cipherPtr = encapsulate(encapsulationKey, 0);
//Bob receives the Secret Key
byte[] secretKey = new byte[getSecretKeySize()];
byte[] cipherText = new byte[cipherTextSize];
Marshal.Copy(cipherPtr, secretKey, 0, secretKey.Length);
Marshal.Copy(cipherPtr + secretKey.Length, cipherText, 0, cipherText.Length);
//Bob sends the Cipher Text to Alice
//Alice uses it to get a copy of the Secret Key
IntPtr secretKeyPtr = decapsulate(decapsulationKey, cipherText, 0);
//Alice's Copy of the Secret Key
byte[] secretKey2 = new byte[getSecretKeySize()];
Marshal.Copy(secretKeyPtr, secretKey2, 0, secretKey2.Length);
//Use the debugger to see the values.
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.7")
}
Extract kyber-0.4.7-native-mingw-windows.zip
and copy the contents inside your C# project.
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.6")
}
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.3")
}
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.2")
}
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.1")
}
Published by ronhombre 8 months ago
OPTIMIZED/MASTER VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.4.0")
}
Published by ronhombre 9 months ago
UNOPTIMIZED/STANDARD VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.3.1-standard")
}
Published by ronhombre 9 months ago
UNOPTIMIZED/STANDARD VERSION
Kotlin
val aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512)
val aliceAgreement = KyberAgreement(aliceKeys)
val bobAgreement = KyberAgreement(bobKeys)
val encapsResult = aliceAgreement.encapsulate(bobAgreement.keypair.encapsulationKey)
val decapsSecretKey = bobAgreement.decapsulate(encapsResult.cipherText)
println(encapsResult.secretKey.contentToString())
println(decapsSecretKey.contentToString())
Java
KyberKEMKeyPair aliceKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberKEMKeyPair bobKeys = KyberKeyGenerator.generate(KyberParameter.ML_KEM_512);
KyberAgreement aliceAgreement = new KyberAgreement(aliceKeys);
KyberAgreement bobAgreement = new KyberAgreement(bobKeys);
KyberEncapsulationResult encapsResult = aliceAgreement.encapsulate(bobAgreement.getKeypair().getEncapsulationKey());
byte[] decapsSecretKey = bobAgreement.decapsulate(encapsResult.getCipherText());
System.out.println(Arrays.toString(encapsResult.getSecretKey()));
System.out.println(Arrays.toString(decapsSecretKey));
Output:
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
[1, -123, 89, 94, -70, -97, -54, -58, -82, -10, -92, 10, -85, 115, -61, 85, 33, -109, 66, 71, -76, 86, -19, -37, 28, 66, 56, 72, -101, -56, -58, 22]
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
Add to libs/
folder
dependencies {
implementation("asia.hombre:kyber:0.3.0-standard")
}