@aztec/aztec.js 0.1.0-alpha62 → 0.6.2
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/.tsbuildinfo +1 -1
- package/dest/abis/ecdsa_account_contract.json +3 -3
- package/dest/abis/schnorr_account_contract.json +3 -3
- package/dest/abis/schnorr_auth_witness_account_contract.json +3 -3
- package/dest/abis/schnorr_single_key_account_contract.json +2 -2
- package/dest/account/account.d.ts +2 -2
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +1 -1
- package/dest/account/contract/auth_witness_account_contract.d.ts +2 -2
- package/dest/account/contract/auth_witness_account_contract.d.ts.map +1 -1
- package/dest/account/contract/auth_witness_account_contract.js +1 -1
- package/dest/account/contract/ecdsa_account_contract.d.ts +2 -2
- package/dest/account/contract/ecdsa_account_contract.d.ts.map +1 -1
- package/dest/account/contract/ecdsa_account_contract.js +4 -2
- package/dest/account/contract/schnorr_account_contract.d.ts +2 -2
- package/dest/account/contract/schnorr_account_contract.d.ts.map +1 -1
- package/dest/account/contract/schnorr_account_contract.js +4 -2
- package/dest/account/contract/single_key_account_contract.d.ts +2 -2
- package/dest/account/contract/single_key_account_contract.d.ts.map +1 -1
- package/dest/account/contract/single_key_account_contract.js +3 -4
- package/dest/account/entrypoint/auth_witness_account_entrypoint.d.ts +3 -3
- package/dest/account/entrypoint/auth_witness_account_entrypoint.d.ts.map +1 -1
- package/dest/account/entrypoint/auth_witness_account_entrypoint.js +1 -1
- package/dest/account/entrypoint/single_key_account_entrypoint.d.ts +2 -4
- package/dest/account/entrypoint/single_key_account_entrypoint.d.ts.map +1 -1
- package/dest/account/entrypoint/single_key_account_entrypoint.js +5 -4
- package/dest/account/entrypoint/stored_key_account_entrypoint.d.ts +5 -5
- package/dest/account/entrypoint/stored_key_account_entrypoint.d.ts.map +1 -1
- package/dest/account/entrypoint/stored_key_account_entrypoint.js +4 -5
- package/dest/account/index.d.ts +6 -5
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -1
- package/dest/aztec_rpc_client/aztec_rpc_client.js +3 -3
- package/dest/aztec_rpc_client/wallet.d.ts +2 -2
- package/dest/aztec_rpc_client/wallet.d.ts.map +1 -1
- package/dest/aztec_rpc_client/wallet.js +1 -1
- package/dest/index.d.ts +4 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -3
- package/dest/main.js +1 -1
- package/dest/sandbox/index.d.ts +4 -4
- package/dest/sandbox/index.d.ts.map +1 -1
- package/dest/sandbox/index.js +5 -5
- package/dest/utils/account.d.ts +3 -3
- package/dest/utils/account.d.ts.map +1 -1
- package/dest/utils/account.js +7 -5
- package/dest/utils/pub_key.d.ts +2 -2
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -1
- package/package.json +4 -4
- package/src/abis/ecdsa_account_contract.json +3 -3
- package/src/abis/schnorr_account_contract.json +3 -3
- package/src/abis/schnorr_auth_witness_account_contract.json +3 -3
- package/src/abis/schnorr_single_key_account_contract.json +2 -2
- package/src/account/account.ts +2 -2
- package/src/account/contract/auth_witness_account_contract.ts +2 -2
- package/src/account/contract/ecdsa_account_contract.ts +5 -3
- package/src/account/contract/schnorr_account_contract.ts +5 -3
- package/src/account/contract/single_key_account_contract.ts +5 -11
- package/src/account/entrypoint/auth_witness_account_entrypoint.ts +4 -4
- package/src/account/entrypoint/single_key_account_entrypoint.ts +5 -5
- package/src/account/entrypoint/stored_key_account_entrypoint.ts +4 -5
- package/src/account/index.ts +7 -7
- package/src/aztec_rpc_client/aztec_rpc_client.ts +2 -2
- package/src/aztec_rpc_client/wallet.ts +2 -2
- package/src/index.ts +4 -3
- package/src/sandbox/index.ts +4 -4
- package/src/utils/account.ts +11 -15
- package/src/utils/pub_key.ts +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schnorr } from '@aztec/circuits.js/barretenberg';
|
|
2
2
|
import { ContractAbi } from '@aztec/foundation/abi';
|
|
3
|
-
import { CompleteAddress,
|
|
3
|
+
import { CompleteAddress, GrumpkinPrivateKey, NodeInfo } from '@aztec/types';
|
|
4
4
|
|
|
5
5
|
import SchnorrAccountContractAbi from '../../abis/schnorr_account_contract.json' assert { type: 'json' };
|
|
6
6
|
import { StoredKeyAccountEntrypoint } from '../entrypoint/stored_key_account_entrypoint.js';
|
|
@@ -11,7 +11,7 @@ import { AccountContract } from './index.js';
|
|
|
11
11
|
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
12
12
|
*/
|
|
13
13
|
export class SchnorrAccountContract implements AccountContract {
|
|
14
|
-
constructor(private signingPrivateKey:
|
|
14
|
+
constructor(private signingPrivateKey: GrumpkinPrivateKey) {}
|
|
15
15
|
|
|
16
16
|
public async getDeploymentArgs() {
|
|
17
17
|
const signingPublicKey = await Schnorr.new().then(e => e.computePublicKey(this.signingPrivateKey));
|
|
@@ -19,7 +19,9 @@ export class SchnorrAccountContract implements AccountContract {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
public async getEntrypoint({ address }: CompleteAddress, { chainId, version }: NodeInfo) {
|
|
22
|
-
|
|
22
|
+
const schnorr = await Schnorr.new();
|
|
23
|
+
const signClosure = (msg: Buffer) => schnorr.constructSignature(msg, this.signingPrivateKey);
|
|
24
|
+
return new StoredKeyAccountEntrypoint(address, signClosure, chainId, version);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
public getContractAbi(): ContractAbi {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Schnorr } from '@aztec/circuits.js/barretenberg';
|
|
2
1
|
import { ContractAbi } from '@aztec/foundation/abi';
|
|
3
|
-
import { CompleteAddress,
|
|
2
|
+
import { CompleteAddress, GrumpkinPrivateKey, NodeInfo } from '@aztec/types';
|
|
4
3
|
|
|
5
4
|
import SchnorrSingleKeyAccountContractAbi from '../../abis/schnorr_single_key_account_contract.json' assert { type: 'json' };
|
|
6
5
|
import { SingleKeyAccountEntrypoint } from '../entrypoint/single_key_account_entrypoint.js';
|
|
@@ -11,20 +10,15 @@ import { AccountContract } from './index.js';
|
|
|
11
10
|
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
12
11
|
*/
|
|
13
12
|
export class SingleKeyAccountContract implements AccountContract {
|
|
14
|
-
constructor(private encryptionPrivateKey:
|
|
13
|
+
constructor(private encryptionPrivateKey: GrumpkinPrivateKey) {}
|
|
15
14
|
|
|
16
15
|
public getDeploymentArgs() {
|
|
17
16
|
return Promise.resolve([]);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
public
|
|
21
|
-
return
|
|
22
|
-
address,
|
|
23
|
-
partialAddress,
|
|
24
|
-
this.encryptionPrivateKey,
|
|
25
|
-
await Schnorr.new(),
|
|
26
|
-
chainId,
|
|
27
|
-
version,
|
|
19
|
+
public getEntrypoint({ address, partialAddress }: CompleteAddress, { chainId, version }: NodeInfo) {
|
|
20
|
+
return Promise.resolve(
|
|
21
|
+
new SingleKeyAccountEntrypoint(address, partialAddress, this.encryptionPrivateKey, chainId, version),
|
|
28
22
|
);
|
|
29
23
|
}
|
|
30
24
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AztecAddress, Fr, FunctionData,
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress, Fr, FunctionData, GrumpkinPrivateKey, PartialAddress, TxContext } from '@aztec/circuits.js';
|
|
2
|
+
import { Schnorr } from '@aztec/circuits.js/barretenberg';
|
|
3
3
|
import { ContractAbi, FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
|
|
4
4
|
import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/types';
|
|
5
5
|
|
|
@@ -19,8 +19,8 @@ export class AuthWitnessAccountEntrypoint implements Entrypoint {
|
|
|
19
19
|
constructor(
|
|
20
20
|
private address: AztecAddress,
|
|
21
21
|
private partialAddress: PartialAddress,
|
|
22
|
-
private privateKey:
|
|
23
|
-
private signer:
|
|
22
|
+
private privateKey: GrumpkinPrivateKey,
|
|
23
|
+
private signer: Schnorr,
|
|
24
24
|
private chainId: number = DEFAULT_CHAIN_ID,
|
|
25
25
|
private version: number = DEFAULT_VERSION,
|
|
26
26
|
) {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AztecAddress, FunctionData,
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress, FunctionData, GrumpkinPrivateKey, PartialAddress, TxContext } from '@aztec/circuits.js';
|
|
2
|
+
import { Schnorr } from '@aztec/circuits.js/barretenberg';
|
|
3
3
|
import { ContractAbi, encodeArguments } from '@aztec/foundation/abi';
|
|
4
4
|
import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/types';
|
|
5
5
|
|
|
@@ -18,8 +18,7 @@ export class SingleKeyAccountEntrypoint implements Entrypoint {
|
|
|
18
18
|
constructor(
|
|
19
19
|
private address: AztecAddress,
|
|
20
20
|
private partialAddress: PartialAddress,
|
|
21
|
-
private privateKey:
|
|
22
|
-
private signer: Signer,
|
|
21
|
+
private privateKey: GrumpkinPrivateKey,
|
|
23
22
|
private chainId: number = DEFAULT_CHAIN_ID,
|
|
24
23
|
private version: number = DEFAULT_VERSION,
|
|
25
24
|
) {}
|
|
@@ -35,7 +34,8 @@ export class SingleKeyAccountEntrypoint implements Entrypoint {
|
|
|
35
34
|
const { payload, packedArguments: callsPackedArguments } = await buildPayload(executions);
|
|
36
35
|
const message = await hashPayload(payload);
|
|
37
36
|
|
|
38
|
-
const
|
|
37
|
+
const signer = await Schnorr.new();
|
|
38
|
+
const signature = signer.constructSignature(message, this.privateKey).toBuffer();
|
|
39
39
|
const publicKey = await generatePublicKey(this.privateKey);
|
|
40
40
|
const args = [payload, publicKey.toBuffer(), signature, this.partialAddress];
|
|
41
41
|
const abi = this.getEntrypointAbi();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AztecAddress, FunctionData,
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress, FunctionData, TxContext } from '@aztec/circuits.js';
|
|
2
|
+
import { Signature } from '@aztec/circuits.js/barretenberg';
|
|
3
3
|
import { ContractAbi, encodeArguments } from '@aztec/foundation/abi';
|
|
4
4
|
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/types';
|
|
@@ -18,8 +18,7 @@ export class StoredKeyAccountEntrypoint implements Entrypoint {
|
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
20
|
private address: AztecAddress,
|
|
21
|
-
private
|
|
22
|
-
private signer: Signer,
|
|
21
|
+
private sign: (msg: Buffer) => Signature,
|
|
23
22
|
private chainId: number = DEFAULT_CHAIN_ID,
|
|
24
23
|
private version: number = DEFAULT_VERSION,
|
|
25
24
|
) {
|
|
@@ -36,7 +35,7 @@ export class StoredKeyAccountEntrypoint implements Entrypoint {
|
|
|
36
35
|
|
|
37
36
|
const { payload, packedArguments: callsPackedArguments } = await buildPayload(executions);
|
|
38
37
|
const message = await hashPayload(payload);
|
|
39
|
-
const signature = this.
|
|
38
|
+
const signature = this.sign(message).toBuffer();
|
|
40
39
|
this.log(`Signed challenge ${message.toString('hex')} as ${signature.toString('hex')}`);
|
|
41
40
|
|
|
42
41
|
const args = [payload, signature];
|
package/src/account/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AztecRPC, CompleteAddress,
|
|
1
|
+
import { AztecRPC, CompleteAddress, GrumpkinPrivateKey } from '@aztec/types';
|
|
2
2
|
|
|
3
3
|
import { AccountContract, AccountWallet, AztecAddress, Fr } from '../index.js';
|
|
4
4
|
import { Account } from './account.js';
|
|
@@ -23,8 +23,8 @@ export type Salt = Fr | number | bigint;
|
|
|
23
23
|
*/
|
|
24
24
|
export function getEcdsaAccount(
|
|
25
25
|
rpc: AztecRPC,
|
|
26
|
-
encryptionPrivateKey:
|
|
27
|
-
signingPrivateKey:
|
|
26
|
+
encryptionPrivateKey: GrumpkinPrivateKey,
|
|
27
|
+
signingPrivateKey: Buffer,
|
|
28
28
|
saltOrAddress?: Salt | CompleteAddress,
|
|
29
29
|
): Account {
|
|
30
30
|
return new Account(rpc, encryptionPrivateKey, new EcdsaAccountContract(signingPrivateKey), saltOrAddress);
|
|
@@ -39,8 +39,8 @@ export function getEcdsaAccount(
|
|
|
39
39
|
*/
|
|
40
40
|
export function getSchnorrAccount(
|
|
41
41
|
rpc: AztecRPC,
|
|
42
|
-
encryptionPrivateKey:
|
|
43
|
-
signingPrivateKey:
|
|
42
|
+
encryptionPrivateKey: GrumpkinPrivateKey,
|
|
43
|
+
signingPrivateKey: GrumpkinPrivateKey,
|
|
44
44
|
saltOrAddress?: Salt | CompleteAddress,
|
|
45
45
|
): Account {
|
|
46
46
|
return new Account(rpc, encryptionPrivateKey, new SchnorrAccountContract(signingPrivateKey), saltOrAddress);
|
|
@@ -54,7 +54,7 @@ export function getSchnorrAccount(
|
|
|
54
54
|
*/
|
|
55
55
|
export function getUnsafeSchnorrAccount(
|
|
56
56
|
rpc: AztecRPC,
|
|
57
|
-
encryptionAndSigningPrivateKey:
|
|
57
|
+
encryptionAndSigningPrivateKey: GrumpkinPrivateKey,
|
|
58
58
|
saltOrAddress?: Salt | CompleteAddress,
|
|
59
59
|
): Account {
|
|
60
60
|
return new Account(
|
|
@@ -75,7 +75,7 @@ export function getUnsafeSchnorrAccount(
|
|
|
75
75
|
export function getUnsafeSchnorrWallet(
|
|
76
76
|
rpc: AztecRPC,
|
|
77
77
|
address: AztecAddress,
|
|
78
|
-
signingKey:
|
|
78
|
+
signingKey: GrumpkinPrivateKey,
|
|
79
79
|
): Promise<AccountWallet> {
|
|
80
80
|
return getWallet(rpc, address, new SingleKeyAccountContract(signingKey));
|
|
81
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AztecAddress, CompleteAddress, EthAddress, Fr,
|
|
1
|
+
import { AztecAddress, CompleteAddress, EthAddress, Fr, GrumpkinScalar, Point } from '@aztec/circuits.js';
|
|
2
2
|
import { createJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
|
|
3
3
|
import {
|
|
4
4
|
AztecRPC,
|
|
@@ -26,8 +26,8 @@ export const createAztecRpcClient = (url: string, fetch = defaultFetch): AztecRP
|
|
|
26
26
|
TxHash,
|
|
27
27
|
EthAddress,
|
|
28
28
|
Point,
|
|
29
|
-
PrivateKey,
|
|
30
29
|
Fr,
|
|
30
|
+
GrumpkinScalar,
|
|
31
31
|
NotePreimage,
|
|
32
32
|
},
|
|
33
33
|
{ Tx, TxReceipt, L2BlockL2Logs },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AztecAddress, CircuitsWasm, Fr,
|
|
1
|
+
import { AztecAddress, CircuitsWasm, Fr, GrumpkinPrivateKey, PartialAddress, TxContext } from '@aztec/circuits.js';
|
|
2
2
|
import {
|
|
3
3
|
AztecRPC,
|
|
4
4
|
ContractData,
|
|
@@ -32,7 +32,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
32
32
|
|
|
33
33
|
abstract createTxExecutionRequest(execs: FunctionCall[], opts?: CreateTxRequestOpts): Promise<TxExecutionRequest>;
|
|
34
34
|
|
|
35
|
-
registerAccount(privKey:
|
|
35
|
+
registerAccount(privKey: GrumpkinPrivateKey, partialAddress: PartialAddress): Promise<void> {
|
|
36
36
|
return this.rpc.registerAccount(privKey, partialAddress);
|
|
37
37
|
}
|
|
38
38
|
registerRecipient(account: CompleteAddress): Promise<void> {
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from './account/index.js';
|
|
|
6
6
|
export * from './contract_deployer/deploy_method.js';
|
|
7
7
|
export * from './sandbox/index.js';
|
|
8
8
|
|
|
9
|
-
export { AztecAddress, EthAddress, Point, Fr } from '@aztec/circuits.js';
|
|
9
|
+
export { AztecAddress, EthAddress, Point, Fr, GrumpkinScalar } from '@aztec/circuits.js';
|
|
10
10
|
export {
|
|
11
11
|
AztecRPC,
|
|
12
12
|
ContractData,
|
|
@@ -17,7 +17,7 @@ export {
|
|
|
17
17
|
NodeInfo,
|
|
18
18
|
PackedArguments,
|
|
19
19
|
PublicKey,
|
|
20
|
-
|
|
20
|
+
GrumpkinPrivateKey,
|
|
21
21
|
SyncStatus,
|
|
22
22
|
Tx,
|
|
23
23
|
TxExecutionRequest,
|
|
@@ -27,5 +27,6 @@ export {
|
|
|
27
27
|
emptyFunctionCall,
|
|
28
28
|
} from '@aztec/types';
|
|
29
29
|
|
|
30
|
-
export { createDebugLogger } from '@aztec/foundation/log';
|
|
30
|
+
export { createDebugLogger, DebugLogger } from '@aztec/foundation/log';
|
|
31
|
+
export { fileURLToPath } from '@aztec/foundation/url';
|
|
31
32
|
export { sleep } from '@aztec/foundation/sleep';
|
package/src/sandbox/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr,
|
|
1
|
+
import { Fr, GrumpkinScalar } from '@aztec/circuits.js';
|
|
2
2
|
import { ContractAbi } from '@aztec/foundation/abi';
|
|
3
3
|
import { sleep } from '@aztec/foundation/sleep';
|
|
4
4
|
|
|
@@ -8,9 +8,9 @@ import SchnorrAccountContractAbi from '../abis/schnorr_account_contract.json' as
|
|
|
8
8
|
import { AccountWallet, AztecRPC, EntrypointWallet, getAccountWallets, getSchnorrAccount } from '../index.js';
|
|
9
9
|
|
|
10
10
|
export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
GrumpkinScalar.fromString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
|
|
12
|
+
GrumpkinScalar.fromString('aebd1b4be76efa44f5ee655c20bf9ea60f7ae44b9a7fd1fd9f189c7a0b0cdae'),
|
|
13
|
+
GrumpkinScalar.fromString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c'),
|
|
14
14
|
];
|
|
15
15
|
|
|
16
16
|
export const INITIAL_SANDBOX_SIGNING_KEYS = INITIAL_SANDBOX_ENCRYPTION_KEYS;
|
package/src/utils/account.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr,
|
|
1
|
+
import { Fr, GrumpkinPrivateKey, GrumpkinScalar, getContractDeploymentInfo } from '@aztec/circuits.js';
|
|
2
2
|
import { Schnorr } from '@aztec/circuits.js/barretenberg';
|
|
3
3
|
import { ContractAbi } from '@aztec/foundation/abi';
|
|
4
4
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -15,7 +15,7 @@ import { ContractDeployer, EntrypointCollection, StoredKeyAccountEntrypoint, gen
|
|
|
15
15
|
export async function createAccounts(
|
|
16
16
|
aztecRpcClient: AztecRPC,
|
|
17
17
|
accountContractAbi: ContractAbi,
|
|
18
|
-
privateKey?:
|
|
18
|
+
privateKey?: GrumpkinPrivateKey,
|
|
19
19
|
salt = Fr.random(),
|
|
20
20
|
numberOfAccounts = 1,
|
|
21
21
|
logger = createDebugLogger('aztec:aztec.js:accounts'),
|
|
@@ -24,7 +24,7 @@ export async function createAccounts(
|
|
|
24
24
|
|
|
25
25
|
for (let i = 0; i < numberOfAccounts; ++i) {
|
|
26
26
|
// TODO(#662): Let the aztec rpc server generate the keypair rather than hardcoding the private key
|
|
27
|
-
const privKey = i == 0 && privateKey ? privateKey :
|
|
27
|
+
const privKey = i == 0 && privateKey ? privateKey : GrumpkinScalar.random();
|
|
28
28
|
const publicKey = await generatePublicKey(privKey);
|
|
29
29
|
const deploymentInfo = await getContractDeploymentInfo(accountContractAbi, [], salt, publicKey);
|
|
30
30
|
await aztecRpcClient.registerAccount(privKey, deploymentInfo.completeAddress.partialAddress);
|
|
@@ -44,12 +44,7 @@ export async function createAccounts(
|
|
|
44
44
|
logger(`Created account ${address.toString()} with public key ${publicKey.toString()}`);
|
|
45
45
|
accountImpls.registerAccount(
|
|
46
46
|
address,
|
|
47
|
-
new SingleKeyAccountEntrypoint(
|
|
48
|
-
address,
|
|
49
|
-
deploymentInfo.completeAddress.partialAddress,
|
|
50
|
-
privKey,
|
|
51
|
-
await Schnorr.new(),
|
|
52
|
-
),
|
|
47
|
+
new SingleKeyAccountEntrypoint(address, deploymentInfo.completeAddress.partialAddress, privKey),
|
|
53
48
|
);
|
|
54
49
|
}
|
|
55
50
|
return new EntrypointWallet(aztecRpcClient, accountImpls);
|
|
@@ -67,14 +62,16 @@ export async function createAccounts(
|
|
|
67
62
|
export async function getAccountWallets(
|
|
68
63
|
aztecRpcClient: AztecRPC,
|
|
69
64
|
accountContractAbi: ContractAbi,
|
|
70
|
-
privateKeys:
|
|
71
|
-
signingKeys:
|
|
65
|
+
privateKeys: GrumpkinPrivateKey[],
|
|
66
|
+
signingKeys: GrumpkinPrivateKey[],
|
|
72
67
|
salts: Fr[],
|
|
73
68
|
) {
|
|
74
69
|
if (privateKeys.length != salts.length || signingKeys.length != privateKeys.length) {
|
|
75
70
|
throw new Error('Keys and salts must be the same length');
|
|
76
71
|
}
|
|
77
72
|
const accountCollection = new EntrypointCollection();
|
|
73
|
+
const schnorr = await Schnorr.new();
|
|
74
|
+
|
|
78
75
|
for (let i = 0; i < privateKeys.length; i++) {
|
|
79
76
|
const publicKey = await generatePublicKey(privateKeys[i]);
|
|
80
77
|
const signingPublicKey = await generatePublicKey(signingKeys[i]);
|
|
@@ -86,10 +83,9 @@ export async function getAccountWallets(
|
|
|
86
83
|
);
|
|
87
84
|
const address = deploymentInfo.completeAddress.address;
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
86
|
+
const signClosure = (msg: Buffer) => schnorr.constructSignature(msg, signingKeys[i]);
|
|
87
|
+
|
|
88
|
+
accountCollection.registerAccount(address, new StoredKeyAccountEntrypoint(address, signClosure));
|
|
93
89
|
}
|
|
94
90
|
return new EntrypointWallet(aztecRpcClient, accountCollection);
|
|
95
91
|
}
|
package/src/utils/pub_key.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js';
|
|
2
2
|
import { Grumpkin } from '@aztec/circuits.js/barretenberg';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import { Grumpkin } from '@aztec/circuits.js/barretenberg';
|
|
|
6
6
|
* @param privateKey - The private key.
|
|
7
7
|
* @returns The generated public key.
|
|
8
8
|
*/
|
|
9
|
-
export async function generatePublicKey(privateKey:
|
|
9
|
+
export async function generatePublicKey(privateKey: GrumpkinPrivateKey): Promise<PublicKey> {
|
|
10
10
|
const grumpkin = await Grumpkin.new();
|
|
11
11
|
return grumpkin.mul(grumpkin.generator(), privateKey);
|
|
12
12
|
}
|