@aztec/accounts 0.0.1-commit.2f68f620 → 0.0.1-commit.321f6a9
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.
- package/artifacts/EcdsaKAccount.json +2867 -1728
- package/artifacts/EcdsaRAccount.json +2870 -1731
- package/artifacts/SchnorrAccount.json +2917 -1782
- package/artifacts/SchnorrInitializerlessAccount.d.json.ts +3 -0
- package/artifacts/SchnorrInitializerlessAccount.json +8526 -0
- package/artifacts/SimulatedEcdsaAccount.json +2010 -1156
- package/artifacts/SimulatedSchnorrAccount.json +2229 -1355
- package/dest/defaults/account_contract.d.ts +7 -1
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +6 -0
- package/dest/{stub/account_contract.d.ts → defaults/stub_account_contract.d.ts} +1 -1
- package/dest/defaults/stub_account_contract.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/lazy.js +1 -1
- package/dest/ecdsa/ecdsa_r/lazy.js +1 -1
- package/dest/{stub/ecdsa → ecdsa/stub}/index.d.ts +2 -2
- package/dest/ecdsa/stub/index.d.ts.map +1 -0
- package/dest/{stub/ecdsa → ecdsa/stub}/index.js +1 -1
- package/dest/{stub/ecdsa → ecdsa/stub}/lazy.d.ts +2 -2
- package/dest/ecdsa/stub/lazy.d.ts.map +1 -0
- package/dest/{stub/ecdsa → ecdsa/stub}/lazy.js +1 -1
- package/dest/schnorr/account_contract.d.ts +8 -4
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +4 -1
- package/dest/schnorr/index.d.ts +3 -23
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +2 -35
- package/dest/schnorr/initializerless/index.d.ts +25 -0
- package/dest/schnorr/initializerless/index.d.ts.map +1 -0
- package/dest/schnorr/initializerless/index.js +46 -0
- package/dest/schnorr/initializerless/lazy.d.ts +29 -0
- package/dest/schnorr/initializerless/lazy.d.ts.map +1 -0
- package/dest/schnorr/initializerless/lazy.js +54 -0
- package/dest/schnorr/lazy.d.ts +3 -27
- package/dest/schnorr/lazy.d.ts.map +1 -1
- package/dest/schnorr/lazy.js +2 -43
- package/dest/schnorr/private_immutable/index.d.ts +23 -0
- package/dest/schnorr/private_immutable/index.d.ts.map +1 -0
- package/dest/schnorr/private_immutable/index.js +35 -0
- package/dest/schnorr/private_immutable/lazy.d.ts +27 -0
- package/dest/schnorr/private_immutable/lazy.d.ts.map +1 -0
- package/dest/schnorr/private_immutable/lazy.js +43 -0
- package/dest/{stub/schnorr → schnorr/stub}/index.d.ts +2 -2
- package/dest/schnorr/stub/index.d.ts.map +1 -0
- package/dest/{stub/schnorr → schnorr/stub}/index.js +1 -1
- package/dest/{stub/schnorr → schnorr/stub}/lazy.d.ts +2 -2
- package/dest/schnorr/stub/lazy.d.ts.map +1 -0
- package/dest/{stub/schnorr → schnorr/stub}/lazy.js +1 -1
- package/dest/testing/configuration.d.ts +9 -1
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +6 -2
- package/dest/testing/index.d.ts +5 -5
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +20 -12
- package/dest/testing/lazy.d.ts +4 -4
- package/dest/testing/lazy.d.ts.map +1 -1
- package/dest/testing/lazy.js +20 -12
- package/dest/utils/index.d.ts +2 -1
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -0
- package/dest/utils/key_derivation.d.ts +9 -0
- package/dest/utils/key_derivation.d.ts.map +1 -0
- package/dest/utils/key_derivation.js +16 -0
- package/package.json +10 -12
- package/src/defaults/account_contract.ts +9 -0
- package/src/ecdsa/ecdsa_k/lazy.ts +1 -1
- package/src/ecdsa/ecdsa_r/lazy.ts +1 -1
- package/src/{stub/ecdsa → ecdsa/stub}/index.ts +1 -1
- package/src/{stub/ecdsa → ecdsa/stub}/lazy.ts +1 -1
- package/src/schnorr/account_contract.ts +16 -3
- package/src/schnorr/index.ts +2 -50
- package/src/schnorr/initializerless/index.ts +62 -0
- package/src/schnorr/initializerless/lazy.ts +70 -0
- package/src/schnorr/lazy.ts +2 -60
- package/src/schnorr/private_immutable/index.ts +50 -0
- package/src/schnorr/private_immutable/lazy.ts +60 -0
- package/src/{stub/schnorr → schnorr/stub}/index.ts +1 -1
- package/src/{stub/schnorr → schnorr/stub}/lazy.ts +1 -1
- package/src/testing/configuration.ts +15 -2
- package/src/testing/index.ts +29 -13
- package/src/testing/lazy.ts +28 -13
- package/src/utils/index.ts +1 -0
- package/src/utils/key_derivation.ts +15 -0
- package/dest/stub/account_contract.d.ts.map +0 -1
- package/dest/stub/ecdsa/index.d.ts.map +0 -1
- package/dest/stub/ecdsa/lazy.d.ts.map +0 -1
- package/dest/stub/schnorr/index.d.ts.map +0 -1
- package/dest/stub/schnorr/lazy.d.ts.map +0 -1
- /package/dest/{stub/account_contract.js → defaults/stub_account_contract.js} +0 -0
- /package/src/{stub/account_contract.ts → defaults/stub_account_contract.ts} +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
3
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { SchnorrBaseAccountContract } from '../account_contract.js';
|
|
6
|
+
/**
|
|
7
|
+
* Lazily loads the contract artifact
|
|
8
|
+
* @returns The contract artifact for the schnorr account contract
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSchnorrAccountContractArtifact(): Promise<ContractArtifact>;
|
|
11
|
+
/**
|
|
12
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
13
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
14
|
+
* Lazily loads the contract artifact
|
|
15
|
+
*/
|
|
16
|
+
export declare class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
17
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
18
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Compute the address of a schnorr account contract.
|
|
22
|
+
* @param signingPrivateKey - The account's signing private key.
|
|
23
|
+
* @param salt - The contract address salt.
|
|
24
|
+
* @param secretKey - Seed for the account's privacy keys. Derived from the signing key when omitted.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getSchnorrAccountContractAddress(signingPrivateKey: GrumpkinScalar, salt: Fr, secretKey?: Fr): Promise<AztecAddress>;
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NjaG5vcnIvcHJpdmF0ZV9pbW11dGFibGUvbGF6eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFPQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQ25FLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFMUQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFHaEUsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFcEU7OztHQUdHO0FBQ0gsd0JBQXNCLGlDQUFpQyw4QkFRdEQ7QUFFRDs7OztHQUlHO0FBQ0gscUJBQWEsc0JBQXVCLFNBQVEsMEJBQTBCO0lBQ3BFLFlBQVksaUJBQWlCLEVBQUUsY0FBYyxFQUU1QztJQUVRLG1CQUFtQixJQUFJLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUV4RDtDQUNGO0FBRUQ7Ozs7O0dBS0c7QUFDSCx3QkFBc0IsZ0NBQWdDLENBQ3BELGlCQUFpQixFQUFFLGNBQWMsRUFDakMsSUFBSSxFQUFFLEVBQUUsRUFDUixTQUFTLENBQUMsRUFBRSxFQUFFLEdBQ2IsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUl2QiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/schnorr/private_immutable/lazy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE;;;GAGG;AACH,wBAAsB,iCAAiC,8BAQtD;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,0BAA0B;IACpE,YAAY,iBAAiB,EAAE,cAAc,EAE5C;IAEQ,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAExD;CACF;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CACpD,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,EAAE,EACR,SAAS,CAAC,EAAE,EAAE,GACb,OAAO,CAAC,YAAY,CAAC,CAIvB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/schnorr` export provides an account contract implementation that uses Schnorr signatures with a Grumpkin key for authentication, and a separate Grumpkin key for encryption.
|
|
3
|
+
* This is the suggested account contract type for most use cases within Aztec.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/ import { getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
7
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
8
|
+
import { deriveSecretKeyFromSigningKey } from '../../utils/key_derivation.js';
|
|
9
|
+
import { SchnorrBaseAccountContract } from '../account_contract.js';
|
|
10
|
+
/**
|
|
11
|
+
* Lazily loads the contract artifact
|
|
12
|
+
* @returns The contract artifact for the schnorr account contract
|
|
13
|
+
*/ export async function getSchnorrAccountContractArtifact() {
|
|
14
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
15
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
16
|
+
// Even if now supported by all major browsers, the MIME type is replaced with
|
|
17
|
+
// "text/javascript"
|
|
18
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
|
+
const { default: schnorrAccountContractJson } = await import('../../../artifacts/SchnorrAccount.json');
|
|
20
|
+
return loadContractArtifact(schnorrAccountContractJson);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
24
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
25
|
+
* Lazily loads the contract artifact
|
|
26
|
+
*/ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
27
|
+
constructor(signingPrivateKey){
|
|
28
|
+
super(signingPrivateKey);
|
|
29
|
+
}
|
|
30
|
+
getContractArtifact() {
|
|
31
|
+
return getSchnorrAccountContractArtifact();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Compute the address of a schnorr account contract.
|
|
36
|
+
* @param signingPrivateKey - The account's signing private key.
|
|
37
|
+
* @param salt - The contract address salt.
|
|
38
|
+
* @param secretKey - Seed for the account's privacy keys. Derived from the signing key when omitted.
|
|
39
|
+
*/ export async function getSchnorrAccountContractAddress(signingPrivateKey, salt, secretKey) {
|
|
40
|
+
const resolvedSecretKey = secretKey ?? await deriveSecretKeyFromSigningKey(signingPrivateKey);
|
|
41
|
+
const accountContract = new SchnorrAccountContract(signingPrivateKey);
|
|
42
|
+
return await getAccountContractAddress(accountContract, resolvedSecretKey, salt);
|
|
43
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { StubBaseAccountContract } from '
|
|
3
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
4
4
|
export declare const StubSchnorrAccountContractArtifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
5
5
|
/** Stub account contract for Schnorr accounts. Eagerly loads the contract artifact. */
|
|
6
6
|
export declare class StubSchnorrAccountContract extends StubBaseAccountContract {
|
|
@@ -8,4 +8,4 @@ export declare class StubSchnorrAccountContract extends StubBaseAccountContract
|
|
|
8
8
|
}
|
|
9
9
|
/** Creates a Schnorr stub account that impersonates the one with the provided address. */
|
|
10
10
|
export declare function createStubSchnorrAccount(originalAddress: CompleteAddress): BaseAccount;
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zY2hub3JyL3N0dWIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBTWpFLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxNQUFNLHlDQUF5QyxDQUFDO0FBRWxGLGVBQU8sTUFBTSxrQ0FBa0MsOENBRTlDLENBQUM7QUFFRix1RkFBdUY7QUFDdkYscUJBQWEsMEJBQTJCLFNBQVEsdUJBQXVCO0lBQzVELG1CQUFtQiwwREFFM0I7Q0FDRjtBQUVELDBGQUEwRjtBQUMxRix3QkFBZ0Isd0JBQXdCLENBQUMsZUFBZSxFQUFFLGVBQWUsZUFReEUifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schnorr/stub/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAMjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,eAAO,MAAM,kCAAkC,8CAE9C,CAAC;AAEF,uFAAuF;AACvF,qBAAa,0BAA2B,SAAQ,uBAAuB;IAC5D,mBAAmB,0DAE3B;CACF;AAED,0FAA0F;AAC1F,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,eAAe,eAQxE"}
|
|
@@ -4,7 +4,7 @@ import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
|
4
4
|
import SimulatedSchnorrAccountJson from '../../../artifacts/SimulatedSchnorrAccount.json' with {
|
|
5
5
|
type: 'json'
|
|
6
6
|
};
|
|
7
|
-
import { StubBaseAccountContract } from '
|
|
7
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
8
8
|
export const StubSchnorrAccountContractArtifact = loadContractArtifact(SimulatedSchnorrAccountJson);
|
|
9
9
|
/** Stub account contract for Schnorr accounts. Eagerly loads the contract artifact. */ export class StubSchnorrAccountContract extends StubBaseAccountContract {
|
|
10
10
|
getContractArtifact() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { StubBaseAccountContract } from '
|
|
3
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
4
4
|
/**
|
|
5
5
|
* Lazily loads the Schnorr stub contract artifact (browser-compatible).
|
|
6
6
|
*/
|
|
@@ -11,4 +11,4 @@ export declare class StubSchnorrAccountContract extends StubBaseAccountContract
|
|
|
11
11
|
}
|
|
12
12
|
/** Creates a Schnorr stub account that impersonates the one with the provided address. */
|
|
13
13
|
export declare function createStubSchnorrAccount(originalAddress: CompleteAddress): BaseAccount;
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NjaG5vcnIvc3R1Yi9sYXp5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUlqRSxPQUFPLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQUVsRjs7R0FFRztBQUNILHdCQUFzQixxQ0FBcUMsMERBSzFEO0FBRUQsc0ZBQXNGO0FBQ3RGLHFCQUFhLDBCQUEyQixTQUFRLHVCQUF1QjtJQUM1RCxtQkFBbUIsMERBRTNCO0NBQ0Y7QUFFRCwwRkFBMEY7QUFDMUYsd0JBQWdCLHdCQUF3QixDQUFDLGVBQWUsRUFBRSxlQUFlLGVBUXhFIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/schnorr/stub/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAIjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF;;GAEG;AACH,wBAAsB,qCAAqC,0DAK1D;AAED,sFAAsF;AACtF,qBAAa,0BAA2B,SAAQ,uBAAuB;IAC5D,mBAAmB,0DAE3B;CACF;AAED,0FAA0F;AAC1F,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,eAAe,eAQxE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
2
|
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
3
3
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
4
|
-
import { StubBaseAccountContract } from '
|
|
4
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
5
5
|
/**
|
|
6
6
|
* Lazily loads the Schnorr stub contract artifact (browser-compatible).
|
|
7
7
|
*/ export async function getStubSchnorrAccountContractArtifact() {
|
|
@@ -5,6 +5,10 @@ export declare const INITIAL_TEST_SECRET_KEYS: Fr[];
|
|
|
5
5
|
export declare const INITIAL_TEST_ENCRYPTION_KEYS: import("@aztec/foundation/curves/bn254").Fq[];
|
|
6
6
|
export declare const INITIAL_TEST_SIGNING_KEYS: import("@aztec/foundation/curves/bn254").Fq[];
|
|
7
7
|
export declare const INITIAL_TEST_ACCOUNT_SALTS: Fr[];
|
|
8
|
+
/**
|
|
9
|
+
* The schnorr account contract variant a test account uses.
|
|
10
|
+
*/
|
|
11
|
+
export type InitialAccountType = 'schnorr' | 'schnorr_initializerless';
|
|
8
12
|
/**
|
|
9
13
|
* Data for generating an initial account.
|
|
10
14
|
*/
|
|
@@ -25,5 +29,9 @@ export interface InitialAccountData {
|
|
|
25
29
|
* Address of the schnorr account contract.
|
|
26
30
|
*/
|
|
27
31
|
address: AztecAddress;
|
|
32
|
+
/**
|
|
33
|
+
* Account contract variant.
|
|
34
|
+
*/
|
|
35
|
+
type?: InitialAccountType;
|
|
28
36
|
}
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3RpbmcvY29uZmlndXJhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQ25FLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR2hFLGVBQU8sTUFBTSx3QkFBd0IsTUFJcEMsQ0FBQztBQUVGLGVBQU8sTUFBTSw0QkFBNEIsK0NBRXhDLENBQUM7QUFFRixlQUFPLE1BQU0seUJBQXlCLCtDQUlyQyxDQUFDO0FBRUYsZUFBTyxNQUFNLDBCQUEwQixNQUE4QixDQUFDO0FBRXRFOztHQUVHO0FBQ0gsTUFBTSxNQUFNLGtCQUFrQixHQUFHLFNBQVMsR0FBRyx5QkFBeUIsQ0FBQztBQUV2RTs7R0FFRztBQUNILE1BQU0sV0FBVyxrQkFBa0I7SUFDakM7O09BRUc7SUFDSCxNQUFNLEVBQUUsRUFBRSxDQUFDO0lBQ1g7O09BRUc7SUFDSCxVQUFVLEVBQUUsY0FBYyxDQUFDO0lBQzNCOztPQUVHO0lBQ0gsSUFBSSxFQUFFLEVBQUUsQ0FBQztJQUNUOztPQUVHO0lBQ0gsT0FBTyxFQUFFLFlBQVksQ0FBQztJQUN0Qjs7T0FFRztJQUNILElBQUksQ0FBQyxFQUFFLGtCQUFrQixDQUFDO0NBQzNCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/testing/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,eAAO,MAAM,wBAAwB,MAIpC,CAAC;AAEF,eAAO,MAAM,4BAA4B,+CAExC,CAAC;AAEF,eAAO,MAAM,yBAAyB,+
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/testing/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,eAAO,MAAM,wBAAwB,MAIpC,CAAC;AAEF,eAAO,MAAM,4BAA4B,+CAExC,CAAC;AAEF,eAAO,MAAM,yBAAyB,+CAIrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,MAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,yBAAyB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,EAAE,CAAC;IACX;;OAEG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B;;OAEG;IACH,IAAI,EAAE,EAAE,CAAC;IACT;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC3B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
2
3
|
import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
|
|
3
4
|
export const INITIAL_TEST_SECRET_KEYS = [
|
|
4
5
|
Fr.fromHexString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
|
|
@@ -6,8 +7,11 @@ export const INITIAL_TEST_SECRET_KEYS = [
|
|
|
6
7
|
Fr.fromHexString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c')
|
|
7
8
|
];
|
|
8
9
|
export const INITIAL_TEST_ENCRYPTION_KEYS = INITIAL_TEST_SECRET_KEYS.map((secretKey)=>deriveMasterIncomingViewingSecretKey(secretKey));
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export const INITIAL_TEST_SIGNING_KEYS = [
|
|
11
|
+
GrumpkinScalar.fromHexString('0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'),
|
|
12
|
+
GrumpkinScalar.fromHexString('202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e'),
|
|
13
|
+
GrumpkinScalar.fromHexString('404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e')
|
|
14
|
+
];
|
|
11
15
|
export const INITIAL_TEST_ACCOUNT_SALTS = [
|
|
12
16
|
Fr.ZERO,
|
|
13
17
|
Fr.ZERO,
|
package/dest/testing/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type InitialAccountData } from './configuration.js';
|
|
2
|
-
export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, type InitialAccountData, } from './configuration.js';
|
|
1
|
+
import { type InitialAccountData, type InitialAccountType } from './configuration.js';
|
|
2
|
+
export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, type InitialAccountData, type InitialAccountType, } from './configuration.js';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the basic information for initial test accounts.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getInitialTestAccountsData(): Promise<InitialAccountData[]>;
|
|
7
7
|
/**
|
|
8
|
-
* Generate a fixed amount of random schnorr account contract
|
|
8
|
+
* Generate a fixed amount of random schnorr account contract instances of the given type
|
|
9
9
|
*/
|
|
10
|
-
export declare function generateSchnorrAccounts(numberOfAccounts: number): Promise<
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
export declare function generateSchnorrAccounts(numberOfAccounts: number, type?: InitialAccountType): Promise<InitialAccountData[]>;
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVdBLE9BQU8sRUFJTCxLQUFLLGtCQUFrQixFQUN2QixLQUFLLGtCQUFrQixFQUN4QixNQUFNLG9CQUFvQixDQUFDO0FBRTVCLE9BQU8sRUFDTCwwQkFBMEIsRUFDMUIsNEJBQTRCLEVBQzVCLHdCQUF3QixFQUN4Qix5QkFBeUIsRUFDekIsS0FBSyxrQkFBa0IsRUFDdkIsS0FBSyxrQkFBa0IsR0FDeEIsTUFBTSxvQkFBb0IsQ0FBQztBQVM1Qjs7R0FFRztBQUNILHdCQUFnQiwwQkFBMEIsSUFBSSxPQUFPLENBQUMsa0JBQWtCLEVBQUUsQ0FBQyxDQWMxRTtBQUVEOztHQUVHO0FBQ0gsd0JBQXNCLHVCQUF1QixDQUMzQyxnQkFBZ0IsRUFBRSxNQUFNLEVBQ3hCLElBQUksR0FBRSxrQkFBOEMsR0FDbkQsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUMsQ0FlL0IifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAS5B;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAc1E;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,gBAAgB,EAAE,MAAM,EACxB,IAAI,GAAE,kBAA8C,GACnD,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAe/B"}
|
package/dest/testing/index.js
CHANGED
|
@@ -3,33 +3,41 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/ import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
7
|
+
import { getSchnorrInitializerlessAccountContractAddress } from '../schnorr/initializerless/index.js';
|
|
8
|
+
import { getSchnorrAccountContractAddress } from '../schnorr/private_immutable/index.js';
|
|
9
|
+
import { deriveSecretKeyFromSigningKey } from '../utils/key_derivation.js';
|
|
10
|
+
import { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS } from './configuration.js';
|
|
9
11
|
export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS } from './configuration.js';
|
|
12
|
+
/** Derives the account contract address for the given type */ function getTestAccountAddress(type, signingKey, salt, secret) {
|
|
13
|
+
return type === 'schnorr' ? getSchnorrAccountContractAddress(signingKey, salt, secret) : getSchnorrInitializerlessAccountContractAddress(signingKey, salt, secret);
|
|
14
|
+
}
|
|
10
15
|
/**
|
|
11
16
|
* Gets the basic information for initial test accounts.
|
|
12
17
|
*/ export function getInitialTestAccountsData() {
|
|
13
18
|
return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (secret, i)=>({
|
|
14
19
|
secret,
|
|
15
|
-
signingKey:
|
|
20
|
+
signingKey: INITIAL_TEST_SIGNING_KEYS[i],
|
|
16
21
|
salt: INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
17
|
-
|
|
22
|
+
type: 'schnorr_initializerless',
|
|
23
|
+
address: await getSchnorrInitializerlessAccountContractAddress(INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i], secret)
|
|
18
24
|
})));
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
|
-
* Generate a fixed amount of random schnorr account contract
|
|
22
|
-
*/ export async function generateSchnorrAccounts(numberOfAccounts) {
|
|
23
|
-
const
|
|
27
|
+
* Generate a fixed amount of random schnorr account contract instances of the given type
|
|
28
|
+
*/ export async function generateSchnorrAccounts(numberOfAccounts, type = 'schnorr_initializerless') {
|
|
29
|
+
const signingKeys = Array.from({
|
|
24
30
|
length: numberOfAccounts
|
|
25
|
-
}, ()=>
|
|
26
|
-
return await Promise.all(
|
|
31
|
+
}, ()=>GrumpkinScalar.random());
|
|
32
|
+
return await Promise.all(signingKeys.map(async (signingKey)=>{
|
|
27
33
|
const salt = Fr.random();
|
|
34
|
+
const secret = await deriveSecretKeyFromSigningKey(signingKey);
|
|
28
35
|
return {
|
|
29
36
|
secret,
|
|
30
|
-
signingKey
|
|
37
|
+
signingKey,
|
|
31
38
|
salt,
|
|
32
|
-
|
|
39
|
+
type,
|
|
40
|
+
address: await getTestAccountAddress(type, signingKey, salt, secret)
|
|
33
41
|
};
|
|
34
42
|
}));
|
|
35
43
|
}
|
package/dest/testing/lazy.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type InitialAccountData } from './configuration.js';
|
|
1
|
+
import { type InitialAccountData, type InitialAccountType } from './configuration.js';
|
|
2
2
|
export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS } from './configuration.js';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the basic information for initial test accounts.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getInitialTestAccountsData(): Promise<InitialAccountData[]>;
|
|
7
7
|
/**
|
|
8
|
-
* Generate a fixed amount of random schnorr account contract
|
|
8
|
+
* Generate a fixed amount of random schnorr account contract instances of the given type
|
|
9
9
|
*/
|
|
10
|
-
export declare function generateSchnorrAccounts(numberOfAccounts: number): Promise<InitialAccountData[]>;
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
export declare function generateSchnorrAccounts(numberOfAccounts: number, type?: InitialAccountType): Promise<InitialAccountData[]>;
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3RpbmcvbGF6eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFXQSxPQUFPLEVBSUwsS0FBSyxrQkFBa0IsRUFDdkIsS0FBSyxrQkFBa0IsRUFDeEIsTUFBTSxvQkFBb0IsQ0FBQztBQUU1QixPQUFPLEVBQUUsMEJBQTBCLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQVMxRjs7R0FFRztBQUNILHdCQUFnQiwwQkFBMEIsSUFBSSxPQUFPLENBQUMsa0JBQWtCLEVBQUUsQ0FBQyxDQWMxRTtBQUVEOztHQUVHO0FBQ0gsd0JBQXNCLHVCQUF1QixDQUMzQyxnQkFBZ0IsRUFBRSxNQUFNLEVBQ3hCLElBQUksR0FBRSxrQkFBOEMsR0FDbkQsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUMsQ0FlL0IifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/testing/lazy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/testing/lazy.ts"],"names":[],"mappings":"AAWA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAS1F;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAc1E;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,gBAAgB,EAAE,MAAM,EACxB,IAAI,GAAE,kBAA8C,GACnD,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAe/B"}
|
package/dest/testing/lazy.js
CHANGED
|
@@ -3,33 +3,41 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/ import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
7
|
+
import { getSchnorrInitializerlessAccountContractAddress } from '../schnorr/initializerless/lazy.js';
|
|
8
|
+
import { getSchnorrAccountContractAddress } from '../schnorr/private_immutable/lazy.js';
|
|
9
|
+
import { deriveSecretKeyFromSigningKey } from '../utils/key_derivation.js';
|
|
10
|
+
import { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS } from './configuration.js';
|
|
9
11
|
export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS } from './configuration.js';
|
|
12
|
+
/** Derives the account contract address for the given type */ function getTestAccountAddress(type, signingKey, salt, secret) {
|
|
13
|
+
return type === 'schnorr' ? getSchnorrAccountContractAddress(signingKey, salt, secret) : getSchnorrInitializerlessAccountContractAddress(signingKey, salt, secret);
|
|
14
|
+
}
|
|
10
15
|
/**
|
|
11
16
|
* Gets the basic information for initial test accounts.
|
|
12
17
|
*/ export function getInitialTestAccountsData() {
|
|
13
18
|
return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (secret, i)=>({
|
|
14
19
|
secret,
|
|
15
|
-
signingKey:
|
|
20
|
+
signingKey: INITIAL_TEST_SIGNING_KEYS[i],
|
|
16
21
|
salt: INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
17
|
-
|
|
22
|
+
type: 'schnorr_initializerless',
|
|
23
|
+
address: await getSchnorrInitializerlessAccountContractAddress(INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i], secret)
|
|
18
24
|
})));
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
|
-
* Generate a fixed amount of random schnorr account contract
|
|
22
|
-
*/ export async function generateSchnorrAccounts(numberOfAccounts) {
|
|
23
|
-
const
|
|
27
|
+
* Generate a fixed amount of random schnorr account contract instances of the given type
|
|
28
|
+
*/ export async function generateSchnorrAccounts(numberOfAccounts, type = 'schnorr_initializerless') {
|
|
29
|
+
const signingKeys = Array.from({
|
|
24
30
|
length: numberOfAccounts
|
|
25
|
-
}, ()=>
|
|
26
|
-
return await Promise.all(
|
|
31
|
+
}, ()=>GrumpkinScalar.random());
|
|
32
|
+
return await Promise.all(signingKeys.map(async (signingKey)=>{
|
|
27
33
|
const salt = Fr.random();
|
|
34
|
+
const secret = await deriveSecretKeyFromSigningKey(signingKey);
|
|
28
35
|
return {
|
|
29
36
|
secret,
|
|
30
|
-
signingKey
|
|
37
|
+
signingKey,
|
|
31
38
|
salt,
|
|
32
|
-
|
|
39
|
+
type,
|
|
40
|
+
address: await getTestAccountAddress(type, signingKey, salt, secret)
|
|
33
41
|
};
|
|
34
42
|
}));
|
|
35
43
|
}
|
package/dest/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
export * from './key_derivation.js';
|
|
1
2
|
export * from './ssh_agent.js';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMsZ0JBQWdCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
package/dest/utils/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
3
|
+
/**
|
|
4
|
+
* Derives the privacy secret key (the seed for the viewing/nullifier keyset that PXE holds) from the account's signing
|
|
5
|
+
* key. The signing key is the ownership root the user controls; the privacy keyset hangs off it through this one-way
|
|
6
|
+
* hash, so a value handled by PXE can never be used to recover the signing key.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deriveSecretKeyFromSigningKey(signingKey: GrumpkinScalar): Promise<Fr>;
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5X2Rlcml2YXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9rZXlfZGVyaXZhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUl4RTs7OztHQUlHO0FBQ0gsd0JBQWdCLDZCQUE2QixDQUFDLFVBQVUsRUFBRSxjQUFjLEdBQUcsT0FBTyxDQUFDLEVBQUUsQ0FBQyxDQUVyRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key_derivation.d.ts","sourceRoot":"","sources":["../../src/utils/key_derivation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAIxE;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,EAAE,CAAC,CAErF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
+
import { sha256ToField } from '@aztec/foundation/crypto/sha256';
|
|
3
|
+
const SIGNING_KEY_TO_SECRET_KEY_SEPARATOR = sha256ToField([
|
|
4
|
+
Buffer.from('@aztec/accounts/signing_key_to_secret_key')
|
|
5
|
+
]);
|
|
6
|
+
/**
|
|
7
|
+
* Derives the privacy secret key (the seed for the viewing/nullifier keyset that PXE holds) from the account's signing
|
|
8
|
+
* key. The signing key is the ownership root the user controls; the privacy keyset hangs off it through this one-way
|
|
9
|
+
* hash, so a value handled by PXE can never be used to recover the signing key.
|
|
10
|
+
*/ export function deriveSecretKeyFromSigningKey(signingKey) {
|
|
11
|
+
return poseidon2Hash([
|
|
12
|
+
SIGNING_KEY_TO_SECRET_KEY_SEPARATOR,
|
|
13
|
+
signingKey.hi,
|
|
14
|
+
signingKey.lo
|
|
15
|
+
]);
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
"name": "@aztec/accounts",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/accounts",
|
|
4
4
|
"description": "Implementation of sample account contracts for Aztec Network",
|
|
5
|
-
"version": "0.0.1-commit.
|
|
5
|
+
"version": "0.0.1-commit.321f6a9",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./defaults": "./dest/defaults/index.js",
|
|
9
9
|
"./ecdsa": "./dest/ecdsa/index.js",
|
|
10
10
|
"./ecdsa/lazy": "./dest/ecdsa/lazy.js",
|
|
11
|
+
"./ecdsa/stub": "./dest/ecdsa/stub/index.js",
|
|
12
|
+
"./ecdsa/stub/lazy": "./dest/ecdsa/stub/lazy.js",
|
|
11
13
|
"./schnorr": "./dest/schnorr/index.js",
|
|
12
14
|
"./schnorr/lazy": "./dest/schnorr/lazy.js",
|
|
13
|
-
"./stub
|
|
14
|
-
"./stub/
|
|
15
|
-
"./stub/ecdsa": "./dest/stub/ecdsa/index.js",
|
|
16
|
-
"./stub/ecdsa/lazy": "./dest/stub/ecdsa/lazy.js",
|
|
15
|
+
"./schnorr/stub": "./dest/schnorr/stub/index.js",
|
|
16
|
+
"./schnorr/stub/lazy": "./dest/schnorr/stub/lazy.js",
|
|
17
17
|
"./testing": "./dest/testing/index.js",
|
|
18
18
|
"./testing/lazy": "./dest/testing/lazy.js",
|
|
19
|
-
"./copy-cat": "./dest/copy_cat/index.js",
|
|
20
|
-
"./copy-cat/lazy": "./dest/copy_cat/lazy.js",
|
|
21
19
|
"./utils": "./dest/utils/index.js"
|
|
22
20
|
},
|
|
23
21
|
"typedocOptions": {
|
|
@@ -81,11 +79,11 @@
|
|
|
81
79
|
]
|
|
82
80
|
},
|
|
83
81
|
"dependencies": {
|
|
84
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
85
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
86
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
87
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
88
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
+
"@aztec/aztec.js": "0.0.1-commit.321f6a9",
|
|
83
|
+
"@aztec/entrypoints": "0.0.1-commit.321f6a9",
|
|
84
|
+
"@aztec/ethereum": "0.0.1-commit.321f6a9",
|
|
85
|
+
"@aztec/foundation": "0.0.1-commit.321f6a9",
|
|
86
|
+
"@aztec/stdlib": "0.0.1-commit.321f6a9",
|
|
89
87
|
"tslib": "^2.4.0"
|
|
90
88
|
},
|
|
91
89
|
"devDependencies": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Account, type AccountContract, type AuthWitnessProvider, BaseAccount } from '@aztec/aztec.js/account';
|
|
2
2
|
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
5
|
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
6
|
|
|
@@ -22,6 +23,14 @@ export abstract class DefaultAccountContract implements AccountContract {
|
|
|
22
23
|
|
|
23
24
|
constructor() {}
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Accounts without immutables (the default) contribute to their address via an on-chain
|
|
28
|
+
* initializer instead. Account contracts that commit immutables into their address override this.
|
|
29
|
+
*/
|
|
30
|
+
getImmutablesHash(): Promise<Fr | undefined> {
|
|
31
|
+
return Promise.resolve(undefined);
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
getAccount(completeAddress: CompleteAddress): Account {
|
|
26
35
|
const authWitnessProvider = this.getAuthWitnessProvider(completeAddress);
|
|
27
36
|
return new BaseAccount(
|
|
@@ -16,7 +16,7 @@ import { EcdsaKBaseAccountContract } from './account_contract.js';
|
|
|
16
16
|
export async function getEcdsaKAccountContractArtifact() {
|
|
17
17
|
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
18
18
|
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
19
|
-
// Even if now supported by
|
|
19
|
+
// Even if now supported by all major browsers, the MIME type is replaced with
|
|
20
20
|
// "text/javascript"
|
|
21
21
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
22
22
|
const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaKAccount.json');
|
|
@@ -16,7 +16,7 @@ import { EcdsaRBaseAccountContract } from './account_contract.js';
|
|
|
16
16
|
export async function getEcdsaRAccountContractArtifact() {
|
|
17
17
|
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
18
18
|
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
19
|
-
// Even if now supported by
|
|
19
|
+
// Even if now supported by all major browsers, the MIME type is replaced with
|
|
20
20
|
// "text/javascript"
|
|
21
21
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
22
22
|
const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
|
|
@@ -5,7 +5,7 @@ import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
|
5
5
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
6
6
|
|
|
7
7
|
import SimulatedEcdsaAccountJson from '../../../artifacts/SimulatedEcdsaAccount.json' with { type: 'json' };
|
|
8
|
-
import { StubBaseAccountContract } from '
|
|
8
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
9
9
|
|
|
10
10
|
export const StubEcdsaAccountContractArtifact = loadContractArtifact(SimulatedEcdsaAccountJson as NoirCompiledContract);
|
|
11
11
|
|
|
@@ -3,7 +3,7 @@ import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
|
3
3
|
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
4
4
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
5
5
|
|
|
6
|
-
import { StubBaseAccountContract } from '
|
|
6
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Lazily loads the ECDSA stub contract artifact (browser-compatible).
|
|
@@ -14,12 +14,25 @@ import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
|
14
14
|
* can be implemented with or without lazy loading.
|
|
15
15
|
*/
|
|
16
16
|
export abstract class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(protected signingPrivateKey: GrumpkinScalar) {
|
|
18
18
|
super();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/** The Grumpkin public key this account verifies signatures against. */
|
|
22
|
+
getSigningPublicKey() {
|
|
23
|
+
return new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getInitializationFunctionAndArgs(): Promise<
|
|
27
|
+
| {
|
|
28
|
+
/** The name of the function used to initialize the contract */
|
|
29
|
+
constructorName: string;
|
|
30
|
+
/** The args to the function used to initialize the contract */
|
|
31
|
+
constructorArgs: any[];
|
|
32
|
+
}
|
|
33
|
+
| undefined
|
|
34
|
+
> {
|
|
35
|
+
const signingPublicKey = await this.getSigningPublicKey();
|
|
23
36
|
return { constructorName: 'constructor', constructorArgs: [signingPublicKey.x, signingPublicKey.y] };
|
|
24
37
|
}
|
|
25
38
|
|
package/src/schnorr/index.ts
CHANGED
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* This is the suggested account contract type for most use cases within Aztec.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
import { getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
8
|
-
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
9
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
-
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
11
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
13
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
14
|
-
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
15
|
-
|
|
16
|
-
import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' with { type: 'json' };
|
|
17
|
-
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
18
|
-
|
|
19
|
-
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Account contract that authenticates transactions using Schnorr signatures
|
|
23
|
-
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
24
|
-
* Eagerly loads the contract artifact
|
|
25
|
-
*/
|
|
26
|
-
export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
27
|
-
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
28
|
-
super(signingPrivateKey);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
override getContractArtifact(): Promise<ContractArtifact> {
|
|
32
|
-
return Promise.resolve(SchnorrAccountContractArtifact);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Compute the address of a schnorr account contract.
|
|
38
|
-
* @param secret - A seed for deriving the signing key and public keys.
|
|
39
|
-
* @param salt - The contract address salt.
|
|
40
|
-
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
41
|
-
*/
|
|
42
|
-
export async function getSchnorrAccountContractAddress(
|
|
43
|
-
secret: Fr,
|
|
44
|
-
salt: Fr,
|
|
45
|
-
signingPrivateKey?: GrumpkinScalar,
|
|
46
|
-
): Promise<AztecAddress> {
|
|
47
|
-
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
48
|
-
const accountContract = new SchnorrAccountContract(signingKey);
|
|
49
|
-
return await getAccountContractAddress(accountContract, secret, salt);
|
|
50
|
-
}
|
|
1
|
+
export * from './private_immutable/index.js';
|
|
2
|
+
export * from './initializerless/index.js';
|