@@ -9,13 +9,50 @@ import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from '../../utils/defaults.js';
9
9
import { buildPayload , hashPayload } from './entrypoint_payload.js' ;
10
10
import { Entrypoint } from './index.js' ;
11
11
12
+ /**
13
+ * An extended interface for entrypoints that support signing and adding auth witnesses.
14
+ */
15
+ export interface IAuthWitnessAccountEntrypoint extends Entrypoint {
16
+ /**
17
+ * Sign a message hash with the private key.
18
+ * @param message - The message hash to sign.
19
+ * @returns The signature as a Buffer.
20
+ */
21
+ sign ( message : Buffer ) : Buffer ;
22
+
23
+ /**
24
+ * Creates an AuthWitness witness for the given message. In this case, witness is the public key, the signature
25
+ * and the partial address, to be used for verification.
26
+ * @param message - The message hash to sign.
27
+ * @param opts - Options.
28
+ * @returns [publicKey, signature, partialAddress] as Fr[].
29
+ */
30
+ createAuthWitness ( message : Buffer ) : Promise < Fr [ ] > ;
31
+
32
+ /**
33
+ * Returns the transaction request and the auth witness for the given function calls.
34
+ * Returning the witness here as a nonce is generated in the buildPayload action.
35
+ * @param executions - The function calls to execute
36
+ * @param opts - The options
37
+ * @returns The TxRequest, the auth witness to insert in db and the message signed
38
+ */
39
+ createTxExecutionRequestWithWitness ( executions : FunctionCall [ ] ) : Promise < {
40
+ /** The transaction request */
41
+ txRequest : TxExecutionRequest ;
42
+ /** The auth witness */
43
+ witness : Fr [ ] ;
44
+ /** The message signed */
45
+ message : Buffer ;
46
+ } > ;
47
+ }
48
+
12
49
/**
13
50
* Account contract implementation that uses a single key for signing and encryption. This public key is not
14
51
* stored in the contract, but rather verified against the contract address. Note that this approach is not
15
52
* secure and should not be used in real use cases.
16
53
* The entrypoint is extended to support signing and creating eip1271-like witnesses.
17
54
*/
18
- export class AuthWitnessAccountEntrypoint implements Entrypoint {
55
+ export class AuthWitnessAccountEntrypoint implements IAuthWitnessAccountEntrypoint {
19
56
constructor (
20
57
private address : AztecAddress ,
21
58
private partialAddress : PartialAddress ,
@@ -25,21 +62,10 @@ export class AuthWitnessAccountEntrypoint implements Entrypoint {
25
62
private version : number = DEFAULT_VERSION ,
26
63
) { }
27
64
28
- /**
29
- * Sign a message hash with the private key.
30
- * @param message - The message hash to sign.
31
- * @returns The signature as a Buffer.
32
- */
33
65
public sign ( message : Buffer ) : Buffer {
34
66
return this . signer . constructSignature ( message , this . privateKey ) . toBuffer ( ) ;
35
67
}
36
68
37
- /**
38
- * Creates an AuthWitness witness for the given message. In this case, witness is the public key, the signature
39
- * and the partial address, to be used for verification.
40
- * @param message - The message hash to sign.
41
- * @returns [publicKey, signature, partialAddress] as Fr[].
42
- */
43
69
async createAuthWitness ( message : Buffer ) : Promise < Fr [ ] > {
44
70
const signature = this . sign ( message ) ;
45
71
const publicKey = await generatePublicKey ( this . privateKey ) ;
0 commit comments