@aztec/accounts 0.30.1 → 0.31.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.
@@ -1,4 +1,5 @@
1
- import { AccountInterface, AuthWitnessProvider, EntrypointInterface, FeeOptions } from '@aztec/aztec.js/account';
1
+ import { AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
2
+ import { EntrypointInterface, FeeOptions } from '@aztec/aztec.js/entrypoint';
2
3
  import { AuthWitness, FunctionCall, TxExecutionRequest } from '@aztec/circuit-types';
3
4
  import { AztecAddress, CompleteAddress, Fr } from '@aztec/circuits.js';
4
5
  import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
@@ -10,6 +11,8 @@ import { NodeInfo } from '@aztec/types/interfaces';
10
11
  */
11
12
  export class DefaultAccountInterface implements AccountInterface {
12
13
  private entrypoint: EntrypointInterface;
14
+ private chainId: Fr;
15
+ private version: Fr;
13
16
 
14
17
  constructor(
15
18
  private authWitnessProvider: AuthWitnessProvider,
@@ -22,14 +25,16 @@ export class DefaultAccountInterface implements AccountInterface {
22
25
  nodeInfo.chainId,
23
26
  nodeInfo.protocolVersion,
24
27
  );
28
+ this.chainId = new Fr(nodeInfo.chainId);
29
+ this.version = new Fr(nodeInfo.protocolVersion);
25
30
  }
26
31
 
27
32
  createTxExecutionRequest(executions: FunctionCall[], fee?: FeeOptions): Promise<TxExecutionRequest> {
28
33
  return this.entrypoint.createTxExecutionRequest(executions, fee);
29
34
  }
30
35
 
31
- createAuthWit(message: Fr): Promise<AuthWitness> {
32
- return this.authWitnessProvider.createAuthWit(message);
36
+ createAuthWit(messageHash: Fr): Promise<AuthWitness> {
37
+ return this.authWitnessProvider.createAuthWit(messageHash);
33
38
  }
34
39
 
35
40
  getCompleteAddress(): CompleteAddress {
@@ -39,4 +44,12 @@ export class DefaultAccountInterface implements AccountInterface {
39
44
  getAddress(): AztecAddress {
40
45
  return this.address.address;
41
46
  }
47
+
48
+ getChainId(): Fr {
49
+ return this.chainId;
50
+ }
51
+
52
+ getVersion(): Fr {
53
+ return this.version;
54
+ }
42
55
  }
@@ -30,9 +30,9 @@ export class EcdsaAccountContract extends DefaultAccountContract {
30
30
  class EcdsaAuthWitnessProvider implements AuthWitnessProvider {
31
31
  constructor(private signingPrivateKey: Buffer) {}
32
32
 
33
- createAuthWit(message: Fr): Promise<AuthWitness> {
33
+ createAuthWit(messageHash: Fr): Promise<AuthWitness> {
34
34
  const ecdsa = new Ecdsa();
35
- const signature = ecdsa.constructSignature(message.toBuffer(), this.signingPrivateKey);
36
- return Promise.resolve(new AuthWitness(message, [...signature.r, ...signature.s]));
35
+ const signature = ecdsa.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
36
+ return Promise.resolve(new AuthWitness(messageHash, [...signature.r, ...signature.s]));
37
37
  }
38
38
  }
@@ -30,9 +30,9 @@ export class SchnorrAccountContract extends DefaultAccountContract {
30
30
  class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
31
31
  constructor(private signingPrivateKey: GrumpkinPrivateKey) {}
32
32
 
33
- createAuthWit(message: Fr): Promise<AuthWitness> {
33
+ createAuthWit(messageHash: Fr): Promise<AuthWitness> {
34
34
  const schnorr = new Schnorr();
35
- const signature = schnorr.constructSignature(message.toBuffer(), this.signingPrivateKey).toBuffer();
36
- return Promise.resolve(new AuthWitness(message, [...signature]));
35
+ const signature = schnorr.constructSignature(messageHash.toBuffer(), this.signingPrivateKey).toBuffer();
36
+ return Promise.resolve(new AuthWitness(messageHash, [...signature]));
37
37
  }
38
38
  }
@@ -35,11 +35,11 @@ export class SingleKeyAccountContract extends DefaultAccountContract {
35
35
  class SingleKeyAuthWitnessProvider implements AuthWitnessProvider {
36
36
  constructor(private privateKey: GrumpkinPrivateKey, private partialAddress: PartialAddress) {}
37
37
 
38
- createAuthWit(message: Fr): Promise<AuthWitness> {
38
+ createAuthWit(messageHash: Fr): Promise<AuthWitness> {
39
39
  const schnorr = new Schnorr();
40
- const signature = schnorr.constructSignature(message.toBuffer(), this.privateKey);
40
+ const signature = schnorr.constructSignature(messageHash.toBuffer(), this.privateKey);
41
41
  const publicKey = generatePublicKey(this.privateKey);
42
42
  const witness = [...publicKey.toFields(), ...signature.toBuffer(), this.partialAddress];
43
- return Promise.resolve(new AuthWitness(message, witness));
43
+ return Promise.resolve(new AuthWitness(messageHash, witness));
44
44
  }
45
45
  }