@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.
@@ -178,6 +178,7 @@ declare class StreamTamperedError extends Error {
178
178
  cause?: unknown;
179
179
  });
180
180
  }
181
+ declare function streamSealedLength(plaintextLength: number): number;
181
182
  declare class StreamSealer {
182
183
  private readonly payloadKey;
183
184
  private readonly nonce;
@@ -262,4 +263,4 @@ interface ParsedEnvelopeShape {
262
263
  }
263
264
  declare function sealedEnvelopeFromParsed(enc: ParsedEnvelopeShape): SealedEnvelope | null;
264
265
 
265
- export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PASSPHRASE_MAC, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_ITEM_HASHES_PREFIX, CARDANO_POE_PASSPHRASE_TRANSCRIPT_PREFIX, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_X25519_KEK_SALT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, CHUNK_SIZE, EciesSealedPoeError, type EciesSealedPoeErrorCode, type ItemHashes, MAX_DECODED_ENVELOPE_BYTES, MAX_PASSPHRASE_INPUT_BYTES, MAX_SLOTS, type Mlkem768X25519Slot, type ParsedEnvelopeShape, type ParsedSlotShape, type PassphraseOpenArgs, type PassphraseOpenResult, type PassphraseParams, type PassphraseSealArgs, type PassphraseSealedEnvelope, type PassphraseSealedPoeOutput, type RecipientKeyBundle, SEALED_POE_AEAD, type SealedEnvelope, type SealedKem, type SealedPoeOutput, StreamOpener, StreamSealer, StreamTamperedError, TAG_SIZE, type TrialDecryptOnlyArgs, type TrialDecryptOnlyResult, type UnwrapArgs, type UnwrapArgsBundle, type UnwrapArgsMultiPriv, type UnwrapArgsSinglePriv, type UnwrapFailureReason, type UnwrapResult, type WrapArgs, type X25519Slot, computePassphraseCommitment, computePassphraseHash, computeSlotsHash, computeSlotsMac, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, itemHashesHash, normalizePassphrase, passphrasePayloadKey, passphraseSealedPoeOpen, passphraseSealedPoeSeal, sealedEnvelopeFromParsed, slotsPayloadKey, streamOpen, streamSeal, uniformIndexBelow, x25519KekSalt, xwingKekSalt };
266
+ export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PASSPHRASE_MAC, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_ITEM_HASHES_PREFIX, CARDANO_POE_PASSPHRASE_TRANSCRIPT_PREFIX, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_X25519_KEK_SALT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, CHUNK_SIZE, EciesSealedPoeError, type EciesSealedPoeErrorCode, type ItemHashes, MAX_DECODED_ENVELOPE_BYTES, MAX_PASSPHRASE_INPUT_BYTES, MAX_SLOTS, type Mlkem768X25519Slot, type ParsedEnvelopeShape, type ParsedSlotShape, type PassphraseOpenArgs, type PassphraseOpenResult, type PassphraseParams, type PassphraseSealArgs, type PassphraseSealedEnvelope, type PassphraseSealedPoeOutput, type RecipientKeyBundle, SEALED_POE_AEAD, type SealedEnvelope, type SealedKem, type SealedPoeOutput, StreamOpener, StreamSealer, StreamTamperedError, TAG_SIZE, type TrialDecryptOnlyArgs, type TrialDecryptOnlyResult, type UnwrapArgs, type UnwrapArgsBundle, type UnwrapArgsMultiPriv, type UnwrapArgsSinglePriv, type UnwrapFailureReason, type UnwrapResult, type WrapArgs, type X25519Slot, computePassphraseCommitment, computePassphraseHash, computeSlotsHash, computeSlotsMac, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, itemHashesHash, normalizePassphrase, passphrasePayloadKey, passphraseSealedPoeOpen, passphraseSealedPoeSeal, sealedEnvelopeFromParsed, slotsPayloadKey, streamOpen, streamSeal, streamSealedLength, uniformIndexBelow, x25519KekSalt, xwingKekSalt };
@@ -178,6 +178,7 @@ declare class StreamTamperedError extends Error {
178
178
  cause?: unknown;
179
179
  });
180
180
  }
181
+ declare function streamSealedLength(plaintextLength: number): number;
181
182
  declare class StreamSealer {
182
183
  private readonly payloadKey;
183
184
  private readonly nonce;
@@ -262,4 +263,4 @@ interface ParsedEnvelopeShape {
262
263
  }
263
264
  declare function sealedEnvelopeFromParsed(enc: ParsedEnvelopeShape): SealedEnvelope | null;
264
265
 
265
- export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PASSPHRASE_MAC, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_ITEM_HASHES_PREFIX, CARDANO_POE_PASSPHRASE_TRANSCRIPT_PREFIX, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_X25519_KEK_SALT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, CHUNK_SIZE, EciesSealedPoeError, type EciesSealedPoeErrorCode, type ItemHashes, MAX_DECODED_ENVELOPE_BYTES, MAX_PASSPHRASE_INPUT_BYTES, MAX_SLOTS, type Mlkem768X25519Slot, type ParsedEnvelopeShape, type ParsedSlotShape, type PassphraseOpenArgs, type PassphraseOpenResult, type PassphraseParams, type PassphraseSealArgs, type PassphraseSealedEnvelope, type PassphraseSealedPoeOutput, type RecipientKeyBundle, SEALED_POE_AEAD, type SealedEnvelope, type SealedKem, type SealedPoeOutput, StreamOpener, StreamSealer, StreamTamperedError, TAG_SIZE, type TrialDecryptOnlyArgs, type TrialDecryptOnlyResult, type UnwrapArgs, type UnwrapArgsBundle, type UnwrapArgsMultiPriv, type UnwrapArgsSinglePriv, type UnwrapFailureReason, type UnwrapResult, type WrapArgs, type X25519Slot, computePassphraseCommitment, computePassphraseHash, computeSlotsHash, computeSlotsMac, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, itemHashesHash, normalizePassphrase, passphrasePayloadKey, passphraseSealedPoeOpen, passphraseSealedPoeSeal, sealedEnvelopeFromParsed, slotsPayloadKey, streamOpen, streamSeal, uniformIndexBelow, x25519KekSalt, xwingKekSalt };
266
+ export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PASSPHRASE_MAC, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_ITEM_HASHES_PREFIX, CARDANO_POE_PASSPHRASE_TRANSCRIPT_PREFIX, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_X25519_KEK_SALT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, CHUNK_SIZE, EciesSealedPoeError, type EciesSealedPoeErrorCode, type ItemHashes, MAX_DECODED_ENVELOPE_BYTES, MAX_PASSPHRASE_INPUT_BYTES, MAX_SLOTS, type Mlkem768X25519Slot, type ParsedEnvelopeShape, type ParsedSlotShape, type PassphraseOpenArgs, type PassphraseOpenResult, type PassphraseParams, type PassphraseSealArgs, type PassphraseSealedEnvelope, type PassphraseSealedPoeOutput, type RecipientKeyBundle, SEALED_POE_AEAD, type SealedEnvelope, type SealedKem, type SealedPoeOutput, StreamOpener, StreamSealer, StreamTamperedError, TAG_SIZE, type TrialDecryptOnlyArgs, type TrialDecryptOnlyResult, type UnwrapArgs, type UnwrapArgsBundle, type UnwrapArgsMultiPriv, type UnwrapArgsSinglePriv, type UnwrapFailureReason, type UnwrapResult, type WrapArgs, type X25519Slot, computePassphraseCommitment, computePassphraseHash, computeSlotsHash, computeSlotsMac, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, itemHashesHash, normalizePassphrase, passphrasePayloadKey, passphraseSealedPoeOpen, passphraseSealedPoeSeal, sealedEnvelopeFromParsed, slotsPayloadKey, streamOpen, streamSeal, streamSealedLength, uniformIndexBelow, x25519KekSalt, xwingKekSalt };
@@ -148,6 +148,15 @@ var ChunkNonce = class {
148
148
  throw new Error("STREAM: chunk counter overflow");
149
149
  }
150
150
  };
151
+ function streamSealedLength(plaintextLength) {
152
+ if (!Number.isInteger(plaintextLength) || plaintextLength < 0) {
153
+ throw new Error(
154
+ `STREAM: plaintextLength MUST be a non-negative integer, got ${plaintextLength}`
155
+ );
156
+ }
157
+ const chunkCount = Math.max(1, Math.ceil(plaintextLength / CHUNK_SIZE));
158
+ return plaintextLength + chunkCount * TAG_SIZE;
159
+ }
151
160
  function assertPayloadKey(payloadKey) {
152
161
  if (payloadKey.length !== PAYLOAD_KEY_LENGTH) {
153
162
  throw new Error(
@@ -2612,6 +2621,6 @@ function sealedEnvelopeFromParsed(enc) {
2612
2621
  return null;
2613
2622
  }
2614
2623
 
2615
- export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PASSPHRASE_MAC, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_ITEM_HASHES_PREFIX, CARDANO_POE_PASSPHRASE_TRANSCRIPT_PREFIX, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_X25519_KEK_SALT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, CHUNK_SIZE, EciesSealedPoeError, MAX_DECODED_ENVELOPE_BYTES, MAX_PASSPHRASE_INPUT_BYTES, MAX_SLOTS, SEALED_POE_AEAD, StreamOpener, StreamSealer, StreamTamperedError, TAG_SIZE, computePassphraseCommitment, computePassphraseHash, computeSlotsHash, computeSlotsMac, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, itemHashesHash, normalizePassphrase, passphrasePayloadKey, passphraseSealedPoeOpen, passphraseSealedPoeSeal, sealedEnvelopeFromParsed, slotsPayloadKey, streamOpen, streamSeal, uniformIndexBelow, x25519KekSalt, xwingKekSalt };
2624
+ export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PASSPHRASE_MAC, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_ITEM_HASHES_PREFIX, CARDANO_POE_PASSPHRASE_TRANSCRIPT_PREFIX, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_X25519_KEK_SALT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, CHUNK_SIZE, EciesSealedPoeError, MAX_DECODED_ENVELOPE_BYTES, MAX_PASSPHRASE_INPUT_BYTES, MAX_SLOTS, SEALED_POE_AEAD, StreamOpener, StreamSealer, StreamTamperedError, TAG_SIZE, computePassphraseCommitment, computePassphraseHash, computeSlotsHash, computeSlotsMac, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, itemHashesHash, normalizePassphrase, passphrasePayloadKey, passphraseSealedPoeOpen, passphraseSealedPoeSeal, sealedEnvelopeFromParsed, slotsPayloadKey, streamOpen, streamSeal, streamSealedLength, uniformIndexBelow, x25519KekSalt, xwingKekSalt };
2616
2625
  //# sourceMappingURL=sealed-poe.js.map
2617
2626
  //# sourceMappingURL=sealed-poe.js.map