@cardanowall/crypto-core 0.1.0 → 0.3.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.
@@ -1,7 +1,9 @@
1
+ import { C as CanonicalCborValue } from './canonical-DHeJLYDR.js';
2
+
1
3
  type SealedKem = 'x25519' | 'mlkem768x25519';
2
4
  declare function chunkKemCt(value: Uint8Array): Uint8Array[];
3
5
  declare function joinKemCt(chunks: ReadonlyArray<Uint8Array>): Uint8Array;
4
- declare function slotsToMacCbor(slots: ReadonlyArray<X25519Slot | Mlkem768X25519Slot>, kem: SealedKem): Uint8Array;
6
+ declare function canonicalizeSlots(slots: ReadonlyArray<X25519Slot | Mlkem768X25519Slot>, kem: SealedKem): CanonicalCborValue;
5
7
 
6
8
  declare const CARDANO_POE_HKDF_INFO_KEK: Uint8Array;
7
9
  declare const CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519: Uint8Array;
@@ -108,7 +110,7 @@ type TrialDecryptOnlyResult = {
108
110
  declare function eciesSealedPoeUnwrap(args: UnwrapArgs): UnwrapResult;
109
111
  declare function eciesSealedPoeTrialDecrypt(args: TrialDecryptOnlyArgs): TrialDecryptOnlyResult;
110
112
 
111
- type EciesSealedPoeErrorCode = 'ENC_SLOTS_EMPTY' | 'ENC_SLOTS_REQUIRED' | 'ENC_SLOTS_MAC_REQUIRED' | 'ENC_SLOTS_MAC_INVALID_LENGTH' | 'KEM_EPK_LENGTH_MISMATCH' | 'KEM_CT_LENGTH_MISMATCH' | 'INVALID_CEK_LENGTH' | 'NONCE_LENGTH_MISMATCH' | 'INVALID_EPHEMERAL_SECRET_LENGTH' | 'EPHEMERAL_SECRETS_COUNT_MISMATCH' | 'UNSUPPORTED_ENC_VERSION' | 'UNSUPPORTED_AEAD_ALG' | 'UNSUPPORTED_KEM_ALG' | 'INVALID_ENVELOPE_SHAPE' | 'INVALID_RECIPIENT_KEY' | 'WRAP_LENGTH_MISMATCH';
113
+ type EciesSealedPoeErrorCode = 'ENC_SLOTS_EMPTY' | 'ENC_SLOTS_REQUIRED' | 'ENC_SLOTS_MAC_REQUIRED' | 'ENC_SLOTS_MAC_INVALID_LENGTH' | 'ENC_SLOTS_DUPLICATE_KEM_MATERIAL' | 'ENC_SLOTS_TOO_MANY' | 'ENC_ENVELOPE_TOO_LARGE' | 'KEM_EPK_LENGTH_MISMATCH' | 'KEM_CT_LENGTH_MISMATCH' | 'INVALID_CEK_LENGTH' | 'NONCE_LENGTH_MISMATCH' | 'INVALID_EPHEMERAL_SECRET_LENGTH' | 'EPHEMERAL_SECRETS_COUNT_MISMATCH' | 'UNSUPPORTED_ENC_VERSION' | 'UNSUPPORTED_AEAD_ALG' | 'UNSUPPORTED_KEM_ALG' | 'INVALID_ENVELOPE_SHAPE' | 'INVALID_RECIPIENT_KEY' | 'WRAP_LENGTH_MISMATCH';
112
114
  declare class EciesSealedPoeError extends Error {
113
115
  readonly code: EciesSealedPoeErrorCode;
114
116
  constructor(code: EciesSealedPoeErrorCode, message: string, options?: {
@@ -116,6 +118,56 @@ declare class EciesSealedPoeError extends Error {
116
118
  });
117
119
  }
118
120
 
121
+ declare const CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX: Uint8Array;
122
+ declare const CARDANO_POE_HKDF_INFO_PAYLOAD: Uint8Array;
123
+ declare const CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE: Uint8Array;
124
+ declare const CARDANO_POE_XWING_KEK_SALT_PREFIX: Uint8Array;
125
+ declare const CARDANO_POE_PW_NORM_PROFILE: "cardano-poe-pw-norm-v1";
126
+ declare const MAX_SLOTS = 1024;
127
+ declare const MAX_DECODED_ENVELOPE_BYTES = 65536;
128
+ declare const MAX_SEALED_PLAINTEXT = 274877906880;
129
+ declare const MAX_SEALED_CIPHERTEXT: number;
130
+ declare function assertPlaintextWithinBound(plaintextLength: number): void;
131
+ declare function assertCiphertextWithinBound(ciphertextLength: number): void;
132
+ declare class SealedPayloadTooLargeError extends Error {
133
+ constructor(message: string);
134
+ }
135
+ declare function computeSlotsHash(args: {
136
+ kem: SealedKem;
137
+ nonce: Uint8Array;
138
+ slots: ReadonlyArray<X25519Slot | Mlkem768X25519Slot>;
139
+ }): Uint8Array;
140
+ declare function adContentSlots(args: {
141
+ kem: SealedKem;
142
+ nonce: Uint8Array;
143
+ slotsHash: Uint8Array;
144
+ slotsMac: Uint8Array;
145
+ }): Uint8Array;
146
+ declare function adContentPassphrase(args: {
147
+ nonce: Uint8Array;
148
+ passphrase: {
149
+ alg: string;
150
+ salt: Uint8Array;
151
+ params: {
152
+ m: number;
153
+ t: number;
154
+ p: number;
155
+ };
156
+ };
157
+ }): Uint8Array;
158
+ declare function slotsPayloadKey(args: {
159
+ cek: Uint8Array;
160
+ nonce: Uint8Array;
161
+ }): Uint8Array;
162
+ declare function passphrasePayloadKey(args: {
163
+ cek: Uint8Array;
164
+ nonce: Uint8Array;
165
+ }): Uint8Array;
166
+ declare function xwingKekSalt(args: {
167
+ kemCt: Uint8Array;
168
+ pubR: Uint8Array;
169
+ }): Uint8Array;
170
+
119
171
  interface ParsedSlotShape {
120
172
  readonly epk?: Uint8Array | undefined;
121
173
  readonly kem_ct?: ReadonlyArray<Uint8Array> | undefined;
@@ -131,4 +183,4 @@ interface ParsedEnvelopeShape {
131
183
  }
132
184
  declare function sealedEnvelopeFromParsed(enc: ParsedEnvelopeShape): SealedEnvelope | null;
133
185
 
134
- export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_SLOTS_MAC, EciesSealedPoeError, type EciesSealedPoeErrorCode, type Mlkem768X25519Slot, type ParsedEnvelopeShape, type ParsedSlotShape, type RecipientKeyBundle, type SealedEnvelope, type SealedKem, type SealedPoeOutput, type TrialDecryptOnlyArgs, type TrialDecryptOnlyResult, type UnwrapArgs, type UnwrapArgsBundle, type UnwrapArgsMultiPriv, type UnwrapArgsSinglePriv, type UnwrapFailureReason, type UnwrapResult, type WrapArgs, type X25519Slot, chunkKemCt, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, joinKemCt, sealedEnvelopeFromParsed, slotsToMacCbor, uniformIndexBelow };
186
+ export { CARDANO_POE_HKDF_INFO_KEK, CARDANO_POE_HKDF_INFO_KEK_MLKEM768X25519, CARDANO_POE_HKDF_INFO_PAYLOAD, CARDANO_POE_HKDF_INFO_PAYLOAD_PASSPHRASE, CARDANO_POE_HKDF_INFO_SLOTS_MAC, CARDANO_POE_PW_NORM_PROFILE, CARDANO_POE_SLOTS_TRANSCRIPT_PREFIX, CARDANO_POE_XWING_KEK_SALT_PREFIX, EciesSealedPoeError, type EciesSealedPoeErrorCode, MAX_DECODED_ENVELOPE_BYTES, MAX_SEALED_CIPHERTEXT, MAX_SEALED_PLAINTEXT, MAX_SLOTS, type Mlkem768X25519Slot, type ParsedEnvelopeShape, type ParsedSlotShape, type RecipientKeyBundle, type SealedEnvelope, type SealedKem, SealedPayloadTooLargeError, type SealedPoeOutput, type TrialDecryptOnlyArgs, type TrialDecryptOnlyResult, type UnwrapArgs, type UnwrapArgsBundle, type UnwrapArgsMultiPriv, type UnwrapArgsSinglePriv, type UnwrapFailureReason, type UnwrapResult, type WrapArgs, type X25519Slot, adContentPassphrase, adContentSlots, assertCiphertextWithinBound, assertPlaintextWithinBound, canonicalizeSlots, chunkKemCt, computeSlotsHash, eciesSealedPoeTrialDecrypt, eciesSealedPoeUnwrap, eciesSealedPoeWrap, joinKemCt, passphrasePayloadKey, sealedEnvelopeFromParsed, slotsPayloadKey, uniformIndexBelow, xwingKekSalt };