Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions yarn-project/node-keystore/examples/everything.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,17 @@
"mnemonic": "test test test test test test test test test test test junk",
"addressCount": 1
},
[
"0x5555555555555555555555555555555555555555555555555555555555555555",
"0x6666666666666666666666666666666666666666",
{
"address": "0x7777777777777777777777777777777777777777",
"remoteSignerUrl": "https://localhost:9300",
"certPath": "/path/to/prover-cert.pem"
},
{
"path": "/tmp/prover-publishers",
"password": "prover-pass"
}
]
"0x5555555555555555555555555555555555555555555555555555555555555555",
"0x6666666666666666666666666666666666666666",
{
"address": "0x7777777777777777777777777777777777777777",
"remoteSignerUrl": "https://localhost:9300",
"certPath": "/path/to/prover-cert.pem"
},
{
"path": "/tmp/prover-publishers",
"password": "prover-pass"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"schemaVersion": 1,
"prover": {
"id": "0x1234567890123456789012345678901234567890",
"publisher": "0x1234567890123456789012345678901234567890123456789012345678901234"
}
}
15 changes: 3 additions & 12 deletions yarn-project/node-keystore/src/keystore_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,10 @@ export class KeystoreManager {
};
}

// Handle complex prover case with id and publishers
const proverConfig = this.keystore.prover;
const signers: EthSigner[] = [];

for (const publisherAccounts of proverConfig.publisher) {
const publisherSigners = this.createSignersFromEthAccounts(publisherAccounts, this.keystore.remoteSigner);
signers.push(...publisherSigners);
}
const id = EthAddress.fromString(this.keystore.prover.id);
const signers = this.createSignersFromEthAccounts(this.keystore.prover.publisher, this.keystore.remoteSigner);

return {
id: EthAddress.fromString(proverConfig.id),
signers,
};
return { id, signers };
}

/**
Expand Down
11 changes: 11 additions & 0 deletions yarn-project/node-keystore/src/schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe('Keystore Schema Validation', () => {
expect((parsed.prover as any).publisher).toHaveLength(2);
});

it('should validate prover with single publisher example', () => {
const keystore = loadExample('prover-with-single-publisher.json');
expect(() => keystoreSchema.parse(keystore)).not.toThrow();

const parsed = keystoreSchema.parse(keystore);
expect(parsed.schemaVersion).toBe(1);
expect(typeof parsed.prover).toBe('object');
expect((parsed.prover as any).id).toBe('0x1234567890123456789012345678901234567890');
expect((parsed.prover as any).publisher).toBe('0x1234567890123456789012345678901234567890123456789012345678901234');
});

it('should reject keystore with invalid schema version', () => {
const keystore = {
schemaVersion: 2, // Invalid
Expand Down
11 changes: 8 additions & 3 deletions yarn-project/node-keystore/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,22 @@ const mnemonicConfigSchema = z.object({
});

// EthAccount schema
const ethAccountSchema = z.union([ethPrivateKeySchema, remoteSignerAccountSchema, jsonKeyFileV3Schema]);
const ethAccountSchema = z.union([
ethPrivateKeySchema,
remoteSignerAccountSchema,
jsonKeyFileV3Schema,
mnemonicConfigSchema,
]);

// EthAccounts schema
const ethAccountsSchema = z.union([ethAccountSchema, z.array(ethAccountSchema), mnemonicConfigSchema]);
const ethAccountsSchema = z.union([ethAccountSchema, z.array(ethAccountSchema)]);

// Prover keystore schema
const proverKeyStoreSchema = z.union([
ethAccountSchema,
z.object({
id: ethAddressSchema,
publisher: z.array(ethAccountsSchema),
publisher: ethAccountsSchema,
}),
]);

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/node-keystore/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type ProverKeyStore =
/** Address that identifies the prover. This address will receive the rewards. */
id: EthAddressHex;
/** One or more EOAs used for sending proof L1 txs. */
publisher: EthAccounts[];
publisher: EthAccounts;
}
| EthAccount;

Expand Down
Loading