@@ -29,6 +29,24 @@ export {
2929 CallForest ,
3030} ;
3131
32+ /**
33+ * Signs a zkApp command JSON object with the provided private key.
34+ *
35+ * This function applies a Schnorr signature to the fee payer and any account
36+ * updates within the command that require signatures and are owned by the same
37+ * public key.
38+ *
39+ * If this method is not called as the fee payer (i.e. the private key provided
40+ * does not match the fee payer's public key), the fee payer authorization will
41+ * remain unsigned after this method returns. This behavior allows for collaborative
42+ * construction of zkApp commands where two different users sign the account update
43+ * and pay the fee.
44+ *
45+ * @param zkappCommand_ - The zkApp command in JSON format, before signatures.
46+ * @param privateKeyBase58 - The Base58-encoded private key used for signing.
47+ * @param networkId - The network identifier that determines the signature domain.
48+ * @returns The signed zkApp command in JSON format.
49+ */
3250function signZkappCommand (
3351 zkappCommand_ : Json . ZkappCommand ,
3452 privateKeyBase58 : string ,
@@ -42,7 +60,7 @@ function signZkappCommand(
4260
4361 let signature = signFieldElement ( fullCommitment , privateKey , networkId ) ;
4462
45- // sign fee payer
63+ // sign fee payer whenever the public key matches
4664 if ( PublicKey . equal ( zkappCommand . feePayer . body . publicKey , publicKey ) ) {
4765 zkappCommand . feePayer . authorization = Signature . toBase58 ( signature ) ;
4866 }
0 commit comments