@aztec/accounts 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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/README.md +1 -2
- package/artifacts/EcdsaKAccount.json +10501 -4885
- package/artifacts/EcdsaRAccount.json +10521 -4905
- package/artifacts/SchnorrAccount.json +10632 -5192
- package/artifacts/SchnorrInitializerlessAccount.json +8526 -0
- package/artifacts/SimulatedEcdsaAccount.json +10976 -0
- package/artifacts/SimulatedSchnorrAccount.d.json.ts +3 -0
- package/artifacts/SimulatedSchnorrAccount.json +11088 -0
- package/dest/defaults/account_contract.d.ts +9 -3
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +11 -3
- package/dest/defaults/index.d.ts +1 -2
- package/dest/defaults/index.d.ts.map +1 -1
- package/dest/defaults/index.js +1 -2
- package/dest/{stub/account_contract.d.ts → defaults/stub_account_contract.d.ts} +2 -2
- package/dest/defaults/stub_account_contract.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +7 -3
- package/dest/ecdsa/ecdsa_k/lazy.js +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.js +7 -3
- package/dest/ecdsa/ecdsa_r/lazy.js +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +7 -3
- package/dest/ecdsa/stub/index.d.ts +11 -0
- package/dest/ecdsa/stub/index.d.ts.map +1 -0
- package/dest/ecdsa/stub/index.js +18 -0
- package/dest/ecdsa/stub/lazy.d.ts +14 -0
- package/dest/ecdsa/stub/lazy.d.ts.map +1 -0
- package/dest/ecdsa/stub/lazy.js +22 -0
- package/dest/schnorr/account_contract.d.ts +10 -5
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +7 -6
- package/dest/schnorr/index.d.ts +3 -22
- 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 -26
- 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/schnorr/stub/index.d.ts +11 -0
- package/dest/schnorr/stub/index.d.ts.map +1 -0
- package/dest/schnorr/stub/index.js +18 -0
- package/dest/schnorr/stub/lazy.d.ts +14 -0
- package/dest/schnorr/stub/lazy.d.ts.map +1 -0
- package/dest/schnorr/stub/lazy.js +22 -0
- package/dest/testing/configuration.d.ts +13 -4
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +7 -3
- 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/dest/utils/ssh_agent.d.ts +1 -1
- package/dest/utils/ssh_agent.d.ts.map +1 -1
- package/dest/utils/ssh_agent.js +2 -0
- package/package.json +12 -15
- package/src/defaults/account_contract.ts +18 -5
- package/src/defaults/index.ts +0 -1
- package/src/{stub/account_contract.ts → defaults/stub_account_contract.ts} +1 -1
- package/src/ecdsa/ecdsa_k/account_contract.ts +3 -3
- package/src/ecdsa/ecdsa_k/lazy.ts +1 -1
- package/src/ecdsa/ecdsa_r/account_contract.ts +3 -3
- package/src/ecdsa/ecdsa_r/lazy.ts +1 -1
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +3 -3
- package/src/ecdsa/stub/index.ts +28 -0
- package/src/ecdsa/stub/lazy.ts +34 -0
- package/src/schnorr/account_contract.ts +21 -7
- package/src/schnorr/index.ts +2 -49
- package/src/schnorr/initializerless/index.ts +62 -0
- package/src/schnorr/initializerless/lazy.ts +70 -0
- package/src/schnorr/lazy.ts +2 -59
- package/src/schnorr/private_immutable/index.ts +50 -0
- package/src/schnorr/private_immutable/lazy.ts +60 -0
- package/src/schnorr/stub/index.ts +30 -0
- package/src/schnorr/stub/lazy.ts +34 -0
- package/src/testing/configuration.ts +17 -3
- 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/src/utils/ssh_agent.ts +2 -0
- package/artifacts/SchnorrSingleKeyAccount.json +0 -4679
- package/artifacts/SimulatedAccount.json +0 -4623
- package/dest/defaults/account_interface.d.ts +0 -28
- package/dest/defaults/account_interface.d.ts.map +0 -1
- package/dest/defaults/account_interface.js +0 -36
- package/dest/single_key/account_contract.d.ts +0 -17
- package/dest/single_key/account_contract.d.ts.map +0 -1
- package/dest/single_key/account_contract.js +0 -42
- package/dest/single_key/index.d.ts +0 -20
- package/dest/single_key/index.d.ts.map +0 -1
- package/dest/single_key/index.js +0 -23
- package/dest/single_key/lazy.d.ts +0 -24
- package/dest/single_key/lazy.d.ts.map +0 -1
- package/dest/single_key/lazy.js +0 -31
- package/dest/stub/account_contract.d.ts.map +0 -1
- package/dest/stub/index.d.ts +0 -21
- package/dest/stub/index.d.ts.map +0 -1
- package/dest/stub/index.js +0 -29
- package/dest/stub/lazy.d.ts +0 -23
- package/dest/stub/lazy.d.ts.map +0 -1
- package/dest/stub/lazy.js +0 -35
- package/src/defaults/account_interface.ts +0 -63
- package/src/single_key/account_contract.ts +0 -46
- package/src/single_key/index.ts +0 -32
- package/src/single_key/lazy.ts +0 -40
- package/src/stub/index.ts +0 -41
- package/src/stub/lazy.ts +0 -49
- /package/artifacts/{SchnorrSingleKeyAccount.d.json.ts → SchnorrInitializerlessAccount.d.json.ts} +0 -0
- /package/artifacts/{SimulatedAccount.d.json.ts → SimulatedEcdsaAccount.d.json.ts} +0 -0
- /package/dest/{stub/account_contract.js → defaults/stub_account_contract.js} +0 -0
|
@@ -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
|
+
}
|
|
@@ -30,4 +30,4 @@ export declare function getIdentities(): Promise<StoredKey[]>;
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function signWithAgent(keyType: Buffer, curveName: Buffer, publicKey: Buffer, data: Buffer): Promise<Buffer<ArrayBufferLike>>;
|
|
32
32
|
export {};
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3NoX2FnZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvc3NoX2FnZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFDaEMsT0FBTyxHQUFHLE1BQU0sS0FBSyxDQUFDO0FBT3RCOztHQUVHO0FBQ0gsd0JBQWdCLGNBQWMsZUFNN0I7QUFFRDs7R0FFRztBQUNILEtBQUssU0FBUyxHQUFHO0lBQ2Y7O09BRUc7SUFDSCxJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2I7O09BRUc7SUFDSCxTQUFTLEVBQUUsTUFBTSxDQUFDO0lBQ2xCOztPQUVHO0lBQ0gsT0FBTyxFQUFFLE1BQU0sQ0FBQztDQUNqQixDQUFDO0FBRUY7O0dBRUc7QUFDSCx3QkFBZ0IsYUFBYSxJQUFJLE9BQU8sQ0FBQyxTQUFTLEVBQUUsQ0FBQyxDQW1EcEQ7QUFFRDs7R0FFRztBQUNILHdCQUFnQixhQUFhLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLE1BQU0sb0NBeUNoRyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh_agent.d.ts","sourceRoot":"","sources":["../../src/utils/ssh_agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AAOtB;;GAEG;AACH,wBAAgB,cAAc,eAM7B;AAED;;GAEG;AACH,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"ssh_agent.d.ts","sourceRoot":"","sources":["../../src/utils/ssh_agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AAOtB;;GAEG;AACH,wBAAgB,cAAc,eAM7B;AAED;;GAEG;AACH,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAmDpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oCAyChG"}
|
package/dest/utils/ssh_agent.js
CHANGED
|
@@ -18,6 +18,7 @@ const SSH_AGENT_SIGN_RESPONSE = 14;
|
|
|
18
18
|
*/ export function getIdentities() {
|
|
19
19
|
return new Promise((resolve, reject)=>{
|
|
20
20
|
const stream = connectToAgent();
|
|
21
|
+
stream.on('error', reject);
|
|
21
22
|
stream.on('connect', ()=>{
|
|
22
23
|
const request = Buffer.concat([
|
|
23
24
|
Buffer.from([
|
|
@@ -78,6 +79,7 @@ const SSH_AGENT_SIGN_RESPONSE = 14;
|
|
|
78
79
|
*/ export function signWithAgent(keyType, curveName, publicKey, data) {
|
|
79
80
|
return new Promise((resolve, reject)=>{
|
|
80
81
|
const stream = connectToAgent();
|
|
82
|
+
stream.on('error', reject);
|
|
81
83
|
stream.on('connect', ()=>{
|
|
82
84
|
// Construct the key blob
|
|
83
85
|
const keyBlob = Buffer.concat([
|
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.d58ff9d0",
|
|
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
|
-
"./
|
|
14
|
-
"./
|
|
15
|
-
"./stub": "./dest/stub/index.js",
|
|
16
|
-
"./stub/lazy": "./dest/stub/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": {
|
|
@@ -25,7 +23,6 @@
|
|
|
25
23
|
"./src/defaults/index.ts",
|
|
26
24
|
"./src/ecdsa/index.ts",
|
|
27
25
|
"./src/schnorr/index.ts",
|
|
28
|
-
"./src/single_key/index.ts",
|
|
29
26
|
"./src/testing/index.ts"
|
|
30
27
|
],
|
|
31
28
|
"name": "Accounts",
|
|
@@ -36,7 +33,7 @@
|
|
|
36
33
|
"generate": "yarn generate:noir-contracts",
|
|
37
34
|
"generate:noir-contracts": "./scripts/copy-contracts.sh",
|
|
38
35
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
39
|
-
"build:ts": "
|
|
36
|
+
"build:ts": "../scripts/tsc.sh",
|
|
40
37
|
"clean": "rm -rf ./dest .tsbuildinfo ./artifacts",
|
|
41
38
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
42
39
|
},
|
|
@@ -82,18 +79,18 @@
|
|
|
82
79
|
]
|
|
83
80
|
},
|
|
84
81
|
"dependencies": {
|
|
85
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
86
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
87
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
88
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
89
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
+
"@aztec/aztec.js": "0.0.1-commit.d58ff9d0",
|
|
83
|
+
"@aztec/entrypoints": "0.0.1-commit.d58ff9d0",
|
|
84
|
+
"@aztec/ethereum": "0.0.1-commit.d58ff9d0",
|
|
85
|
+
"@aztec/foundation": "0.0.1-commit.d58ff9d0",
|
|
86
|
+
"@aztec/stdlib": "0.0.1-commit.d58ff9d0",
|
|
90
87
|
"tslib": "^2.4.0"
|
|
91
88
|
},
|
|
92
89
|
"devDependencies": {
|
|
93
90
|
"@jest/globals": "^30.0.0",
|
|
94
91
|
"@types/jest": "^30.0.0",
|
|
95
92
|
"@types/node": "^22.15.17",
|
|
96
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
93
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
97
94
|
"jest": "^30.0.0",
|
|
98
95
|
"jest-mock-extended": "^4.0.0",
|
|
99
96
|
"ts-loader": "^9.5.4",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Account, type AccountContract, type AuthWitnessProvider, BaseAccount } from '@aztec/aztec.js/account';
|
|
2
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
3
5
|
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
6
|
|
|
5
|
-
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
6
|
-
|
|
7
7
|
/**
|
|
8
8
|
* Base class for implementing an account contract. Requires that the account uses the
|
|
9
9
|
* default entrypoint method signature.
|
|
@@ -23,7 +23,20 @@ export abstract class DefaultAccountContract implements AccountContract {
|
|
|
23
23
|
|
|
24
24
|
constructor() {}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
|
|
34
|
+
getAccount(completeAddress: CompleteAddress): Account {
|
|
35
|
+
const authWitnessProvider = this.getAuthWitnessProvider(completeAddress);
|
|
36
|
+
return new BaseAccount(
|
|
37
|
+
new DefaultAccountEntrypoint(completeAddress.address, authWitnessProvider),
|
|
38
|
+
authWitnessProvider,
|
|
39
|
+
completeAddress,
|
|
40
|
+
);
|
|
28
41
|
}
|
|
29
42
|
}
|
package/src/defaults/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
4
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { Ecdsa } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Ecdsa } from '@aztec/foundation/crypto/ecdsa';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
5
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@ export abstract class EcdsaKBaseAccountContract extends DefaultAccountContract {
|
|
|
21
21
|
const signingPublicKey = await new Ecdsa().computePublicKey(this.signingPrivateKey);
|
|
22
22
|
return {
|
|
23
23
|
constructorName: 'constructor',
|
|
24
|
-
constructorArgs: [signingPublicKey.subarray(0, 32), signingPublicKey.subarray(32, 64)],
|
|
24
|
+
constructorArgs: [[...signingPublicKey.subarray(0, 32)], [...signingPublicKey.subarray(32, 64)]],
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -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');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { Ecdsa } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Ecdsa } from '@aztec/foundation/crypto/ecdsa';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
5
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@ export abstract class EcdsaRBaseAccountContract extends DefaultAccountContract {
|
|
|
21
21
|
const signingPublicKey = await new Ecdsa('secp256r1').computePublicKey(this.signingPrivateKey);
|
|
22
22
|
return {
|
|
23
23
|
constructorName: 'constructor',
|
|
24
|
-
constructorArgs: [signingPublicKey.subarray(0, 32), signingPublicKey.subarray(32, 64)],
|
|
24
|
+
constructorArgs: [[...signingPublicKey.subarray(0, 32)], [...signingPublicKey.subarray(32, 64)]],
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -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');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { EcdsaSignature } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import { EcdsaSignature } from '@aztec/foundation/crypto/ecdsa';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
5
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ export abstract class EcdsaRSSHBaseAccountContract extends DefaultAccountContrac
|
|
|
25
25
|
getInitializationFunctionAndArgs() {
|
|
26
26
|
return Promise.resolve({
|
|
27
27
|
constructorName: 'constructor',
|
|
28
|
-
constructorArgs: [this.signingPublicKey.subarray(0, 32), this.signingPublicKey.subarray(32, 64)],
|
|
28
|
+
constructorArgs: [[...this.signingPublicKey.subarray(0, 32)], [...this.signingPublicKey.subarray(32, 64)]],
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
4
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
5
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
6
|
+
|
|
7
|
+
import SimulatedEcdsaAccountJson from '../../../artifacts/SimulatedEcdsaAccount.json' with { type: 'json' };
|
|
8
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
9
|
+
|
|
10
|
+
export const StubEcdsaAccountContractArtifact = loadContractArtifact(SimulatedEcdsaAccountJson as NoirCompiledContract);
|
|
11
|
+
|
|
12
|
+
/** Stub account contract for ECDSA accounts (secp256k1 and secp256r1). Eagerly loads the contract artifact. */
|
|
13
|
+
export class StubEcdsaAccountContract extends StubBaseAccountContract {
|
|
14
|
+
override getContractArtifact() {
|
|
15
|
+
return Promise.resolve(StubEcdsaAccountContractArtifact);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Creates an ECDSA stub account that impersonates the one with the provided address. */
|
|
20
|
+
export function createStubEcdsaAccount(originalAddress: CompleteAddress) {
|
|
21
|
+
const accountContract = new StubEcdsaAccountContract();
|
|
22
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
23
|
+
return new BaseAccount(
|
|
24
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
25
|
+
authWitnessProvider,
|
|
26
|
+
originalAddress,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
4
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
5
|
+
|
|
6
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Lazily loads the ECDSA stub contract artifact (browser-compatible).
|
|
10
|
+
*/
|
|
11
|
+
export async function getStubEcdsaAccountContractArtifact() {
|
|
12
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
13
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
14
|
+
const { default: json } = await import('../../../artifacts/SimulatedEcdsaAccount.json');
|
|
15
|
+
return loadContractArtifact(json);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Stub account contract for ECDSA accounts (secp256k1 and secp256r1). Lazily loads the contract artifact. */
|
|
19
|
+
export class StubEcdsaAccountContract extends StubBaseAccountContract {
|
|
20
|
+
override getContractArtifact() {
|
|
21
|
+
return getStubEcdsaAccountContractArtifact();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Creates an ECDSA stub account that impersonates the one with the provided address. */
|
|
26
|
+
export function createStubEcdsaAccount(originalAddress: CompleteAddress) {
|
|
27
|
+
const accountContract = new StubEcdsaAccountContract();
|
|
28
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
29
|
+
return new BaseAccount(
|
|
30
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
31
|
+
authWitnessProvider,
|
|
32
|
+
originalAddress,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { Schnorr } from '@aztec/foundation/crypto';
|
|
3
|
-
import { Fr
|
|
2
|
+
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
6
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
7
|
|
|
@@ -13,12 +14,25 @@ import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
|
13
14
|
* can be implemented with or without lazy loading.
|
|
14
15
|
*/
|
|
15
16
|
export abstract class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
16
|
-
constructor(
|
|
17
|
+
constructor(protected signingPrivateKey: GrumpkinScalar) {
|
|
17
18
|
super();
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
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();
|
|
22
36
|
return { constructorName: 'constructor', constructorArgs: [signingPublicKey.x, signingPublicKey.y] };
|
|
23
37
|
}
|
|
24
38
|
|
|
@@ -33,7 +47,7 @@ export class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
|
|
|
33
47
|
|
|
34
48
|
async createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
35
49
|
const schnorr = new Schnorr();
|
|
36
|
-
const signature = await schnorr.constructSignature(messageHash
|
|
37
|
-
return new AuthWitness(messageHash,
|
|
50
|
+
const signature = await schnorr.constructSignature(messageHash, this.signingPrivateKey);
|
|
51
|
+
return new AuthWitness(messageHash, signature.toLimbFields());
|
|
38
52
|
}
|
|
39
53
|
}
|
package/src/schnorr/index.ts
CHANGED
|
@@ -1,49 +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, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
10
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
13
|
-
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
14
|
-
|
|
15
|
-
import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' with { type: 'json' };
|
|
16
|
-
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
17
|
-
|
|
18
|
-
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Account contract that authenticates transactions using Schnorr signatures
|
|
22
|
-
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
23
|
-
* Eagerly loads the contract artifact
|
|
24
|
-
*/
|
|
25
|
-
export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
26
|
-
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
27
|
-
super(signingPrivateKey);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override getContractArtifact(): Promise<ContractArtifact> {
|
|
31
|
-
return Promise.resolve(SchnorrAccountContractArtifact);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Compute the address of a schnorr account contract.
|
|
37
|
-
* @param secret - A seed for deriving the signing key and public keys.
|
|
38
|
-
* @param salt - The contract address salt.
|
|
39
|
-
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
40
|
-
*/
|
|
41
|
-
export async function getSchnorrAccountContractAddress(
|
|
42
|
-
secret: Fr,
|
|
43
|
-
salt: Fr,
|
|
44
|
-
signingPrivateKey?: GrumpkinScalar,
|
|
45
|
-
): Promise<AztecAddress> {
|
|
46
|
-
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
47
|
-
const accountContract = new SchnorrAccountContract(signingKey);
|
|
48
|
-
return await getAccountContractAddress(accountContract, secret, salt);
|
|
49
|
-
}
|
|
1
|
+
export * from './private_immutable/index.js';
|
|
2
|
+
export * from './initializerless/index.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
*/
|
|
7
|
+
import { getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
8
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
9
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
12
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
13
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
14
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
15
|
+
|
|
16
|
+
import SchnorrInitializerlessAccountContractJson from '../../../artifacts/SchnorrInitializerlessAccount.json' with { type: 'json' };
|
|
17
|
+
import { deriveSecretKeyFromSigningKey } from '../../utils/key_derivation.js';
|
|
18
|
+
import { SchnorrBaseAccountContract } from '../account_contract.js';
|
|
19
|
+
|
|
20
|
+
export const SchnorrInitializerlessAccountContractArtifact = loadContractArtifact(
|
|
21
|
+
SchnorrInitializerlessAccountContractJson as NoirCompiledContract,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
26
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
27
|
+
* Eagerly loads the contract artifact
|
|
28
|
+
*/
|
|
29
|
+
export class SchnorrInitializerlessAccountContract extends SchnorrBaseAccountContract {
|
|
30
|
+
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
31
|
+
super(signingPrivateKey);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override getInitializationFunctionAndArgs() {
|
|
35
|
+
return Promise.resolve(undefined);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override async getImmutablesHash(): Promise<Fr> {
|
|
39
|
+
const signingPublicKey = await this.getSigningPublicKey();
|
|
40
|
+
return poseidon2Hash([signingPublicKey.x, signingPublicKey.y]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
44
|
+
return Promise.resolve(SchnorrInitializerlessAccountContractArtifact);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Compute the address of a schnorr account contract.
|
|
50
|
+
* @param signingPrivateKey - The account's signing private key.
|
|
51
|
+
* @param salt - The contract address salt.
|
|
52
|
+
* @param secretKey - Seed for the account's privacy keys. Derived from the signing key when omitted.
|
|
53
|
+
*/
|
|
54
|
+
export async function getSchnorrInitializerlessAccountContractAddress(
|
|
55
|
+
signingPrivateKey: GrumpkinScalar,
|
|
56
|
+
salt: Fr,
|
|
57
|
+
secretKey?: Fr,
|
|
58
|
+
): Promise<AztecAddress> {
|
|
59
|
+
const resolvedSecretKey = secretKey ?? (await deriveSecretKeyFromSigningKey(signingPrivateKey));
|
|
60
|
+
const accountContract = new SchnorrInitializerlessAccountContract(signingPrivateKey);
|
|
61
|
+
return await getAccountContractAddress(accountContract, resolvedSecretKey, salt);
|
|
62
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
*/
|
|
7
|
+
import { getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
8
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
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 type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
+
|
|
15
|
+
import { deriveSecretKeyFromSigningKey } from '../../utils/key_derivation.js';
|
|
16
|
+
import { SchnorrBaseAccountContract } from '../account_contract.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Lazily loads the contract artifact
|
|
20
|
+
* @returns The contract artifact for the schnorr account contract
|
|
21
|
+
*/
|
|
22
|
+
export async function getSchnorrInitializerlessAccountContractArtifact() {
|
|
23
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
24
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
25
|
+
// Even if now supported by all major browsers, the MIME type is replaced with
|
|
26
|
+
// "text/javascript"
|
|
27
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
28
|
+
const { default: schnorrAccountContractJson } = await import('../../../artifacts/SchnorrInitializerlessAccount.json');
|
|
29
|
+
return loadContractArtifact(schnorrAccountContractJson);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
34
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
35
|
+
* Lazily loads the contract artifact
|
|
36
|
+
*/
|
|
37
|
+
export class SchnorrInitializerlessAccountContract extends SchnorrBaseAccountContract {
|
|
38
|
+
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
39
|
+
super(signingPrivateKey);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override getInitializationFunctionAndArgs() {
|
|
43
|
+
return Promise.resolve(undefined);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override async getImmutablesHash(): Promise<Fr> {
|
|
47
|
+
const signingPublicKey = await this.getSigningPublicKey();
|
|
48
|
+
return poseidon2Hash([signingPublicKey.x, signingPublicKey.y]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
52
|
+
return getSchnorrInitializerlessAccountContractArtifact();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Compute the address of a schnorr account contract.
|
|
58
|
+
* @param signingPrivateKey - The account's signing private key.
|
|
59
|
+
* @param salt - The contract address salt.
|
|
60
|
+
* @param secretKey - Seed for the account's privacy keys. Derived from the signing key when omitted.
|
|
61
|
+
*/
|
|
62
|
+
export async function getSchnorrInitializerlessAccountContractAddress(
|
|
63
|
+
signingPrivateKey: GrumpkinScalar,
|
|
64
|
+
salt: Fr,
|
|
65
|
+
secretKey?: Fr,
|
|
66
|
+
): Promise<AztecAddress> {
|
|
67
|
+
const resolvedSecretKey = secretKey ?? (await deriveSecretKeyFromSigningKey(signingPrivateKey));
|
|
68
|
+
const accountContract = new SchnorrInitializerlessAccountContract(signingPrivateKey);
|
|
69
|
+
return await getAccountContractAddress(accountContract, resolvedSecretKey, salt);
|
|
70
|
+
}
|
package/src/schnorr/lazy.ts
CHANGED
|
@@ -1,59 +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 { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
9
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
10
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
13
|
-
|
|
14
|
-
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Lazily loads the contract artifact
|
|
18
|
-
* @returns The contract artifact for the schnorr account contract
|
|
19
|
-
*/
|
|
20
|
-
export async function getSchnorrAccountContractArtifact() {
|
|
21
|
-
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
22
|
-
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
23
|
-
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
24
|
-
// "text/javascript"
|
|
25
|
-
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
26
|
-
const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
|
|
27
|
-
return loadContractArtifact(schnorrAccountContractJson);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Account contract that authenticates transactions using Schnorr signatures
|
|
32
|
-
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
33
|
-
* Lazily loads the contract artifact
|
|
34
|
-
*/
|
|
35
|
-
export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
36
|
-
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
37
|
-
super(signingPrivateKey);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
override getContractArtifact(): Promise<ContractArtifact> {
|
|
41
|
-
return getSchnorrAccountContractArtifact();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Compute the address of a schnorr account contract.
|
|
47
|
-
* @param secret - A seed for deriving the signing key and public keys.
|
|
48
|
-
* @param salt - The contract address salt.
|
|
49
|
-
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
50
|
-
*/
|
|
51
|
-
export async function getSchnorrAccountContractAddress(
|
|
52
|
-
secret: Fr,
|
|
53
|
-
salt: Fr,
|
|
54
|
-
signingPrivateKey?: GrumpkinScalar,
|
|
55
|
-
): Promise<AztecAddress> {
|
|
56
|
-
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
57
|
-
const accountContract = new SchnorrAccountContract(signingKey);
|
|
58
|
-
return await getAccountContractAddress(accountContract, secret, salt);
|
|
59
|
-
}
|
|
1
|
+
export * from './private_immutable/lazy.js';
|
|
2
|
+
export * from './initializerless/lazy.js';
|