setBbsBlsProofMC method
Generates a BbsBls signature proof using the BbsFlutter library for selective message disclosure.
Similar to setBbsBlsProofFFI, this function creates cryptographic proofs using a BBS+ signature
and public key. Messages specified in the revealIndex list are publicly revealed in the proof,
while others remain hidden. A random nonce is generated to ensure uniqueness.
Implementation
Future<Proof> setBbsBlsProofMC(
List<Uint8List> messages,
Uint8List publicKey,
String bbsSignature,
List<int> revealIndex,
String id,
) async {
GeneratorUtils generatorUtil = GeneratorUtils();
final nonce = generatorUtil.generateRandomNonce(32);
final revealIndexSet = revealIndex.toSet();
// Decode bbsSignature (skipping first char, as in Java)
final decodedBbsSignature =
base64Url.decode(encryption.formatDecode(bbsSignature.substring(1)));
String proofValue;
try {
proofValue = await createSelectiveDisclosureProofBlsMC(
publicKey,
nonce,
decodedBbsSignature,
messages,
revealIndexSet,
);
} catch (e) {
throw Exception("Proof generation error: $e");
}
// ISO8601 UTC time
final created = DateTime.now().toUtc().toIso8601String();
final proof = Proof()
..type = "BbsBlsSignatureProof2020"
..created = created
..verificationMethod = id
..proofPurpose = "assertionMethod"
..nonce = "u${base64UrlEncode(nonce)}"
..proofValue = proofValue;
return proof;
}