Skip to content

Commit c7567ff

Browse files
committed
reduction of memory usage.
1 parent 17576ed commit c7567ff

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/mlkem/MLKEMIndCpa.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,9 @@ private byte[] packCipherText(PolyVec b, Poly v)
277277

278278
private void unpackCipherText(PolyVec b, Poly v, byte[] cipherText)
279279
{
280-
byte[] compressedPolyVecCipherText = Arrays.copyOfRange(cipherText, 0, engine.getKyberPolyVecCompressedBytes());
281-
b.decompressPolyVec(compressedPolyVecCipherText);
280+
b.decompressPolyVec(cipherText);
282281

283-
byte[] compressedPolyCipherText = Arrays.copyOfRange(cipherText, engine.getKyberPolyVecCompressedBytes(), cipherText.length);
284-
v.decompressPoly(compressedPolyCipherText);
282+
v.decompressPoly(cipherText, engine.getKyberPolyVecCompressedBytes());
285283
}
286284

287285
public byte[] packPublicKey(PolyVec publicKeyPolyVec, byte[] seed)

core/src/main/java/org/bouncycastle/pqc/crypto/mlkem/Poly.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ else if (polyCompressedBytes == 160)
180180
return r;
181181
}
182182

183-
public void decompressPoly(byte[] compressedPolyCipherText)
183+
public void decompressPoly(byte[] compressedPolyCipherText, int polyCipherOff)
184184
{
185-
int i, count = 0;
185+
int i, count = polyCipherOff;
186186

187187
if (engine.getKyberPolyCompressedBytes() == 128)
188188
{

0 commit comments

Comments
 (0)