@aztec/foundation 0.0.1-commit.72dcdcda8 → 0.0.1-commit.7689c7f
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/bigint-buffer/index.d.ts +1 -1
- package/dest/bigint-buffer/index.d.ts.map +1 -1
- package/dest/bigint-buffer/index.js +6 -1
- package/dest/branded-types/block_number.d.ts +3 -3
- package/dest/branded-types/block_number.d.ts.map +1 -1
- package/dest/branded-types/block_number.js +15 -4
- package/dest/branded-types/buffer32_hash.d.ts +27 -0
- package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
- package/dest/branded-types/buffer32_hash.js +12 -0
- package/dest/branded-types/checkpoint_number.d.ts +9 -3
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +11 -0
- package/dest/branded-types/epoch.d.ts +2 -2
- package/dest/branded-types/epoch.d.ts.map +1 -1
- package/dest/branded-types/index.d.ts +2 -1
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +1 -0
- package/dest/branded-types/index_within_checkpoint.d.ts +2 -2
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -1
- package/dest/branded-types/slot.d.ts +5 -2
- package/dest/branded-types/slot.d.ts.map +1 -1
- package/dest/branded-types/slot.js +3 -0
- package/dest/buffer/buffer16.d.ts +3 -1
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer32.d.ts +28 -61
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +29 -63
- package/dest/buffer/index.d.ts +2 -1
- package/dest/buffer/index.d.ts.map +1 -1
- package/dest/buffer/index.js +1 -0
- package/dest/buffer/utils.d.ts +3 -0
- package/dest/buffer/utils.d.ts.map +1 -0
- package/dest/buffer/utils.js +7 -0
- package/dest/collection/array.d.ts +11 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +33 -0
- package/dest/collection/index.d.ts +3 -1
- package/dest/collection/index.d.ts.map +1 -1
- package/dest/collection/index.js +2 -0
- package/dest/collection/lru_map.d.ts +41 -0
- package/dest/collection/lru_map.d.ts.map +1 -0
- package/dest/collection/lru_map.js +119 -0
- package/dest/collection/lru_set.d.ts +35 -0
- package/dest/collection/lru_set.d.ts.map +1 -0
- package/dest/collection/lru_set.js +95 -0
- package/dest/committable/committable.js +1 -1
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +47 -30
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +44 -44
- package/dest/config/network_config.d.ts +15 -41
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +4 -1
- package/dest/config/network_name.d.ts +2 -2
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +0 -2
- package/dest/config/secret_value.d.ts +2 -2
- package/dest/config/secret_value.d.ts.map +1 -1
- package/dest/crypto/aes128/index.d.ts +2 -1
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +11 -2
- package/dest/crypto/bls/bn254_keystore.d.ts +9 -176
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
- package/dest/crypto/bls/bn254_keystore.js +0 -17
- package/dest/crypto/poseidon/index.d.ts +1 -1
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +40 -33
- package/dest/crypto/schnorr/index.d.ts +8 -7
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +6 -6
- package/dest/crypto/schnorr/signature.d.ts +9 -29
- package/dest/crypto/schnorr/signature.d.ts.map +1 -1
- package/dest/crypto/schnorr/signature.js +20 -36
- package/dest/crypto/secp256k1-signer/utils.d.ts +12 -1
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +26 -0
- package/dest/curves/bls12/field.d.ts +3 -3
- package/dest/curves/bls12/field.d.ts.map +1 -1
- package/dest/curves/bls12/field.js +0 -5
- package/dest/curves/bls12/point.d.ts +2 -2
- package/dest/curves/bls12/point.d.ts.map +1 -1
- package/dest/curves/bn254/field.d.ts +23 -19
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +23 -17
- package/dest/curves/grumpkin/point.d.ts +14 -28
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/curves/grumpkin/point.js +29 -43
- package/dest/eth-address/index.d.ts +2 -2
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +0 -3
- package/dest/eth-signature/eth_signature.d.ts +3 -2
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +7 -2
- package/dest/fifo/fifo_frame_reader.d.ts +41 -0
- package/dest/fifo/fifo_frame_reader.d.ts.map +1 -0
- package/dest/fifo/fifo_frame_reader.js +74 -0
- package/dest/fifo/index.d.ts +2 -0
- package/dest/fifo/index.d.ts.map +1 -0
- package/dest/fifo/index.js +1 -0
- package/dest/fifo_set/fifo_set.d.ts +15 -0
- package/dest/fifo_set/fifo_set.d.ts.map +1 -0
- package/dest/fifo_set/fifo_set.js +39 -0
- package/dest/fifo_set/index.d.ts +2 -0
- package/dest/fifo_set/index.d.ts.map +1 -0
- package/dest/fifo_set/index.js +1 -0
- package/dest/json-rpc/client/fetch.d.ts +1 -1
- package/dest/json-rpc/client/fetch.d.ts.map +1 -1
- package/dest/json-rpc/client/fetch.js +4 -3
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +2 -2
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +5 -3
- package/dest/json-rpc/fixtures/test_state.d.ts +4 -8
- package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/test_state.js +57 -17
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts +8 -3
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +27 -13
- package/dest/log/bigint-utils.d.ts +1 -1
- package/dest/log/bigint-utils.d.ts.map +1 -1
- package/dest/log/bigint-utils.js +3 -0
- package/dest/log/pino-logger.d.ts +1 -1
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +17 -2
- package/dest/noir/noir_package_config.d.ts +19 -104
- package/dest/noir/noir_package_config.d.ts.map +1 -1
- package/dest/noir/noir_package_config.js +1 -1
- package/dest/queue/batch_queue.d.ts +1 -1
- package/dest/queue/batch_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.js +1 -0
- package/dest/retry/index.d.ts +12 -1
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +21 -0
- package/dest/schemas/api.d.ts +12 -10
- package/dest/schemas/api.d.ts.map +1 -1
- package/dest/schemas/api.js +7 -1
- package/dest/schemas/parse.d.ts +4 -4
- package/dest/schemas/parse.d.ts.map +1 -1
- package/dest/schemas/parse.js +6 -5
- package/dest/schemas/schemas.d.ts +15 -15
- package/dest/schemas/types.d.ts +3 -3
- package/dest/schemas/types.d.ts.map +1 -1
- package/dest/schemas/utils.d.ts +7 -11
- package/dest/schemas/utils.d.ts.map +1 -1
- package/dest/schemas/utils.js +2 -18
- package/dest/serialize/buffer_sink.d.ts +134 -0
- package/dest/serialize/buffer_sink.d.ts.map +1 -0
- package/dest/serialize/buffer_sink.js +297 -0
- package/dest/serialize/index.d.ts +2 -1
- package/dest/serialize/index.d.ts.map +1 -1
- package/dest/serialize/index.js +1 -0
- package/dest/string/index.js +1 -1
- package/dest/timer/index.d.ts +2 -2
- package/dest/timer/index.d.ts.map +1 -1
- package/dest/timer/index.js +1 -1
- package/dest/timer/timeout.d.ts +3 -1
- package/dest/timer/timeout.d.ts.map +1 -1
- package/dest/timer/timeout.js +26 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
- package/dest/transport/index.d.ts +1 -2
- package/dest/transport/index.d.ts.map +1 -1
- package/dest/transport/index.js +0 -1
- package/dest/trees/balanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/balanced_merkle_tree_root.js +2 -3
- package/dest/trees/hasher.d.ts +3 -2
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +5 -5
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.js +5 -1
- package/dest/trees/membership_witness.d.ts +2 -2
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts +4 -2
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +1 -5
- package/dest/trees/sibling_path.d.ts +5 -4
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +10 -8
- package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
- package/dest/types/index.d.ts +9 -1
- package/dest/types/index.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/bigint-buffer/index.ts +6 -1
- package/src/branded-types/block_number.ts +20 -2
- package/src/branded-types/buffer32_hash.ts +38 -0
- package/src/branded-types/checkpoint_number.ts +16 -1
- package/src/branded-types/epoch.ts +1 -1
- package/src/branded-types/index.ts +1 -0
- package/src/branded-types/index_within_checkpoint.ts +1 -1
- package/src/branded-types/slot.ts +6 -1
- package/src/buffer/buffer16.ts +3 -0
- package/src/buffer/buffer32.ts +39 -68
- package/src/buffer/index.ts +1 -0
- package/src/buffer/utils.ts +8 -0
- package/src/collection/array.ts +34 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/lru_map.ts +143 -0
- package/src/collection/lru_set.ts +115 -0
- package/src/committable/committable.ts +1 -1
- package/src/config/env_var.ts +41 -23
- package/src/config/index.ts +116 -96
- package/src/config/network_config.ts +3 -0
- package/src/config/network_name.ts +0 -3
- package/src/config/secret_value.ts +1 -1
- package/src/crypto/aes128/index.ts +11 -2
- package/src/crypto/bls/bn254_keystore.ts +0 -23
- package/src/crypto/poseidon/index.ts +42 -34
- package/src/crypto/schnorr/index.ts +9 -8
- package/src/crypto/schnorr/signature.ts +17 -46
- package/src/crypto/secp256k1-signer/utils.ts +32 -0
- package/src/curves/bls12/field.ts +0 -7
- package/src/curves/bn254/field.ts +35 -34
- package/src/curves/grumpkin/point.ts +23 -40
- package/src/eth-address/index.ts +0 -4
- package/src/eth-signature/eth_signature.ts +7 -1
- package/src/fifo/fifo_frame_reader.ts +98 -0
- package/src/fifo/index.ts +1 -0
- package/src/fifo_set/fifo_set.ts +52 -0
- package/src/fifo_set/index.ts +1 -0
- package/src/json-rpc/client/fetch.ts +4 -3
- package/src/json-rpc/client/safe_json_rpc_client.ts +2 -2
- package/src/json-rpc/client/undici.ts +5 -3
- package/src/json-rpc/fixtures/test_state.ts +10 -10
- package/src/json-rpc/server/safe_json_rpc_server.ts +31 -13
- package/src/log/bigint-utils.ts +3 -0
- package/src/log/pino-logger.ts +19 -2
- package/src/noir/noir_package_config.ts +32 -20
- package/src/queue/batch_queue.ts +1 -0
- package/src/retry/index.ts +30 -0
- package/src/schemas/api.ts +25 -25
- package/src/schemas/parse.ts +9 -6
- package/src/schemas/schemas.ts +4 -4
- package/src/schemas/types.ts +2 -2
- package/src/schemas/utils.ts +4 -38
- package/src/serialize/buffer_sink.ts +350 -0
- package/src/serialize/index.ts +1 -0
- package/src/string/index.ts +1 -1
- package/src/timer/index.ts +1 -1
- package/src/timer/timeout.ts +31 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
- package/src/transport/index.ts +0 -1
- package/src/trees/balanced_merkle_tree_root.ts +2 -5
- package/src/trees/hasher.ts +6 -3
- package/src/trees/indexed_merkle_tree_calculator.ts +5 -1
- package/src/trees/merkle_tree_calculator.ts +4 -10
- package/src/trees/sibling_path.ts +11 -6
- package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
- package/src/types/index.ts +14 -0
- package/dest/crypto/serialize.d.ts +0 -51
- package/dest/crypto/serialize.d.ts.map +0 -1
- package/dest/crypto/serialize.js +0 -68
- package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
- package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
- package/src/crypto/serialize.ts +0 -85
- package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
package/src/config/index.ts
CHANGED
|
@@ -10,14 +10,14 @@ export type { EnvVar, NetworkNames };
|
|
|
10
10
|
export type { NetworkConfig, NetworkConfigMap } from './network_config.js';
|
|
11
11
|
export { NetworkConfigMapSchema, NetworkConfigSchema } from './network_config.js';
|
|
12
12
|
|
|
13
|
-
export interface ConfigMapping {
|
|
13
|
+
export interface ConfigMapping<T> {
|
|
14
14
|
env?: EnvVar;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/** Parse an env-var string into `T`. Throws on invalid input. */
|
|
16
|
+
parseEnv?: (val: string) => T;
|
|
17
|
+
defaultValue?: T;
|
|
17
18
|
printDefault?: (val: any) => string;
|
|
18
19
|
description: string;
|
|
19
20
|
isBoolean?: boolean;
|
|
20
|
-
nested?: Record<string, ConfigMapping>;
|
|
21
21
|
fallback?: EnvVar[];
|
|
22
22
|
/**
|
|
23
23
|
* List of deprecated env vars that are still supported but will log a warning.
|
|
@@ -30,7 +30,9 @@ export function isBooleanConfigValue<T>(obj: T, key: keyof T): boolean {
|
|
|
30
30
|
return typeof obj[key] === 'boolean';
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export type ConfigMappingsType<T> =
|
|
33
|
+
export type ConfigMappingsType<T> = {
|
|
34
|
+
[K in keyof T]-?: ConfigMapping<Required<T>[K]>;
|
|
35
|
+
};
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Shared utility function to get a value from environment variables with fallback support.
|
|
@@ -66,8 +68,8 @@ export function getValueFromEnvWithFallback<T>(
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
// Parse the value if needed
|
|
70
|
-
if (value !== undefined) {
|
|
71
|
+
// Parse the value if needed. Empty strings are treated as "not set".
|
|
72
|
+
if (value !== undefined && value !== '') {
|
|
71
73
|
return parseFunc ? parseFunc(value) : (value as unknown as T);
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -79,22 +81,20 @@ export function getConfigFromMappings<T>(configMappings: ConfigMappingsType<T>):
|
|
|
79
81
|
const config = {} as T;
|
|
80
82
|
|
|
81
83
|
for (const key in configMappings) {
|
|
82
|
-
const { env, parseEnv, defaultValue,
|
|
83
|
-
|
|
84
|
-
(config as any)[key] = getConfigFromMappings(nested);
|
|
85
|
-
} else {
|
|
86
|
-
// Use the shared utility function
|
|
84
|
+
const { env, parseEnv, defaultValue, fallback, deprecatedFallback } = configMappings[key];
|
|
85
|
+
try {
|
|
87
86
|
(config as any)[key] = getValueFromEnvWithFallback(env, parseEnv, defaultValue, fallback);
|
|
87
|
+
} catch (e: any) {
|
|
88
|
+
throw new Error(`Failed to parse config '${key}' (env: ${env ?? 'none'}): ${e.message}`);
|
|
89
|
+
}
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
userLog(warningMessage, { deprecatedEnvVar: deprecatedEnv, newEnvVar: env });
|
|
97
|
-
}
|
|
91
|
+
if (deprecatedFallback?.length) {
|
|
92
|
+
const userLog = createConsoleLogger('[DEPRECATED]');
|
|
93
|
+
for (const { env: deprecatedEnv, message } of deprecatedFallback) {
|
|
94
|
+
if (process.env[deprecatedEnv]) {
|
|
95
|
+
const warningMessage =
|
|
96
|
+
message ?? `Environment variable ${deprecatedEnv} is deprecated. Please use ${env} instead.`;
|
|
97
|
+
userLog(warningMessage, { deprecatedEnvVar: deprecatedEnv, newEnvVar: env });
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -123,7 +123,7 @@ export function omitConfigMappings<T, K extends keyof T>(
|
|
|
123
123
|
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
124
124
|
* @returns Object with parseEnv and default values for a numerical config value
|
|
125
125
|
*/
|
|
126
|
-
export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping
|
|
126
|
+
export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
|
|
127
127
|
return {
|
|
128
128
|
parseEnv: (val: string) => safeParseNumber(val, defaultVal),
|
|
129
129
|
defaultValue: defaultVal,
|
|
@@ -138,7 +138,7 @@ export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'par
|
|
|
138
138
|
export function floatConfigHelper(
|
|
139
139
|
defaultVal: number,
|
|
140
140
|
validationFn?: (val: number) => void,
|
|
141
|
-
): Pick<ConfigMapping
|
|
141
|
+
): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
|
|
142
142
|
return {
|
|
143
143
|
parseEnv: (val: string): number => {
|
|
144
144
|
const parsed = safeParseFloat(val, defaultVal);
|
|
@@ -152,7 +152,7 @@ export function floatConfigHelper(
|
|
|
152
152
|
/**
|
|
153
153
|
* Parses an environment variable to a 0-1 percentage value
|
|
154
154
|
*/
|
|
155
|
-
export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping
|
|
155
|
+
export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
|
|
156
156
|
return {
|
|
157
157
|
parseEnv: (val: string): number => {
|
|
158
158
|
const parsed = safeParseFloat(val, defaultVal);
|
|
@@ -171,11 +171,27 @@ export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping,
|
|
|
171
171
|
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
172
172
|
* @returns Object with parseEnv and default values for a numerical config value
|
|
173
173
|
*/
|
|
174
|
-
export function bigintConfigHelper(defaultVal
|
|
174
|
+
export function bigintConfigHelper(defaultVal: bigint): Pick<ConfigMapping<bigint>, 'parseEnv' | 'defaultValue'>;
|
|
175
|
+
export function bigintConfigHelper(): Pick<ConfigMapping<bigint | undefined>, 'parseEnv' | 'defaultValue'>;
|
|
176
|
+
export function bigintConfigHelper(
|
|
177
|
+
defaultVal?: bigint,
|
|
178
|
+
): Pick<ConfigMapping<bigint | undefined>, 'parseEnv' | 'defaultValue'> {
|
|
175
179
|
return {
|
|
176
180
|
parseEnv: (val: string) => {
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
// Handle scientific notation (e.g. "1e+23", "2E23") which BigInt() doesn't accept directly.
|
|
182
|
+
// We parse it losslessly using bigint arithmetic instead of going through float64.
|
|
183
|
+
if (/[eE]/.test(val)) {
|
|
184
|
+
const match = val.match(/^(-?\d+(?:\.(\d+))?)[eE]([+-]?\d+)$/);
|
|
185
|
+
if (!match) {
|
|
186
|
+
throw new Error(`Cannot convert '${val}' to a BigInt`);
|
|
187
|
+
}
|
|
188
|
+
const digits = match[1].replace('.', '');
|
|
189
|
+
const decimalPlaces = match[2]?.length ?? 0;
|
|
190
|
+
const exponent = parseInt(match[3], 10) - decimalPlaces;
|
|
191
|
+
if (exponent < 0) {
|
|
192
|
+
throw new Error(`Cannot convert '${val}' to a BigInt: result is not an integer`);
|
|
193
|
+
}
|
|
194
|
+
return BigInt(digits) * 10n ** BigInt(exponent);
|
|
179
195
|
}
|
|
180
196
|
return BigInt(val);
|
|
181
197
|
},
|
|
@@ -185,32 +201,37 @@ export function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'pa
|
|
|
185
201
|
|
|
186
202
|
/**
|
|
187
203
|
* Generates parseEnv for an optional numerical config value.
|
|
204
|
+
* Empty strings are already handled by getValueFromEnvWithFallback.
|
|
188
205
|
*/
|
|
189
|
-
export function optionalNumberConfigHelper(): Pick<ConfigMapping
|
|
206
|
+
export function optionalNumberConfigHelper(): Pick<ConfigMapping<number>, 'parseEnv'> {
|
|
190
207
|
return {
|
|
191
|
-
parseEnv: (val: string
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
208
|
+
parseEnv: (val: string) => {
|
|
209
|
+
const parsedValue = parseInt(val);
|
|
210
|
+
if (!Number.isSafeInteger(parsedValue)) {
|
|
211
|
+
throw new Error(`Invalid number: ${val}`);
|
|
195
212
|
}
|
|
196
|
-
return
|
|
213
|
+
return parsedValue;
|
|
197
214
|
},
|
|
198
215
|
};
|
|
199
216
|
}
|
|
200
217
|
|
|
201
218
|
/** Generates parseEnv for an enum-like config value. */
|
|
219
|
+
export function enumConfigHelper<T extends string>(
|
|
220
|
+
values: T[],
|
|
221
|
+
defaultValue: NoInfer<T>,
|
|
222
|
+
): Pick<ConfigMapping<T>, 'parseEnv' | 'defaultValue'>;
|
|
223
|
+
export function enumConfigHelper<T extends string>(
|
|
224
|
+
values: T[],
|
|
225
|
+
): Pick<ConfigMapping<T | undefined>, 'parseEnv' | 'defaultValue'>;
|
|
202
226
|
export function enumConfigHelper<T extends string>(
|
|
203
227
|
values: T[],
|
|
204
228
|
defaultValue?: NoInfer<T>,
|
|
205
|
-
): Pick<ConfigMapping
|
|
229
|
+
): Pick<ConfigMapping<T | undefined>, 'parseEnv' | 'defaultValue'> {
|
|
206
230
|
return {
|
|
207
231
|
parseEnv: (val: string) => {
|
|
208
|
-
const sanitizedVal =
|
|
209
|
-
if (values.
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
if (!val && defaultValue) {
|
|
213
|
-
return defaultValue;
|
|
232
|
+
const sanitizedVal = val.trim().toLowerCase();
|
|
233
|
+
if (values.some(v => v.toLowerCase() === sanitizedVal)) {
|
|
234
|
+
return values.find(v => v.toLowerCase() === sanitizedVal)!;
|
|
214
235
|
}
|
|
215
236
|
throw new Error(`Invalid config value '${val}' (must be one of ${values.join(', ')})`);
|
|
216
237
|
},
|
|
@@ -225,7 +246,9 @@ export function enumConfigHelper<T extends string>(
|
|
|
225
246
|
*/
|
|
226
247
|
export function booleanConfigHelper(
|
|
227
248
|
defaultVal = false,
|
|
228
|
-
): Required<
|
|
249
|
+
): Required<
|
|
250
|
+
Pick<ConfigMapping<boolean>, 'parseEnv' | 'defaultValue' | 'isBoolean'> & { parseVal: (val: string) => boolean }
|
|
251
|
+
> {
|
|
229
252
|
const parse = (val: string | boolean) => (typeof val === 'boolean' ? val : parseBooleanEnv(val));
|
|
230
253
|
return {
|
|
231
254
|
parseEnv: parse,
|
|
@@ -235,91 +258,88 @@ export function booleanConfigHelper(
|
|
|
235
258
|
};
|
|
236
259
|
}
|
|
237
260
|
|
|
238
|
-
export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T):
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
261
|
+
export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T): Pick<
|
|
262
|
+
ConfigMapping<SecretValue<T>>,
|
|
263
|
+
'parseEnv' | 'defaultValue'
|
|
264
|
+
> & {
|
|
265
|
+
parseVal: (val: string) => SecretValue<T>;
|
|
266
|
+
} {
|
|
243
267
|
const wrap = (val: string) => new SecretValue(parse(val));
|
|
244
268
|
return {
|
|
245
269
|
parseEnv: wrap,
|
|
246
270
|
parseVal: wrap,
|
|
247
271
|
defaultValue: new SecretValue(parse(undefined)),
|
|
248
|
-
isBoolean: true,
|
|
249
272
|
};
|
|
250
273
|
}
|
|
251
274
|
|
|
252
275
|
export { parseBooleanEnv } from './parse-env.js';
|
|
253
276
|
|
|
254
|
-
export function secretStringConfigHelper():
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
export function secretStringConfigHelper(defaultValue: string):
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
export function secretStringConfigHelper(defaultValue?: string):
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
277
|
+
export function secretStringConfigHelper(): {
|
|
278
|
+
parseEnv: (val: string) => SecretValue<string>;
|
|
279
|
+
parseVal: (val: string) => SecretValue<string>;
|
|
280
|
+
defaultValue: undefined;
|
|
281
|
+
};
|
|
282
|
+
export function secretStringConfigHelper(defaultValue: string): {
|
|
283
|
+
parseEnv: (val: string) => SecretValue<string>;
|
|
284
|
+
parseVal: (val: string) => SecretValue<string>;
|
|
285
|
+
defaultValue: SecretValue<string>;
|
|
286
|
+
};
|
|
287
|
+
export function secretStringConfigHelper(defaultValue?: string): {
|
|
288
|
+
parseEnv: (val: string) => SecretValue<string>;
|
|
289
|
+
parseVal: (val: string) => SecretValue<string>;
|
|
290
|
+
defaultValue: SecretValue<string> | undefined;
|
|
291
|
+
} {
|
|
269
292
|
const parse = (val: string) => new SecretValue(val);
|
|
270
293
|
return {
|
|
271
294
|
parseEnv: parse,
|
|
272
295
|
parseVal: parse,
|
|
273
296
|
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
274
|
-
isBoolean: true,
|
|
275
297
|
};
|
|
276
298
|
}
|
|
277
299
|
|
|
278
|
-
export function secretFrConfigHelper():
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
export function secretFrConfigHelper(defaultValue: Fr):
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
export function secretFrConfigHelper(defaultValue?: Fr):
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
300
|
+
export function secretFrConfigHelper(): {
|
|
301
|
+
parseEnv: (val: string) => SecretValue<Fr>;
|
|
302
|
+
parseVal: (val: string) => SecretValue<Fr>;
|
|
303
|
+
defaultValue: undefined;
|
|
304
|
+
};
|
|
305
|
+
export function secretFrConfigHelper(defaultValue: Fr): {
|
|
306
|
+
parseEnv: (val: string) => SecretValue<Fr>;
|
|
307
|
+
parseVal: (val: string) => SecretValue<Fr>;
|
|
308
|
+
defaultValue: SecretValue<Fr>;
|
|
309
|
+
};
|
|
310
|
+
export function secretFrConfigHelper(defaultValue?: Fr): {
|
|
311
|
+
parseEnv: (val: string) => SecretValue<Fr>;
|
|
312
|
+
parseVal: (val: string) => SecretValue<Fr>;
|
|
313
|
+
defaultValue: SecretValue<Fr> | undefined;
|
|
314
|
+
} {
|
|
293
315
|
const parse = (val: string) => new SecretValue(Fr.fromHexString(val));
|
|
294
316
|
return {
|
|
295
317
|
parseEnv: parse,
|
|
296
318
|
parseVal: parse,
|
|
297
319
|
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
298
|
-
isBoolean: true,
|
|
299
320
|
};
|
|
300
321
|
}
|
|
301
322
|
|
|
302
|
-
export function secretFqConfigHelper(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
export function secretFqConfigHelper():
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
export function secretFqConfigHelper(defaultValue?: Fq):
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
323
|
+
export function secretFqConfigHelper(): {
|
|
324
|
+
parseEnv: (val: string) => SecretValue<Fq>;
|
|
325
|
+
parseVal: (val: string) => SecretValue<Fq>;
|
|
326
|
+
defaultValue: undefined;
|
|
327
|
+
};
|
|
328
|
+
export function secretFqConfigHelper(defaultValue: Fq): {
|
|
329
|
+
parseEnv: (val: string) => SecretValue<Fq>;
|
|
330
|
+
parseVal: (val: string) => SecretValue<Fq>;
|
|
331
|
+
defaultValue: SecretValue<Fq>;
|
|
332
|
+
};
|
|
333
|
+
export function secretFqConfigHelper(defaultValue?: Fq): {
|
|
334
|
+
parseEnv: (val: string) => SecretValue<Fq>;
|
|
335
|
+
parseVal: (val: string) => SecretValue<Fq>;
|
|
336
|
+
defaultValue: SecretValue<Fq> | undefined;
|
|
337
|
+
} {
|
|
317
338
|
const parse = (val: string) => new SecretValue(Fq.fromHexString(val));
|
|
318
339
|
return {
|
|
319
340
|
parseEnv: parse,
|
|
320
341
|
parseVal: parse,
|
|
321
|
-
defaultValue:
|
|
322
|
-
isBoolean: true,
|
|
342
|
+
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
323
343
|
};
|
|
324
344
|
}
|
|
325
345
|
|
|
@@ -5,10 +5,13 @@ export const NetworkConfigSchema = z
|
|
|
5
5
|
bootnodes: z.array(z.string()),
|
|
6
6
|
snapshots: z.array(z.string()),
|
|
7
7
|
blobFileStoreUrls: z.array(z.string()).optional(),
|
|
8
|
+
txCollectionFileStoreUrls: z.array(z.string()).optional(),
|
|
8
9
|
registryAddress: z.string(),
|
|
9
10
|
feeAssetHandlerAddress: z.string().optional(),
|
|
10
11
|
l1ChainId: z.number(),
|
|
11
12
|
blockDurationMs: z.number().positive().optional(),
|
|
13
|
+
txPublicSetupAllowListExtend: z.string().optional(),
|
|
14
|
+
nodeVersion: z.string().optional(),
|
|
12
15
|
})
|
|
13
16
|
.passthrough(); // Allow additional unknown fields to pass through
|
|
14
17
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type NetworkNames =
|
|
2
2
|
| 'local'
|
|
3
|
-
| 'staging-ignition'
|
|
4
3
|
| 'staging-public'
|
|
5
4
|
| 'testnet'
|
|
6
5
|
| 'mainnet'
|
|
@@ -12,8 +11,6 @@ export function getActiveNetworkName(name?: string): NetworkNames {
|
|
|
12
11
|
const network = name || process.env.NETWORK;
|
|
13
12
|
if (!network || network === '' || network === 'local') {
|
|
14
13
|
return 'local';
|
|
15
|
-
} else if (network === 'staging-ignition') {
|
|
16
|
-
return network;
|
|
17
14
|
} else if (network === 'staging-public') {
|
|
18
15
|
return network;
|
|
19
16
|
} else if (network === 'testnet' || network === 'alpha-testnet') {
|
|
@@ -43,7 +43,7 @@ export class SecretValue<T> {
|
|
|
43
43
|
/**
|
|
44
44
|
* Returns a Zod schema
|
|
45
45
|
*/
|
|
46
|
-
static schema<O>(valueSchema: ZodType<O, any
|
|
46
|
+
static schema<O>(valueSchema: ZodType<O, any>): ZodType<SecretValue<O>, any> {
|
|
47
47
|
return valueSchema.transform(value => new SecretValue<O>(value));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -59,10 +59,19 @@ export class Aes128 {
|
|
|
59
59
|
* @param iv - AES initialization vector.
|
|
60
60
|
* @param key - Key to decrypt with.
|
|
61
61
|
* @returns Decrypted data.
|
|
62
|
+
* @throws If the decrypted buffer has invalid PKCS#7 padding.
|
|
62
63
|
*/
|
|
63
64
|
public async decryptBufferCBC(data: Uint8Array, iv: Uint8Array, key: Uint8Array) {
|
|
64
65
|
const paddedBuffer = await this.decryptBufferCBCKeepPadding(data, iv, key);
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const paddingLen = paddedBuffer[paddedBuffer.length - 1];
|
|
67
|
+
if (paddingLen === 0 || paddingLen > 16) {
|
|
68
|
+
throw new Error(`Invalid PKCS#7 padding length: ${paddingLen}`);
|
|
69
|
+
}
|
|
70
|
+
for (let i = paddedBuffer.length - paddingLen; i < paddedBuffer.length; i++) {
|
|
71
|
+
if (paddedBuffer[i] !== paddingLen) {
|
|
72
|
+
throw new Error('Invalid PKCS#7 padding');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return paddedBuffer.subarray(0, paddedBuffer.length - paddingLen);
|
|
67
76
|
}
|
|
68
77
|
}
|
|
@@ -262,26 +262,3 @@ export function decryptBn254KeystoreFromObject(keystore: Bn254Keystore, password
|
|
|
262
262
|
throw new Bn254KeystoreError(`Failed to decrypt keystore: ${String(error)}`, error as Error);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Validates that a decrypted private key matches the public key in the keystore.
|
|
268
|
-
*
|
|
269
|
-
* @param privateKeyHex - Decrypted private key (0x-prefixed)
|
|
270
|
-
* @param expectedPubkey - Expected public key from keystore
|
|
271
|
-
* @param computePublicKey - Function to compute public key from private key
|
|
272
|
-
* @returns true if keys match, false otherwise
|
|
273
|
-
*/
|
|
274
|
-
export function verifyBn254Keypair(
|
|
275
|
-
privateKeyHex: string,
|
|
276
|
-
expectedPubkey: string,
|
|
277
|
-
computePublicKey: (privateKey: string) => string,
|
|
278
|
-
): boolean {
|
|
279
|
-
try {
|
|
280
|
-
const computedPubkey = computePublicKey(privateKeyHex);
|
|
281
|
-
const normalizedExpected = expectedPubkey.toLowerCase().replace(/^0x/i, '');
|
|
282
|
-
const normalizedComputed = computedPubkey.toLowerCase().replace(/^0x/i, '');
|
|
283
|
-
return normalizedExpected === normalizedComputed;
|
|
284
|
-
} catch {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import { Barretenberg } from '@aztec/bb.js';
|
|
1
|
+
import { Barretenberg, BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
|
|
3
3
|
import { Fr } from '../../curves/bn254/field.js';
|
|
4
4
|
import { type Fieldable, serializeToFields } from '../../serialize/serialize.js';
|
|
5
5
|
|
|
6
|
+
const IS_BROWSER = typeof self !== 'undefined';
|
|
7
|
+
|
|
8
|
+
async function poseidon2HashFields(inputFields: Fr[]): Promise<Fr> {
|
|
9
|
+
if (IS_BROWSER) {
|
|
10
|
+
await BarretenbergSync.initSingleton();
|
|
11
|
+
const api = BarretenbergSync.getSingleton();
|
|
12
|
+
const response = api.poseidon2Hash({
|
|
13
|
+
inputs: inputFields.map(i => i.toBuffer()),
|
|
14
|
+
});
|
|
15
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
16
|
+
} else {
|
|
17
|
+
await Barretenberg.initSingleton();
|
|
18
|
+
const api = Barretenberg.getSingleton();
|
|
19
|
+
const response = await api.poseidon2Hash({
|
|
20
|
+
inputs: inputFields.map(i => i.toBuffer()),
|
|
21
|
+
});
|
|
22
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
6
26
|
/**
|
|
7
27
|
* Create a poseidon hash (field) from an array of input fields.
|
|
8
28
|
* @param input - The input fields to hash.
|
|
9
29
|
* @returns The poseidon hash.
|
|
10
30
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
await Barretenberg.initSingleton();
|
|
14
|
-
const api = Barretenberg.getSingleton();
|
|
15
|
-
const response = await api.poseidon2Hash({
|
|
16
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
17
|
-
});
|
|
18
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
31
|
+
export function poseidon2Hash(input: Fieldable[]): Promise<Fr> {
|
|
32
|
+
return poseidon2HashFields(serializeToFields(input));
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
/**
|
|
@@ -24,15 +38,10 @@ export async function poseidon2Hash(input: Fieldable[]): Promise<Fr> {
|
|
|
24
38
|
* @param separator - The domain separator.
|
|
25
39
|
* @returns The poseidon hash.
|
|
26
40
|
*/
|
|
27
|
-
export
|
|
41
|
+
export function poseidon2HashWithSeparator(input: Fieldable[], separator: number): Promise<Fr> {
|
|
28
42
|
const inputFields = serializeToFields(input);
|
|
29
43
|
inputFields.unshift(new Fr(separator));
|
|
30
|
-
|
|
31
|
-
const api = Barretenberg.getSingleton();
|
|
32
|
-
const response = await api.poseidon2Hash({
|
|
33
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
34
|
-
});
|
|
35
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
44
|
+
return poseidon2HashFields(inputFields);
|
|
36
45
|
}
|
|
37
46
|
|
|
38
47
|
/**
|
|
@@ -42,19 +51,24 @@ export async function poseidon2HashWithSeparator(input: Fieldable[], separator:
|
|
|
42
51
|
*/
|
|
43
52
|
export async function poseidon2Permutation(input: Fieldable[]): Promise<Fr[]> {
|
|
44
53
|
const inputFields = serializeToFields(input);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if (IS_BROWSER) {
|
|
55
|
+
await BarretenbergSync.initSingleton();
|
|
56
|
+
const api = BarretenbergSync.getSingleton();
|
|
57
|
+
const response = api.poseidon2Permutation({
|
|
58
|
+
inputs: inputFields.map(i => i.toBuffer()),
|
|
59
|
+
});
|
|
60
|
+
return response.outputs.map(o => Fr.fromBuffer(Buffer.from(o)));
|
|
61
|
+
} else {
|
|
62
|
+
await Barretenberg.initSingleton();
|
|
63
|
+
const api = Barretenberg.getSingleton();
|
|
64
|
+
const response = await api.poseidon2Permutation({
|
|
65
|
+
inputs: inputFields.map(i => i.toBuffer()),
|
|
66
|
+
});
|
|
67
|
+
return response.outputs.map(o => Fr.fromBuffer(Buffer.from(o)));
|
|
68
|
+
}
|
|
55
69
|
}
|
|
56
70
|
|
|
57
|
-
export
|
|
71
|
+
export function poseidon2HashBytes(input: Buffer): Promise<Fr> {
|
|
58
72
|
const inputFields = [];
|
|
59
73
|
for (let i = 0; i < input.length; i += 31) {
|
|
60
74
|
const fieldBytes = Buffer.alloc(32, 0);
|
|
@@ -65,11 +79,5 @@ export async function poseidon2HashBytes(input: Buffer): Promise<Fr> {
|
|
|
65
79
|
inputFields.push(Fr.fromBuffer(fieldBytes));
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
|
|
69
|
-
const api = Barretenberg.getSingleton();
|
|
70
|
-
const response = await api.poseidon2Hash({
|
|
71
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
82
|
+
return poseidon2HashFields(inputFields);
|
|
75
83
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
3
4
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
|
|
@@ -23,33 +24,33 @@ export class Schnorr {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
|
-
* Constructs a Schnorr signature
|
|
27
|
-
* @param msg -
|
|
27
|
+
* Constructs a Schnorr signature over a 32-byte message field element.
|
|
28
|
+
* @param msg - The message hash, as a grumpkin base field element.
|
|
28
29
|
* @param privateKey - The private key of the signer.
|
|
29
30
|
* @returns A Schnorr signature of the form (s, e).
|
|
30
31
|
*/
|
|
31
|
-
public async constructSignature(msg:
|
|
32
|
+
public async constructSignature(msg: Fr, privateKey: GrumpkinScalar) {
|
|
32
33
|
await BarretenbergSync.initSingleton();
|
|
33
34
|
const api = BarretenbergSync.getSingleton();
|
|
34
35
|
const response = api.schnorrConstructSignature({
|
|
35
|
-
|
|
36
|
+
messageField: msg.toBuffer(),
|
|
36
37
|
privateKey: privateKey.toBuffer(),
|
|
37
38
|
});
|
|
38
39
|
return new SchnorrSignature(Buffer.from([...response.s, ...response.e]));
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
* Verifies a Schnorr signature
|
|
43
|
-
* @param msg -
|
|
43
|
+
* Verifies a Schnorr signature against a Grumpkin public key.
|
|
44
|
+
* @param msg - The message hash, as a grumpkin base field element.
|
|
44
45
|
* @param pubKey - The Grumpkin public key of the signer.
|
|
45
46
|
* @param sig - The Schnorr signature.
|
|
46
47
|
* @returns True or false.
|
|
47
48
|
*/
|
|
48
|
-
public async verifySignature(msg:
|
|
49
|
+
public async verifySignature(msg: Fr, pubKey: Point, sig: SchnorrSignature) {
|
|
49
50
|
await BarretenbergSync.initSingleton();
|
|
50
51
|
const api = BarretenbergSync.getSingleton();
|
|
51
52
|
const response = api.schnorrVerifySignature({
|
|
52
|
-
|
|
53
|
+
messageField: msg.toBuffer(),
|
|
53
54
|
publicKey: { x: pubKey.x.toBuffer(), y: pubKey.y.toBuffer() },
|
|
54
55
|
s: sig.s,
|
|
55
56
|
e: sig.e,
|