// Based on src/signers/Sodot.ts
export class SodotSigner implements BaseSigner {
public chainId: string;
public signerSpec: AdamikSignerSpec;
public signerName = "SODOT";
private SODOT_VERTICES = [
"https://sodot-vertex-1.example.com",
"https://sodot-vertex-2.example.com",
"https://sodot-vertex-3.example.com",
];
private n = 3; // Number of parties
private t = 2; // Threshold (minimum parties needed)
private keyIds: string[] = [];
constructor(chainId: string, signerSpec: AdamikSignerSpec) {
this.chainId = chainId;
this.signerSpec = signerSpec;
}
// Check if Sodot configuration is valid
static isConfigValid(): boolean {
// Verify environment variables and configuration
return true; // Simplified for this example
}
// Get or generate public key
public async getPubkey(): Promise<string> {
// If keys don't exist, generate them
if (this.keyIds.length === 0) {
await this.keygenVertex(
this.adamikCurveToSodotCurve(this.signerSpec.curve)
);
}
// Derive public key using the first vertex
const pubkeyResponse = await this.derivePubkeyWithVertex(
0,
this.keyIds[0],
[44, Number(this.signerSpec.coinType), 0, 0, 0],
this.adamikCurveToSodotCurve(this.signerSpec.curve)
);
return pubkeyResponse.pubkey;
}
// Sign a transaction
public async signTransaction(encodedMessage: string): Promise<string> {
// Determine hash method based on chain
const hashMethod = this.adamikHashFunctionToSodotHashMethod(
this.signerSpec.hashFunction,
this.signerSpec.curve
);
// Sign the transaction
const signature = await this.sign(
encodedMessage,
this.keyIds,
[44, Number(this.signerSpec.coinType), 0, 0, 0],
this.signerSpec.curve,
hashMethod
);
return signature;
}
// Helper methods (simplified)
private adamikCurveToSodotCurve(
adamikCurve: AdamikCurve
): "ecdsa" | "ed25519" {
return adamikCurve === AdamikCurve.SECP256K1 ? "ecdsa" : "ed25519";
}
private adamikHashFunctionToSodotHashMethod(
hashAlgo: AdamikHashFunction,
curve: AdamikCurve
): "sha256" | "keccak256" | undefined {
// Map Adamik hash functions to Sodot hash methods
if (hashAlgo === AdamikHashFunction.SHA256) return "sha256";
if (hashAlgo === AdamikHashFunction.KECCAK256) return "keccak256";
return undefined;
}
// Additional methods for key generation, signing, etc.
// See the full implementation in the GitHub repository
}