You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// See ts/deploy-account-contract.ts for full example
119
-
```
114
+
## Security Considerations
120
115
121
-
### 2. Create Transactions
116
+
- The password is hashed using Poseidon2 before storage
117
+
- Password is required for every transaction (no caching)
118
+
- Password is included in transaction data (encrypted in private state)
119
+
- This is a demonstration contract - production use should consider additional security measures
120
+
- Consider using signature-based accounts for most production use cases
122
121
123
-
The account contract authenticates transactions by verifying the password hash:
122
+
## Important Considerations
124
123
125
-
```typescript
126
-
// Transactions automatically include the password in the entrypoint call
127
-
// The password is hashed with Poseidon2 and compared to stored hash
128
-
```
124
+
When implementing custom account contracts in Aztec, be aware of these critical points:
129
125
130
-
### 3. Authorization Witnesses
126
+
### All Execution Starts in Private
131
127
132
-
For cross-contract calls requiring authorization:
128
+
**This is the most important gotcha**: In Aztec, all transaction execution begins in the private context, even if your contract only has public functions. The account contract's `entrypoint` function always executes in private first.
133
129
134
-
```typescript
135
-
// The account can authorize actions for other contracts
136
-
// Password is used to verify the authorization
137
-
```
130
+
- Your `entrypoint` function must be a `private` or `unconstrained private` function
131
+
- Even when calling public functions on other contracts, the call originates from private execution
132
+
- Authentication logic in the entrypoint runs in the private context
133
+
- If you need to validate anything on-chain, you must enqueue public calls and handle them accordingly
138
134
139
-
##Fee Payment Methods
135
+
### Password/Secret Storage
140
136
141
-
The contract supports three fee payment options:
137
+
-**Never store passwords in plain text**: Always hash sensitive data before storage (like we do with Poseidon2)
138
+
- The `hashed_password` is stored in `PublicImmutable` storage, meaning it's visible on-chain but cannot be changed
139
+
- Consider whether your authentication secret should be changeable (would require mutable storage)
142
140
143
-
1.**EXTERNAL (0)**: Another contract pays the fee
144
-
2.**PREEXISTING_FEE_JUICE (1)**: Account pays with existing FeeJuice balance
145
-
3.**FEE_JUICE_WITH_CLAIM (2)**: Account pays with FeeJuice claimed in same transaction
141
+
### Entrypoint Function Signature
146
142
147
-
## Security Considerations
143
+
- The entrypoint must match the expected signature for account contracts
144
+
- It receives the payload (functions to call) and fee payment options
148
145
149
-
- The password is hashed using Poseidon2 before storage
150
-
- Password is required for every transaction (no caching)
151
-
- Password is included in transaction data (encrypted in private state)
152
-
- This is a demonstration contract - production use should consider additional security measures
153
-
- Consider using signature-based accounts for most production use cases
146
+
### State Management
147
+
148
+
- Private state is encrypted and only visible to those with the viewing key
0 commit comments