createSelectiveDisclosureProofBlsMC method

Future<String> createSelectiveDisclosureProofBlsMC(
  1. Uint8List publicKey,
  2. Uint8List nonce,
  3. Uint8List signature,
  4. List<Uint8List> messages,
  5. Set<int> revealedIndices,
)

Creates a selective disclosure proof using a BLS public key, nonce, signature, and a set of messages.

This function enables selective disclosure by allowing specific messages to be "revealed" in the proof while keeping the rest "hidden." It prepares messages as ProofMessage objects marked as revealed or hidden, generates the proof using BbsFlutter.blsCreateProof, and returns a Base64 URL-encoded proof string.

Implementation

Future<String> createSelectiveDisclosureProofBlsMC(
  Uint8List publicKey,
  Uint8List nonce,
  Uint8List signature,
  List<Uint8List> messages,
  Set<int> revealedIndices,
) {
  final proofMessages = <ProofMessage>[];

  for (int i = 0; i < messages.length; i++) {
    final type = revealedIndices.contains(i)
        ? ProofMessageType.Revealed
        : ProofMessageType.HiddenProofSpecificBlinding;

    proofMessages.add(ProofMessage(
      type,
      messages[i],
      Uint8List(0), // empty blinding factor
    ));
  }

  return Future.sync(() async {
    final proof = await BbsFlutter.blsCreateProof(
      publicKey: publicKey,
      nonce: nonce,
      signature: signature,
      messages: proofMessages,
    );

    final encoded = base64Url.encode(proof).replaceAll('=', '');
    return 'u$encoded'; // prepend "u"
  });
}