@aztec/accounts 0.0.0-test.0
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 +41 -0
- package/artifacts/EcdsaKAccount.d.json.ts +3 -0
- package/artifacts/EcdsaKAccount.json +6257 -0
- package/artifacts/EcdsaRAccount.d.json.ts +3 -0
- package/artifacts/EcdsaRAccount.json +6257 -0
- package/artifacts/SchnorrAccount.d.json.ts +3 -0
- package/artifacts/SchnorrAccount.json +6354 -0
- package/artifacts/SchnorrSingleKeyAccount.d.json.ts +3 -0
- package/artifacts/SchnorrSingleKeyAccount.json +3937 -0
- package/dest/dapp/dapp_interface.d.ts +10 -0
- package/dest/dapp/dapp_interface.d.ts.map +1 -0
- package/dest/dapp/dapp_interface.js +16 -0
- package/dest/dapp/index.d.ts +2 -0
- package/dest/dapp/index.d.ts.map +1 -0
- package/dest/dapp/index.js +1 -0
- package/dest/defaults/account_contract.d.ts +15 -0
- package/dest/defaults/account_contract.d.ts.map +1 -0
- package/dest/defaults/account_contract.js +10 -0
- package/dest/defaults/account_interface.d.ts +27 -0
- package/dest/defaults/account_interface.d.ts.map +1 -0
- package/dest/defaults/account_interface.js +37 -0
- package/dest/defaults/index.d.ts +10 -0
- package/dest/defaults/index.d.ts.map +1 -0
- package/dest/defaults/index.js +8 -0
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +18 -0
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/account_contract.js +38 -0
- package/dest/ecdsa/ecdsa_k/index.d.ts +43 -0
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/index.js +44 -0
- package/dest/ecdsa/ecdsa_k/lazy.d.ts +47 -0
- package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/lazy.js +52 -0
- package/dest/ecdsa/index.d.ts +3 -0
- package/dest/ecdsa/index.d.ts.map +1 -0
- package/dest/ecdsa/index.js +2 -0
- package/dest/ecdsa/lazy.d.ts +3 -0
- package/dest/ecdsa/lazy.d.ts.map +1 -0
- package/dest/ecdsa/lazy.js +2 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +21 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +80 -0
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +46 -0
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/index.js +47 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +49 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.js +57 -0
- package/dest/schnorr/account_contract.d.ts +24 -0
- package/dest/schnorr/account_contract.d.ts.map +1 -0
- package/dest/schnorr/account_contract.js +37 -0
- package/dest/schnorr/index.d.ts +57 -0
- package/dest/schnorr/index.d.ts.map +1 -0
- package/dest/schnorr/index.js +66 -0
- package/dest/schnorr/lazy.d.ts +61 -0
- package/dest/schnorr/lazy.d.ts.map +1 -0
- package/dest/schnorr/lazy.js +74 -0
- package/dest/single_key/account_contract.d.ts +17 -0
- package/dest/single_key/account_contract.d.ts.map +1 -0
- package/dest/single_key/account_contract.js +42 -0
- package/dest/single_key/index.d.ts +39 -0
- package/dest/single_key/index.d.ts.map +1 -0
- package/dest/single_key/index.js +45 -0
- package/dest/single_key/lazy.d.ts +43 -0
- package/dest/single_key/lazy.d.ts.map +1 -0
- package/dest/single_key/lazy.js +53 -0
- package/dest/testing/configuration.d.ts +28 -0
- package/dest/testing/configuration.d.ts.map +1 -0
- package/dest/testing/configuration.js +15 -0
- package/dest/testing/create_account.d.ts +43 -0
- package/dest/testing/create_account.d.ts.map +1 -0
- package/dest/testing/create_account.js +58 -0
- package/dest/testing/index.d.ts +35 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +47 -0
- package/dest/testing/lazy.d.ts +34 -0
- package/dest/testing/lazy.d.ts.map +1 -0
- package/dest/testing/lazy.js +46 -0
- package/dest/utils/index.d.ts +2 -0
- package/dest/utils/index.d.ts.map +1 -0
- package/dest/utils/index.js +1 -0
- package/dest/utils/ssh_agent.d.ts +36 -0
- package/dest/utils/ssh_agent.d.ts.map +1 -0
- package/dest/utils/ssh_agent.js +153 -0
- package/package.json +106 -0
- package/src/dapp/dapp_interface.ts +38 -0
- package/src/dapp/index.ts +1 -0
- package/src/defaults/account_contract.ts +21 -0
- package/src/defaults/account_interface.ts +59 -0
- package/src/defaults/index.ts +10 -0
- package/src/ecdsa/ecdsa_k/account_contract.ts +39 -0
- package/src/ecdsa/ecdsa_k/index.ts +63 -0
- package/src/ecdsa/ecdsa_k/lazy.ts +71 -0
- package/src/ecdsa/index.ts +2 -0
- package/src/ecdsa/lazy.ts +2 -0
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +89 -0
- package/src/ecdsa/ssh_ecdsa_r/index.ts +67 -0
- package/src/ecdsa/ssh_ecdsa_r/lazy.ts +78 -0
- package/src/schnorr/account_contract.ts +39 -0
- package/src/schnorr/index.ts +97 -0
- package/src/schnorr/lazy.ts +107 -0
- package/src/single_key/account_contract.ts +43 -0
- package/src/single_key/index.ts +63 -0
- package/src/single_key/lazy.ts +71 -0
- package/src/testing/configuration.ts +39 -0
- package/src/testing/create_account.ts +93 -0
- package/src/testing/index.ts +92 -0
- package/src/testing/lazy.ts +86 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/ssh_agent.ts +136 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
|
|
3
|
+
* Consider using this account type when working with integrations with Ethereum wallets.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/ import { AccountManager } from '@aztec/aztec.js/account';
|
|
7
|
+
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import EcdsaRAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert {
|
|
10
|
+
type: 'json'
|
|
11
|
+
};
|
|
12
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
13
|
+
export const EcdsaRAccountContractArtifact = loadContractArtifact(EcdsaRAccountContractJson);
|
|
14
|
+
/**
|
|
15
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
16
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
17
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
18
|
+
* public key here not for signature verification, but to identify actual identity
|
|
19
|
+
* that will be used to sign authwitnesses.
|
|
20
|
+
* Eagerly loads the contract artifact
|
|
21
|
+
*/ export class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
22
|
+
constructor(signingPrivateKey){
|
|
23
|
+
super(signingPrivateKey);
|
|
24
|
+
}
|
|
25
|
+
getContractArtifact() {
|
|
26
|
+
return Promise.resolve(EcdsaRAccountContractArtifact);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
31
|
+
* @param pxe - An PXE server instance.
|
|
32
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
33
|
+
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
34
|
+
* @param salt - Deployment salt.
|
|
35
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
36
|
+
*/ export function getEcdsaRSSHAccount(pxe, secretKey, signingPublicKey, salt) {
|
|
37
|
+
return AccountManager.create(pxe, secretKey, new EcdsaRSSHAccountContract(signingPublicKey), salt);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
41
|
+
* @param pxe - An PXE server instance.
|
|
42
|
+
* @param address - Address for the account.
|
|
43
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
44
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
45
|
+
*/ export function getEcdsaRSSHWallet(pxe, address, signingPublicKey) {
|
|
46
|
+
return getWallet(pxe, address, new EcdsaRSSHAccountContract(signingPublicKey));
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/**
|
|
4
|
+
* The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
|
|
5
|
+
* Consider using this account type when working with integrations with Ethereum wallets.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
10
|
+
import { type AccountWallet } from '@aztec/aztec.js/wallet';
|
|
11
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
12
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
13
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
15
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare function getEcdsaRAccountContractArtifact(): Promise<ContractArtifact>;
|
|
20
|
+
/**
|
|
21
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
22
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
23
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
24
|
+
* public key here not for signature verification, but to identify actual identity
|
|
25
|
+
* that will be used to sign authwitnesses.
|
|
26
|
+
* Lazily loads the contract artifact
|
|
27
|
+
*/
|
|
28
|
+
export declare class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
29
|
+
constructor(signingPrivateKey: Buffer);
|
|
30
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
34
|
+
* @param pxe - An PXE server instance.
|
|
35
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
36
|
+
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
37
|
+
* @param salt - Deployment salt.
|
|
38
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
39
|
+
*/
|
|
40
|
+
export declare function getEcdsaRSSHAccount(pxe: PXE, secretKey: Fr, signingPublicKey: Buffer, salt?: Salt): Promise<AccountManager>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
43
|
+
* @param pxe - An PXE server instance.
|
|
44
|
+
* @param address - Address for the account.
|
|
45
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
46
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getEcdsaRSSHWallet(pxe: PXE, address: AztecAddress, signingPublicKey: Buffer): Promise<AccountWallet>;
|
|
49
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/lazy.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAMrE;;GAEG;AACH,wBAAsB,gCAAgC,8BAQrD;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
|
|
3
|
+
* Consider using this account type when working with integrations with Ethereum wallets.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/ import { AccountManager } from '@aztec/aztec.js/account';
|
|
7
|
+
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
10
|
+
/*
|
|
11
|
+
* Lazily loads the contract artifact
|
|
12
|
+
* @returns The contract artifact for the ecdsa R account contract
|
|
13
|
+
*/ /**
|
|
14
|
+
*
|
|
15
|
+
*/ export async function getEcdsaRAccountContractArtifact() {
|
|
16
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
17
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
18
|
+
// Use the new "with" syntax once supported by firefox
|
|
19
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
20
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
21
|
+
const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
|
|
22
|
+
return loadContractArtifact(ecdsaKAccountContractJson);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
26
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
27
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
28
|
+
* public key here not for signature verification, but to identify actual identity
|
|
29
|
+
* that will be used to sign authwitnesses.
|
|
30
|
+
* Lazily loads the contract artifact
|
|
31
|
+
*/ export class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
32
|
+
constructor(signingPrivateKey){
|
|
33
|
+
super(signingPrivateKey);
|
|
34
|
+
}
|
|
35
|
+
getContractArtifact() {
|
|
36
|
+
return getEcdsaRAccountContractArtifact();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
41
|
+
* @param pxe - An PXE server instance.
|
|
42
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
43
|
+
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
44
|
+
* @param salt - Deployment salt.
|
|
45
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
46
|
+
*/ export function getEcdsaRSSHAccount(pxe, secretKey, signingPublicKey, salt) {
|
|
47
|
+
return AccountManager.create(pxe, secretKey, new EcdsaRSSHAccountContract(signingPublicKey), salt);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
51
|
+
* @param pxe - An PXE server instance.
|
|
52
|
+
* @param address - Address for the account.
|
|
53
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
54
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
55
|
+
*/ export function getEcdsaRSSHWallet(pxe, address, signingPublicKey) {
|
|
56
|
+
return getWallet(pxe, address, new EcdsaRSSHAccountContract(signingPublicKey));
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
3
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
6
|
+
/**
|
|
7
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
8
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
9
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
10
|
+
* can be implemented with or without lazy loading.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
13
|
+
private signingPrivateKey;
|
|
14
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
15
|
+
getDeploymentArgs(): Promise<Fr[]>;
|
|
16
|
+
getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider;
|
|
17
|
+
}
|
|
18
|
+
/** Creates auth witnesses using Schnorr signatures. */
|
|
19
|
+
export declare class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
|
|
20
|
+
private signingPrivateKey;
|
|
21
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
22
|
+
createAuthWit(messageHash: Fr): Promise<AuthWitness>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/schnorr/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,0BAA2B,SAAQ,sBAAsB;IACjE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAI/C,iBAAiB;IAKvB,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE;AAED,uDAAuD;AACvD,qBAAa,0BAA2B,YAAW,mBAAmB;IACxD,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAE/C,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;CAK3D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Schnorr } from '@aztec/foundation/crypto';
|
|
2
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
4
|
+
/**
|
|
5
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
6
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
7
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
8
|
+
* can be implemented with or without lazy loading.
|
|
9
|
+
*/ export class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
10
|
+
signingPrivateKey;
|
|
11
|
+
constructor(signingPrivateKey){
|
|
12
|
+
super(), this.signingPrivateKey = signingPrivateKey;
|
|
13
|
+
}
|
|
14
|
+
async getDeploymentArgs() {
|
|
15
|
+
const signingPublicKey = await new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
16
|
+
return [
|
|
17
|
+
signingPublicKey.x,
|
|
18
|
+
signingPublicKey.y
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
getAuthWitnessProvider(_address) {
|
|
22
|
+
return new SchnorrAuthWitnessProvider(this.signingPrivateKey);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Creates auth witnesses using Schnorr signatures. */ export class SchnorrAuthWitnessProvider {
|
|
26
|
+
signingPrivateKey;
|
|
27
|
+
constructor(signingPrivateKey){
|
|
28
|
+
this.signingPrivateKey = signingPrivateKey;
|
|
29
|
+
}
|
|
30
|
+
async createAuthWit(messageHash) {
|
|
31
|
+
const schnorr = new Schnorr();
|
|
32
|
+
const signature = await schnorr.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
|
|
33
|
+
return new AuthWitness(messageHash, [
|
|
34
|
+
...signature.toBuffer()
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
8
|
+
import { type AccountWallet, type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
14
|
+
export declare const SchnorrAccountContractArtifact: ContractArtifact;
|
|
15
|
+
/**
|
|
16
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
17
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
18
|
+
* Eagerly loads the contract artifact
|
|
19
|
+
*/
|
|
20
|
+
export declare class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
21
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
22
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
26
|
+
* @param pxe - An PXE server instance.
|
|
27
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
28
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
29
|
+
* @param salt - Deployment salt.
|
|
30
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
31
|
+
*/
|
|
32
|
+
export declare function getSchnorrAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt?: Salt): Promise<AccountManager>;
|
|
33
|
+
/**
|
|
34
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
35
|
+
* @param pxe - An PXE server instance.
|
|
36
|
+
* @param address - Address for the account.
|
|
37
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
38
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
43
|
+
* @param pxe - An PXE server instance.
|
|
44
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
45
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
46
|
+
* @param salt - Deployment salt.
|
|
47
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSchnorrWalletWithSecretKey(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt: Salt): Promise<AccountWalletWithSecretKey>;
|
|
50
|
+
/**
|
|
51
|
+
* Compute the address of a schnorr account contract.
|
|
52
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
53
|
+
* @param salt - The contract address salt.
|
|
54
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSchnorrAccountContractAddress(secret: Fr, salt: Fr, signingPrivateKey?: GrumpkinScalar): Promise<AztecAddress>;
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schnorr/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAA6B,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,0BAA0B,EAAa,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAK3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,eAAO,MAAM,8BAA8B,kBAA2E,CAAC;AAEvH;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,0BAA0B;gBACxD,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,0BAA0B,CAAC,CAGrC;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,CAAC,EAAE,cAAc,yBAI9G"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { AccountManager, getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
7
|
+
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
|
+
import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' assert {
|
|
11
|
+
type: 'json'
|
|
12
|
+
};
|
|
13
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
14
|
+
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson);
|
|
15
|
+
/**
|
|
16
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
17
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
18
|
+
* Eagerly loads the contract artifact
|
|
19
|
+
*/ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
20
|
+
constructor(signingPrivateKey){
|
|
21
|
+
super(signingPrivateKey);
|
|
22
|
+
}
|
|
23
|
+
getContractArtifact() {
|
|
24
|
+
return Promise.resolve(SchnorrAccountContractArtifact);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
29
|
+
* @param pxe - An PXE server instance.
|
|
30
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
31
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
32
|
+
* @param salt - Deployment salt.
|
|
33
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
34
|
+
*/ export function getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
35
|
+
return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
39
|
+
* @param pxe - An PXE server instance.
|
|
40
|
+
* @param address - Address for the account.
|
|
41
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
42
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
43
|
+
*/ export function getSchnorrWallet(pxe, address, signingPrivateKey) {
|
|
44
|
+
return getWallet(pxe, address, new SchnorrAccountContract(signingPrivateKey));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
48
|
+
* @param pxe - An PXE server instance.
|
|
49
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
50
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
51
|
+
* @param salt - Deployment salt.
|
|
52
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
53
|
+
*/ export async function getSchnorrWalletWithSecretKey(pxe, secretKey, signingPrivateKey, salt) {
|
|
54
|
+
const account = await getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt);
|
|
55
|
+
return account.getWallet();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Compute the address of a schnorr account contract.
|
|
59
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
60
|
+
* @param salt - The contract address salt.
|
|
61
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
62
|
+
*/ export async function getSchnorrAccountContractAddress(secret, salt, signingPrivateKey) {
|
|
63
|
+
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
64
|
+
const accountContract = new SchnorrAccountContract(signingKey);
|
|
65
|
+
return await getAccountContractAddress(accountContract, secret, salt);
|
|
66
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
8
|
+
import { type AccountWallet, type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
14
|
+
/**
|
|
15
|
+
* Lazily loads the contract artifact
|
|
16
|
+
* @returns The contract artifact for the schnorr account contract
|
|
17
|
+
*/
|
|
18
|
+
export declare function getSchnorrAccountContractArtifact(): Promise<ContractArtifact>;
|
|
19
|
+
/**
|
|
20
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
21
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
22
|
+
* Lazily loads the contract artifact
|
|
23
|
+
*/
|
|
24
|
+
export declare class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
25
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
26
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
30
|
+
* @param pxe - An PXE server instance.
|
|
31
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
32
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
33
|
+
* @param salt - Deployment salt.
|
|
34
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
35
|
+
*/
|
|
36
|
+
export declare function getSchnorrAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt?: Salt): Promise<AccountManager>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
39
|
+
* @param pxe - An PXE server instance.
|
|
40
|
+
* @param address - Address for the account.
|
|
41
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
42
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
47
|
+
* @param pxe - An PXE server instance.
|
|
48
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
49
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
50
|
+
* @param salt - Deployment salt.
|
|
51
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getSchnorrWalletWithSecretKey(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt: Salt): Promise<AccountWalletWithSecretKey>;
|
|
54
|
+
/**
|
|
55
|
+
* Compute the address of a schnorr account contract.
|
|
56
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
57
|
+
* @param salt - The contract address salt.
|
|
58
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getSchnorrAccountContractAddress(secret: Fr, salt: Fr, signingPrivateKey?: GrumpkinScalar): Promise<AztecAddress>;
|
|
61
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/schnorr/lazy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAA6B,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,0BAA0B,EAAa,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAG3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE;;;GAGG;AACH,wBAAsB,iCAAiC,8BAQtD;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,0BAA0B;gBACxD,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,0BAA0B,CAAC,CAGrC;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,CAAC,EAAE,cAAc,yBAI9G"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { AccountManager, getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
7
|
+
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
11
|
+
/**
|
|
12
|
+
* Lazily loads the contract artifact
|
|
13
|
+
* @returns The contract artifact for the schnorr account contract
|
|
14
|
+
*/ export async function getSchnorrAccountContractArtifact() {
|
|
15
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
16
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
17
|
+
// Use the new "with" syntax once supported by firefox
|
|
18
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
19
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
20
|
+
const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
|
|
21
|
+
return loadContractArtifact(schnorrAccountContractJson);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
25
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
26
|
+
* Lazily loads the contract artifact
|
|
27
|
+
*/ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
28
|
+
constructor(signingPrivateKey){
|
|
29
|
+
super(signingPrivateKey);
|
|
30
|
+
}
|
|
31
|
+
getContractArtifact() {
|
|
32
|
+
return getSchnorrAccountContractArtifact();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
37
|
+
* @param pxe - An PXE server instance.
|
|
38
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
39
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
40
|
+
* @param salt - Deployment salt.
|
|
41
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
42
|
+
*/ export function getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
43
|
+
return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
47
|
+
* @param pxe - An PXE server instance.
|
|
48
|
+
* @param address - Address for the account.
|
|
49
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
50
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
51
|
+
*/ export function getSchnorrWallet(pxe, address, signingPrivateKey) {
|
|
52
|
+
return getWallet(pxe, address, new SchnorrAccountContract(signingPrivateKey));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
56
|
+
* @param pxe - An PXE server instance.
|
|
57
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
58
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
59
|
+
* @param salt - Deployment salt.
|
|
60
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
61
|
+
*/ export async function getSchnorrWalletWithSecretKey(pxe, secretKey, signingPrivateKey, salt) {
|
|
62
|
+
const account = await getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt);
|
|
63
|
+
return account.getWallet();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compute the address of a schnorr account contract.
|
|
67
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
68
|
+
* @param salt - The contract address salt.
|
|
69
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
70
|
+
*/ export async function getSchnorrAccountContractAddress(secret, salt, signingPrivateKey) {
|
|
71
|
+
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
72
|
+
const accountContract = new SchnorrAccountContract(signingKey);
|
|
73
|
+
return await getAccountContractAddress(accountContract, secret, salt);
|
|
74
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/fields';
|
|
3
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
+
import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
5
|
+
/**
|
|
6
|
+
* Account contract that authenticates transactions using Schnorr signatures verified against
|
|
7
|
+
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
8
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
9
|
+
* can be implemented with or without lazy loading.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class SingleKeyBaseAccountContract extends DefaultAccountContract {
|
|
12
|
+
private encryptionPrivateKey;
|
|
13
|
+
constructor(encryptionPrivateKey: GrumpkinScalar);
|
|
14
|
+
getDeploymentArgs(): Promise<undefined>;
|
|
15
|
+
getAuthWitnessProvider(account: CompleteAddress): AuthWitnessProvider;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/single_key/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAW,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,oBAAoB;gBAApB,oBAAoB,EAAE,cAAc;IAIxD,iBAAiB;IAIjB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;CAGtE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Schnorr } from '@aztec/foundation/crypto';
|
|
2
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
4
|
+
/**
|
|
5
|
+
* Account contract that authenticates transactions using Schnorr signatures verified against
|
|
6
|
+
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
7
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
8
|
+
* can be implemented with or without lazy loading.
|
|
9
|
+
*/ export class SingleKeyBaseAccountContract extends DefaultAccountContract {
|
|
10
|
+
encryptionPrivateKey;
|
|
11
|
+
constructor(encryptionPrivateKey){
|
|
12
|
+
super(), this.encryptionPrivateKey = encryptionPrivateKey;
|
|
13
|
+
}
|
|
14
|
+
getDeploymentArgs() {
|
|
15
|
+
return Promise.resolve(undefined);
|
|
16
|
+
}
|
|
17
|
+
getAuthWitnessProvider(account) {
|
|
18
|
+
return new SingleKeyAuthWitnessProvider(this.encryptionPrivateKey, account);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates auth witnesses using Schnorr signatures and including the partial address and public key
|
|
23
|
+
* in the witness, so verifiers do not need to store the public key and can instead validate it
|
|
24
|
+
* by reconstructing the current address.
|
|
25
|
+
*/ class SingleKeyAuthWitnessProvider {
|
|
26
|
+
privateKey;
|
|
27
|
+
account;
|
|
28
|
+
constructor(privateKey, account){
|
|
29
|
+
this.privateKey = privateKey;
|
|
30
|
+
this.account = account;
|
|
31
|
+
}
|
|
32
|
+
async createAuthWit(messageHash) {
|
|
33
|
+
const schnorr = new Schnorr();
|
|
34
|
+
const signature = await schnorr.constructSignature(messageHash.toBuffer(), this.privateKey);
|
|
35
|
+
const witness = [
|
|
36
|
+
...this.account.publicKeys.toFields(),
|
|
37
|
+
...signature.toBuffer(),
|
|
38
|
+
this.account.partialAddress
|
|
39
|
+
];
|
|
40
|
+
return Promise.resolve(new AuthWitness(messageHash, witness));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/single_key` export provides a testing account contract implementation that uses a single Grumpkin key for both authentication and encryption.
|
|
3
|
+
* It is not recommended to use this account type in production.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { AztecAddress, Fr, GrumpkinScalar } from '@aztec/aztec.js';
|
|
8
|
+
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
9
|
+
import { type AccountWallet } from '@aztec/aztec.js/wallet';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
12
|
+
import { SingleKeyBaseAccountContract } from './account_contract.js';
|
|
13
|
+
export declare const SchnorrSingleKeyAccountContractArtifact: ContractArtifact;
|
|
14
|
+
/**
|
|
15
|
+
* Account contract that authenticates transactions using Schnorr signatures verified against
|
|
16
|
+
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
17
|
+
* Eagerly loads the contract artifact
|
|
18
|
+
*/
|
|
19
|
+
export declare class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
|
|
20
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
21
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an Account that uses the same Grumpkin key for encryption and authentication.
|
|
25
|
+
* @param pxe - An PXE server instance.
|
|
26
|
+
* @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
|
|
27
|
+
* @param salt - Deployment salt.
|
|
28
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
29
|
+
*/
|
|
30
|
+
export declare function getUnsafeSchnorrAccount(pxe: PXE, secretKey: Fr, salt?: Salt): Promise<AccountManager>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
|
|
33
|
+
* @param pxe - An PXE server instance.
|
|
34
|
+
* @param address - Address for the account.
|
|
35
|
+
* @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
|
|
36
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getUnsafeSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/single_key/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAK3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,eAAO,MAAM,uCAAuC,kBAEnD,CAAC;AAEF;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,2BAG3E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB"}
|