@aztec/accounts 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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 +0 -1
- package/artifacts/EcdsaKAccount.json +7999 -2080
- package/artifacts/EcdsaRAccount.json +7999 -2080
- package/artifacts/SchnorrAccount.json +7912 -2027
- package/artifacts/SchnorrInitializerlessAccount.json +8526 -0
- package/artifacts/SimulatedEcdsaAccount.json +10972 -0
- package/artifacts/SimulatedSchnorrAccount.d.json.ts +3 -0
- package/artifacts/SimulatedSchnorrAccount.json +11084 -0
- 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/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +6 -2
- 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 +6 -2
- 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 +6 -2
- 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 +8 -4
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +6 -5
- 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/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 +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/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 +10 -13
- package/src/defaults/account_contract.ts +9 -0
- package/src/ecdsa/ecdsa_k/account_contract.ts +1 -1
- package/src/ecdsa/ecdsa_k/lazy.ts +1 -1
- package/src/ecdsa/ecdsa_r/account_contract.ts +1 -1
- package/src/ecdsa/ecdsa_r/lazy.ts +1 -1
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +1 -1
- package/src/ecdsa/stub/index.ts +28 -0
- package/src/ecdsa/stub/lazy.ts +34 -0
- package/src/schnorr/account_contract.ts +18 -5
- 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/schnorr/stub/index.ts +30 -0
- package/src/schnorr/stub/lazy.ts +34 -0
- 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/src/utils/ssh_agent.ts +2 -0
- package/artifacts/SchnorrSingleKeyAccount.json +0 -4716
- package/artifacts/SimulatedAccount.json +0 -4496
- 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 -20
- package/dest/stub/index.d.ts.map +0 -1
- package/dest/stub/index.js +0 -28
- package/dest/stub/lazy.d.ts +0 -25
- package/dest/stub/lazy.d.ts.map +0 -1
- package/dest/stub/lazy.js +0 -37
- package/src/single_key/account_contract.ts +0 -47
- package/src/single_key/index.ts +0 -32
- package/src/single_key/lazy.ts +0 -40
- package/src/stub/index.ts +0 -40
- package/src/stub/lazy.ts +0 -51
- /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
- /package/src/{stub/account_contract.ts → defaults/stub_account_contract.ts} +0 -0
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.f5a9928",
|
|
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",
|
|
@@ -82,11 +79,11 @@
|
|
|
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.f5a9928",
|
|
83
|
+
"@aztec/entrypoints": "0.0.1-commit.f5a9928",
|
|
84
|
+
"@aztec/ethereum": "0.0.1-commit.f5a9928",
|
|
85
|
+
"@aztec/foundation": "0.0.1-commit.f5a9928",
|
|
86
|
+
"@aztec/stdlib": "0.0.1-commit.f5a9928",
|
|
90
87
|
"tslib": "^2.4.0"
|
|
91
88
|
},
|
|
92
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(
|
|
@@ -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');
|
|
@@ -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');
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
|
@@ -34,7 +47,7 @@ export class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
|
|
|
34
47
|
|
|
35
48
|
async createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
36
49
|
const schnorr = new Schnorr();
|
|
37
|
-
const signature = await schnorr.constructSignature(messageHash
|
|
38
|
-
return new AuthWitness(messageHash,
|
|
50
|
+
const signature = await schnorr.constructSignature(messageHash, this.signingPrivateKey);
|
|
51
|
+
return new AuthWitness(messageHash, signature.toLimbFields());
|
|
39
52
|
}
|
|
40
53
|
}
|
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';
|
|
@@ -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,60 +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 } from '@aztec/foundation/curves/bn254';
|
|
9
|
-
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
10
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
14
|
-
|
|
15
|
-
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Lazily loads the contract artifact
|
|
19
|
-
* @returns The contract artifact for the schnorr account contract
|
|
20
|
-
*/
|
|
21
|
-
export async function getSchnorrAccountContractArtifact() {
|
|
22
|
-
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
23
|
-
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
24
|
-
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
25
|
-
// "text/javascript"
|
|
26
|
-
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
27
|
-
const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
|
|
28
|
-
return loadContractArtifact(schnorrAccountContractJson);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Account contract that authenticates transactions using Schnorr signatures
|
|
33
|
-
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
34
|
-
* Lazily loads the contract artifact
|
|
35
|
-
*/
|
|
36
|
-
export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
37
|
-
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
38
|
-
super(signingPrivateKey);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
override getContractArtifact(): Promise<ContractArtifact> {
|
|
42
|
-
return getSchnorrAccountContractArtifact();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Compute the address of a schnorr account contract.
|
|
48
|
-
* @param secret - A seed for deriving the signing key and public keys.
|
|
49
|
-
* @param salt - The contract address salt.
|
|
50
|
-
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
51
|
-
*/
|
|
52
|
-
export async function getSchnorrAccountContractAddress(
|
|
53
|
-
secret: Fr,
|
|
54
|
-
salt: Fr,
|
|
55
|
-
signingPrivateKey?: GrumpkinScalar,
|
|
56
|
-
): Promise<AztecAddress> {
|
|
57
|
-
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
58
|
-
const accountContract = new SchnorrAccountContract(signingKey);
|
|
59
|
-
return await getAccountContractAddress(accountContract, secret, salt);
|
|
60
|
-
}
|
|
1
|
+
export * from './private_immutable/lazy.js';
|
|
2
|
+
export * from './initializerless/lazy.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { 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 { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
14
|
+
|
|
15
|
+
import SchnorrAccountContractJson from '../../../artifacts/SchnorrAccount.json' with { type: 'json' };
|
|
16
|
+
import { deriveSecretKeyFromSigningKey } from '../../utils/key_derivation.js';
|
|
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 signingPrivateKey - The account's signing private key.
|
|
39
|
+
* @param salt - The contract address salt.
|
|
40
|
+
* @param secretKey - Seed for the account's privacy keys. Derived from the signing key when omitted.
|
|
41
|
+
*/
|
|
42
|
+
export async function getSchnorrAccountContractAddress(
|
|
43
|
+
signingPrivateKey: GrumpkinScalar,
|
|
44
|
+
salt: Fr,
|
|
45
|
+
secretKey?: Fr,
|
|
46
|
+
): Promise<AztecAddress> {
|
|
47
|
+
const resolvedSecretKey = secretKey ?? (await deriveSecretKeyFromSigningKey(signingPrivateKey));
|
|
48
|
+
const accountContract = new SchnorrAccountContract(signingPrivateKey);
|
|
49
|
+
return await getAccountContractAddress(accountContract, resolvedSecretKey, salt);
|
|
50
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
+
|
|
14
|
+
import { deriveSecretKeyFromSigningKey } from '../../utils/key_derivation.js';
|
|
15
|
+
import { SchnorrBaseAccountContract } from '../account_contract.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Lazily loads the contract artifact
|
|
19
|
+
* @returns The contract artifact for the schnorr account contract
|
|
20
|
+
*/
|
|
21
|
+
export async function getSchnorrAccountContractArtifact() {
|
|
22
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
23
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
24
|
+
// Even if now supported by all major browsers, the MIME type is replaced with
|
|
25
|
+
// "text/javascript"
|
|
26
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
27
|
+
const { default: schnorrAccountContractJson } = await import('../../../artifacts/SchnorrAccount.json');
|
|
28
|
+
return loadContractArtifact(schnorrAccountContractJson);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
33
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
34
|
+
* Lazily loads the contract artifact
|
|
35
|
+
*/
|
|
36
|
+
export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
37
|
+
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
38
|
+
super(signingPrivateKey);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
42
|
+
return getSchnorrAccountContractArtifact();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Compute the address of a schnorr account contract.
|
|
48
|
+
* @param signingPrivateKey - The account's signing private key.
|
|
49
|
+
* @param salt - The contract address salt.
|
|
50
|
+
* @param secretKey - Seed for the account's privacy keys. Derived from the signing key when omitted.
|
|
51
|
+
*/
|
|
52
|
+
export async function getSchnorrAccountContractAddress(
|
|
53
|
+
signingPrivateKey: GrumpkinScalar,
|
|
54
|
+
salt: Fr,
|
|
55
|
+
secretKey?: Fr,
|
|
56
|
+
): Promise<AztecAddress> {
|
|
57
|
+
const resolvedSecretKey = secretKey ?? (await deriveSecretKeyFromSigningKey(signingPrivateKey));
|
|
58
|
+
const accountContract = new SchnorrAccountContract(signingPrivateKey);
|
|
59
|
+
return await getAccountContractAddress(accountContract, resolvedSecretKey, salt);
|
|
60
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 SimulatedSchnorrAccountJson from '../../../artifacts/SimulatedSchnorrAccount.json' with { type: 'json' };
|
|
8
|
+
import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
|
|
9
|
+
|
|
10
|
+
export const StubSchnorrAccountContractArtifact = loadContractArtifact(
|
|
11
|
+
SimulatedSchnorrAccountJson as NoirCompiledContract,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
/** Stub account contract for Schnorr accounts. Eagerly loads the contract artifact. */
|
|
15
|
+
export class StubSchnorrAccountContract extends StubBaseAccountContract {
|
|
16
|
+
override getContractArtifact() {
|
|
17
|
+
return Promise.resolve(StubSchnorrAccountContractArtifact);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Creates a Schnorr stub account that impersonates the one with the provided address. */
|
|
22
|
+
export function createStubSchnorrAccount(originalAddress: CompleteAddress) {
|
|
23
|
+
const accountContract = new StubSchnorrAccountContract();
|
|
24
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
25
|
+
return new BaseAccount(
|
|
26
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
27
|
+
authWitnessProvider,
|
|
28
|
+
originalAddress,
|
|
29
|
+
);
|
|
30
|
+
}
|