@aidc-toolkit/utility 1.0.22-beta → 1.0.24-beta
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/README.md +30 -30
- package/dist/index.cjs +3569 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +947 -0
- package/dist/index.d.ts +947 -26
- package/dist/index.js +3504 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/src/character-set.ts +6 -6
- package/src/index.ts +9 -9
- package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/i18n.ts +6 -8
- package/src/locale/i18next.d.ts +2 -2
- package/src/record.ts +2 -2
- package/src/reg-exp.ts +2 -2
- package/src/transformer.ts +3 -3
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/character-set.d.ts +0 -307
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -563
- package/dist/character-set.js.map +0 -1
- package/dist/exclusion.d.ts +0 -22
- package/dist/exclusion.d.ts.map +0 -1
- package/dist/exclusion.js +0 -18
- package/dist/exclusion.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/iterable-utility.d.ts +0 -39
- package/dist/iterable-utility.d.ts.map +0 -1
- package/dist/iterable-utility.js +0 -35
- package/dist/iterable-utility.js.map +0 -1
- package/dist/locale/en/locale-strings.d.ts +0 -32
- package/dist/locale/en/locale-strings.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.js +0 -32
- package/dist/locale/en/locale-strings.js.map +0 -1
- package/dist/locale/fr/locale-strings.d.ts +0 -32
- package/dist/locale/fr/locale-strings.d.ts.map +0 -1
- package/dist/locale/fr/locale-strings.js +0 -32
- package/dist/locale/fr/locale-strings.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -35
- package/dist/locale/i18n.js.map +0 -1
- package/dist/record.d.ts +0 -44
- package/dist/record.d.ts.map +0 -1
- package/dist/record.js +0 -58
- package/dist/record.js.map +0 -1
- package/dist/reg-exp.d.ts +0 -43
- package/dist/reg-exp.d.ts.map +0 -1
- package/dist/reg-exp.js +0 -55
- package/dist/reg-exp.js.map +0 -1
- package/dist/sequence.d.ts +0 -68
- package/dist/sequence.d.ts.map +0 -1
- package/dist/sequence.js +0 -96
- package/dist/sequence.js.map +0 -1
- package/dist/string.d.ts +0 -25
- package/dist/string.d.ts.map +0 -1
- package/dist/string.js +0 -2
- package/dist/string.js.map +0 -1
- package/dist/transformer.d.ts +0 -346
- package/dist/transformer.d.ts.map +0 -1
- package/dist/transformer.js +0 -456
- package/dist/transformer.js.map +0 -1
package/dist/sequence.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACjB;;OAEG;IACc,WAAW,CAAS;IAErC;;OAEG;IACc,SAAS,CAAS;IAEnC;;OAEG;IACc,MAAM,CAAS;IAEhC;;OAEG;IACc,UAAU,CAAW;IAEtC;;OAEG;IACc,aAAa,CAAS;IAEvC;;OAEG;IACc,aAAa,CAAS;IAEvC;;;;;;;;;OASG;IACH,YAAY,UAA2B,EAAE,KAAa;QAClD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;YACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpF,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
|
package/dist/string.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String validation interface. To ensure signature compatibility in implementing classes, string validation is
|
|
3
|
-
* controlled by validation interfaces specific to each validator type.
|
|
4
|
-
*/
|
|
5
|
-
export interface StringValidation {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* String validator interface.
|
|
9
|
-
*
|
|
10
|
-
* @template V
|
|
11
|
-
* String validation type.
|
|
12
|
-
*/
|
|
13
|
-
export interface StringValidator<V extends StringValidation = StringValidation> {
|
|
14
|
-
/**
|
|
15
|
-
* Validate a string and throw an error if validation fails.
|
|
16
|
-
*
|
|
17
|
-
* @param s
|
|
18
|
-
* String.
|
|
19
|
-
*
|
|
20
|
-
* @param validation
|
|
21
|
-
* String validation parameters.
|
|
22
|
-
*/
|
|
23
|
-
validate: (s: string, validation?: V) => void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=string.d.ts.map
|
package/dist/string.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB;IAC1E;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;CACjD"}
|
package/dist/string.js
DELETED
package/dist/string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":""}
|
package/dist/transformer.d.ts
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { type IndexedCallback } from "./iterable-utility.js";
|
|
2
|
-
/**
|
|
3
|
-
* Transformer primitive type.
|
|
4
|
-
*/
|
|
5
|
-
export type TransformerPrimitive = string | number | bigint | boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Transformer input type, one of:
|
|
8
|
-
*
|
|
9
|
-
* - TInput (primitive type)
|
|
10
|
-
* - Iterable\<TInput\>
|
|
11
|
-
*
|
|
12
|
-
* @template TInput
|
|
13
|
-
* Transformer input primitive type.
|
|
14
|
-
*/
|
|
15
|
-
export type TransformerInput<TInput extends TransformerPrimitive> = TInput | Iterable<TInput>;
|
|
16
|
-
/**
|
|
17
|
-
* Transformer output, based on transformer input:
|
|
18
|
-
*
|
|
19
|
-
* - If type TTransformerInput is primitive, result is type TOutput.
|
|
20
|
-
* - If type TTransformerInput is Iterable, result is type Iterable\<TOutput\>.
|
|
21
|
-
*
|
|
22
|
-
* @template TTransformerInput
|
|
23
|
-
* Transformer input type.
|
|
24
|
-
*
|
|
25
|
-
* @template TOutput
|
|
26
|
-
* Output base type.
|
|
27
|
-
*/
|
|
28
|
-
export type TransformerOutput<TTransformerInput extends TransformerInput<TransformerPrimitive>, TOutput> = TTransformerInput extends (TTransformerInput extends TransformerInput<infer TInput> ? TInput : never) ? TOutput : Iterable<TOutput>;
|
|
29
|
-
/**
|
|
30
|
-
* Transformer that transforms values in a numeric domain to values in a range equal to the domain or to another range
|
|
31
|
-
* defined by a callback function. In other words, the domain determines valid input values and, without a callback, the
|
|
32
|
-
* range of valid output values.
|
|
33
|
-
*
|
|
34
|
-
* The concept is similar to {@link https://en.wikipedia.org/wiki/Format-preserving_encryption | format-preserving
|
|
35
|
-
* encryption}, where input values within a specified domain (e.g., {@link
|
|
36
|
-
* https://en.wikipedia.org/wiki/Payment_card_number | payment card numbers} ranging from 8-19 digits) are transformed
|
|
37
|
-
* into values in the same domain, typically for storage in a database where the data type and length are already fixed
|
|
38
|
-
* and exfiltration of the data can have significant repercussions.
|
|
39
|
-
*
|
|
40
|
-
* Two subclasses are supported directly by this class: {@link IdentityTransformer} (which operates based on a domain
|
|
41
|
-
* only) and {@link EncryptionTransformer} (which operates based on a domain and a tweak). If an application is expected
|
|
42
|
-
* to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the transformer
|
|
43
|
-
* object, an in-memory cache is available via the {@link get} method. Properties in {@link IdentityTransformer} and
|
|
44
|
-
* {@link EncryptionTransformer} are read-only once constructed, so there is no issue with their shared use.
|
|
45
|
-
*/
|
|
46
|
-
export declare abstract class Transformer {
|
|
47
|
-
/**
|
|
48
|
-
* Transformers cache, mapping a domain to another map, which maps an optional tweak to a transformer.
|
|
49
|
-
*/
|
|
50
|
-
private static readonly TRANSFORMER_MAPS_MAP;
|
|
51
|
-
/**
|
|
52
|
-
* Domain.
|
|
53
|
-
*/
|
|
54
|
-
private readonly _domain;
|
|
55
|
-
/**
|
|
56
|
-
* Constructor.
|
|
57
|
-
*
|
|
58
|
-
* @param domain
|
|
59
|
-
* Domain.
|
|
60
|
-
*/
|
|
61
|
-
constructor(domain: number | bigint);
|
|
62
|
-
/**
|
|
63
|
-
* Get a transformer, constructing it if necessary. The type returned is {@link IdentityTransformer} if tweak is
|
|
64
|
-
* undefined, {@link EncryptionTransformer} if tweak is defined. Note that although an {@link EncryptionTransformer}
|
|
65
|
-
* with a zero tweak operates as an {@link IdentityTransformer}, {@link EncryptionTransformer} is still the type
|
|
66
|
-
* returned if a zero tweak is explicitly specified.
|
|
67
|
-
*
|
|
68
|
-
* @param domain
|
|
69
|
-
* Domain.
|
|
70
|
-
*
|
|
71
|
-
* @param tweak
|
|
72
|
-
* Tweak.
|
|
73
|
-
*
|
|
74
|
-
* @returns
|
|
75
|
-
* {@link IdentityTransformer} if tweak is undefined, {@link EncryptionTransformer} if tweak is defined.
|
|
76
|
-
*/
|
|
77
|
-
static get(domain: number | bigint, tweak?: number | bigint): Transformer;
|
|
78
|
-
/**
|
|
79
|
-
* Get the domain.
|
|
80
|
-
*/
|
|
81
|
-
get domain(): bigint;
|
|
82
|
-
/**
|
|
83
|
-
* Validate that a value is within the domain.
|
|
84
|
-
*
|
|
85
|
-
* @param value
|
|
86
|
-
* Value.
|
|
87
|
-
*/
|
|
88
|
-
private validate;
|
|
89
|
-
/**
|
|
90
|
-
* Do the work of transforming a value forward.
|
|
91
|
-
*
|
|
92
|
-
* @param value
|
|
93
|
-
* Value.
|
|
94
|
-
*
|
|
95
|
-
* @returns
|
|
96
|
-
* Transformed value.
|
|
97
|
-
*/
|
|
98
|
-
protected abstract doForward(value: bigint): bigint;
|
|
99
|
-
/**
|
|
100
|
-
* Validate that a value is within the domain and do the work of transforming it forward.
|
|
101
|
-
*
|
|
102
|
-
* @param value
|
|
103
|
-
* Value.
|
|
104
|
-
*
|
|
105
|
-
* @returns
|
|
106
|
-
* Transformed value.
|
|
107
|
-
*/
|
|
108
|
-
private validateDoForward;
|
|
109
|
-
/**
|
|
110
|
-
* Validate that a value is within the domain, do the work of transforming it forward, and apply a callback.
|
|
111
|
-
*
|
|
112
|
-
* @param transformerCallback
|
|
113
|
-
* Called after each value is transformed to convert it to its final value.
|
|
114
|
-
*
|
|
115
|
-
* @param value
|
|
116
|
-
* Value.
|
|
117
|
-
*
|
|
118
|
-
* @param index
|
|
119
|
-
* Index in sequence (0 for single transformation).
|
|
120
|
-
*
|
|
121
|
-
* @returns
|
|
122
|
-
* Transformed value.
|
|
123
|
-
*/
|
|
124
|
-
private validateDoForwardCallback;
|
|
125
|
-
/**
|
|
126
|
-
* Transform value(s) forward.
|
|
127
|
-
*
|
|
128
|
-
* @template TTransformerInput
|
|
129
|
-
* Value(s) input type.
|
|
130
|
-
*
|
|
131
|
-
* @param valueOrValues
|
|
132
|
-
* Value(s). If this is an instance of {@link Sequence}, the minimum and maximum values are validated prior to
|
|
133
|
-
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
134
|
-
*
|
|
135
|
-
* @returns
|
|
136
|
-
* Transformed value(s).
|
|
137
|
-
*/
|
|
138
|
-
forward<TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput): TransformerOutput<TTransformerInput, bigint>;
|
|
139
|
-
/**
|
|
140
|
-
* Transform value(s) forward, optionally applying a transformation.
|
|
141
|
-
*
|
|
142
|
-
* @template TTransformerInput
|
|
143
|
-
* Value(s) input type.
|
|
144
|
-
*
|
|
145
|
-
* @template TOutput
|
|
146
|
-
* Transformation callback output type.
|
|
147
|
-
*
|
|
148
|
-
* @param valueOrValues
|
|
149
|
-
* Value(s). If this is an instance of {@link Sequence}, the minimum and maximum values are validated prior to
|
|
150
|
-
* transformation. Otherwise, the individual value(s) is/are validated at the time of transformation.
|
|
151
|
-
*
|
|
152
|
-
* @param transformerCallback
|
|
153
|
-
* Called after each value is transformed to convert it to its final value.
|
|
154
|
-
*
|
|
155
|
-
* @returns
|
|
156
|
-
* Transformed value(s).
|
|
157
|
-
*/
|
|
158
|
-
forward<TTransformerInput extends TransformerInput<number | bigint>, TOutput>(valueOrValues: TTransformerInput, transformerCallback: IndexedCallback<bigint, TOutput>): TransformerOutput<TTransformerInput, TOutput>;
|
|
159
|
-
/**
|
|
160
|
-
* Do the work of transforming a value in reverse.
|
|
161
|
-
*
|
|
162
|
-
* @param transformedValue
|
|
163
|
-
* Transformed value.
|
|
164
|
-
*
|
|
165
|
-
* @returns
|
|
166
|
-
* Value.
|
|
167
|
-
*/
|
|
168
|
-
protected abstract doReverse(transformedValue: bigint): bigint;
|
|
169
|
-
/**
|
|
170
|
-
* Transform a value in reverse.
|
|
171
|
-
*
|
|
172
|
-
* @param transformedValue
|
|
173
|
-
* Transformed value.
|
|
174
|
-
*
|
|
175
|
-
* @returns
|
|
176
|
-
* Value.
|
|
177
|
-
*/
|
|
178
|
-
reverse(transformedValue: number | bigint): bigint;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Identity transformer. Values are transformed to themselves.
|
|
182
|
-
*/
|
|
183
|
-
export declare class IdentityTransformer extends Transformer {
|
|
184
|
-
/**
|
|
185
|
-
* @inheritDoc
|
|
186
|
-
*/
|
|
187
|
-
protected doForward(value: bigint): bigint;
|
|
188
|
-
/**
|
|
189
|
-
* @inheritDoc
|
|
190
|
-
*/
|
|
191
|
-
protected doReverse(transformedValue: bigint): bigint;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Encryption transformer. Values are transformed using repeated shuffle and xor operations, similar to those found in
|
|
195
|
-
* many cryptography algorithms, particularly AES. While sufficient for obfuscation of numeric sequences (e.g., serial
|
|
196
|
-
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as
|
|
197
|
-
* {@link https://doi.org/10.6028/NIST.SP.800-38Gr1-draft | FF1} is recommended. Furthermore, no work has been done to
|
|
198
|
-
* mitigate {@link https://timing.attacks.cr.yp.to/index.html | timing attacks} for key detection.
|
|
199
|
-
*
|
|
200
|
-
* The purpose of the encryption transformer is to generate pseudo-random values in a deterministic manner to obscure
|
|
201
|
-
* the sequence of values generated over time. A typical example is for serial number generation, where knowledge of the
|
|
202
|
-
* sequence can infer production volumes (e.g., serial number 1000 implies that at least 1,000 units have been
|
|
203
|
-
* manufactured) or can be used in counterfeiting (e.g., a counterfeiter can generate serial numbers 1001, 1002, ...
|
|
204
|
-
* with reasonable confidence that they would be valid if queried).
|
|
205
|
-
*
|
|
206
|
-
* The domain and the tweak together determine the encryption key, which in turn determines the number of rounds of
|
|
207
|
-
* shuffle and xor operations. The minimum number of rounds is 4, except where the domain is less than or equal to 256,
|
|
208
|
-
* which results in single-byte operations. To ensure that the operations are effective for single-byte domains, the
|
|
209
|
-
* number of rounds is 1 and only the xor operation is applied (shuffling a single byte is an identity operation).
|
|
210
|
-
*
|
|
211
|
-
* Another exception is when there is a tweak value of 0; this results in identity operations where the output value is
|
|
212
|
-
* identical to the input value, as no shuffle or xor takes place.
|
|
213
|
-
*/
|
|
214
|
-
export declare class EncryptionTransformer extends Transformer {
|
|
215
|
-
/**
|
|
216
|
-
* Individual bits, pre-calculated for performance.
|
|
217
|
-
*/
|
|
218
|
-
private static readonly BITS;
|
|
219
|
-
/**
|
|
220
|
-
* Inverse individual bits, pre-calculated for performance.
|
|
221
|
-
*/
|
|
222
|
-
private static readonly INVERSE_BITS;
|
|
223
|
-
/**
|
|
224
|
-
* Number of bytes covered by the domain.
|
|
225
|
-
*/
|
|
226
|
-
private readonly _domainBytes;
|
|
227
|
-
/**
|
|
228
|
-
* Xor bytes array generated from the domain and tweak.
|
|
229
|
-
*/
|
|
230
|
-
private readonly _xorBytes;
|
|
231
|
-
/**
|
|
232
|
-
* Bits array generated from the domain and tweak.
|
|
233
|
-
*/
|
|
234
|
-
private readonly _bits;
|
|
235
|
-
/**
|
|
236
|
-
* Inverse bits array generated from the domain and tweak.
|
|
237
|
-
*/
|
|
238
|
-
private readonly _inverseBits;
|
|
239
|
-
/**
|
|
240
|
-
* Number of rounds (length of arrays) generated from the domain and tweak.
|
|
241
|
-
*/
|
|
242
|
-
private readonly _rounds;
|
|
243
|
-
/**
|
|
244
|
-
* Constructor.
|
|
245
|
-
*
|
|
246
|
-
* @param domain
|
|
247
|
-
* Domain.
|
|
248
|
-
*
|
|
249
|
-
* @param tweak
|
|
250
|
-
* Tweak.
|
|
251
|
-
*/
|
|
252
|
-
constructor(domain: number | bigint, tweak: number | bigint);
|
|
253
|
-
/**
|
|
254
|
-
* Convert a value to a byte array big enough to handle the entire domain.
|
|
255
|
-
*
|
|
256
|
-
* @param value
|
|
257
|
-
* Value.
|
|
258
|
-
*
|
|
259
|
-
* @returns
|
|
260
|
-
* Big-endian byte array equivalent to the value.
|
|
261
|
-
*/
|
|
262
|
-
private valueToBytes;
|
|
263
|
-
/**
|
|
264
|
-
* Convert a byte array to a value.
|
|
265
|
-
*
|
|
266
|
-
* @param bytes
|
|
267
|
-
* Big-endian byte array equivalent to the value.
|
|
268
|
-
*
|
|
269
|
-
* @returns
|
|
270
|
-
* Value.
|
|
271
|
-
*/
|
|
272
|
-
private static bytesToValue;
|
|
273
|
-
/**
|
|
274
|
-
* Shuffle a byte array.
|
|
275
|
-
*
|
|
276
|
-
* The input array to the forward operation (output from the reverse operation) is `bytes` and the output array from
|
|
277
|
-
* the forward operation (input to the reverse operation) is `bytes'`.
|
|
278
|
-
*
|
|
279
|
-
* The shuffle operation starts by testing the bit at `bits[round]` for each `byte` in `bytes`. The indexes for all
|
|
280
|
-
* bytes with that bit set are put into one array (`shuffleIndexes1`) and the rest are put into another
|
|
281
|
-
* (`shuffleIndexes0`). The two arrays are concatenated and used to shuffle the input array, using their values
|
|
282
|
-
* (`shuffleIndex`) and the indexes of those values (`index`) in the concatenated array.
|
|
283
|
-
*
|
|
284
|
-
* Forward shuffling moves the entry at `shuffleIndex` to the `index` position.
|
|
285
|
-
*
|
|
286
|
-
* Reverse shuffling moves the entry at `index` to the `shuffleIndex` position.
|
|
287
|
-
*
|
|
288
|
-
* As each byte is moved, the bit at `bits[round]` is preserved in its original position. This ensures that the
|
|
289
|
-
* process is reversible.
|
|
290
|
-
*
|
|
291
|
-
* @param bytes
|
|
292
|
-
* Byte array.
|
|
293
|
-
*
|
|
294
|
-
* @param round
|
|
295
|
-
* Round number.
|
|
296
|
-
*
|
|
297
|
-
* @param forward
|
|
298
|
-
* True if operating forward (encrypting), false if operating in reverse (decrypting).
|
|
299
|
-
*
|
|
300
|
-
* @returns
|
|
301
|
-
* Shuffled byte array.
|
|
302
|
-
*/
|
|
303
|
-
private shuffle;
|
|
304
|
-
/**
|
|
305
|
-
* Xor a byte array.
|
|
306
|
-
*
|
|
307
|
-
* The input array to the forward operation (output from the reverse operation) is `bytes` and the output array from
|
|
308
|
-
* the forward operation (input to the reverse operation) is `bytes'`.
|
|
309
|
-
*
|
|
310
|
-
* Forward:
|
|
311
|
-
* - `bytes'[0] = bytes[0] ^ xorBytes[round]`
|
|
312
|
-
* - `bytes'[1] = bytes[1] ^ bytes'[0]`
|
|
313
|
-
* - `bytes'[2] = bytes[2] ^ bytes'[1]`
|
|
314
|
-
* - `...`
|
|
315
|
-
* - `bytes'[domainBytes - 1] = bytes[domainBytes - 1] ^ bytes'[domainBytes - 2]`
|
|
316
|
-
*
|
|
317
|
-
* Reverse:
|
|
318
|
-
* - `bytes[0] = bytes'[0] ^ xorBytes[round]`
|
|
319
|
-
* - `bytes[1] = bytes'[1] ^ bytes'[0]`
|
|
320
|
-
* - `bytes[2] = bytes'[2] ^ bytes'[1]`
|
|
321
|
-
* - `...`
|
|
322
|
-
* - `bytes[domainBytes - 1] = bytes'[domainBytes - 1] ^ bytes'[domainBytes - 2]`
|
|
323
|
-
*
|
|
324
|
-
* @param bytes
|
|
325
|
-
* Byte array.
|
|
326
|
-
*
|
|
327
|
-
* @param round
|
|
328
|
-
* Round number.
|
|
329
|
-
*
|
|
330
|
-
* @param forward
|
|
331
|
-
* True if operating forward (encrypting), false if operating in reverse (decrypting).
|
|
332
|
-
*
|
|
333
|
-
* @returns
|
|
334
|
-
* Xored byte array.
|
|
335
|
-
*/
|
|
336
|
-
private xor;
|
|
337
|
-
/**
|
|
338
|
-
* @inheritDoc
|
|
339
|
-
*/
|
|
340
|
-
protected doForward(value: bigint): bigint;
|
|
341
|
-
/**
|
|
342
|
-
* @inheritDoc
|
|
343
|
-
*/
|
|
344
|
-
protected doReverse(transformedValue: bigint): bigint;
|
|
345
|
-
}
|
|
346
|
-
//# sourceMappingURL=transformer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAe,MAAM,uBAAuB,CAAC;AAI1E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,oBAAoB,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE9F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,oBAAoB,CAAC,EAAE,OAAO,IAAI,iBAAiB,SAAS,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AAE/O;;;;;;;;;;;;;;;;GAgBG;AACH,8BAAsB,WAAW;IAC7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAA2D;IAEvG;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;;OA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