Skip to main content

signWithUserShare(hashedMessages_b64: string[], signatureScheme: string): Promise<SignWithUserShareResponse>

This method allows the AeonSigner to use its locally managed key share (the user’s secret cryptographic material) to participate in Ika’s distributed signature generation for one or more pre-hashed messages.

Parameters

  • hashedMessages_b64: string[] - An array of Base64 encoded strings, where each string is a pre-hashed message digest to be signed as part of the MPC protocol. The hashing algorithm used to produce these digests is defined by the signatureScheme.
  • signatureScheme: string - An identifier for the specific MPC signature scheme (e.g., “ECDSA”,“EDDSA”). This informs the SDK how to process the local key share and interact with the MPC protocol.

Returns

  • Promise<SignWithUserShareResponse>: A promise that resolves with the user’s signature contribution and a message.
    • SignWithUserShareResponse:
      • signature_b64: string - The Base64 encoded string of the resulting cryptographic signature component (e.g., a partial signature in a threshold scheme, or the complete signature if this AeonSigner is the final party or the scheme is non-threshold for this user). This output is typically then sent to the MPC coordination service (“ika”) or other participants.
      • message: string - A descriptive message about the outcome of the signing operation (e.g., “Partial signature generated successfully”, “MPC round N completed”).

Example

import { AeonSigner } from "@aeon-protocol/aeon-sdk";
// Assuming AeonSigner is initialized correctly as `signer`
// Assuming `hashedMessagesFromPreparePhase` are obtained from a prior MPC setup step

interface SignWithUserShareResponse {
  signature_b64: string;
  message: string;
}

async function contributeToMpcSigning(
  signer: AeonSigner,
  hashedMessagesFromPreparePhase: string[],
  mpcScheme: string
) {
  try {
    console.log(`Contributing to MPC signing for scheme: ${mpcScheme}...`);

    const response: SignWithUserShareResponse = await signer.signWithUserShare(
      hashedMessagesFromPreparePhase,
      mpcScheme
    );

    console.log("MPC signing share generated successfully!");
    console.log(`  Signature Share (Base64): ${response.signature_b64}`);
    console.log(`  Message: ${response.message}`);

    // The response.signature_b64 would now be communicated to the MPC
    // coordination service ("ika") or other protocol participants.
  } catch (error) {
    console.error(
      "Failed to contribute to MPC signing with user share:",
      error
    );
    // Handle errors related to invalid parameters, MPC protocol issues, or local key share problems
  }
}