@aztec/key-store 0.34.0 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ import { type NewKeyStore, type PublicKey } from '@aztec/circuit-types';
2
+ import { AztecAddress, Fr, type GrumpkinPrivateKey, type PartialAddress } from '@aztec/circuits.js';
3
+ import { type Grumpkin } from '@aztec/circuits.js/barretenberg';
4
+ import { type AztecKVStore } from '@aztec/kv-store';
5
+ /**
6
+ * TestKeyStore is an implementation of the KeyStore interface, used for managing key pairs in a testing environment.
7
+ * It should be utilized in testing scenarios where secure key management is not required, and ease-of-use is prioritized.
8
+ */
9
+ export declare class NewTestKeyStore implements NewKeyStore {
10
+ #private;
11
+ private curve;
12
+ constructor(curve: Grumpkin, database: AztecKVStore);
13
+ /**
14
+ * Creates a new account from a randomly generated secret key.
15
+ * @returns A promise that resolves to the newly created account's AztecAddress.
16
+ */
17
+ createAccount(): Promise<AztecAddress>;
18
+ /**
19
+ * Adds an account to the key store from the provided secret key.
20
+ * @param sk - The secret key of the account.
21
+ * @param partialAddress - The partial address of the account.
22
+ * @returns The account's address.
23
+ */
24
+ addAccount(sk: Fr, partialAddress: PartialAddress): Promise<AztecAddress>;
25
+ /**
26
+ * Retrieves addresses of accounts stored in the key store.
27
+ * @returns A Promise that resolves to an array of account addresses.
28
+ */
29
+ getAccounts(): Promise<AztecAddress[]>;
30
+ /**
31
+ * Gets the master nullifier public key for a given account.
32
+ * @throws If the account does not exist in the key store.
33
+ * @param account - The account address for which to retrieve the master nullifier public key.
34
+ * @returns The master nullifier public key for the account.
35
+ */
36
+ getMasterNullifierPublicKey(account: AztecAddress): Promise<PublicKey>;
37
+ /**
38
+ * Gets the master incoming viewing public key for a given account.
39
+ * @throws If the account does not exist in the key store.
40
+ * @param account - The account address for which to retrieve the master incoming viewing public key.
41
+ * @returns The master incoming viewing public key for the account.
42
+ */
43
+ getMasterIncomingViewingPublicKey(account: AztecAddress): Promise<PublicKey>;
44
+ /**
45
+ * Retrieves the master outgoing viewing public key.
46
+ * @throws If the account does not exist in the key store.
47
+ * @param account - The account to retrieve the master outgoing viewing key for.
48
+ * @returns A Promise that resolves to the master outgoing viewing key.
49
+ */
50
+ getMasterOutgoingViewingPublicKey(account: AztecAddress): Promise<PublicKey>;
51
+ /**
52
+ * Retrieves the master tagging public key.
53
+ * @throws If the account does not exist in the key store.
54
+ * @param account - The account to retrieve the master tagging key for.
55
+ * @returns A Promise that resolves to the master tagging key.
56
+ */
57
+ getMasterTaggingPublicKey(account: AztecAddress): Promise<PublicKey>;
58
+ /**
59
+ * Retrieves application nullifier secret key.
60
+ * @throws If the account does not exist in the key store.
61
+ * @param account - The account to retrieve the application nullifier secret key for.
62
+ * @param app - The application address to retrieve the nullifier secret key for.
63
+ * @returns A Promise that resolves to the application nullifier secret key.
64
+ */
65
+ getAppNullifierSecretKey(account: AztecAddress, app: AztecAddress): Promise<Fr>;
66
+ /**
67
+ * Retrieves application incoming viewing secret key.
68
+ * @throws If the account does not exist in the key store.
69
+ * @param account - The account to retrieve the application incoming viewing secret key for.
70
+ * @param app - The application address to retrieve the incoming viewing secret key for.
71
+ * @returns A Promise that resolves to the application incoming viewing secret key.
72
+ */
73
+ getAppIncomingViewingSecretKey(account: AztecAddress, app: AztecAddress): Promise<Fr>;
74
+ /**
75
+ * Retrieves application outgoing viewing secret key.
76
+ * @throws If the account does not exist in the key store.
77
+ * @param account - The account to retrieve the application outgoing viewing secret key for.
78
+ * @param app - The application address to retrieve the outgoing viewing secret key for.
79
+ * @returns A Promise that resolves to the application outgoing viewing secret key.
80
+ */
81
+ getAppOutgoingViewingSecretKey(account: AztecAddress, app: AztecAddress): Promise<Fr>;
82
+ /**
83
+ * Retrieves the master nullifier secret key (nsk_m) corresponding to the specified master nullifier public key
84
+ * (Npk_m).
85
+ * @throws If the provided public key is not associated with any of the registered accounts.
86
+ * @param masterNullifierPublicKey - The master nullifier public key to get secret key for.
87
+ * @returns A Promise that resolves to the master nullifier secret key.
88
+ * @dev Used when feeding the master nullifier secret key to the kernel circuit for nullifier keys verification.
89
+ */
90
+ getMasterNullifierSecretKeyForPublicKey(masterNullifierPublicKey: PublicKey): Promise<GrumpkinPrivateKey>;
91
+ }
92
+ //# sourceMappingURL=new_test_key_store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new_test_key_store.d.ts","sourceRoot":"","sources":["../src/new_test_key_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EACL,YAAY,EACZ,EAAE,EAEF,KAAK,kBAAkB,EAEvB,KAAK,cAAc,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAEnE;;;GAGG;AACH,qBAAa,eAAgB,YAAW,WAAW;;IAGrC,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY;IAI3D;;;OAGG;IACI,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;IAM7C;;;;;OAKG;IACU,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IA4CtF;;;OAGG;IACI,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAO7C;;;;;OAKG;IACI,2BAA2B,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAQ7E;;;;;OAKG;IACI,iCAAiC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAQnF;;;;;OAKG;IACI,iCAAiC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAQnF;;;;;OAKG;IACI,yBAAyB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAQ3E;;;;;;OAMG;IACI,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IAYtF;;;;;;OAMG;IACI,8BAA8B,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IAiB5F;;;;;;OAMG;IACI,8BAA8B,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IAiB5F;;;;;;;OAOG;IACI,uCAAuC,CAAC,wBAAwB,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiBjH"}
@@ -0,0 +1,210 @@
1
+ var _NewTestKeyStore_keys;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { AztecAddress, Fr, GeneratorIndex, GrumpkinScalar, Point, } from '@aztec/circuits.js';
4
+ import { poseidon2Hash, sha512ToGrumpkinScalar } from '@aztec/foundation/crypto';
5
+ /**
6
+ * TestKeyStore is an implementation of the KeyStore interface, used for managing key pairs in a testing environment.
7
+ * It should be utilized in testing scenarios where secure key management is not required, and ease-of-use is prioritized.
8
+ */
9
+ export class NewTestKeyStore {
10
+ constructor(curve, database) {
11
+ this.curve = curve;
12
+ _NewTestKeyStore_keys.set(this, void 0);
13
+ __classPrivateFieldSet(this, _NewTestKeyStore_keys, database.openMap('key_store'), "f");
14
+ }
15
+ /**
16
+ * Creates a new account from a randomly generated secret key.
17
+ * @returns A promise that resolves to the newly created account's AztecAddress.
18
+ */
19
+ createAccount() {
20
+ const sk = Fr.random();
21
+ const partialAddress = Fr.random();
22
+ return this.addAccount(sk, partialAddress);
23
+ }
24
+ /**
25
+ * Adds an account to the key store from the provided secret key.
26
+ * @param sk - The secret key of the account.
27
+ * @param partialAddress - The partial address of the account.
28
+ * @returns The account's address.
29
+ */
30
+ async addAccount(sk, partialAddress) {
31
+ // First we derive master secret keys - we use sha512 here because this derivation will never take place
32
+ // in a circuit
33
+ const masterNullifierSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.NSK_M]);
34
+ const masterIncomingViewingSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.IVSK_M]);
35
+ const masterOutgoingViewingSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.OVSK_M]);
36
+ const masterTaggingSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.TSK_M]);
37
+ // Then we derive master public keys
38
+ const masterNullifierPublicKey = this.curve.mul(this.curve.generator(), masterNullifierSecretKey);
39
+ const masterIncomingViewingPublicKey = this.curve.mul(this.curve.generator(), masterIncomingViewingSecretKey);
40
+ const masterOutgoingViewingPublicKey = this.curve.mul(this.curve.generator(), masterOutgoingViewingSecretKey);
41
+ const masterTaggingPublicKey = this.curve.mul(this.curve.generator(), masterTaggingSecretKey);
42
+ // We hash the public keys to get the public keys hash
43
+ const publicKeysHash = poseidon2Hash([
44
+ masterNullifierPublicKey,
45
+ masterIncomingViewingPublicKey,
46
+ masterOutgoingViewingPublicKey,
47
+ masterTaggingPublicKey,
48
+ GeneratorIndex.PUBLIC_KEYS_HASH,
49
+ ]);
50
+ // We hash the partial address and the public keys hash to get the account address
51
+ // TODO(#5726): Should GeneratorIndex.CONTRACT_ADDRESS be removed given that we introduced CONTRACT_ADDRESS_V1?
52
+ // TODO(#5726): Move the following line to AztecAddress class?
53
+ const accountAddressFr = poseidon2Hash([partialAddress, publicKeysHash, GeneratorIndex.CONTRACT_ADDRESS_V1]);
54
+ const accountAddress = AztecAddress.fromField(accountAddressFr);
55
+ // We store all the public and secret keys in the database
56
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-nsk_m`, masterNullifierSecretKey.toBuffer());
57
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-ivsk_m`, masterIncomingViewingSecretKey.toBuffer());
58
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-ovsk_m`, masterOutgoingViewingSecretKey.toBuffer());
59
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-tsk_m`, masterTaggingSecretKey.toBuffer());
60
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-npk_m`, masterNullifierPublicKey.toBuffer());
61
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-ivpk_m`, masterIncomingViewingPublicKey.toBuffer());
62
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-ovpk_m`, masterOutgoingViewingPublicKey.toBuffer());
63
+ await __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").set(`${accountAddress.toString()}-tpk_m`, masterTaggingPublicKey.toBuffer());
64
+ // At last, we return the newly derived account address
65
+ return Promise.resolve(accountAddress);
66
+ }
67
+ /**
68
+ * Retrieves addresses of accounts stored in the key store.
69
+ * @returns A Promise that resolves to an array of account addresses.
70
+ */
71
+ getAccounts() {
72
+ const allMapKeys = Array.from(__classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").keys());
73
+ // We return account addresses based on the map keys that end with '-nsk_m'
74
+ const accounts = allMapKeys.filter(key => key.endsWith('-nsk_m')).map(key => key.split('-')[0]);
75
+ return Promise.resolve(accounts.map(account => AztecAddress.fromString(account)));
76
+ }
77
+ /**
78
+ * Gets the master nullifier public key for a given account.
79
+ * @throws If the account does not exist in the key store.
80
+ * @param account - The account address for which to retrieve the master nullifier public key.
81
+ * @returns The master nullifier public key for the account.
82
+ */
83
+ getMasterNullifierPublicKey(account) {
84
+ const masterNullifierPublicKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-npk_m`);
85
+ if (!masterNullifierPublicKeyBuffer) {
86
+ throw new Error(`Account ${account.toString()} does not exist.`);
87
+ }
88
+ return Promise.resolve(Point.fromBuffer(masterNullifierPublicKeyBuffer));
89
+ }
90
+ /**
91
+ * Gets the master incoming viewing public key for a given account.
92
+ * @throws If the account does not exist in the key store.
93
+ * @param account - The account address for which to retrieve the master incoming viewing public key.
94
+ * @returns The master incoming viewing public key for the account.
95
+ */
96
+ getMasterIncomingViewingPublicKey(account) {
97
+ const masterIncomingViewingPublicKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-ivpk_m`);
98
+ if (!masterIncomingViewingPublicKeyBuffer) {
99
+ throw new Error(`Account ${account.toString()} does not exist.`);
100
+ }
101
+ return Promise.resolve(Point.fromBuffer(masterIncomingViewingPublicKeyBuffer));
102
+ }
103
+ /**
104
+ * Retrieves the master outgoing viewing public key.
105
+ * @throws If the account does not exist in the key store.
106
+ * @param account - The account to retrieve the master outgoing viewing key for.
107
+ * @returns A Promise that resolves to the master outgoing viewing key.
108
+ */
109
+ getMasterOutgoingViewingPublicKey(account) {
110
+ const masterOutgoingViewingPublicKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-ovpk_m`);
111
+ if (!masterOutgoingViewingPublicKeyBuffer) {
112
+ throw new Error(`Account ${account.toString()} does not exist.`);
113
+ }
114
+ return Promise.resolve(Point.fromBuffer(masterOutgoingViewingPublicKeyBuffer));
115
+ }
116
+ /**
117
+ * Retrieves the master tagging public key.
118
+ * @throws If the account does not exist in the key store.
119
+ * @param account - The account to retrieve the master tagging key for.
120
+ * @returns A Promise that resolves to the master tagging key.
121
+ */
122
+ getMasterTaggingPublicKey(account) {
123
+ const masterTaggingPublicKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-tpk_m`);
124
+ if (!masterTaggingPublicKeyBuffer) {
125
+ throw new Error(`Account ${account.toString()} does not exist.`);
126
+ }
127
+ return Promise.resolve(Point.fromBuffer(masterTaggingPublicKeyBuffer));
128
+ }
129
+ /**
130
+ * Retrieves application nullifier secret key.
131
+ * @throws If the account does not exist in the key store.
132
+ * @param account - The account to retrieve the application nullifier secret key for.
133
+ * @param app - The application address to retrieve the nullifier secret key for.
134
+ * @returns A Promise that resolves to the application nullifier secret key.
135
+ */
136
+ getAppNullifierSecretKey(account, app) {
137
+ const masterNullifierSecretKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-nsk_m`);
138
+ if (!masterNullifierSecretKeyBuffer) {
139
+ throw new Error(`Account ${account.toString()} does not exist.`);
140
+ }
141
+ const masterNullifierSecretKey = GrumpkinScalar.fromBuffer(masterNullifierSecretKeyBuffer);
142
+ return Promise.resolve(poseidon2Hash([masterNullifierSecretKey.high, masterNullifierSecretKey.low, app, GeneratorIndex.NSK_M]));
143
+ }
144
+ /**
145
+ * Retrieves application incoming viewing secret key.
146
+ * @throws If the account does not exist in the key store.
147
+ * @param account - The account to retrieve the application incoming viewing secret key for.
148
+ * @param app - The application address to retrieve the incoming viewing secret key for.
149
+ * @returns A Promise that resolves to the application incoming viewing secret key.
150
+ */
151
+ getAppIncomingViewingSecretKey(account, app) {
152
+ const masterIncomingViewingSecretKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-ivsk_m`);
153
+ if (!masterIncomingViewingSecretKeyBuffer) {
154
+ throw new Error(`Account ${account.toString()} does not exist.`);
155
+ }
156
+ const masterIncomingViewingSecretKey = GrumpkinScalar.fromBuffer(masterIncomingViewingSecretKeyBuffer);
157
+ return Promise.resolve(poseidon2Hash([
158
+ masterIncomingViewingSecretKey.high,
159
+ masterIncomingViewingSecretKey.low,
160
+ app,
161
+ GeneratorIndex.IVSK_M,
162
+ ]));
163
+ }
164
+ /**
165
+ * Retrieves application outgoing viewing secret key.
166
+ * @throws If the account does not exist in the key store.
167
+ * @param account - The account to retrieve the application outgoing viewing secret key for.
168
+ * @param app - The application address to retrieve the outgoing viewing secret key for.
169
+ * @returns A Promise that resolves to the application outgoing viewing secret key.
170
+ */
171
+ getAppOutgoingViewingSecretKey(account, app) {
172
+ const masterOutgoingViewingSecretKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${account.toString()}-ovsk_m`);
173
+ if (!masterOutgoingViewingSecretKeyBuffer) {
174
+ throw new Error(`Account ${account.toString()} does not exist.`);
175
+ }
176
+ const masterOutgoingViewingSecretKey = GrumpkinScalar.fromBuffer(masterOutgoingViewingSecretKeyBuffer);
177
+ return Promise.resolve(poseidon2Hash([
178
+ masterOutgoingViewingSecretKey.high,
179
+ masterOutgoingViewingSecretKey.low,
180
+ app,
181
+ GeneratorIndex.OVSK_M,
182
+ ]));
183
+ }
184
+ /**
185
+ * Retrieves the master nullifier secret key (nsk_m) corresponding to the specified master nullifier public key
186
+ * (Npk_m).
187
+ * @throws If the provided public key is not associated with any of the registered accounts.
188
+ * @param masterNullifierPublicKey - The master nullifier public key to get secret key for.
189
+ * @returns A Promise that resolves to the master nullifier secret key.
190
+ * @dev Used when feeding the master nullifier secret key to the kernel circuit for nullifier keys verification.
191
+ */
192
+ getMasterNullifierSecretKeyForPublicKey(masterNullifierPublicKey) {
193
+ // We iterate over the map keys to find the account address that corresponds to the provided public key
194
+ for (const [key, value] of __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").entries()) {
195
+ if (value.equals(masterNullifierPublicKey.toBuffer())) {
196
+ // We extract the account address from the map key
197
+ const accountAddress = key.split('-')[0];
198
+ // We fetch the secret key and return it
199
+ const masterNullifierSecretKeyBuffer = __classPrivateFieldGet(this, _NewTestKeyStore_keys, "f").get(`${accountAddress.toString()}-nsk_m`);
200
+ if (!masterNullifierSecretKeyBuffer) {
201
+ throw new Error(`Could not find master nullifier secret key for account ${accountAddress.toString()}`);
202
+ }
203
+ return Promise.resolve(GrumpkinScalar.fromBuffer(masterNullifierSecretKeyBuffer));
204
+ }
205
+ }
206
+ throw new Error(`Could not find master nullifier secret key for public key ${masterNullifierPublicKey.toString()}`);
207
+ }
208
+ }
209
+ _NewTestKeyStore_keys = new WeakMap();
210
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV3X3Rlc3Rfa2V5X3N0b3JlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL25ld190ZXN0X2tleV9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLE9BQU8sRUFDTCxZQUFZLEVBQ1osRUFBRSxFQUNGLGNBQWMsRUFFZCxjQUFjLEVBRWQsS0FBSyxHQUNOLE1BQU0sb0JBQW9CLENBQUM7QUFFNUIsT0FBTyxFQUFFLGFBQWEsRUFBRSxzQkFBc0IsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBR2pGOzs7R0FHRztBQUNILE1BQU0sT0FBTyxlQUFlO0lBRzFCLFlBQW9CLEtBQWUsRUFBRSxRQUFzQjtRQUF2QyxVQUFLLEdBQUwsS0FBSyxDQUFVO1FBRm5DLHdDQUFnQztRQUc5Qix1QkFBQSxJQUFJLHlCQUFTLFFBQVEsQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLE1BQUEsQ0FBQztJQUM3QyxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksYUFBYTtRQUNsQixNQUFNLEVBQUUsR0FBRyxFQUFFLENBQUMsTUFBTSxFQUFFLENBQUM7UUFDdkIsTUFBTSxjQUFjLEdBQUcsRUFBRSxDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQ25DLE9BQU8sSUFBSSxDQUFDLFVBQVUsQ0FBQyxFQUFFLEVBQUUsY0FBYyxDQUFDLENBQUM7SUFDN0MsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0ksS0FBSyxDQUFDLFVBQVUsQ0FBQyxFQUFNLEVBQUUsY0FBOEI7UUFDNUQseUdBQXlHO1FBQ3pHLGVBQWU7UUFDZixNQUFNL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HdDQUF3QztnQkFDeEMsTUFBTSw4QkFBOEIsR0FBRyx1QkFBQSxJQUFJLDZCQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsY0FBYyxDQUFDLFFBQVEsRUFBRSxRQUFRLENBQUMsQ0FBQztnQkFDNUYsSUFBSSxDQUFDLDhCQUE4QixFQUFFLENBQUM7b0JBQ3BDLE1BQU0sSUFBSSxLQUFLLENBQUMsMERBQTBELGNBQWMsQ0FBQyxRQUFRLEVBQUUsRUFBRSxDQUFDLENBQUM7Z0JBQ3pHLENBQUM7Z0JBQ0QsT0FBTyxPQUFPLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxVQUFVLENBQUMsOEJBQThCLENBQUMsQ0FBQyxDQUFDO1lBQ3BGLENBQUM7UUFDSCxDQUFDO1FBRUQsTUFBTSxJQUFJLEtBQUssQ0FBQyw2REFBNkQsd0JBQXdCLENBQUMsUUFBUSxFQUFFLEVBQUUsQ0FBQyxDQUFDO0lBQ3RILENBQUM7Q0FDRiJ9
@@ -5,6 +5,7 @@ import { type AztecKVStore } from '@aztec/kv-store';
5
5
  /**
6
6
  * TestKeyStore is an implementation of the KeyStore interface, used for managing key pairs in a testing environment.
7
7
  * It should be utilized in testing scenarios where secure key management is not required, and ease-of-use is prioritized.
8
+ * TODO(#5627): 💣💣💣
8
9
  */
9
10
  export declare class TestKeyStore implements KeyStore {
10
11
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"test_key_store.d.ts","sourceRoot":"","sources":["../src/test_key_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAEvB,KAAK,EAIN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,iBAAiB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,EAAE,CAAC;IAKnC,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK9D,qBAAqB,CAAC,MAAM,EAAE,SAAS;IAKvC,kCAAkC,CAAC,eAAe,EAAE,SAAS;IAc7D,qBAAqB,CAAC,MAAM,EAAE,SAAS;IAKvC,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY;IAKzF;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;CASnB"}
@@ -5,6 +5,7 @@ import { ConstantKeyPair } from './key_pair.js';
5
5
  /**
6
6
  * TestKeyStore is an implementation of the KeyStore interface, used for managing key pairs in a testing environment.
7
7
  * It should be utilized in testing scenarios where secure key management is not required, and ease-of-use is prioritized.
8
+ * TODO(#5627): 💣💣💣
8
9
  */
9
10
  export class TestKeyStore {
10
11
  constructor(curve, database) {
@@ -72,4 +73,4 @@ export class TestKeyStore {
72
73
  }
73
74
  }
74
75
  _TestKeyStore_keys = new WeakMap();
75
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF9rZXlfc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdGVzdF9rZXlfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDQSxPQUFPLEVBR0wsY0FBYyxFQUNkLEtBQUssRUFDTCx5QkFBeUIsRUFDekIsK0JBQStCLEVBQy9CLGVBQWUsR0FDaEIsTUFBTSxvQkFBb0IsQ0FBQztBQUk1QixPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRWhEOzs7R0FHRztBQUNILE1BQU0sT0FBTyxZQUFZO0lBR3ZCLFlBQW9CLEtBQWUsRUFBRSxRQUFzQjtRQUF2QyxVQUFLLEdBQUwsS0FBSyxDQUFVO1FBRm5DLHFDQUFnQztRQUc5Qix1QkFBQSxJQUFJLHN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BQUMsR0FBRyxDQUFDLE1BQU0sQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO1FBQ2xELElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztZQUNiLE1BQU0sSUFBSSxLQUFLLENBQ2IsOEtBQThLLENBQy9LLENBQUM7UUFDSixDQUFDO1FBQ0QsT0FBTyxlQUFlLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsY0FBYyxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO0lBQ3hGLENBQUM7Q0FDRiJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/key-store",
3
- "version": "0.34.0",
3
+ "version": "0.35.1",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "typedocOptions": {
@@ -37,10 +37,10 @@
37
37
  ]
38
38
  },
39
39
  "dependencies": {
40
- "@aztec/circuit-types": "0.34.0",
41
- "@aztec/circuits.js": "0.34.0",
42
- "@aztec/foundation": "0.34.0",
43
- "@aztec/kv-store": "0.34.0",
40
+ "@aztec/circuit-types": "0.35.1",
41
+ "@aztec/circuits.js": "0.35.1",
42
+ "@aztec/foundation": "0.35.1",
43
+ "@aztec/kv-store": "0.35.1",
44
44
  "tslib": "^2.4.0"
45
45
  },
46
46
  "devDependencies": {
@@ -0,0 +1,245 @@
1
+ import { type NewKeyStore, type PublicKey } from '@aztec/circuit-types';
2
+ import {
3
+ AztecAddress,
4
+ Fr,
5
+ GeneratorIndex,
6
+ type GrumpkinPrivateKey,
7
+ GrumpkinScalar,
8
+ type PartialAddress,
9
+ Point,
10
+ } from '@aztec/circuits.js';
11
+ import { type Grumpkin } from '@aztec/circuits.js/barretenberg';
12
+ import { poseidon2Hash, sha512ToGrumpkinScalar } from '@aztec/foundation/crypto';
13
+ import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
14
+
15
+ /**
16
+ * TestKeyStore is an implementation of the KeyStore interface, used for managing key pairs in a testing environment.
17
+ * It should be utilized in testing scenarios where secure key management is not required, and ease-of-use is prioritized.
18
+ */
19
+ export class NewTestKeyStore implements NewKeyStore {
20
+ #keys: AztecMap<string, Buffer>;
21
+
22
+ constructor(private curve: Grumpkin, database: AztecKVStore) {
23
+ this.#keys = database.openMap('key_store');
24
+ }
25
+
26
+ /**
27
+ * Creates a new account from a randomly generated secret key.
28
+ * @returns A promise that resolves to the newly created account's AztecAddress.
29
+ */
30
+ public createAccount(): Promise<AztecAddress> {
31
+ const sk = Fr.random();
32
+ const partialAddress = Fr.random();
33
+ return this.addAccount(sk, partialAddress);
34
+ }
35
+
36
+ /**
37
+ * Adds an account to the key store from the provided secret key.
38
+ * @param sk - The secret key of the account.
39
+ * @param partialAddress - The partial address of the account.
40
+ * @returns The account's address.
41
+ */
42
+ public async addAccount(sk: Fr, partialAddress: PartialAddress): Promise<AztecAddress> {
43
+ // First we derive master secret keys - we use sha512 here because this derivation will never take place
44
+ // in a circuit
45
+ const masterNullifierSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.NSK_M]);
46
+ const masterIncomingViewingSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.IVSK_M]);
47
+ const masterOutgoingViewingSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.OVSK_M]);
48
+ const masterTaggingSecretKey = sha512ToGrumpkinScalar([sk, GeneratorIndex.TSK_M]);
49
+
50
+ // Then we derive master public keys
51
+ const masterNullifierPublicKey = this.curve.mul(this.curve.generator(), masterNullifierSecretKey);
52
+ const masterIncomingViewingPublicKey = this.curve.mul(this.curve.generator(), masterIncomingViewingSecretKey);
53
+ const masterOutgoingViewingPublicKey = this.curve.mul(this.curve.generator(), masterOutgoingViewingSecretKey);
54
+ const masterTaggingPublicKey = this.curve.mul(this.curve.generator(), masterTaggingSecretKey);
55
+
56
+ // We hash the public keys to get the public keys hash
57
+ const publicKeysHash = poseidon2Hash([
58
+ masterNullifierPublicKey,
59
+ masterIncomingViewingPublicKey,
60
+ masterOutgoingViewingPublicKey,
61
+ masterTaggingPublicKey,
62
+ GeneratorIndex.PUBLIC_KEYS_HASH,
63
+ ]);
64
+
65
+ // We hash the partial address and the public keys hash to get the account address
66
+ // TODO(#5726): Should GeneratorIndex.CONTRACT_ADDRESS be removed given that we introduced CONTRACT_ADDRESS_V1?
67
+ // TODO(#5726): Move the following line to AztecAddress class?
68
+ const accountAddressFr = poseidon2Hash([partialAddress, publicKeysHash, GeneratorIndex.CONTRACT_ADDRESS_V1]);
69
+ const accountAddress = AztecAddress.fromField(accountAddressFr);
70
+
71
+ // We store all the public and secret keys in the database
72
+ await this.#keys.set(`${accountAddress.toString()}-nsk_m`, masterNullifierSecretKey.toBuffer());
73
+ await this.#keys.set(`${accountAddress.toString()}-ivsk_m`, masterIncomingViewingSecretKey.toBuffer());
74
+ await this.#keys.set(`${accountAddress.toString()}-ovsk_m`, masterOutgoingViewingSecretKey.toBuffer());
75
+ await this.#keys.set(`${accountAddress.toString()}-tsk_m`, masterTaggingSecretKey.toBuffer());
76
+
77
+ await this.#keys.set(`${accountAddress.toString()}-npk_m`, masterNullifierPublicKey.toBuffer());
78
+ await this.#keys.set(`${accountAddress.toString()}-ivpk_m`, masterIncomingViewingPublicKey.toBuffer());
79
+ await this.#keys.set(`${accountAddress.toString()}-ovpk_m`, masterOutgoingViewingPublicKey.toBuffer());
80
+ await this.#keys.set(`${accountAddress.toString()}-tpk_m`, masterTaggingPublicKey.toBuffer());
81
+
82
+ // At last, we return the newly derived account address
83
+ return Promise.resolve(accountAddress);
84
+ }
85
+
86
+ /**
87
+ * Retrieves addresses of accounts stored in the key store.
88
+ * @returns A Promise that resolves to an array of account addresses.
89
+ */
90
+ public getAccounts(): Promise<AztecAddress[]> {
91
+ const allMapKeys = Array.from(this.#keys.keys());
92
+ // We return account addresses based on the map keys that end with '-nsk_m'
93
+ const accounts = allMapKeys.filter(key => key.endsWith('-nsk_m')).map(key => key.split('-')[0]);
94
+ return Promise.resolve(accounts.map(account => AztecAddress.fromString(account)));
95
+ }
96
+
97
+ /**
98
+ * Gets the master nullifier public key for a given account.
99
+ * @throws If the account does not exist in the key store.
100
+ * @param account - The account address for which to retrieve the master nullifier public key.
101
+ * @returns The master nullifier public key for the account.
102
+ */
103
+ public getMasterNullifierPublicKey(account: AztecAddress): Promise<PublicKey> {
104
+ const masterNullifierPublicKeyBuffer = this.#keys.get(`${account.toString()}-npk_m`);
105
+ if (!masterNullifierPublicKeyBuffer) {
106
+ throw new Error(`Account ${account.toString()} does not exist.`);
107
+ }
108
+ return Promise.resolve(Point.fromBuffer(masterNullifierPublicKeyBuffer));
109
+ }
110
+
111
+ /**
112
+ * Gets the master incoming viewing public key for a given account.
113
+ * @throws If the account does not exist in the key store.
114
+ * @param account - The account address for which to retrieve the master incoming viewing public key.
115
+ * @returns The master incoming viewing public key for the account.
116
+ */
117
+ public getMasterIncomingViewingPublicKey(account: AztecAddress): Promise<PublicKey> {
118
+ const masterIncomingViewingPublicKeyBuffer = this.#keys.get(`${account.toString()}-ivpk_m`);
119
+ if (!masterIncomingViewingPublicKeyBuffer) {
120
+ throw new Error(`Account ${account.toString()} does not exist.`);
121
+ }
122
+ return Promise.resolve(Point.fromBuffer(masterIncomingViewingPublicKeyBuffer));
123
+ }
124
+
125
+ /**
126
+ * Retrieves the master outgoing viewing public key.
127
+ * @throws If the account does not exist in the key store.
128
+ * @param account - The account to retrieve the master outgoing viewing key for.
129
+ * @returns A Promise that resolves to the master outgoing viewing key.
130
+ */
131
+ public getMasterOutgoingViewingPublicKey(account: AztecAddress): Promise<PublicKey> {
132
+ const masterOutgoingViewingPublicKeyBuffer = this.#keys.get(`${account.toString()}-ovpk_m`);
133
+ if (!masterOutgoingViewingPublicKeyBuffer) {
134
+ throw new Error(`Account ${account.toString()} does not exist.`);
135
+ }
136
+ return Promise.resolve(Point.fromBuffer(masterOutgoingViewingPublicKeyBuffer));
137
+ }
138
+
139
+ /**
140
+ * Retrieves the master tagging public key.
141
+ * @throws If the account does not exist in the key store.
142
+ * @param account - The account to retrieve the master tagging key for.
143
+ * @returns A Promise that resolves to the master tagging key.
144
+ */
145
+ public getMasterTaggingPublicKey(account: AztecAddress): Promise<PublicKey> {
146
+ const masterTaggingPublicKeyBuffer = this.#keys.get(`${account.toString()}-tpk_m`);
147
+ if (!masterTaggingPublicKeyBuffer) {
148
+ throw new Error(`Account ${account.toString()} does not exist.`);
149
+ }
150
+ return Promise.resolve(Point.fromBuffer(masterTaggingPublicKeyBuffer));
151
+ }
152
+
153
+ /**
154
+ * Retrieves application nullifier secret key.
155
+ * @throws If the account does not exist in the key store.
156
+ * @param account - The account to retrieve the application nullifier secret key for.
157
+ * @param app - The application address to retrieve the nullifier secret key for.
158
+ * @returns A Promise that resolves to the application nullifier secret key.
159
+ */
160
+ public getAppNullifierSecretKey(account: AztecAddress, app: AztecAddress): Promise<Fr> {
161
+ const masterNullifierSecretKeyBuffer = this.#keys.get(`${account.toString()}-nsk_m`);
162
+ if (!masterNullifierSecretKeyBuffer) {
163
+ throw new Error(`Account ${account.toString()} does not exist.`);
164
+ }
165
+ const masterNullifierSecretKey = GrumpkinScalar.fromBuffer(masterNullifierSecretKeyBuffer);
166
+
167
+ return Promise.resolve(
168
+ poseidon2Hash([masterNullifierSecretKey.high, masterNullifierSecretKey.low, app, GeneratorIndex.NSK_M]),
169
+ );
170
+ }
171
+
172
+ /**
173
+ * Retrieves application incoming viewing secret key.
174
+ * @throws If the account does not exist in the key store.
175
+ * @param account - The account to retrieve the application incoming viewing secret key for.
176
+ * @param app - The application address to retrieve the incoming viewing secret key for.
177
+ * @returns A Promise that resolves to the application incoming viewing secret key.
178
+ */
179
+ public getAppIncomingViewingSecretKey(account: AztecAddress, app: AztecAddress): Promise<Fr> {
180
+ const masterIncomingViewingSecretKeyBuffer = this.#keys.get(`${account.toString()}-ivsk_m`);
181
+ if (!masterIncomingViewingSecretKeyBuffer) {
182
+ throw new Error(`Account ${account.toString()} does not exist.`);
183
+ }
184
+ const masterIncomingViewingSecretKey = GrumpkinScalar.fromBuffer(masterIncomingViewingSecretKeyBuffer);
185
+
186
+ return Promise.resolve(
187
+ poseidon2Hash([
188
+ masterIncomingViewingSecretKey.high,
189
+ masterIncomingViewingSecretKey.low,
190
+ app,
191
+ GeneratorIndex.IVSK_M,
192
+ ]),
193
+ );
194
+ }
195
+
196
+ /**
197
+ * Retrieves application outgoing viewing secret key.
198
+ * @throws If the account does not exist in the key store.
199
+ * @param account - The account to retrieve the application outgoing viewing secret key for.
200
+ * @param app - The application address to retrieve the outgoing viewing secret key for.
201
+ * @returns A Promise that resolves to the application outgoing viewing secret key.
202
+ */
203
+ public getAppOutgoingViewingSecretKey(account: AztecAddress, app: AztecAddress): Promise<Fr> {
204
+ const masterOutgoingViewingSecretKeyBuffer = this.#keys.get(`${account.toString()}-ovsk_m`);
205
+ if (!masterOutgoingViewingSecretKeyBuffer) {
206
+ throw new Error(`Account ${account.toString()} does not exist.`);
207
+ }
208
+ const masterOutgoingViewingSecretKey = GrumpkinScalar.fromBuffer(masterOutgoingViewingSecretKeyBuffer);
209
+
210
+ return Promise.resolve(
211
+ poseidon2Hash([
212
+ masterOutgoingViewingSecretKey.high,
213
+ masterOutgoingViewingSecretKey.low,
214
+ app,
215
+ GeneratorIndex.OVSK_M,
216
+ ]),
217
+ );
218
+ }
219
+
220
+ /**
221
+ * Retrieves the master nullifier secret key (nsk_m) corresponding to the specified master nullifier public key
222
+ * (Npk_m).
223
+ * @throws If the provided public key is not associated with any of the registered accounts.
224
+ * @param masterNullifierPublicKey - The master nullifier public key to get secret key for.
225
+ * @returns A Promise that resolves to the master nullifier secret key.
226
+ * @dev Used when feeding the master nullifier secret key to the kernel circuit for nullifier keys verification.
227
+ */
228
+ public getMasterNullifierSecretKeyForPublicKey(masterNullifierPublicKey: PublicKey): Promise<GrumpkinPrivateKey> {
229
+ // We iterate over the map keys to find the account address that corresponds to the provided public key
230
+ for (const [key, value] of this.#keys.entries()) {
231
+ if (value.equals(masterNullifierPublicKey.toBuffer())) {
232
+ // We extract the account address from the map key
233
+ const accountAddress = key.split('-')[0];
234
+ // We fetch the secret key and return it
235
+ const masterNullifierSecretKeyBuffer = this.#keys.get(`${accountAddress.toString()}-nsk_m`);
236
+ if (!masterNullifierSecretKeyBuffer) {
237
+ throw new Error(`Could not find master nullifier secret key for account ${accountAddress.toString()}`);
238
+ }
239
+ return Promise.resolve(GrumpkinScalar.fromBuffer(masterNullifierSecretKeyBuffer));
240
+ }
241
+ }
242
+
243
+ throw new Error(`Could not find master nullifier secret key for public key ${masterNullifierPublicKey.toString()}`);
244
+ }
245
+ }
@@ -16,6 +16,7 @@ import { ConstantKeyPair } from './key_pair.js';
16
16
  /**
17
17
  * TestKeyStore is an implementation of the KeyStore interface, used for managing key pairs in a testing environment.
18
18
  * It should be utilized in testing scenarios where secure key management is not required, and ease-of-use is prioritized.
19
+ * TODO(#5627): 💣💣💣
19
20
  */
20
21
  export class TestKeyStore implements KeyStore {
21
22
  #keys: AztecMap<string, Buffer>;