@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,10 @@
|
|
|
1
|
+
import { type AccountWallet, type AuthWitnessProvider, AztecAddress, CompleteAddress, type NodeInfo } from '@aztec/aztec.js';
|
|
2
|
+
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default implementation for an account interface that uses a dapp entrypoint.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultDappInterface extends DefaultAccountInterface {
|
|
7
|
+
constructor(authWitnessProvider: AuthWitnessProvider, userAddress: CompleteAddress, dappAddress: AztecAddress, nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'protocolVersion'>);
|
|
8
|
+
static createFromUserWallet(wallet: AccountWallet, dappAddress: AztecAddress): DefaultDappInterface;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=dapp_interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dapp_interface.d.ts","sourceRoot":"","sources":["../../src/dapp/dapp_interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,YAAY,EACZ,eAAe,EACf,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,uBAAuB;gBAE7D,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,YAAY,EACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB,CAAC;IAY3D,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,GAAG,oBAAoB;CAMpG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DefaultDappEntrypoint } from '@aztec/entrypoints/dapp';
|
|
2
|
+
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default implementation for an account interface that uses a dapp entrypoint.
|
|
5
|
+
*/ export class DefaultDappInterface extends DefaultAccountInterface {
|
|
6
|
+
constructor(authWitnessProvider, userAddress, dappAddress, nodeInfo){
|
|
7
|
+
super(authWitnessProvider, userAddress, nodeInfo);
|
|
8
|
+
this.entrypoint = new DefaultDappEntrypoint(userAddress.address, authWitnessProvider, dappAddress, nodeInfo.l1ChainId, nodeInfo.protocolVersion);
|
|
9
|
+
}
|
|
10
|
+
static createFromUserWallet(wallet, dappAddress) {
|
|
11
|
+
return new DefaultDappInterface(wallet, wallet.getCompleteAddress(), dappAddress, {
|
|
12
|
+
l1ChainId: wallet.getChainId().toNumber(),
|
|
13
|
+
protocolVersion: wallet.getVersion().toNumber()
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dapp/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dapp_interface.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AccountContract, AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for implementing an account contract. Requires that the account uses the
|
|
6
|
+
* default entrypoint method signature.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class DefaultAccountContract implements AccountContract {
|
|
9
|
+
abstract getAuthWitnessProvider(address: CompleteAddress): AuthWitnessProvider;
|
|
10
|
+
abstract getDeploymentArgs(): Promise<any[] | undefined>;
|
|
11
|
+
abstract getContractArtifact(): Promise<ContractArtifact>;
|
|
12
|
+
constructor();
|
|
13
|
+
getInterface(address: CompleteAddress, nodeInfo: NodeInfo): AccountInterface;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/defaults/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIxE;;;GAGG;AACH,8BAAsB,sBAAuB,YAAW,eAAe;IACrE,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;;IAIzD,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,gBAAgB;CAG7E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for implementing an account contract. Requires that the account uses the
|
|
4
|
+
* default entrypoint method signature.
|
|
5
|
+
*/ export class DefaultAccountContract {
|
|
6
|
+
constructor(){}
|
|
7
|
+
getInterface(address, nodeInfo) {
|
|
8
|
+
return new DefaultAccountInterface(this.getAuthWitnessProvider(address), address, nodeInfo);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { EntrypointInterface, ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
7
|
+
import type { NodeInfo } from '@aztec/stdlib/contract';
|
|
8
|
+
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
9
|
+
/**
|
|
10
|
+
* Default implementation for an account interface. Requires that the account uses the default
|
|
11
|
+
* entrypoint signature, which accept an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
12
|
+
*/
|
|
13
|
+
export declare class DefaultAccountInterface implements AccountInterface {
|
|
14
|
+
private authWitnessProvider;
|
|
15
|
+
private address;
|
|
16
|
+
protected entrypoint: EntrypointInterface;
|
|
17
|
+
private chainId;
|
|
18
|
+
private version;
|
|
19
|
+
constructor(authWitnessProvider: AuthWitnessProvider, address: CompleteAddress, nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'protocolVersion'>);
|
|
20
|
+
createTxExecutionRequest(execution: ExecutionRequestInit): Promise<TxExecutionRequest>;
|
|
21
|
+
createAuthWit(messageHash: Fr): Promise<AuthWitness>;
|
|
22
|
+
getCompleteAddress(): CompleteAddress;
|
|
23
|
+
getAddress(): AztecAddress;
|
|
24
|
+
getChainId(): Fr;
|
|
25
|
+
getVersion(): Fr;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=account_interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account_interface.d.ts","sourceRoot":"","sources":["../../src/defaults/account_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAO5D,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,OAAO;IAPjB,SAAS,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAE1C,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;gBAGV,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,eAAe,EAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB,CAAC;IAY3D,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAItF,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAIpD,kBAAkB,IAAI,eAAe;IAIrC,UAAU,IAAI,YAAY;IAI1B,UAAU,IAAI,EAAE;IAIhB,UAAU,IAAI,EAAE;CAGjB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
/**
|
|
4
|
+
* Default implementation for an account interface. Requires that the account uses the default
|
|
5
|
+
* entrypoint signature, which accept an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
6
|
+
*/ export class DefaultAccountInterface {
|
|
7
|
+
authWitnessProvider;
|
|
8
|
+
address;
|
|
9
|
+
entrypoint;
|
|
10
|
+
chainId;
|
|
11
|
+
version;
|
|
12
|
+
constructor(authWitnessProvider, address, nodeInfo){
|
|
13
|
+
this.authWitnessProvider = authWitnessProvider;
|
|
14
|
+
this.address = address;
|
|
15
|
+
this.entrypoint = new DefaultAccountEntrypoint(address.address, authWitnessProvider, nodeInfo.l1ChainId, nodeInfo.protocolVersion);
|
|
16
|
+
this.chainId = new Fr(nodeInfo.l1ChainId);
|
|
17
|
+
this.version = new Fr(nodeInfo.protocolVersion);
|
|
18
|
+
}
|
|
19
|
+
createTxExecutionRequest(execution) {
|
|
20
|
+
return this.entrypoint.createTxExecutionRequest(execution);
|
|
21
|
+
}
|
|
22
|
+
createAuthWit(messageHash) {
|
|
23
|
+
return this.authWitnessProvider.createAuthWit(messageHash);
|
|
24
|
+
}
|
|
25
|
+
getCompleteAddress() {
|
|
26
|
+
return this.address;
|
|
27
|
+
}
|
|
28
|
+
getAddress() {
|
|
29
|
+
return this.address.address;
|
|
30
|
+
}
|
|
31
|
+
getChainId() {
|
|
32
|
+
return this.chainId;
|
|
33
|
+
}
|
|
34
|
+
getVersion() {
|
|
35
|
+
return this.version;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module.
|
|
3
|
+
*
|
|
4
|
+
* Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export * from './account_interface.js';
|
|
9
|
+
export * from './account_contract.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/defaults/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module.
|
|
3
|
+
*
|
|
4
|
+
* Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/ export * from './account_interface.js';
|
|
8
|
+
export * from './account_contract.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
4
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
6
|
+
/**
|
|
7
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
8
|
+
* verified against a secp256k1 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 EcdsaKBaseAccountContract extends DefaultAccountContract {
|
|
13
|
+
private signingPrivateKey;
|
|
14
|
+
constructor(signingPrivateKey: Buffer);
|
|
15
|
+
getDeploymentArgs(): Promise<Buffer[]>;
|
|
16
|
+
getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_k/account_contract.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,yBAA0B,SAAQ,sBAAsB;IAChE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,MAAM;IAIvC,iBAAiB;IAKvB,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Ecdsa } 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 ECDSA signatures
|
|
6
|
+
* verified against a secp256k1 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 EcdsaKBaseAccountContract extends DefaultAccountContract {
|
|
10
|
+
signingPrivateKey;
|
|
11
|
+
constructor(signingPrivateKey){
|
|
12
|
+
super(), this.signingPrivateKey = signingPrivateKey;
|
|
13
|
+
}
|
|
14
|
+
async getDeploymentArgs() {
|
|
15
|
+
const signingPublicKey = await new Ecdsa().computePublicKey(this.signingPrivateKey);
|
|
16
|
+
return [
|
|
17
|
+
signingPublicKey.subarray(0, 32),
|
|
18
|
+
signingPublicKey.subarray(32, 64)
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
getAuthWitnessProvider(_address) {
|
|
22
|
+
return new EcdsaKAuthWitnessProvider(this.signingPrivateKey);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Creates auth witnesses using ECDSA signatures. */ class EcdsaKAuthWitnessProvider {
|
|
26
|
+
signingPrivateKey;
|
|
27
|
+
constructor(signingPrivateKey){
|
|
28
|
+
this.signingPrivateKey = signingPrivateKey;
|
|
29
|
+
}
|
|
30
|
+
async createAuthWit(messageHash) {
|
|
31
|
+
const ecdsa = new Ecdsa();
|
|
32
|
+
const signature = await ecdsa.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
|
|
33
|
+
return Promise.resolve(new AuthWitness(messageHash, [
|
|
34
|
+
...signature.r,
|
|
35
|
+
...signature.s
|
|
36
|
+
]));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { EcdsaKBaseAccountContract } from './account_contract.js';
|
|
16
|
+
export declare const EcdsaKAccountContractArtifact: ContractArtifact;
|
|
17
|
+
/**
|
|
18
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
19
|
+
* verified against a secp256k1 public key stored in an immutable encrypted note.
|
|
20
|
+
* Eagerly loads the contract artifact
|
|
21
|
+
*/
|
|
22
|
+
export declare class EcdsaKAccountContract extends EcdsaKBaseAccountContract {
|
|
23
|
+
constructor(signingPrivateKey: Buffer);
|
|
24
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
28
|
+
* @param pxe - An PXE server instance.
|
|
29
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
30
|
+
* @param signingPrivateKey - Secp256k1 key used for signing transactions.
|
|
31
|
+
* @param salt - Deployment salt.
|
|
32
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
33
|
+
*/
|
|
34
|
+
export declare function getEcdsaKAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: Buffer, salt?: Salt): Promise<AccountManager>;
|
|
35
|
+
/**
|
|
36
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
37
|
+
* @param pxe - An PXE server instance.
|
|
38
|
+
* @param address - Address for the account.
|
|
39
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
40
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getEcdsaKWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet>;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_k/index.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;AAI3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,6BAA6B,EAAE,gBAE3C,CAAC;AAEF;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB;gBACtD,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AACD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAElH"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 EcdsaKAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert {
|
|
10
|
+
type: 'json'
|
|
11
|
+
};
|
|
12
|
+
import { EcdsaKBaseAccountContract } from './account_contract.js';
|
|
13
|
+
export const EcdsaKAccountContractArtifact = loadContractArtifact(EcdsaKAccountContractJson);
|
|
14
|
+
/**
|
|
15
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
16
|
+
* verified against a secp256k1 public key stored in an immutable encrypted note.
|
|
17
|
+
* Eagerly loads the contract artifact
|
|
18
|
+
*/ export class EcdsaKAccountContract extends EcdsaKBaseAccountContract {
|
|
19
|
+
constructor(signingPrivateKey){
|
|
20
|
+
super(signingPrivateKey);
|
|
21
|
+
}
|
|
22
|
+
getContractArtifact() {
|
|
23
|
+
return Promise.resolve(EcdsaKAccountContractArtifact);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
28
|
+
* @param pxe - An PXE server instance.
|
|
29
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
30
|
+
* @param signingPrivateKey - Secp256k1 key used for signing transactions.
|
|
31
|
+
* @param salt - Deployment salt.
|
|
32
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
33
|
+
*/ export function getEcdsaKAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
34
|
+
return AccountManager.create(pxe, secretKey, new EcdsaKAccountContract(signingPrivateKey), salt);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
38
|
+
* @param pxe - An PXE server instance.
|
|
39
|
+
* @param address - Address for the account.
|
|
40
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
41
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
42
|
+
*/ export function getEcdsaKWallet(pxe, address, signingPrivateKey) {
|
|
43
|
+
return getWallet(pxe, address, new EcdsaKAccountContract(signingPrivateKey));
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { EcdsaKBaseAccountContract } from './account_contract.js';
|
|
16
|
+
/**
|
|
17
|
+
* Lazily loads the contract artifact
|
|
18
|
+
* @returns The contract artifact for the ecdsa K account contract
|
|
19
|
+
*/
|
|
20
|
+
export declare function getEcdsaKAccountContractArtifact(): Promise<ContractArtifact>;
|
|
21
|
+
/**
|
|
22
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
23
|
+
* verified against a secp256k1 public key stored in an immutable encrypted note.
|
|
24
|
+
* Lazily loads the contract artifact
|
|
25
|
+
*/
|
|
26
|
+
export declare class EcdsaKAccountContract extends EcdsaKBaseAccountContract {
|
|
27
|
+
constructor(signingPrivateKey: Buffer);
|
|
28
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
32
|
+
* @param pxe - An PXE server instance.
|
|
33
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
34
|
+
* @param signingPrivateKey - Secp256k1 key used for signing transactions.
|
|
35
|
+
* @param salt - Deployment salt.
|
|
36
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
37
|
+
*/
|
|
38
|
+
export declare function getEcdsaKAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: Buffer, salt?: Salt): Promise<AccountManager>;
|
|
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
|
+
*/
|
|
46
|
+
export declare function getEcdsaKWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet>;
|
|
47
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_k/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,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;GAGG;AACH,wBAAsB,gCAAgC,8BAQrD;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB;gBACtD,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AACD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAElH"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { EcdsaKBaseAccountContract } from './account_contract.js';
|
|
10
|
+
/**
|
|
11
|
+
* Lazily loads the contract artifact
|
|
12
|
+
* @returns The contract artifact for the ecdsa K account contract
|
|
13
|
+
*/ export async function getEcdsaKAccountContractArtifact() {
|
|
14
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
15
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
16
|
+
// Use the new "with" syntax once supported by firefox
|
|
17
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
18
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
|
+
const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaKAccount.json');
|
|
20
|
+
return loadContractArtifact(ecdsaKAccountContractJson);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
24
|
+
* verified against a secp256k1 public key stored in an immutable encrypted note.
|
|
25
|
+
* Lazily loads the contract artifact
|
|
26
|
+
*/ export class EcdsaKAccountContract extends EcdsaKBaseAccountContract {
|
|
27
|
+
constructor(signingPrivateKey){
|
|
28
|
+
super(signingPrivateKey);
|
|
29
|
+
}
|
|
30
|
+
getContractArtifact() {
|
|
31
|
+
return getEcdsaKAccountContractArtifact();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
36
|
+
* @param pxe - An PXE server instance.
|
|
37
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
38
|
+
* @param signingPrivateKey - Secp256k1 key used for signing transactions.
|
|
39
|
+
* @param salt - Deployment salt.
|
|
40
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
41
|
+
*/ export function getEcdsaKAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
42
|
+
return AccountManager.create(pxe, secretKey, new EcdsaKAccountContract(signingPrivateKey), salt);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
46
|
+
* @param pxe - An PXE server instance.
|
|
47
|
+
* @param address - Address for the account.
|
|
48
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
49
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
50
|
+
*/ export function getEcdsaKWallet(pxe, address, signingPrivateKey) {
|
|
51
|
+
return getWallet(pxe, address, new EcdsaKAccountContract(signingPrivateKey));
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecdsa/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ecdsa/lazy.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
4
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
6
|
+
/**
|
|
7
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
8
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
9
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
10
|
+
* public key here not for signature verification, but to identify actual identity
|
|
11
|
+
* that will be used to sign authwitnesses.
|
|
12
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
13
|
+
* can be implemented with or without lazy loading.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class EcdsaRSSHBaseAccountContract extends DefaultAccountContract {
|
|
16
|
+
private signingPublicKey;
|
|
17
|
+
constructor(signingPublicKey: Buffer);
|
|
18
|
+
getDeploymentArgs(): Promise<Buffer[]>;
|
|
19
|
+
getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/account_contract.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAI5E;;;;;;;;GAQG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,MAAM;IAI5C,iBAAiB;IAIjB,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { EcdsaSignature } from '@aztec/foundation/crypto';
|
|
2
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
4
|
+
import { signWithAgent } from '../../utils/ssh_agent.js';
|
|
5
|
+
const secp256r1N = 115792089210356248762697446949407573529996955224135760342422259061068512044369n;
|
|
6
|
+
/**
|
|
7
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
8
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
9
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
10
|
+
* public key here not for signature verification, but to identify actual identity
|
|
11
|
+
* that will be used to sign authwitnesses.
|
|
12
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
13
|
+
* can be implemented with or without lazy loading.
|
|
14
|
+
*/ export class EcdsaRSSHBaseAccountContract extends DefaultAccountContract {
|
|
15
|
+
signingPublicKey;
|
|
16
|
+
constructor(signingPublicKey){
|
|
17
|
+
super(), this.signingPublicKey = signingPublicKey;
|
|
18
|
+
}
|
|
19
|
+
getDeploymentArgs() {
|
|
20
|
+
return Promise.resolve([
|
|
21
|
+
this.signingPublicKey.subarray(0, 32),
|
|
22
|
+
this.signingPublicKey.subarray(32, 64)
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
getAuthWitnessProvider(_address) {
|
|
26
|
+
return new SSHEcdsaRAuthWitnessProvider(this.signingPublicKey);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Creates auth witnesses using ECDSA signatures. */ class SSHEcdsaRAuthWitnessProvider {
|
|
30
|
+
signingPublicKey;
|
|
31
|
+
constructor(signingPublicKey){
|
|
32
|
+
this.signingPublicKey = signingPublicKey;
|
|
33
|
+
}
|
|
34
|
+
#parseECDSASignature(data) {
|
|
35
|
+
// Extract ECDSA signature components
|
|
36
|
+
let offset = 0;
|
|
37
|
+
const sigTypeLen = data.readUInt32BE(offset);
|
|
38
|
+
offset += 4;
|
|
39
|
+
const sigType = data.subarray(offset, offset + sigTypeLen).toString();
|
|
40
|
+
offset += sigTypeLen;
|
|
41
|
+
if (sigType !== 'ecdsa-sha2-nistp256') {
|
|
42
|
+
throw new Error(`Unexpected signature type: ${sigType}`);
|
|
43
|
+
}
|
|
44
|
+
offset += 4;
|
|
45
|
+
const rLen = data.readUInt32BE(offset);
|
|
46
|
+
offset += 4;
|
|
47
|
+
let r = data.subarray(offset, offset + rLen);
|
|
48
|
+
offset += rLen;
|
|
49
|
+
const sLen = data.readUInt32BE(offset);
|
|
50
|
+
offset += 4;
|
|
51
|
+
let s = data.subarray(offset, offset + sLen);
|
|
52
|
+
// R and S are encoded using ASN.1 DER format, which may include a leading zero byte to avoid interpreting the value as negative
|
|
53
|
+
if (r.length > 32) {
|
|
54
|
+
r = Buffer.from(Uint8Array.prototype.slice.call(r, 1));
|
|
55
|
+
}
|
|
56
|
+
if (s.length > 32) {
|
|
57
|
+
s = Buffer.from(Uint8Array.prototype.slice.call(s, 1));
|
|
58
|
+
}
|
|
59
|
+
const maybeHighS = BigInt(`0x${s.toString('hex')}`);
|
|
60
|
+
// ECDSA signatures must have a low S value so they can be used as a nullifier. BB forces a value of 27 for v, so
|
|
61
|
+
// only one PublicKey can verify the signature (and not its negated counterpart) https://ethereum.stackexchange.com/a/55728
|
|
62
|
+
if (maybeHighS > secp256r1N / 2n + 1n) {
|
|
63
|
+
s = Buffer.from((secp256r1N - maybeHighS).toString(16), 'hex');
|
|
64
|
+
}
|
|
65
|
+
return new EcdsaSignature(r, s, Buffer.from([
|
|
66
|
+
0
|
|
67
|
+
]));
|
|
68
|
+
}
|
|
69
|
+
async createAuthWit(messageHash) {
|
|
70
|
+
// Key type and curve name
|
|
71
|
+
const keyType = Buffer.from('ecdsa-sha2-nistp256');
|
|
72
|
+
const curveName = Buffer.from('nistp256');
|
|
73
|
+
const data = await signWithAgent(keyType, curveName, this.signingPublicKey, messageHash.toBuffer());
|
|
74
|
+
const signature = this.#parseECDSASignature(data);
|
|
75
|
+
return new AuthWitness(messageHash, [
|
|
76
|
+
...signature.r,
|
|
77
|
+
...signature.s
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
export declare const EcdsaRAccountContractArtifact: ContractArtifact;
|
|
17
|
+
/**
|
|
18
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
19
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
20
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
21
|
+
* public key here not for signature verification, but to identify actual identity
|
|
22
|
+
* that will be used to sign authwitnesses.
|
|
23
|
+
* Eagerly loads the contract artifact
|
|
24
|
+
*/
|
|
25
|
+
export declare class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
26
|
+
constructor(signingPrivateKey: Buffer);
|
|
27
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
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
|
+
*/
|
|
37
|
+
export declare function getEcdsaRSSHAccount(pxe: PXE, secretKey: Fr, signingPublicKey: Buffer, salt?: Salt): Promise<AccountManager>;
|
|
38
|
+
/**
|
|
39
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
40
|
+
* @param pxe - An PXE server instance.
|
|
41
|
+
* @param address - Address for the account.
|
|
42
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
43
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getEcdsaRSSHWallet(pxe: PXE, address: AztecAddress, signingPublicKey: Buffer): Promise<AccountWallet>;
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/index.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;AAI3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,eAAO,MAAM,6BAA6B,EAAE,gBAE3C,CAAC;AAEF;;;;;;;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"}
|