@cardanowall/crypto-core 0.5.0 → 0.6.0

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.cjs CHANGED
@@ -993,6 +993,15 @@ var ChunkNonce = class {
993
993
  throw new Error("STREAM: chunk counter overflow");
994
994
  }
995
995
  };
996
+ function streamSealedLength(plaintextLength) {
997
+ if (!Number.isInteger(plaintextLength) || plaintextLength < 0) {
998
+ throw new Error(
999
+ `STREAM: plaintextLength MUST be a non-negative integer, got ${plaintextLength}`
1000
+ );
1001
+ }
1002
+ const chunkCount = Math.max(1, Math.ceil(plaintextLength / CHUNK_SIZE));
1003
+ return plaintextLength + chunkCount * TAG_SIZE;
1004
+ }
996
1005
  function assertPayloadKey(payloadKey) {
997
1006
  if (payloadKey.length !== PAYLOAD_KEY_LENGTH) {
998
1007
  throw new Error(
@@ -3727,6 +3736,7 @@ exports.signEd25519 = signEd25519;
3727
3736
  exports.slotsPayloadKey = slotsPayloadKey;
3728
3737
  exports.streamOpen = streamOpen;
3729
3738
  exports.streamSeal = streamSeal;
3739
+ exports.streamSealedLength = streamSealedLength;
3730
3740
  exports.uniformIndexBelow = uniformIndexBelow;
3731
3741
  exports.verifyEd25519 = verifyEd25519;
3732
3742
  exports.x25519Ecdh = x25519Ecdh;