AIDC Toolkit / Utility / EncryptionTransformer
Class: EncryptionTransformer
Defined in: transformer.ts:323
Encryption transformer. Values are transformed using repeated shuffle and xor operations, similar to those found in many cryptography algorithms, particularly AES. While sufficient for obfuscation of numeric sequences (e.g., serial number generation, below), if true format-preserving encryption is required, a more robust algorithm such as FF1 is recommended. Furthermore, no work has been done to mitigate timing attacks for key detection.
The purpose of the encryption transformer is to generate pseudo-random values in a deterministic manner to obscure the sequence of values generated over time. A typical example is for serial number generation, where knowledge of the sequence can infer production volumes (e.g., serial number 1000 implies that at least 1,000 units have been manufactured) or can be used in counterfeiting (e.g., a counterfeiter can generate serial numbers 1001, 1002, ... with reasonable confidence that they would be valid if queried).
The domain and the tweak together determine the encryption key, which in turn determines the number of rounds of shuffle and xor operations. The minimum number of rounds is 4, except where the domain is less than or equal to 256, which results in single-byte operations. To ensure that the operations are effective for single-byte domains, the number of rounds is 1 and only the xor operation is applied (shuffling a single byte is an identity operation).
Another exception is when there is a tweak value of 0; this results in identity operations where the output value is identical to the input value, as no shuffle or xor takes place.
Extends
Constructors
Constructor
new EncryptionTransformer(
domain,tweak):EncryptionTransformer
Defined in: transformer.ts:377
Constructor.
Parameters
domain
Domain.
number | bigint
tweak
Tweak.
number | bigint
Returns
EncryptionTransformer
Overrides
Accessors
domain
Get Signature
get domain():
bigint
Defined in: transformer.ts:90
Get the domain.
Returns
bigint
Inherited from
Methods
get()
staticget(domain,tweak?):Transformer
Defined in: transformer.ts:65
Get a transformer, constructing it if necessary. The type returned is IdentityTransformer if tweak is undefined, EncryptionTransformer if tweak is defined. Note that although an EncryptionTransformer with a zero tweak operates as an IdentityTransformer, EncryptionTransformer is still the type returned if a zero tweak is explicitly specified.
Parameters
domain
Domain.
number | bigint
tweak?
Tweak.
number | bigint
Returns
Transformer.
Inherited from
doForward()
protecteddoForward(value):bigint
Defined in: transformer.ts:579
Do the work of transforming a value forward.
Parameters
value
bigint
Value.
Returns
bigint
Transformed value.
Overrides
doReverse()
protecteddoReverse(transformedValue):bigint
Defined in: transformer.ts:599
Do the work of transforming a value in reverse.
Parameters
transformedValue
bigint
Transformed value.
Returns
bigint
Value.
Overrides
forward()
Call Signature
forward(
value):bigint
Defined in: transformer.ts:171
Transform a value forward.
Parameters
value
Value.
number | bigint
Returns
bigint
Transformed value.
Inherited from
Call Signature
forward<
TOutput>(value,transformerCallback):TOutput
Defined in: transformer.ts:188
Transform a value forward and apply another transformation.
Type Parameters
TOutput
TOutput
Transformer callback output type.
Parameters
value
Value.
number | bigint
transformerCallback
IndexedCallback<bigint, TOutput>
Called with interim transformed value to transform it to its final value.
Returns
TOutput
Transformed value.
Inherited from
Call Signature
forward(
values):Iterable<bigint>
Defined in: transformer.ts:200
Transform values forward.
Parameters
values
Iterable<number | bigint>
Values. If this is an instance of Sequence, the minimum and maximum values are validated prior to transformation. Otherwise, the individual values are validated at the time of each transformation.
Returns
Iterable<bigint>
Transformed values.
Inherited from
Call Signature
forward<
TOutput>(values,transformerCallback):Iterable<TOutput>
Defined in: transformer.ts:218
Transform values forward and apply another transformation to each.
Type Parameters
TOutput
TOutput
Transformer callback output type.
Parameters
values
Iterable<number | bigint>
Values. If this is an instance of Sequence, the minimum and maximum values are validated prior to transformation. Otherwise, the individual values are validated at the time of each transformation.
transformerCallback
IndexedCallback<bigint, TOutput>
Called with each interim transformed value to transform it to its final value.
Returns
Iterable<TOutput>
Transformed values.
Inherited from
Call Signature
forward<
TInput>(valueOrValues):TInputextendsIterable<number|bigint,any,any> ?Iterable<bigint,any,any> :bigint
Defined in: transformer.ts:221
Transform a value forward.
Type Parameters
TInput
TInput extends number | bigint | Iterable<number | bigint, any, any>
Parameters
valueOrValues
TInput extends Iterable<number | bigint, any, any> ? TInput<TInput> : number | bigint
Returns
TInput extends Iterable<number | bigint, any, any> ? Iterable<bigint, any, any> : bigint
Transformed value.
Inherited from
Call Signature
forward<
TInput,TOutput>(valueOrValues,transformerCallback):TInputextendsIterable<number|bigint,any,any> ?Iterable<TOutput,any,any> :TOutput
Defined in: transformer.ts:224
Transform a value forward.
Type Parameters
TInput
TInput extends number | bigint | Iterable<number | bigint, any, any>
TOutput
TOutput
Parameters
valueOrValues
TInput extends Iterable<number | bigint, any, any> ? TInput<TInput> : number | bigint
transformerCallback
IndexedCallback<bigint, TOutput>
Returns
TInput extends Iterable<number | bigint, any, any> ? Iterable<TOutput, any, any> : TOutput
Transformed value.
Inherited from
reverse()
reverse(
transformedValue):bigint
Defined in: transformer.ts:274
Transform a value in reverse.
Parameters
transformedValue
Transformed value.
number | bigint
Returns
bigint
Value.