create static method
Future<TestEnvelopeSigner>
create({
- required String atSign,
- required String enrollmentId,
- SigningAlgoType algorithm = SigningAlgoType.mldsa65,
- KeyEntryStatus listedAs = KeyEntryStatus.active,
A signer with a fresh key pair under algorithm, which
publishedApsk lists as listedAs: active, retired, or any token, such
as one this build does not know.
Throws ArgumentError for an algorithm envelopes are not signed
under.
Implementation
static Future<TestEnvelopeSigner> create({
required String atSign,
required String enrollmentId,
SigningAlgoType algorithm = SigningAlgoType.mldsa65,
KeyEntryStatus listedAs = KeyEntryStatus.active,
}) async {
final ApkamSigningKeys key;
switch (algorithm) {
case SigningAlgoType.mldsa65:
final pair = await MlDsa65PureDartAlgo().generateKeyPair();
key = ApkamSigningKeys(
algorithm: algorithm,
publicKey: base64Encode(pair.publicKey),
privateKey: base64Encode(pair.secretKey));
case SigningAlgoType.rsa2048:
final pair = RsaKeyPair.generate();
key = ApkamSigningKeys(
algorithm: algorithm,
publicKey: pair.atPublicKey.publicKey,
privateKey: pair.atPrivateKey.privateKey);
default:
throw ArgumentError.value(
algorithm, 'algorithm', 'envelopes are not signed under it');
}
return TestEnvelopeSigner._(atSign.toAtsign(), enrollmentId, key, listedAs);
}