@aztec/stdlib 5.0.0-nightly.20260331 → 5.0.0-nightly.20260402

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.
@@ -18,10 +18,10 @@ import type { CompleteAddress } from '../contract/complete_address.js';
18
18
  export declare class ExtendedDirectionalAppTaggingSecret {
19
19
  readonly secret: Fr;
20
20
  readonly app: AztecAddress;
21
- private constructor();
21
+ constructor(secret: Fr, app: AztecAddress);
22
22
  /**
23
23
  * Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
24
- * secret.
24
+ * secret. Returns undefined if `externalAddress` is an invalid address.
25
25
  *
26
26
  * @param localAddress - The complete address of entity A in the shared tagging secret derivation scheme
27
27
  * @param localIvsk - The incoming viewing secret key of entity A
@@ -30,7 +30,7 @@ export declare class ExtendedDirectionalAppTaggingSecret {
30
30
  * @param recipient - Recipient of the log. Defines the "direction of the secret".
31
31
  * @returns The secret that can be used along with an index to compute a tag to be included in a log.
32
32
  */
33
- static compute(localAddress: CompleteAddress, localIvsk: Fq, externalAddress: AztecAddress, app: AztecAddress, recipient: AztecAddress): Promise<ExtendedDirectionalAppTaggingSecret>;
33
+ static compute(localAddress: CompleteAddress, localIvsk: Fq, externalAddress: AztecAddress, app: AztecAddress, recipient: AztecAddress): Promise<ExtendedDirectionalAppTaggingSecret | undefined>;
34
34
  toString(): string;
35
35
  static fromString(str: string): ExtendedDirectionalAppTaggingSecret;
36
36
  }
@@ -44,4 +44,4 @@ export declare const ExtendedDirectionalAppTaggingSecretSchema: z.ZodObject<{
44
44
  secret: string;
45
45
  app?: any;
46
46
  }>;
47
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5kZWRfZGlyZWN0aW9uYWxfYXBwX3RhZ2dpbmdfc2VjcmV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbG9ncy9leHRlbmRlZF9kaXJlY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mRlZF9kaXJlY3Rpb25hbF9hcHBfdGFnZ2luZ19zZWNyZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLEtBQUssRUFBRSxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRzdELE9BQU8sRUFBRSxDQUFDLEVBQUUsTUFBTSxLQUFLLENBQUM7QUFFeEIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBR3ZFOzs7Ozs7Ozs7Ozs7R0FZRztBQUNILHFCQUFhLG1DQUFtQzthQUU1QixNQUFNLEVBQUUsRUFBRTthQUNWLEdBQUcsRUFBRSxZQUFZO0lBRm5DLFlBQ2tCLE1BQU0sRUFBRSxFQUFFLEVBQ1YsR0FBRyxFQUFFLFlBQVksRUFDL0I7SUFFSjs7Ozs7Ozs7OztPQVVHO0lBQ0gsT0FBYSxPQUFPLENBQ2xCLFlBQVksRUFBRSxlQUFlLEVBQzdCLFNBQVMsRUFBRSxFQUFFLEVBQ2IsZUFBZSxFQUFFLFlBQVksRUFDN0IsR0FBRyxFQUFFLFlBQVksRUFDakIsU0FBUyxFQUFFLFlBQVksR0FDdEIsT0FBTyxDQUFDLG1DQUFtQyxHQUFHLFNBQVMsQ0FBQyxDQVUxRDtJQUVELFFBQVEsSUFBSSxNQUFNLENBRWpCO0lBRUQsTUFBTSxDQUFDLFVBQVUsQ0FBQyxHQUFHLEVBQUUsTUFBTSxHQUFHLG1DQUFtQyxDQUdsRTtDQUNGO0FBMkJELGVBQU8sTUFBTSx5Q0FBeUM7Ozs7Ozs7OztFQUdwRCxDQUFDIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"extended_directional_app_tagging_secret.d.ts","sourceRoot":"","sources":["../../src/logs/extended_directional_app_tagging_secret.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGvE;;;;;;;;;;;;GAYG;AACH,qBAAa,mCAAmC;aAE5B,MAAM,EAAE,EAAE;aACV,GAAG,EAAE,YAAY;IAFnC,OAAO,eAGH;IAEJ;;;;;;;;;;OAUG;IACH,OAAa,OAAO,CAClB,YAAY,EAAE,eAAe,EAC7B,SAAS,EAAE,EAAE,EACb,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mCAAmC,CAAC,CAM9C;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,mCAAmC,CAGlE;CACF;AAoBD,eAAO,MAAM,yCAAyC;;;;;;;;;EAGpD,CAAC"}
1
+ {"version":3,"file":"extended_directional_app_tagging_secret.d.ts","sourceRoot":"","sources":["../../src/logs/extended_directional_app_tagging_secret.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGvE;;;;;;;;;;;;GAYG;AACH,qBAAa,mCAAmC;aAE5B,MAAM,EAAE,EAAE;aACV,GAAG,EAAE,YAAY;IAFnC,YACkB,MAAM,EAAE,EAAE,EACV,GAAG,EAAE,YAAY,EAC/B;IAEJ;;;;;;;;;;OAUG;IACH,OAAa,OAAO,CAClB,YAAY,EAAE,eAAe,EAC7B,SAAS,EAAE,EAAE,EACb,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mCAAmC,GAAG,SAAS,CAAC,CAU1D;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,mCAAmC,CAGlE;CACF;AA2BD,eAAO,MAAM,yCAAyC;;;;;;;;;EAGpD,CAAC"}
@@ -25,7 +25,7 @@ import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
25
25
  }
26
26
  /**
27
27
  * Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
28
- * secret.
28
+ * secret. Returns undefined if `externalAddress` is an invalid address.
29
29
  *
30
30
  * @param localAddress - The complete address of entity A in the shared tagging secret derivation scheme
31
31
  * @param localIvsk - The incoming viewing secret key of entity A
@@ -35,6 +35,9 @@ import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
35
35
  * @returns The secret that can be used along with an index to compute a tag to be included in a log.
36
36
  */ static async compute(localAddress, localIvsk, externalAddress, app, recipient) {
37
37
  const taggingSecretPoint = await computeSharedTaggingSecret(localAddress, localIvsk, externalAddress);
38
+ if (!taggingSecretPoint) {
39
+ return undefined;
40
+ }
38
41
  const appTaggingSecret = await poseidon2Hash([
39
42
  taggingSecretPoint.x,
40
43
  taggingSecretPoint.y,
@@ -54,13 +57,17 @@ import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
54
57
  return new ExtendedDirectionalAppTaggingSecret(Fr.fromString(secretStr), AztecAddress.fromString(appStr));
55
58
  }
56
59
  }
57
- // Returns shared tagging secret computed with Diffie-Hellman key exchange.
60
+ // Returns shared tagging secret computed with Diffie-Hellman key exchange, or undefined if `externalAddress` is an
61
+ // invalid address.
58
62
  async function computeSharedTaggingSecret(localAddress, localIvsk, externalAddress) {
59
- const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
60
- // TODO: #8970 - Computation of address point from x coordinate might fail
61
- const externalAddressPoint = await externalAddress.toAddressPoint();
62
63
  // Given A (local complete address) -> B (external address) and h == preaddress
63
64
  // Compute shared secret as S = (h_A + local_ivsk_A) * Addr_Point_B
65
+ const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
66
+ // An invalid address has no corresponding address point
67
+ if (!await externalAddress.isValid()) {
68
+ return undefined;
69
+ }
70
+ const externalAddressPoint = await externalAddress.toAddressPoint();
64
71
  // Beware! h_a + local_ivsk_a (also known as the address secret) can lead to an address point with a negative
65
72
  // y-coordinate, since there's two possible candidates computeAddressSecret takes care of selecting the one that
66
73
  // leads to a positive y-coordinate, which is the only valid address point
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "5.0.0-nightly.20260331",
3
+ "version": "5.0.0-nightly.20260402",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -92,13 +92,13 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@aws-sdk/client-s3": "^3.892.0",
95
- "@aztec/bb.js": "5.0.0-nightly.20260331",
96
- "@aztec/blob-lib": "5.0.0-nightly.20260331",
97
- "@aztec/constants": "5.0.0-nightly.20260331",
98
- "@aztec/ethereum": "5.0.0-nightly.20260331",
99
- "@aztec/foundation": "5.0.0-nightly.20260331",
100
- "@aztec/l1-artifacts": "5.0.0-nightly.20260331",
101
- "@aztec/noir-noirc_abi": "5.0.0-nightly.20260331",
95
+ "@aztec/bb.js": "5.0.0-nightly.20260402",
96
+ "@aztec/blob-lib": "5.0.0-nightly.20260402",
97
+ "@aztec/constants": "5.0.0-nightly.20260402",
98
+ "@aztec/ethereum": "5.0.0-nightly.20260402",
99
+ "@aztec/foundation": "5.0.0-nightly.20260402",
100
+ "@aztec/l1-artifacts": "5.0.0-nightly.20260402",
101
+ "@aztec/noir-noirc_abi": "5.0.0-nightly.20260402",
102
102
  "@google-cloud/storage": "^7.15.0",
103
103
  "axios": "^1.13.5",
104
104
  "json-stringify-deterministic": "1.0.12",
@@ -23,14 +23,14 @@ import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
23
23
  * doesn't seem to be a good way around this.
24
24
  */
25
25
  export class ExtendedDirectionalAppTaggingSecret {
26
- private constructor(
26
+ constructor(
27
27
  public readonly secret: Fr,
28
28
  public readonly app: AztecAddress,
29
29
  ) {}
30
30
 
31
31
  /**
32
32
  * Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
33
- * secret.
33
+ * secret. Returns undefined if `externalAddress` is an invalid address.
34
34
  *
35
35
  * @param localAddress - The complete address of entity A in the shared tagging secret derivation scheme
36
36
  * @param localIvsk - The incoming viewing secret key of entity A
@@ -45,8 +45,12 @@ export class ExtendedDirectionalAppTaggingSecret {
45
45
  externalAddress: AztecAddress,
46
46
  app: AztecAddress,
47
47
  recipient: AztecAddress,
48
- ): Promise<ExtendedDirectionalAppTaggingSecret> {
48
+ ): Promise<ExtendedDirectionalAppTaggingSecret | undefined> {
49
49
  const taggingSecretPoint = await computeSharedTaggingSecret(localAddress, localIvsk, externalAddress);
50
+ if (!taggingSecretPoint) {
51
+ return undefined;
52
+ }
53
+
50
54
  const appTaggingSecret = await poseidon2Hash([taggingSecretPoint.x, taggingSecretPoint.y, app]);
51
55
  const directionalAppTaggingSecret = await poseidon2Hash([appTaggingSecret, recipient]);
52
56
 
@@ -63,18 +67,25 @@ export class ExtendedDirectionalAppTaggingSecret {
63
67
  }
64
68
  }
65
69
 
66
- // Returns shared tagging secret computed with Diffie-Hellman key exchange.
70
+ // Returns shared tagging secret computed with Diffie-Hellman key exchange, or undefined if `externalAddress` is an
71
+ // invalid address.
67
72
  async function computeSharedTaggingSecret(
68
73
  localAddress: CompleteAddress,
69
74
  localIvsk: Fq,
70
75
  externalAddress: AztecAddress,
71
- ): Promise<Point> {
72
- const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
73
- // TODO: #8970 - Computation of address point from x coordinate might fail
74
- const externalAddressPoint = await externalAddress.toAddressPoint();
76
+ ): Promise<Point | undefined> {
75
77
  // Given A (local complete address) -> B (external address) and h == preaddress
76
78
  // Compute shared secret as S = (h_A + local_ivsk_A) * Addr_Point_B
77
79
 
80
+ const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
81
+
82
+ // An invalid address has no corresponding address point
83
+ if (!(await externalAddress.isValid())) {
84
+ return undefined;
85
+ }
86
+
87
+ const externalAddressPoint = await externalAddress.toAddressPoint();
88
+
78
89
  // Beware! h_a + local_ivsk_a (also known as the address secret) can lead to an address point with a negative
79
90
  // y-coordinate, since there's two possible candidates computeAddressSecret takes care of selecting the one that
80
91
  // leads to a positive y-coordinate, which is the only valid address point