Strobe constructor
Strobe(
- String customizationString,
- StrobeSecParam security
Create a new instance of the Strobe protocol with the specified parameters.
This factory constructor is used to initialize a Strobe instance with the given customizationString
and security
level. It performs the necessary setup and configuration for the Strobe protocol with the specified security level.
Parameters:
customizationString
: A string used to customize the Strobe instance.security
: The desired security level, which can be either 128 or 256 bits.
Returns:
A new Strobe instance configured with the provided customizationString
and security
level.
Throws:
ArgumentException
if thesecurity
level is not 128 or 256 bits, indicating an invalid security level.
Example Usage:
Strobe strobeInstance = Strobe("MyCustomizationString", 128);
This factory constructor ensures that the Strobe instance is properly initialized and configured based on the provided parameters, allowing it to be used for secure protocol operations.
Implementation
factory Strobe(String customizationString, StrobeSecParam security) {
final int rate = (1600 ~/ 8) - security.value ~/ 4;
Strobe s = Strobe._(
io: 2,
rate: rate,
strober: rate - 2,
posBegin: 0,
curFlags: 0,
storage: List<int>.filled(rate, 0),
buffer: List.empty(growable: true),
);
List<int> domain = [1, rate, 1, 0, 1, 12 * 8];
domain.addAll(version.codeUnits);
s._duplex(domain, false, false, true);
s._initialized = true;
s.operate(
true, StrobeOperation.ad, customizationString.codeUnits, 0, false);
return s;
}