@wishknish/knishio-client-ts 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3663,6 +3663,12 @@ var Wallet = class _Wallet {
3663
3663
  const messageString = JSON.stringify(message);
3664
3664
  const messageUint8 = new TextEncoder().encode(messageString);
3665
3665
  const deserializedPubkey = this.deserializeKey(recipientPubkey);
3666
+ const ML_KEM_768_PUBLIC_KEY_BYTES = 1184;
3667
+ if (deserializedPubkey.length !== ML_KEM_768_PUBLIC_KEY_BYTES) {
3668
+ throw new Error(
3669
+ `KnishIO: cannot ML-KEM-encrypt \u2014 recipient public key is ${deserializedPubkey.length} bytes, expected ${ML_KEM_768_PUBLIC_KEY_BYTES} (ML-KEM-768). The node likely did not advertise an ML-KEM public key (upgrade the validator to a PQ-transport build), or authenticate with { encrypt: false }.`
3670
+ );
3671
+ }
3666
3672
  const { cipherText, sharedSecret } = ml_kem768.encapsulate(deserializedPubkey);
3667
3673
  const encryptedMessage = await this.encryptWithSharedSecret(messageUint8, sharedSecret);
3668
3674
  return {