@aztec/foundation 0.15.0 → 0.15.1
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/dest/abi/decoder.js +3 -3
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +3 -3
- package/dest/abi/function_selector.js +3 -3
- package/dest/aztec-address/index.d.ts +10 -108
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +18 -139
- package/dest/bigint-buffer/index.d.ts.map +1 -1
- package/dest/bigint-buffer/index.js +7 -4
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +7 -4
- package/dest/crypto/pedersen/pedersen.wasm.d.ts +4 -0
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.js +18 -6
- package/dest/crypto/random/index.d.ts.map +1 -1
- package/dest/crypto/random/index.js +5 -3
- package/dest/crypto/sha256/index.d.ts +0 -8
- package/dest/crypto/sha256/index.d.ts.map +1 -1
- package/dest/crypto/sha256/index.js +1 -12
- package/dest/fields/fields.d.ts +69 -160
- package/dest/fields/fields.d.ts.map +1 -1
- package/dest/fields/fields.js +142 -185
- package/dest/fields/index.d.ts +0 -1
- package/dest/fields/index.d.ts.map +1 -1
- package/dest/fields/index.js +1 -2
- package/dest/fields/point.d.ts.map +1 -1
- package/dest/fields/point.js +5 -4
- package/dest/json-rpc/class_converter.d.ts.map +1 -1
- package/dest/json-rpc/class_converter.js +7 -5
- package/dest/json-rpc/client/json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/json_rpc_client.js +3 -2
- package/dest/log/console.d.ts +1 -1
- package/dest/log/console.d.ts.map +1 -1
- package/dest/log/debug.d.ts +1 -1
- package/dest/log/debug.d.ts.map +1 -1
- package/dest/log/index.d.ts +1 -4
- package/dest/log/index.d.ts.map +1 -1
- package/dest/log/index.js +2 -1
- package/dest/log/log_fn.d.ts +5 -0
- package/dest/log/log_fn.d.ts.map +1 -0
- package/dest/log/log_fn.js +2 -0
- package/dest/log/logger.d.ts +1 -1
- package/dest/log/logger.d.ts.map +1 -1
- package/dest/log/logger.js +7 -4
- package/dest/serialize/buffer_reader.d.ts +0 -16
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +1 -21
- package/dest/serialize/free_funcs.d.ts +6 -0
- package/dest/serialize/free_funcs.d.ts.map +1 -1
- package/dest/serialize/free_funcs.js +11 -1
- package/dest/transport/interface/transferable.d.ts.map +1 -1
- package/dest/transport/interface/transferable.js +5 -3
- package/dest/wasm/empty_wasi_sdk.d.ts +1 -1
- package/dest/wasm/wasm_module.d.ts.map +1 -1
- package/dest/wasm/wasm_module.js +4 -3
- package/package.json +3 -4
- package/src/abi/decoder.ts +2 -2
- package/src/abi/encoder.ts +3 -2
- package/src/abi/function_selector.ts +2 -2
- package/src/aztec-address/index.ts +17 -149
- package/src/bigint-buffer/index.ts +9 -3
- package/src/collection/array.ts +9 -3
- package/src/crypto/pedersen/pedersen.wasm.ts +23 -5
- package/src/crypto/random/index.ts +6 -2
- package/src/crypto/sha256/index.ts +0 -13
- package/src/fields/fields.ts +197 -197
- package/src/fields/index.ts +0 -1
- package/src/fields/point.ts +5 -3
- package/src/json-rpc/class_converter.ts +8 -4
- package/src/json-rpc/client/json_rpc_client.ts +3 -1
- package/src/log/console.ts +1 -1
- package/src/log/debug.ts +1 -1
- package/src/log/index.ts +1 -6
- package/src/log/log_fn.ts +5 -0
- package/src/log/logger.ts +10 -4
- package/src/serialize/buffer_reader.ts +0 -22
- package/src/serialize/free_funcs.ts +11 -0
- package/src/transport/interface/transferable.ts +6 -2
- package/src/wasm/wasm_module.ts +3 -1
- package/dest/fields/grumpkin_scalar.d.ts +0 -96
- package/dest/fields/grumpkin_scalar.d.ts.map +0 -1
- package/dest/fields/grumpkin_scalar.js +0 -125
- package/src/fields/grumpkin_scalar.ts +0 -138
|
@@ -4,10 +4,12 @@ import isNode from 'detect-node';
|
|
|
4
4
|
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
5
5
|
const MAX_BYTES = 65536;
|
|
6
6
|
const getWebCrypto = () => {
|
|
7
|
-
if (typeof window !== 'undefined' && window.crypto)
|
|
7
|
+
if (typeof window !== 'undefined' && window.crypto) {
|
|
8
8
|
return window.crypto;
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
if (typeof self !== 'undefined' && self.crypto) {
|
|
10
11
|
return self.crypto;
|
|
12
|
+
}
|
|
11
13
|
return undefined;
|
|
12
14
|
};
|
|
13
15
|
export const randomBytes = (len) => {
|
|
@@ -33,4 +35,4 @@ export const randomBytes = (len) => {
|
|
|
33
35
|
}
|
|
34
36
|
return buf;
|
|
35
37
|
};
|
|
36
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY3J5cHRvL3JhbmRvbS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLFVBQVUsTUFBTSxRQUFRLENBQUM7QUFDaEMsT0FBTyxNQUFNLE1BQU0sYUFBYSxDQUFDO0FBRWpDLG9DQUFvQztBQUNwQywwRUFBMEU7QUFDMUUsTUFBTSxTQUFTLEdBQUcsS0FBSyxDQUFDO0FBRXhCLE1BQU0sWUFBWSxHQUFHLEdBQUcsRUFBRTtJQUN4QixJQUFJLE9BQU8sTUFBTSxLQUFLLFdBQVcsSUFBSSxNQUFNLENBQUMsTUFBTSxFQUFFO1FBQ2xELE9BQU8sTUFBTSxDQUFDLE1BQU0sQ0FBQztLQUN0QjtJQUNELElBQUksT0FBTyxJQUFJLEtBQUssV0FBVyxJQUFJLElBQUksQ0FBQyxNQUFNLEVBQUU7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
|
export declare const sha256: (data: Buffer) => Buffer;
|
|
4
|
-
/**
|
|
5
|
-
* Squashes the output of sha256 into a field element.
|
|
6
|
-
* WARNING: if you have not thought about why you are using this, or talked to somebody who has do not use it.
|
|
7
|
-
* @param buf - Input buffer
|
|
8
|
-
* @returns Returns a sha256 output squashed into a field element.
|
|
9
|
-
*/
|
|
10
|
-
export declare const sha256ToField: (buf: Buffer) => Fr;
|
|
11
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/sha256/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/sha256/index.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,MAAM,SAAU,MAAM,WAAqD,CAAC"}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
import { default as hash } from 'hash.js';
|
|
2
|
-
import { toBigIntBE, toBufferBE } from '../../bigint-buffer/index.js';
|
|
3
|
-
import { Fr } from '../../fields/fields.js';
|
|
4
2
|
export const sha256 = (data) => Buffer.from(hash.sha256().update(data).digest());
|
|
5
|
-
|
|
6
|
-
* Squashes the output of sha256 into a field element.
|
|
7
|
-
* WARNING: if you have not thought about why you are using this, or talked to somebody who has do not use it.
|
|
8
|
-
* @param buf - Input buffer
|
|
9
|
-
* @returns Returns a sha256 output squashed into a field element.
|
|
10
|
-
*/
|
|
11
|
-
export const sha256ToField = (buf) => {
|
|
12
|
-
return Fr.fromBuffer(toBufferBE(toBigIntBE(sha256(buf)) % Fr.MODULUS, 32));
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY3J5cHRvL3NoYTI1Ni9pbmRleC50cyJdLCJuYW1lcyI6W10sI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SUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDIn0=
|
package/dest/fields/fields.d.ts
CHANGED
|
@@ -1,181 +1,90 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { AztecAddress } from '../aztec-address/index.js';
|
|
3
2
|
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Base field class.
|
|
5
|
+
* Conversions from Buffer to BigInt and vice-versa are not cheap.
|
|
6
|
+
* We allow construction with either form and lazily convert to other as needed.
|
|
7
|
+
* We only check we are within the field modulus when initializing with bigint.
|
|
8
|
+
* If NODE_ENV === 'test', we will always initialize both types to check the modulus.
|
|
9
|
+
* This is also necessary in test environment as a lot of tests just use deep equality to check equality.
|
|
10
|
+
* WARNING: This could lead to a bugs in production that don't reveal in tests, but it's low risk.
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
static ZERO: Fr;
|
|
11
|
-
static MODULUS: bigint;
|
|
12
|
-
static MAX_VALUE: bigint;
|
|
12
|
+
declare abstract class BaseField {
|
|
13
13
|
static SIZE_IN_BYTES: number;
|
|
14
|
+
private asBuffer?;
|
|
15
|
+
private asBigInt?;
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* This method uses randomBytes to generate a random 32-byte buffer, converts it to a bigint
|
|
22
|
-
* and takes the modulus of the result with the class' MODULUS constant.
|
|
23
|
-
*
|
|
24
|
-
* @returns A new Fr or Fq instance with a random value.
|
|
25
|
-
*/
|
|
26
|
-
static random(): Fr;
|
|
27
|
-
/**
|
|
28
|
-
* Returns a new zero-value field.
|
|
29
|
-
* @returns A new zero-value field.
|
|
30
|
-
*/
|
|
31
|
-
static zero(): Fr;
|
|
32
|
-
/**
|
|
33
|
-
* Create an instance of the corresponding class (Fr or Fq) from a Buffer or a BufferReader.
|
|
34
|
-
* Reads 'SIZE_IN_BYTES' bytes from the given Buffer or BufferReader and constructs an instance with the decoded value.
|
|
35
|
-
* If the input is a Buffer, it is internally converted to a BufferReader before reading.
|
|
36
|
-
* Throws an error if the input length is invalid or the decoded value is out of range.
|
|
37
|
-
*
|
|
38
|
-
* @param buffer - The Buffer or BufferReader containing the bytes representing the value.
|
|
39
|
-
* @returns An instance of the corresponding class (Fr or Fq) with the decoded value.
|
|
40
|
-
*/
|
|
41
|
-
static fromBuffer(buffer: Buffer | BufferReader): Fr;
|
|
42
|
-
/**
|
|
43
|
-
* Create a Fr instance from a hex-encoded string.
|
|
44
|
-
* The input 'address' can be either prefixed with '0x' or not, and should have exactly 64 hex characters.
|
|
45
|
-
* Throws an error if the input length is invalid or the address value is out of range.
|
|
46
|
-
*
|
|
47
|
-
* @param address - The hex-encoded string representing the field element.
|
|
48
|
-
* @returns A Fr instance.
|
|
49
|
-
*/
|
|
50
|
-
static fromString(address: string): Fr;
|
|
17
|
+
* Return bigint representation.
|
|
18
|
+
* @deprecated Just to get things compiling. Use toBigInt().
|
|
19
|
+
* */
|
|
20
|
+
get value(): bigint;
|
|
21
|
+
protected constructor(value: number | bigint | boolean | BaseField | Buffer);
|
|
22
|
+
protected abstract modulus(): bigint;
|
|
51
23
|
/**
|
|
52
|
-
*
|
|
53
|
-
* The method uses the provided value and size in bytes to create a buffer representation
|
|
54
|
-
* of the numeric value. This can be useful for serialization and communication purposes.
|
|
55
|
-
*
|
|
56
|
-
* @returns A buffer representing the instance's value.
|
|
24
|
+
* We return a copy of the Buffer to ensure this remains immutable.
|
|
57
25
|
*/
|
|
58
26
|
toBuffer(): Buffer;
|
|
59
|
-
|
|
60
|
-
* Converts the value of the Fr or Fq class instance to a hexadecimal string.
|
|
61
|
-
* The resulting string is prefixed with '0x' and represents the bigint value
|
|
62
|
-
* in base 16.
|
|
63
|
-
*
|
|
64
|
-
* @param padTo32 - Whether to pad the string to 32 bytes.
|
|
65
|
-
* @returns A hex-encoded string representing the value of the class instance.
|
|
66
|
-
*/
|
|
67
|
-
toString(padTo32?: boolean): `0x${string}`;
|
|
68
|
-
/**
|
|
69
|
-
* Retrieves the underlying bigint.
|
|
70
|
-
* This method mostly exists to match user expectations, as value is already public.
|
|
71
|
-
* @returns The underlying bigint.
|
|
72
|
-
*/
|
|
27
|
+
toString(): `0x${string}`;
|
|
73
28
|
toBigInt(): bigint;
|
|
74
|
-
/**
|
|
75
|
-
* Returns a shortened string representation of the Fr value, formatted with '0x' prefix and ellipsis in the middle.
|
|
76
|
-
* The resulting string has first 10 characters (including '0x') and last 4 characters of the full hexadecimal value.
|
|
77
|
-
*
|
|
78
|
-
* @returns A shorter, human-readable string representation of the Fr value.
|
|
79
|
-
*/
|
|
80
29
|
toShortString(): string;
|
|
81
|
-
|
|
82
|
-
* Checks if the provided Fr instance is equal to the current instance.
|
|
83
|
-
* Two instances are considered equal if their 'value' properties are the same.
|
|
84
|
-
*
|
|
85
|
-
* @param rhs - The Fr instance to compare with the current instance.
|
|
86
|
-
* @returns A boolean indicating whether the two instances are equal.
|
|
87
|
-
*/
|
|
88
|
-
equals(rhs: Fr): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Check if the instance value is zero.
|
|
91
|
-
* The method returns true if the value of the instance is 0n (zero in BigInt representation),
|
|
92
|
-
* otherwise, it returns false.
|
|
93
|
-
*
|
|
94
|
-
* @returns A boolean indicating whether the instance value is zero or not.
|
|
95
|
-
*/
|
|
30
|
+
equals(rhs: BaseField): boolean;
|
|
96
31
|
isZero(): boolean;
|
|
97
|
-
|
|
98
|
-
* Converts the current value of the Fq or Fr instance to a friendly JSON representation.
|
|
99
|
-
* The output will be a hexadecimal string prefixed with '0x'.
|
|
100
|
-
*
|
|
101
|
-
* @returns A '0x' prefixed hexadecimal string representing the current value.
|
|
102
|
-
*/
|
|
103
|
-
toFriendlyJSON(): `0x${string}`;
|
|
104
|
-
/** Returns self. */
|
|
32
|
+
toFriendlyJSON(): string;
|
|
105
33
|
toField(): this;
|
|
106
34
|
}
|
|
107
35
|
/**
|
|
108
|
-
*
|
|
109
|
-
* It provides methods for creating, manipulating, and comparing field elements, as well as converting
|
|
110
|
-
* them to/from different data types like Buffers and hex strings. Field elements are used in various
|
|
111
|
-
* cryptographic protocols and operations, such as elliptic curve cryptography.
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* const fqElem = new Fq(BigInt("123456789"));
|
|
115
|
-
* const randomFqElem = Fq.random();
|
|
116
|
-
* const fromBufferFqElem = Fq.fromBuffer(buffer);
|
|
36
|
+
* Branding to ensure fields are not interchangeable types.
|
|
117
37
|
*/
|
|
118
|
-
export
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
38
|
+
export interface Fr {
|
|
39
|
+
/** Brand. */
|
|
40
|
+
_branding: 'Fr';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Fr field class.
|
|
44
|
+
*/
|
|
45
|
+
export declare class Fr extends BaseField {
|
|
46
|
+
static ZERO: Fr;
|
|
123
47
|
static MODULUS: bigint;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
48
|
+
constructor(value: number | bigint | boolean | Fr | Buffer);
|
|
49
|
+
protected modulus(): bigint;
|
|
50
|
+
static random(): Fr;
|
|
51
|
+
static zero(): Fr;
|
|
52
|
+
static fromBuffer(buffer: Buffer | BufferReader): Fr;
|
|
53
|
+
static fromBufferReduce(buffer: Buffer): Fr;
|
|
54
|
+
static fromString(buf: string): Fr;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Branding to ensure fields are not interchangeable types.
|
|
58
|
+
*/
|
|
59
|
+
export interface Fq {
|
|
60
|
+
/** Brand. */
|
|
61
|
+
_branding: 'Fq';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Fq field class.
|
|
65
|
+
*/
|
|
66
|
+
export declare class Fq extends BaseField {
|
|
67
|
+
static ZERO: Fq;
|
|
68
|
+
static MODULUS: bigint;
|
|
69
|
+
private static HIGH_SHIFT;
|
|
70
|
+
private static LOW_MASK;
|
|
71
|
+
get low(): Fr;
|
|
72
|
+
get high(): Fr;
|
|
73
|
+
constructor(value: number | bigint | boolean | Fq | Buffer);
|
|
74
|
+
protected modulus(): bigint;
|
|
138
75
|
static random(): Fq;
|
|
139
|
-
|
|
140
|
-
* Create an instance of the calling class (Fr or Fq) from a given buffer or BufferReader.
|
|
141
|
-
* Reads SIZE_IN_BYTES from the provided buffer and converts it to a bigint, then creates a new instance
|
|
142
|
-
* with that value. Throws an error if the value is out of range for the calling class.
|
|
143
|
-
*
|
|
144
|
-
* @param buffer - The input buffer or BufferReader containing the bytes representing the value.
|
|
145
|
-
* @returns An instance of the calling class (Fr or Fq) initialized with the bigint value.
|
|
146
|
-
*/
|
|
76
|
+
static zero(): Fq;
|
|
147
77
|
static fromBuffer(buffer: Buffer | BufferReader): Fq;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
*
|
|
152
|
-
* @returns A Buffer containing the byte representation of the instance's value.
|
|
153
|
-
*/
|
|
154
|
-
toBuffer(): Buffer;
|
|
155
|
-
/**
|
|
156
|
-
* Converts the Fq value to a hexadecimal string representation.
|
|
157
|
-
* The resulting string is prefixed with '0x' and contains the exact number of hex characters required
|
|
158
|
-
* to represent the numeric value of this instance.
|
|
159
|
-
*
|
|
160
|
-
* @returns A hexadecimal string representing the Fq value.
|
|
161
|
-
*/
|
|
162
|
-
toString(): `0x${string}`;
|
|
163
|
-
/**
|
|
164
|
-
* Check if the value of the current instance is zero.
|
|
165
|
-
* This function compares the internal 'value' property with 0n (BigInt representation of zero).
|
|
166
|
-
* Returns true if the value is zero, otherwise returns false.
|
|
167
|
-
*
|
|
168
|
-
* @returns A boolean indicating whether the value is zero or not.
|
|
169
|
-
*/
|
|
170
|
-
isZero(): boolean;
|
|
171
|
-
/**
|
|
172
|
-
* Converts the value of the Fr or Fq instance to a friendly JSON format.
|
|
173
|
-
* The output is a hexadecimal string representation of the value with '0x' prefix.
|
|
174
|
-
*
|
|
175
|
-
* @returns A string representing the value in the JSON format.
|
|
176
|
-
*/
|
|
177
|
-
toFriendlyJSON(): `0x${string}`;
|
|
178
|
-
/** Returns self. */
|
|
179
|
-
toField(): this;
|
|
78
|
+
static fromBufferReduce(buffer: Buffer): Fq;
|
|
79
|
+
static fromString(buf: string): Fq;
|
|
80
|
+
static fromHighLow(high: Fr, low: Fr): Fq;
|
|
180
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* GrumpkinScalar is an Fq.
|
|
84
|
+
* @remarks Called GrumpkinScalar because it is used to represent elements in Grumpkin's scalar field as defined in
|
|
85
|
+
* the Aztec Yellow Paper.
|
|
86
|
+
*/
|
|
87
|
+
export type GrumpkinScalar = Fq;
|
|
88
|
+
export declare const GrumpkinScalar: typeof Fq;
|
|
89
|
+
export {};
|
|
181
90
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/fields/fields.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/fields/fields.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAiB7D;;;;;;;;GAQG;AACH,uBAAe,SAAS;IACtB,MAAM,CAAC,aAAa,SAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAE1B;;;SAGK;IACL,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,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