-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Target System: Miden Multisig (PSM Architecture)
Goal: Enable users to sign Miden multisig proposals using standard ECDSA wallets (e.g., Para, Privy, MetaMask) instead of being restricted to Miden-native Falcon keys.
Overview
The Private State Manager (PSM) natively supports (or soon to be supported, @MCarlomagno can confirm this) both Falcon512 (Post-Quantum Secure) and ECDSA (secp256k1) tailored for Ethereum compatibility. To allow users to use Para (an embedded wallet provider) or similar ECDSA-based signers, we need to implement an adapter layer in the frontend SDK that bridges these external providers to the PSM's signing interface.
Core Components
1. Frontend SDK: ExternalSignerAdapter
We will introduce an interface in miden-multisig-web-client that abstracts the underlying signer.
// Interface for any signer (Internal Falcon or External ECDSA)
interface MidenSigner {
getPublicKey(): Promise<string>; // Hex-encoded public key
getScheme(): 'falcon' | 'ecdsa';
signHash(hash: string): Promise<string>; // Returns hex-encoded signature
}An adapter for Para/Ethers would look like this:
class EcdsaExternalAdapter implements MidenSigner {
private provider: EIP1193Provider;
private address: string;
constructor(provider: EIP1193Provider, address: string) {
this.provider = provider;
this.address = address;
}
async getPublicKey(): Promise<string> {
// For ECDSA, we need the full public key, not just the address.
// We might need a signature to recover it if the provider doesn't expose it directly.
return recoverPublicKeyFromSignature(await this.signHash("0x...dummy..."));
}
getScheme(): 'falcon' | 'ecdsa' {
return 'ecdsa';
}
async signHash(hash: string): Promise<string> {
// Miden expects raw r,s (and potentially v) in a specific serialization
// EIP-191 signing might limit what we can sign directly.
// We need to ensure the hash is signed as raw bytes or map it to EIPC-712.
const signature = await this.provider.request({
method: 'personal_sign',
params: [hash, this.address],
});
return serializeMidenEcdsa(signature);
}
}2. PSM Backend Configuration
The PSM's state_manager.proto already defines MidenEcdsaAuth.
message AuthConfig {
oneof auth_type {
MidenFalconRpoAuth miden_falcon_rpo = 1;
MidenEcdsaAuth miden_ecdsa = 2; // WE USE THIS FOR PARA
}
}
message MidenEcdsaAuth {
repeated string cosigner_commitments = 1;
}3. Workflow: Registration with Para
- User Login: User logs in with Para (email/social).
- Key Extraction:
- The frontend requests a signature on a standard message to recover the user's full secp256k1 public key.
- Para/Metamask usually exposes the address, but Miden needs the public key to verify authentication within the VM.
- Account Creation:
- The
MidenEcdsaAuthconfig is created using this public key. - The account is registered with the PSM.
- The
4. Workflow: Signing a Proposal
- Proposal: A transaction is proposed. The SDK calculates the
TransactionSummaryhash (e.g.,0x123abc...). - Signing:
- The SDK prompts the Para wallet to sign this hash.
- Challenge: Standard EVM wallets prefix messages (
\x19Ethereum Signed Message:\n...). - Solution: The Miden VM (or the specific account implementation) must support verifying signatures with this prefix, OR we use
eth_sign(dangerous/deprecated), OR we use EIP-712. - Preferred Approach: Use EIP-712 Typed Data signing.
- Domain:
Miden Multisig - Message:
{ proposalHash: "0x..." } - The Miden account code must be able to hash this struct similarly to verify.
- Domain:
- Alternative (Simpler): If the Miden ECDSA kernel only verifies raw secp256k1 signatures on the hash, we must ensure the signer output matches.
- Submission:
- The signature is sent to the PSM via
SignDeltaProposal. - The PSM checks
MidenNetworkClient::validate_credential->MidenAccountInspector.
- The signature is sent to the PSM via
Implementation Checklist
- Frontend:
- Add
ethersdependency for ECDSA utilities. - Create
ParaSignerAdapterimplementing theSignerinterface. - Implement public key recovery from a signature
- Add
- PSM Updates (Verification):
- Verify if
MidenNetworkClientcorrectly handles the specific serialization of signatures produced bypersonal_signor EIP-712. - If Miden's
stdlibECDSA verification expects a raw 64-byte signature(r, s), butpersonal_signproduces 65-byte(r, s, v), we need to slice it in the adapter.
- Verify if