Skip to content

Commit 9df7ae3

Browse files
authored
chore: Accumulated backports to v4-next (#22520)
Backport staging PR. Body will be updated with commit list.
2 parents cb6d99e + 6383b35 commit 9df7ae3

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

yarn-project/pxe/src/logs/log_service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export class LogService {
174174

175175
if (!secret) {
176176
// Note that all senders originate from either the SenderAddressBookStore or the KeyStore.
177-
// TODO(F-512): make sure we actually prevent registering invalid senders.
178177
throw new Error(
179178
`Failed to compute a tagging secret for sender ${sender} - this implies this is an invalid address, which should not happen as they have been previously registered in PXE.`,
180179
);

yarn-project/pxe/src/pxe.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ describe('PXE', () => {
9898
expect(accounts).toContainEqual(completeAddress);
9999
});
100100

101+
it('refuses to register an invalid address as a sender', async () => {
102+
// x = 3 is not a valid x-coordinate on the Grumpkin curve (y^2 = x^3 - 17 = 10 has no square root in Fr)
103+
const invalidAddress = new AztecAddress(new Fr(3));
104+
await expect(pxe.registerSender(invalidAddress)).rejects.toThrow(/not valid/);
105+
});
106+
101107
it('does not throw when registering the same account twice (just ignores the second attempt)', async () => {
102108
const randomSecretKey = Fr.random();
103109
const randomPartialAddress = Fr.random();

yarn-project/pxe/src/pxe.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,12 @@ export class PXE {
558558
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
559559
*/
560560
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
561+
if (!(await sender.isValid())) {
562+
throw new Error(
563+
`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
564+
);
565+
}
566+
561567
const accounts = await this.keyStore.getAccounts();
562568
if (accounts.includes(sender)) {
563569
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);

0 commit comments

Comments
 (0)