@aztec/foundation 0.7.0 → 0.7.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/Dockerfile +15 -0
- package/package.json +1 -1
- package/src/abi/abi.ts +1 -1
- package/src/abi/decoder.ts +1 -1
- package/.tsbuildinfo +0 -1
- package/dest/abi/abi.d.ts +0 -232
- package/dest/abi/abi.d.ts.map +0 -1
- package/dest/abi/abi.js +0 -37
- package/dest/abi/abi_coder.d.ts +0 -8
- package/dest/abi/abi_coder.d.ts.map +0 -1
- package/dest/abi/abi_coder.js +0 -24
- package/dest/abi/decoder.d.ts +0 -57
- package/dest/abi/decoder.d.ts.map +0 -1
- package/dest/abi/decoder.js +0 -149
- package/dest/abi/decoder.test.d.ts +0 -2
- package/dest/abi/decoder.test.d.ts.map +0 -1
- package/dest/abi/decoder.test.js +0 -70
- package/dest/abi/encoder.d.ts +0 -10
- package/dest/abi/encoder.d.ts.map +0 -1
- package/dest/abi/encoder.js +0 -89
- package/dest/abi/encoder.test.d.ts +0 -2
- package/dest/abi/encoder.test.d.ts.map +0 -1
- package/dest/abi/encoder.test.js +0 -74
- package/dest/abi/function_selector.d.ts +0 -73
- package/dest/abi/function_selector.d.ts.map +0 -1
- package/dest/abi/function_selector.js +0 -104
- package/dest/abi/index.d.ts +0 -6
- package/dest/abi/index.d.ts.map +0 -1
- package/dest/abi/index.js +0 -6
- package/dest/async-map/async_map.test.d.ts +0 -2
- package/dest/async-map/async_map.test.d.ts.map +0 -1
- package/dest/async-map/async_map.test.js +0 -9
- package/dest/async-map/index.d.ts +0 -13
- package/dest/async-map/index.d.ts.map +0 -1
- package/dest/async-map/index.js +0 -19
- package/dest/aztec-address/index.d.ts +0 -114
- package/dest/aztec-address/index.d.ts.map +0 -1
- package/dest/aztec-address/index.js +0 -148
- package/dest/bigint-buffer/bigint-buffer.test.d.ts +0 -2
- package/dest/bigint-buffer/bigint-buffer.test.d.ts.map +0 -1
- package/dest/bigint-buffer/bigint-buffer.test.js +0 -18
- package/dest/bigint-buffer/index.d.ts +0 -35
- package/dest/bigint-buffer/index.d.ts.map +0 -1
- package/dest/bigint-buffer/index.js +0 -68
- package/dest/collection/array.d.ts +0 -30
- package/dest/collection/array.d.ts.map +0 -1
- package/dest/collection/array.js +0 -47
- package/dest/collection/index.d.ts +0 -2
- package/dest/collection/index.d.ts.map +0 -1
- package/dest/collection/index.js +0 -2
- package/dest/committable/committable.d.ts +0 -28
- package/dest/committable/committable.d.ts.map +0 -1
- package/dest/committable/committable.js +0 -41
- package/dest/committable/committable.test.d.ts +0 -2
- package/dest/committable/committable.test.d.ts.map +0 -1
- package/dest/committable/committable.test.js +0 -26
- package/dest/committable/index.d.ts +0 -2
- package/dest/committable/index.d.ts.map +0 -1
- package/dest/committable/index.js +0 -2
- package/dest/crypto/index.d.ts +0 -4
- package/dest/crypto/index.d.ts.map +0 -1
- package/dest/crypto/index.js +0 -4
- package/dest/crypto/keccak/index.d.ts +0 -20
- package/dest/crypto/keccak/index.d.ts.map +0 -1
- package/dest/crypto/keccak/index.js +0 -31
- package/dest/crypto/random/index.d.ts +0 -3
- package/dest/crypto/random/index.d.ts.map +0 -1
- package/dest/crypto/random/index.js +0 -36
- package/dest/crypto/random/index.test.d.ts +0 -2
- package/dest/crypto/random/index.test.d.ts.map +0 -1
- package/dest/crypto/random/index.test.js +0 -13
- package/dest/crypto/sha256/index.d.ts +0 -11
- package/dest/crypto/sha256/index.d.ts.map +0 -1
- package/dest/crypto/sha256/index.js +0 -14
- package/dest/crypto/sha256/index.test.d.ts +0 -2
- package/dest/crypto/sha256/index.test.d.ts.map +0 -1
- package/dest/crypto/sha256/index.test.js +0 -11
- package/dest/errors/index.d.ts +0 -8
- package/dest/errors/index.d.ts.map +0 -1
- package/dest/errors/index.js +0 -8
- package/dest/eth-address/eth_address.test.d.ts +0 -2
- package/dest/eth-address/eth_address.test.d.ts.map +0 -1
- package/dest/eth-address/eth_address.test.js +0 -95
- package/dest/eth-address/index.d.ts +0 -144
- package/dest/eth-address/index.d.ts.map +0 -1
- package/dest/eth-address/index.js +0 -228
- package/dest/fields/coordinate.d.ts +0 -67
- package/dest/fields/coordinate.d.ts.map +0 -1
- package/dest/fields/coordinate.js +0 -95
- package/dest/fields/coordinate.test.d.ts +0 -2
- package/dest/fields/coordinate.test.d.ts.map +0 -1
- package/dest/fields/coordinate.test.js +0 -22
- package/dest/fields/fields.d.ts +0 -177
- package/dest/fields/fields.d.ts.map +0 -1
- package/dest/fields/fields.js +0 -219
- 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/dest/fields/grumpkin_scalar.test.d.ts +0 -2
- package/dest/fields/grumpkin_scalar.test.d.ts.map +0 -1
- package/dest/fields/grumpkin_scalar.test.js +0 -45
- package/dest/fields/index.d.ts +0 -5
- package/dest/fields/index.d.ts.map +0 -1
- package/dest/fields/index.js +0 -5
- package/dest/fields/point.d.ts +0 -105
- package/dest/fields/point.d.ts.map +0 -1
- package/dest/fields/point.js +0 -125
- package/dest/fifo/bounded_serial_queue.d.ts +0 -56
- package/dest/fifo/bounded_serial_queue.d.ts.map +0 -1
- package/dest/fifo/bounded_serial_queue.js +0 -94
- package/dest/fifo/index.d.ts +0 -5
- package/dest/fifo/index.d.ts.map +0 -1
- package/dest/fifo/index.js +0 -5
- package/dest/fifo/memory_fifo.d.ts +0 -55
- package/dest/fifo/memory_fifo.d.ts.map +0 -1
- package/dest/fifo/memory_fifo.js +0 -109
- package/dest/fifo/semaphore.d.ts +0 -23
- package/dest/fifo/semaphore.d.ts.map +0 -1
- package/dest/fifo/semaphore.js +0 -30
- package/dest/fifo/serial_queue.d.ts +0 -48
- package/dest/fifo/serial_queue.d.ts.map +0 -1
- package/dest/fifo/serial_queue.js +0 -74
- package/dest/json-rpc/class_converter.d.ts +0 -144
- package/dest/json-rpc/class_converter.d.ts.map +0 -1
- package/dest/json-rpc/class_converter.js +0 -100
- package/dest/json-rpc/client/index.d.ts +0 -2
- package/dest/json-rpc/client/index.d.ts.map +0 -1
- package/dest/json-rpc/client/index.js +0 -2
- package/dest/json-rpc/client/json_rpc_client.d.ts +0 -29
- package/dest/json-rpc/client/json_rpc_client.d.ts.map +0 -1
- package/dest/json-rpc/client/json_rpc_client.js +0 -104
- package/dest/json-rpc/client/json_rpc_client.test.d.ts +0 -2
- package/dest/json-rpc/client/json_rpc_client.test.d.ts.map +0 -1
- package/dest/json-rpc/client/json_rpc_client.test.js +0 -20
- package/dest/json-rpc/convert.d.ts +0 -28
- package/dest/json-rpc/convert.d.ts.map +0 -1
- package/dest/json-rpc/convert.js +0 -139
- package/dest/json-rpc/convert.test.d.ts +0 -2
- package/dest/json-rpc/convert.test.d.ts.map +0 -1
- package/dest/json-rpc/convert.test.js +0 -68
- package/dest/json-rpc/fixtures/class_a.d.ts +0 -11
- package/dest/json-rpc/fixtures/class_a.d.ts.map +0 -1
- package/dest/json-rpc/fixtures/class_a.js +0 -17
- package/dest/json-rpc/fixtures/class_b.d.ts +0 -11
- package/dest/json-rpc/fixtures/class_b.d.ts.map +0 -1
- package/dest/json-rpc/fixtures/class_b.js +0 -17
- package/dest/json-rpc/fixtures/test_state.d.ts +0 -47
- package/dest/json-rpc/fixtures/test_state.d.ts.map +0 -1
- package/dest/json-rpc/fixtures/test_state.js +0 -62
- package/dest/json-rpc/index.d.ts +0 -3
- package/dest/json-rpc/index.d.ts.map +0 -1
- package/dest/json-rpc/index.js +0 -3
- package/dest/json-rpc/js_utils.d.ts +0 -13
- package/dest/json-rpc/js_utils.d.ts.map +0 -1
- package/dest/json-rpc/js_utils.js +0 -18
- package/dest/json-rpc/server/index.d.ts +0 -3
- package/dest/json-rpc/server/index.d.ts.map +0 -1
- package/dest/json-rpc/server/index.js +0 -3
- package/dest/json-rpc/server/json_proxy.d.ts +0 -18
- package/dest/json-rpc/server/json_proxy.d.ts.map +0 -1
- package/dest/json-rpc/server/json_proxy.js +0 -36
- package/dest/json-rpc/server/json_rpc_server.d.ts +0 -34
- package/dest/json-rpc/server/json_rpc_server.d.ts.map +0 -1
- package/dest/json-rpc/server/json_rpc_server.js +0 -133
- package/dest/json-rpc/server/json_rpc_server.test.d.ts +0 -2
- package/dest/json-rpc/server/json_rpc_server.test.d.ts.map +0 -1
- package/dest/json-rpc/server/json_rpc_server.test.js +0 -22
- package/dest/log/console.d.ts +0 -11
- package/dest/log/console.d.ts.map +0 -1
- package/dest/log/console.js +0 -38
- package/dest/log/debug.d.ts +0 -43
- package/dest/log/debug.d.ts.map +0 -1
- package/dest/log/debug.js +0 -75
- package/dest/log/index.d.ts +0 -9
- package/dest/log/index.d.ts.map +0 -1
- package/dest/log/index.js +0 -5
- package/dest/log/log_history.d.ts +0 -31
- package/dest/log/log_history.d.ts.map +0 -1
- package/dest/log/log_history.js +0 -42
- package/dest/log/log_history.test.d.ts +0 -2
- package/dest/log/log_history.test.d.ts.map +0 -1
- package/dest/log/log_history.test.js +0 -78
- package/dest/log/logger.d.ts +0 -34
- package/dest/log/logger.d.ts.map +0 -1
- package/dest/log/logger.js +0 -78
- package/dest/mutex/index.d.ts +0 -53
- package/dest/mutex/index.d.ts.map +0 -1
- package/dest/mutex/index.js +0 -74
- package/dest/mutex/mutex.test.d.ts +0 -9
- package/dest/mutex/mutex.test.d.ts.map +0 -1
- package/dest/mutex/mutex.test.js +0 -58
- package/dest/mutex/mutex_database.d.ts +0 -10
- package/dest/mutex/mutex_database.d.ts.map +0 -1
- package/dest/mutex/mutex_database.js +0 -2
- package/dest/retry/index.d.ts +0 -44
- package/dest/retry/index.d.ts.map +0 -1
- package/dest/retry/index.js +0 -89
- package/dest/running-promise/index.d.ts +0 -35
- package/dest/running-promise/index.d.ts.map +0 -1
- package/dest/running-promise/index.js +0 -59
- package/dest/serialize/buffer_reader.d.ts +0 -188
- package/dest/serialize/buffer_reader.d.ts.map +0 -1
- package/dest/serialize/buffer_reader.js +0 -229
- package/dest/serialize/buffer_reader.test.d.ts +0 -2
- package/dest/serialize/buffer_reader.test.d.ts.map +0 -1
- package/dest/serialize/buffer_reader.test.js +0 -156
- package/dest/serialize/deserializer.d.ts +0 -134
- package/dest/serialize/deserializer.d.ts.map +0 -1
- package/dest/serialize/deserializer.js +0 -145
- package/dest/serialize/free_funcs.d.ts +0 -203
- package/dest/serialize/free_funcs.d.ts.map +0 -1
- package/dest/serialize/free_funcs.js +0 -250
- package/dest/serialize/index.d.ts +0 -6
- package/dest/serialize/index.d.ts.map +0 -1
- package/dest/serialize/index.js +0 -6
- package/dest/serialize/serialize.test.d.ts +0 -2
- package/dest/serialize/serialize.test.d.ts.map +0 -1
- package/dest/serialize/serialize.test.js +0 -68
- package/dest/serialize/serializer.d.ts +0 -89
- package/dest/serialize/serializer.d.ts.map +0 -1
- package/dest/serialize/serializer.js +0 -111
- package/dest/serialize/types.d.ts +0 -33
- package/dest/serialize/types.d.ts.map +0 -1
- package/dest/serialize/types.js +0 -22
- package/dest/sleep/index.d.ts +0 -52
- package/dest/sleep/index.d.ts.map +0 -1
- package/dest/sleep/index.js +0 -70
- package/dest/timer/index.d.ts +0 -3
- package/dest/timer/index.d.ts.map +0 -1
- package/dest/timer/index.js +0 -3
- package/dest/timer/timeout.d.ts +0 -41
- package/dest/timer/timeout.d.ts.map +0 -1
- package/dest/timer/timeout.js +0 -62
- package/dest/timer/timer.d.ts +0 -33
- package/dest/timer/timer.d.ts.map +0 -1
- package/dest/timer/timer.js +0 -38
- package/dest/transport/browser/index.d.ts +0 -5
- package/dest/transport/browser/index.d.ts.map +0 -1
- package/dest/transport/browser/index.js +0 -5
- package/dest/transport/browser/message_port_socket.d.ts +0 -37
- package/dest/transport/browser/message_port_socket.d.ts.map +0 -1
- package/dest/transport/browser/message_port_socket.js +0 -46
- package/dest/transport/browser/shared_worker_connector.d.ts +0 -19
- package/dest/transport/browser/shared_worker_connector.d.ts.map +0 -1
- package/dest/transport/browser/shared_worker_connector.js +0 -21
- package/dest/transport/browser/shared_worker_listener.d.ts +0 -38
- package/dest/transport/browser/shared_worker_listener.d.ts.map +0 -1
- package/dest/transport/browser/shared_worker_listener.js +0 -37
- package/dest/transport/browser/worker_connector.d.ts +0 -26
- package/dest/transport/browser/worker_connector.d.ts.map +0 -1
- package/dest/transport/browser/worker_connector.js +0 -30
- package/dest/transport/browser/worker_listener.d.ts +0 -39
- package/dest/transport/browser/worker_listener.d.ts.map +0 -1
- package/dest/transport/browser/worker_listener.js +0 -39
- 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 -18
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +0 -102
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +0 -1
- package/dest/transport/dispatch/create_dispatch_proxy.js +0 -56
- package/dest/transport/dispatch/messages.d.ts +0 -52
- package/dest/transport/dispatch/messages.d.ts.map +0 -1
- package/dest/transport/dispatch/messages.js +0 -12
- package/dest/transport/index.d.ts +0 -12
- package/dest/transport/index.d.ts.map +0 -1
- package/dest/transport/index.js +0 -12
- package/dest/transport/interface/connector.d.ts +0 -8
- package/dest/transport/interface/connector.d.ts.map +0 -1
- package/dest/transport/interface/connector.js +0 -2
- package/dest/transport/interface/listener.d.ts +0 -13
- package/dest/transport/interface/listener.d.ts.map +0 -1
- package/dest/transport/interface/listener.js +0 -2
- package/dest/transport/interface/socket.d.ts +0 -13
- package/dest/transport/interface/socket.d.ts.map +0 -1
- package/dest/transport/interface/socket.js +0 -2
- package/dest/transport/interface/transferable.d.ts +0 -68
- package/dest/transport/interface/transferable.d.ts.map +0 -1
- package/dest/transport/interface/transferable.js +0 -63
- package/dest/transport/node/index.d.ts +0 -3
- package/dest/transport/node/index.d.ts.map +0 -1
- package/dest/transport/node/index.js +0 -3
- package/dest/transport/node/node_connector.d.ts +0 -28
- package/dest/transport/node/node_connector.d.ts.map +0 -1
- package/dest/transport/node/node_connector.js +0 -28
- package/dest/transport/node/node_connector_socket.d.ts +0 -42
- package/dest/transport/node/node_connector_socket.d.ts.map +0 -1
- package/dest/transport/node/node_connector_socket.js +0 -48
- package/dest/transport/node/node_listener.d.ts +0 -26
- package/dest/transport/node/node_listener.d.ts.map +0 -1
- package/dest/transport/node/node_listener.js +0 -30
- package/dest/transport/node/node_listener_socket.d.ts +0 -37
- package/dest/transport/node/node_listener_socket.d.ts.map +0 -1
- package/dest/transport/node/node_listener_socket.js +0 -44
- package/dest/transport/transport_client.d.ts +0 -61
- package/dest/transport/transport_client.d.ts.map +0 -1
- package/dest/transport/transport_client.js +0 -94
- package/dest/transport/transport_server.d.ts +0 -56
- package/dest/transport/transport_server.d.ts.map +0 -1
- package/dest/transport/transport_server.js +0 -101
- package/dest/types/index.d.ts +0 -7
- package/dest/types/index.d.ts.map +0 -1
- package/dest/types/index.js +0 -2
- package/dest/url/index.d.ts +0 -9
- package/dest/url/index.d.ts.map +0 -1
- package/dest/url/index.js +0 -66
- package/dest/wasm/empty_wasi_sdk.d.ts +0 -130
- package/dest/wasm/empty_wasi_sdk.d.ts.map +0 -1
- package/dest/wasm/empty_wasi_sdk.js +0 -166
- package/dest/wasm/index.d.ts +0 -2
- package/dest/wasm/index.d.ts.map +0 -1
- package/dest/wasm/index.js +0 -2
- package/dest/wasm/wasm_module.d.ts +0 -135
- package/dest/wasm/wasm_module.d.ts.map +0 -1
- package/dest/wasm/wasm_module.js +0 -205
- package/dest/wasm/wasm_module.test.d.ts +0 -2
- package/dest/wasm/wasm_module.test.d.ts.map +0 -1
- package/dest/wasm/wasm_module.test.js +0 -24
- package/dest/worker/browser/index.d.ts +0 -3
- package/dest/worker/browser/index.d.ts.map +0 -1
- package/dest/worker/browser/index.js +0 -3
- package/dest/worker/browser/start_web_module.d.ts +0 -7
- package/dest/worker/browser/start_web_module.d.ts.map +0 -1
- package/dest/worker/browser/start_web_module.js +0 -22
- package/dest/worker/browser/web_data_store.d.ts +0 -23
- package/dest/worker/browser/web_data_store.d.ts.map +0 -1
- package/dest/worker/browser/web_data_store.js +0 -32
- package/dest/worker/browser/web_worker.d.ts +0 -10
- package/dest/worker/browser/web_worker.d.ts.map +0 -1
- package/dest/worker/browser/web_worker.js +0 -23
- package/dest/worker/data_store.d.ts +0 -20
- package/dest/worker/data_store.d.ts.map +0 -1
- package/dest/worker/data_store.js +0 -2
- package/dest/worker/index.d.ts +0 -3
- package/dest/worker/index.d.ts.map +0 -1
- package/dest/worker/index.js +0 -2
- package/dest/worker/node/index.d.ts +0 -3
- package/dest/worker/node/index.d.ts.map +0 -1
- package/dest/worker/node/index.js +0 -3
- package/dest/worker/node/node_data_store.d.ts +0 -12
- package/dest/worker/node/node_data_store.d.ts.map +0 -1
- package/dest/worker/node/node_data_store.js +0 -21
- package/dest/worker/node/node_worker.d.ts +0 -6
- package/dest/worker/node/node_worker.d.ts.map +0 -1
- package/dest/worker/node/node_worker.js +0 -20
- package/dest/worker/node/start_node_module.d.ts +0 -7
- package/dest/worker/node/start_node_module.d.ts.map +0 -1
- package/dest/worker/node/start_node_module.js +0 -26
- package/dest/worker/wasm_worker.d.ts +0 -9
- package/dest/worker/wasm_worker.d.ts.map +0 -1
- package/dest/worker/wasm_worker.js +0 -2
- package/dest/worker/worker_pool.d.ts +0 -40
- package/dest/worker/worker_pool.d.ts.map +0 -1
- package/dest/worker/worker_pool.js +0 -62
package/dest/fields/fields.d.ts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { AztecAddress } from '../aztec-address/index.js';
|
|
3
|
-
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
4
|
-
/**
|
|
5
|
-
* Fr represents a field of integers modulo the prime number MODULUS.
|
|
6
|
-
* It provides utility functions to work with elements in this field, such as conversions between different representations and checks for equality and zero values. The elements can be serialized to and deserialized from byte buffers or strings.
|
|
7
|
-
* Some use cases include working with cryptographic operations and finite fields.
|
|
8
|
-
*/
|
|
9
|
-
export declare class Fr {
|
|
10
|
-
static ZERO: Fr;
|
|
11
|
-
static MODULUS: bigint;
|
|
12
|
-
static MAX_VALUE: bigint;
|
|
13
|
-
static SIZE_IN_BYTES: number;
|
|
14
|
-
/**
|
|
15
|
-
* The numeric value of the field element as a bigint.
|
|
16
|
-
*/
|
|
17
|
-
readonly value: bigint;
|
|
18
|
-
constructor(value: bigint | number | Fr | AztecAddress);
|
|
19
|
-
/**
|
|
20
|
-
* Generates a random Fr or Fq instance with a value modulo the respective class' MODULUS.
|
|
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;
|
|
51
|
-
/**
|
|
52
|
-
* Converts the value of the instance to a buffer with a specified length.
|
|
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.
|
|
57
|
-
*/
|
|
58
|
-
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
|
-
*/
|
|
73
|
-
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
|
-
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
|
-
*/
|
|
96
|
-
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
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Fq represents a field element in a prime finite field with modulus defined by the constant MODULUS.
|
|
107
|
-
* It provides methods for creating, manipulating, and comparing field elements, as well as converting
|
|
108
|
-
* them to/from different data types like Buffers and hex strings. Field elements are used in various
|
|
109
|
-
* cryptographic protocols and operations, such as elliptic curve cryptography.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* const fqElem = new Fq(BigInt("123456789"));
|
|
113
|
-
* const randomFqElem = Fq.random();
|
|
114
|
-
* const fromBufferFqElem = Fq.fromBuffer(buffer);
|
|
115
|
-
*/
|
|
116
|
-
export declare class Fq {
|
|
117
|
-
/**
|
|
118
|
-
* The element's value as a bigint in the finite field.
|
|
119
|
-
*/
|
|
120
|
-
readonly value: bigint;
|
|
121
|
-
static MODULUS: bigint;
|
|
122
|
-
static MAX_VALUE: bigint;
|
|
123
|
-
static SIZE_IN_BYTES: number;
|
|
124
|
-
constructor(
|
|
125
|
-
/**
|
|
126
|
-
* The element's value as a bigint in the finite field.
|
|
127
|
-
*/
|
|
128
|
-
value: bigint);
|
|
129
|
-
/**
|
|
130
|
-
* Generates a random Fr or Fq instance with a value within the range of their respective modulus.
|
|
131
|
-
* The random value is generated from a byte array of length equal to SIZE_IN_BYTES, then truncated
|
|
132
|
-
* to the appropriate modulus before creating the new Fr or Fq instance.
|
|
133
|
-
*
|
|
134
|
-
* @returns A new Fr or Fq instance with a randomly generated value.
|
|
135
|
-
*/
|
|
136
|
-
static random(): Fq;
|
|
137
|
-
/**
|
|
138
|
-
* Create an instance of the calling class (Fr or Fq) from a given buffer or BufferReader.
|
|
139
|
-
* Reads SIZE_IN_BYTES from the provided buffer and converts it to a bigint, then creates a new instance
|
|
140
|
-
* with that value. Throws an error if the value is out of range for the calling class.
|
|
141
|
-
*
|
|
142
|
-
* @param buffer - The input buffer or BufferReader containing the bytes representing the value.
|
|
143
|
-
* @returns An instance of the calling class (Fr or Fq) initialized with the bigint value.
|
|
144
|
-
*/
|
|
145
|
-
static fromBuffer(buffer: Buffer | BufferReader): Fq;
|
|
146
|
-
/**
|
|
147
|
-
* Converts the bigint value of the instance to a Buffer representation.
|
|
148
|
-
* The output buffer has a fixed size, determined by the 'SIZE_IN_BYTES' constant.
|
|
149
|
-
*
|
|
150
|
-
* @returns A Buffer containing the byte representation of the instance's value.
|
|
151
|
-
*/
|
|
152
|
-
toBuffer(): Buffer;
|
|
153
|
-
/**
|
|
154
|
-
* Converts the Fq value to a hexadecimal string representation.
|
|
155
|
-
* The resulting string is prefixed with '0x' and contains the exact number of hex characters required
|
|
156
|
-
* to represent the numeric value of this instance.
|
|
157
|
-
*
|
|
158
|
-
* @returns A hexadecimal string representing the Fq value.
|
|
159
|
-
*/
|
|
160
|
-
toString(): `0x${string}`;
|
|
161
|
-
/**
|
|
162
|
-
* Check if the value of the current instance is zero.
|
|
163
|
-
* This function compares the internal 'value' property with 0n (BigInt representation of zero).
|
|
164
|
-
* Returns true if the value is zero, otherwise returns false.
|
|
165
|
-
*
|
|
166
|
-
* @returns A boolean indicating whether the value is zero or not.
|
|
167
|
-
*/
|
|
168
|
-
isZero(): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Converts the value of the Fr or Fq instance to a friendly JSON format.
|
|
171
|
-
* The output is a hexadecimal string representation of the value with '0x' prefix.
|
|
172
|
-
*
|
|
173
|
-
* @returns A string representing the value in the JSON format.
|
|
174
|
-
*/
|
|
175
|
-
toFriendlyJSON(): `0x${string}`;
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/fields/fields.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D;;;;GAIG;AACH,qBAAa,EAAE;IACb,MAAM,CAAC,IAAI,KAAc;IACzB,MAAM,CAAC,OAAO,SAAuE;IACrF,MAAM,CAAC,SAAS,SAAmB;IACnC,MAAM,CAAC,aAAa,SAAM;IAE1B;;OAEG;IACH,SAAgB,KAAK,EAAE,MAAM,CAAC;gBAElB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,EAAE,GAAG,YAAY;IAQtD;;;;;;OAMG;IACH,MAAM,CAAC,MAAM;IAKb;;;OAGG;IACH,MAAM,CAAC,IAAI;IAIX;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM;IAIjC;;;;;;OAMG;IACH,QAAQ;IAIR;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,UAAQ,GAAG,KAAK,MAAM,EAAE;IAIxC;;;;OAIG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;;;OAKG;IACH,aAAa;IAKb;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,EAAE;IAId;;;;;;OAMG;IACH,MAAM;IAIN;;;;;OAKG;IACH,cAAc;CAGf;AAED;;;;;;;;;;GAUG;AACH,qBAAa,EAAE;IAMX;;OAEG;aACa,KAAK,EAAE,MAAM;IAR/B,MAAM,CAAC,OAAO,SAAuE;IACrF,MAAM,CAAC,SAAS,SAAmB;IACnC,MAAM,CAAC,aAAa,SAAM;;IAGxB;;OAEG;IACa,KAAK,EAAE,MAAM;IAO/B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM;IAKb;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C;;;;;OAKG;IACH,QAAQ;IAIR;;;;;;OAMG;IACH,QAAQ;IAIR;;;;;;OAMG;IACH,MAAM;IAIN;;;;;OAKG;IACH,cAAc;CAGf"}
|
package/dest/fields/fields.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { toBigIntBE, toBufferBE, toHex } from '../bigint-buffer/index.js';
|
|
2
|
-
import { randomBytes } from '../crypto/index.js';
|
|
3
|
-
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
4
|
-
/**
|
|
5
|
-
* Fr represents a field of integers modulo the prime number MODULUS.
|
|
6
|
-
* It provides utility functions to work with elements in this field, such as conversions between different representations and checks for equality and zero values. The elements can be serialized to and deserialized from byte buffers or strings.
|
|
7
|
-
* Some use cases include working with cryptographic operations and finite fields.
|
|
8
|
-
*/
|
|
9
|
-
export class Fr {
|
|
10
|
-
constructor(value) {
|
|
11
|
-
const isFr = (value) => !!value.toBigInt;
|
|
12
|
-
this.value = isFr(value) ? value.toBigInt() : BigInt(value);
|
|
13
|
-
if (this.value > Fr.MAX_VALUE) {
|
|
14
|
-
throw new Error(`Fr out of range ${value}.`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Generates a random Fr or Fq instance with a value modulo the respective class' MODULUS.
|
|
19
|
-
* This method uses randomBytes to generate a random 32-byte buffer, converts it to a bigint
|
|
20
|
-
* and takes the modulus of the result with the class' MODULUS constant.
|
|
21
|
-
*
|
|
22
|
-
* @returns A new Fr or Fq instance with a random value.
|
|
23
|
-
*/
|
|
24
|
-
static random() {
|
|
25
|
-
const r = toBigIntBE(randomBytes(Fr.SIZE_IN_BYTES)) % Fr.MODULUS;
|
|
26
|
-
return new Fr(r);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns a new zero-value field.
|
|
30
|
-
* @returns A new zero-value field.
|
|
31
|
-
*/
|
|
32
|
-
static zero() {
|
|
33
|
-
return new Fr(0n);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Create an instance of the corresponding class (Fr or Fq) from a Buffer or a BufferReader.
|
|
37
|
-
* Reads 'SIZE_IN_BYTES' bytes from the given Buffer or BufferReader and constructs an instance with the decoded value.
|
|
38
|
-
* If the input is a Buffer, it is internally converted to a BufferReader before reading.
|
|
39
|
-
* Throws an error if the input length is invalid or the decoded value is out of range.
|
|
40
|
-
*
|
|
41
|
-
* @param buffer - The Buffer or BufferReader containing the bytes representing the value.
|
|
42
|
-
* @returns An instance of the corresponding class (Fr or Fq) with the decoded value.
|
|
43
|
-
*/
|
|
44
|
-
static fromBuffer(buffer) {
|
|
45
|
-
const reader = BufferReader.asReader(buffer);
|
|
46
|
-
return new Fr(toBigIntBE(reader.readBytes(Fr.SIZE_IN_BYTES)));
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Create a Fr instance from a hex-encoded string.
|
|
50
|
-
* The input 'address' can be either prefixed with '0x' or not, and should have exactly 64 hex characters.
|
|
51
|
-
* Throws an error if the input length is invalid or the address value is out of range.
|
|
52
|
-
*
|
|
53
|
-
* @param address - The hex-encoded string representing the field element.
|
|
54
|
-
* @returns A Fr instance.
|
|
55
|
-
*/
|
|
56
|
-
static fromString(address) {
|
|
57
|
-
return Fr.fromBuffer(Buffer.from(address.replace(/^0x/i, ''), 'hex'));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Converts the value of the instance to a buffer with a specified length.
|
|
61
|
-
* The method uses the provided value and size in bytes to create a buffer representation
|
|
62
|
-
* of the numeric value. This can be useful for serialization and communication purposes.
|
|
63
|
-
*
|
|
64
|
-
* @returns A buffer representing the instance's value.
|
|
65
|
-
*/
|
|
66
|
-
toBuffer() {
|
|
67
|
-
return toBufferBE(this.value, Fr.SIZE_IN_BYTES);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Converts the value of the Fr or Fq class instance to a hexadecimal string.
|
|
71
|
-
* The resulting string is prefixed with '0x' and represents the bigint value
|
|
72
|
-
* in base 16.
|
|
73
|
-
*
|
|
74
|
-
* @param padTo32 - Whether to pad the string to 32 bytes.
|
|
75
|
-
* @returns A hex-encoded string representing the value of the class instance.
|
|
76
|
-
*/
|
|
77
|
-
toString(padTo32 = false) {
|
|
78
|
-
return toHex(this.value, padTo32);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Retrieves the underlying bigint.
|
|
82
|
-
* This method mostly exists to match user expectations, as value is already public.
|
|
83
|
-
* @returns The underlying bigint.
|
|
84
|
-
*/
|
|
85
|
-
toBigInt() {
|
|
86
|
-
return this.value;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Returns a shortened string representation of the Fr value, formatted with '0x' prefix and ellipsis in the middle.
|
|
90
|
-
* The resulting string has first 10 characters (including '0x') and last 4 characters of the full hexadecimal value.
|
|
91
|
-
*
|
|
92
|
-
* @returns A shorter, human-readable string representation of the Fr value.
|
|
93
|
-
*/
|
|
94
|
-
toShortString() {
|
|
95
|
-
const str = this.toString();
|
|
96
|
-
return `${str.slice(0, 10)}...${str.slice(-4)}`;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the provided Fr instance is equal to the current instance.
|
|
100
|
-
* Two instances are considered equal if their 'value' properties are the same.
|
|
101
|
-
*
|
|
102
|
-
* @param rhs - The Fr instance to compare with the current instance.
|
|
103
|
-
* @returns A boolean indicating whether the two instances are equal.
|
|
104
|
-
*/
|
|
105
|
-
equals(rhs) {
|
|
106
|
-
return this.value === rhs.value;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Check if the instance value is zero.
|
|
110
|
-
* The method returns true if the value of the instance is 0n (zero in BigInt representation),
|
|
111
|
-
* otherwise, it returns false.
|
|
112
|
-
*
|
|
113
|
-
* @returns A boolean indicating whether the instance value is zero or not.
|
|
114
|
-
*/
|
|
115
|
-
isZero() {
|
|
116
|
-
return this.value === 0n;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Converts the current value of the Fq or Fr instance to a friendly JSON representation.
|
|
120
|
-
* The output will be a hexadecimal string prefixed with '0x'.
|
|
121
|
-
*
|
|
122
|
-
* @returns A '0x' prefixed hexadecimal string representing the current value.
|
|
123
|
-
*/
|
|
124
|
-
toFriendlyJSON() {
|
|
125
|
-
return this.toString();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
Fr.ZERO = new Fr(0n);
|
|
129
|
-
Fr.MODULUS = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001n;
|
|
130
|
-
Fr.MAX_VALUE = Fr.MODULUS - 1n;
|
|
131
|
-
Fr.SIZE_IN_BYTES = 32;
|
|
132
|
-
/**
|
|
133
|
-
* Fq represents a field element in a prime finite field with modulus defined by the constant MODULUS.
|
|
134
|
-
* It provides methods for creating, manipulating, and comparing field elements, as well as converting
|
|
135
|
-
* them to/from different data types like Buffers and hex strings. Field elements are used in various
|
|
136
|
-
* cryptographic protocols and operations, such as elliptic curve cryptography.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* const fqElem = new Fq(BigInt("123456789"));
|
|
140
|
-
* const randomFqElem = Fq.random();
|
|
141
|
-
* const fromBufferFqElem = Fq.fromBuffer(buffer);
|
|
142
|
-
*/
|
|
143
|
-
export class Fq {
|
|
144
|
-
constructor(
|
|
145
|
-
/**
|
|
146
|
-
* The element's value as a bigint in the finite field.
|
|
147
|
-
*/
|
|
148
|
-
value) {
|
|
149
|
-
this.value = value;
|
|
150
|
-
if (value > Fq.MAX_VALUE) {
|
|
151
|
-
throw new Error(`Fq out of range ${value}.`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Generates a random Fr or Fq instance with a value within the range of their respective modulus.
|
|
156
|
-
* The random value is generated from a byte array of length equal to SIZE_IN_BYTES, then truncated
|
|
157
|
-
* to the appropriate modulus before creating the new Fr or Fq instance.
|
|
158
|
-
*
|
|
159
|
-
* @returns A new Fr or Fq instance with a randomly generated value.
|
|
160
|
-
*/
|
|
161
|
-
static random() {
|
|
162
|
-
const r = toBigIntBE(randomBytes(64)) % Fq.MODULUS;
|
|
163
|
-
return new this(r);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Create an instance of the calling class (Fr or Fq) from a given buffer or BufferReader.
|
|
167
|
-
* Reads SIZE_IN_BYTES from the provided buffer and converts it to a bigint, then creates a new instance
|
|
168
|
-
* with that value. Throws an error if the value is out of range for the calling class.
|
|
169
|
-
*
|
|
170
|
-
* @param buffer - The input buffer or BufferReader containing the bytes representing the value.
|
|
171
|
-
* @returns An instance of the calling class (Fr or Fq) initialized with the bigint value.
|
|
172
|
-
*/
|
|
173
|
-
static fromBuffer(buffer) {
|
|
174
|
-
const reader = BufferReader.asReader(buffer);
|
|
175
|
-
return new this(toBigIntBE(reader.readBytes(this.SIZE_IN_BYTES)));
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Converts the bigint value of the instance to a Buffer representation.
|
|
179
|
-
* The output buffer has a fixed size, determined by the 'SIZE_IN_BYTES' constant.
|
|
180
|
-
*
|
|
181
|
-
* @returns A Buffer containing the byte representation of the instance's value.
|
|
182
|
-
*/
|
|
183
|
-
toBuffer() {
|
|
184
|
-
return toBufferBE(this.value, Fq.SIZE_IN_BYTES);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Converts the Fq value to a hexadecimal string representation.
|
|
188
|
-
* The resulting string is prefixed with '0x' and contains the exact number of hex characters required
|
|
189
|
-
* to represent the numeric value of this instance.
|
|
190
|
-
*
|
|
191
|
-
* @returns A hexadecimal string representing the Fq value.
|
|
192
|
-
*/
|
|
193
|
-
toString() {
|
|
194
|
-
return toHex(this.value);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Check if the value of the current instance is zero.
|
|
198
|
-
* This function compares the internal 'value' property with 0n (BigInt representation of zero).
|
|
199
|
-
* Returns true if the value is zero, otherwise returns false.
|
|
200
|
-
*
|
|
201
|
-
* @returns A boolean indicating whether the value is zero or not.
|
|
202
|
-
*/
|
|
203
|
-
isZero() {
|
|
204
|
-
return this.value === 0n;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Converts the value of the Fr or Fq instance to a friendly JSON format.
|
|
208
|
-
* The output is a hexadecimal string representation of the value with '0x' prefix.
|
|
209
|
-
*
|
|
210
|
-
* @returns A string representing the value in the JSON format.
|
|
211
|
-
*/
|
|
212
|
-
toFriendlyJSON() {
|
|
213
|
-
return this.toString();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
Fq.MODULUS = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n;
|
|
217
|
-
Fq.MAX_VALUE = Fr.MODULUS - 1n;
|
|
218
|
-
Fq.SIZE_IN_BYTES = 32;
|
|
219
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmllbGRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZpZWxkcy9maWVsZHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFVBQVUsRUFBRSxVQUFVLEVBQUUsS0FBSyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDMUUsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUU3RDs7OztHQUlHO0FBQ0gsTUFBTSxPQUFPLEVB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SxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEUsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0gsUUFBUTtRQUNOLE9BQU8sVUFBVSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsRUFBRSxDQUFDLGFBQWEsQ0FBQyxDQUFDO0lBQ2xELENBQUM7SUFFRDs7Ozs7O09BTUc7SUFDSCxRQUFRO1FBQ04sT0FBTyxLQUFLLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQzNCLENBQUM7SUFFRDs7Ozs7O09BTUc7SUFDSCxNQUFNO1FBQ0osT0FBTyxJQUFJLENBQUMsS0FBSyxLQUFLLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSCxjQUFjO1FBQ1osT0FBTyxJQUFJLENBQUMsUUFBUSxFQUFFLENBQUM7SUFDekIsQ0FBQzs7QUFoRk0sVUFBTyxHQUFHLG1FQUFtRSxDQUFDO0FBQzlFLFlBQVMsR0FBRyxFQUFFLENBQUMsT0FBTyxHQUFHLEVBQUUsQ0FBQztBQUM1QixnQkFBYSxHQUFHLEVBQUUsQ0FBQyJ9
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
3
|
-
import { Fr } from './fields.js';
|
|
4
|
-
/**
|
|
5
|
-
* Represents a field element in a prime finite field with modulus defined by the constant MODULUS.
|
|
6
|
-
* @remarks Called GrumpkinScalar because it is used to represent elements in Grumpkin's scalar field as defined in
|
|
7
|
-
* the Aztec Yellow Paper.
|
|
8
|
-
*/
|
|
9
|
-
export declare class GrumpkinScalar {
|
|
10
|
-
/**
|
|
11
|
-
* The element's value as a bigint in the finite field.
|
|
12
|
-
*/
|
|
13
|
-
readonly value: bigint;
|
|
14
|
-
static MODULUS: bigint;
|
|
15
|
-
static MAX_VALUE: bigint;
|
|
16
|
-
static SIZE_IN_BYTES: number;
|
|
17
|
-
private static HIGH_SHIFT;
|
|
18
|
-
private static LOW_MASK;
|
|
19
|
-
constructor(
|
|
20
|
-
/**
|
|
21
|
-
* The element's value as a bigint in the finite field.
|
|
22
|
-
*/
|
|
23
|
-
value: bigint);
|
|
24
|
-
get low(): Fr;
|
|
25
|
-
get high(): Fr;
|
|
26
|
-
/**
|
|
27
|
-
* Deserialize a grumpkin scalar serialized in 2 Fr.
|
|
28
|
-
* @param high - The high Fr element.
|
|
29
|
-
* @param low - The low Fr element.
|
|
30
|
-
* @returns A GrumpkinScalar instance with the value of the two Fr elements.
|
|
31
|
-
*/
|
|
32
|
-
static fromHighLow(high: Fr, low: Fr): GrumpkinScalar;
|
|
33
|
-
/**
|
|
34
|
-
* Generates a random GrumpkinScalar.
|
|
35
|
-
*
|
|
36
|
-
* @returns A new GrumpkinScalar instance with a randomly generated value.
|
|
37
|
-
*/
|
|
38
|
-
static random(): GrumpkinScalar;
|
|
39
|
-
/**
|
|
40
|
-
* Create an instance of GrumpkinScalar from a given buffer or BufferReader.
|
|
41
|
-
* @remarks Reads SIZE_IN_BYTES from the provided buffer and converts it to a bigint, then creates a new instance
|
|
42
|
-
* with that value. Throws an error if the value is out of range for the calling class.
|
|
43
|
-
*
|
|
44
|
-
* @param buffer - The input buffer or BufferReader containing the bytes representing the value.
|
|
45
|
-
* @returns A GrumpkinScalar instance.
|
|
46
|
-
*/
|
|
47
|
-
static fromBuffer(buffer: Buffer | BufferReader): GrumpkinScalar;
|
|
48
|
-
/**
|
|
49
|
-
* Like fromBuffer, but reduces the value modulo MODULUS.
|
|
50
|
-
*
|
|
51
|
-
* @param buffer - The Buffer or BufferReader containing the bytes representing the value.
|
|
52
|
-
* @returns GrumpkinScalar with the decoded value.
|
|
53
|
-
*/
|
|
54
|
-
static fromBufferWithReduction(buffer: Buffer | BufferReader): GrumpkinScalar;
|
|
55
|
-
/**
|
|
56
|
-
* Create a GrumpkinScalar instance from a hex-encoded string.
|
|
57
|
-
* The input 'address' can be either prefixed with '0x' or not, and should have exactly 64 hex characters.
|
|
58
|
-
* Throws an error if the input length is invalid or the address value is out of range.
|
|
59
|
-
*
|
|
60
|
-
* @param address - The hex-encoded string representing the field element.
|
|
61
|
-
* @returns A GrumpkinScalar instance.
|
|
62
|
-
*/
|
|
63
|
-
static fromString(address: string): GrumpkinScalar;
|
|
64
|
-
/**
|
|
65
|
-
* Converts the bigint value of the instance to a Buffer representation.
|
|
66
|
-
* The output buffer has a fixed size, determined by the 'SIZE_IN_BYTES' constant.
|
|
67
|
-
*
|
|
68
|
-
* @returns A Buffer containing the byte representation of the instance's value.
|
|
69
|
-
*/
|
|
70
|
-
toBuffer(): Buffer;
|
|
71
|
-
/**
|
|
72
|
-
* Converts the GrumpkinScalar value to a hexadecimal string representation.
|
|
73
|
-
* The resulting string is prefixed with '0x' and contains the exact number of hex characters required
|
|
74
|
-
* to represent the numeric value of this instance.
|
|
75
|
-
*
|
|
76
|
-
* @param padTo32 - Whether to pad the resulting string to 32 bytes.
|
|
77
|
-
* @returns A hexadecimal string representing the GrumpkinScalar value.
|
|
78
|
-
*/
|
|
79
|
-
toString(padTo32?: boolean): `0x${string}`;
|
|
80
|
-
/**
|
|
81
|
-
* Check if the value of the current instance is zero.
|
|
82
|
-
* This function compares the internal 'value' property with 0n (BigInt representation of zero).
|
|
83
|
-
* Returns true if the value is zero, otherwise returns false.
|
|
84
|
-
*
|
|
85
|
-
* @returns A boolean indicating whether the value is zero or not.
|
|
86
|
-
*/
|
|
87
|
-
isZero(): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Converts the value of the GrumpkinScalar instance to a friendly JSON format.
|
|
90
|
-
* The output is a hexadecimal string representation of the value with '0x' prefix.
|
|
91
|
-
*
|
|
92
|
-
* @returns A string representing the value in the JSON format.
|
|
93
|
-
*/
|
|
94
|
-
toFriendlyJSON(): `0x${string}`;
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=grumpkin_scalar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grumpkin_scalar.d.ts","sourceRoot":"","sources":["../../src/fields/grumpkin_scalar.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;GAIG;AACH,qBAAa,cAAc;IAUvB;;OAEG;aACa,KAAK,EAAE,MAAM;IAZ/B,MAAM,CAAC,OAAO,SAAuE;IACrF,MAAM,CAAC,SAAS,SAA+B;IAC/C,MAAM,CAAC,aAAa,SAAM;IAG1B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAkD;IAC3E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0C;;IAG/D;;OAEG;IACa,KAAK,EAAE,MAAM;IAO/B,IAAI,GAAG,IAAI,EAAE,CAEZ;IAED,IAAI,IAAI,IAAI,EAAE,CAEb;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,cAAc;IAIrD;;;;OAIG;IACH,MAAM,CAAC,MAAM;IAKb;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAM5D;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM;IAIjC;;;;;OAKG;IACH,QAAQ;IAIR;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,UAAQ;IAIxB;;;;;;OAMG;IACH,MAAM;IAIN;;;;;OAKG;IACH,cAAc;CAGf"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { toBigIntBE, toBufferBE, toHex } from '../bigint-buffer/index.js';
|
|
2
|
-
import { randomBytes } from '../crypto/index.js';
|
|
3
|
-
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
4
|
-
import { Fr } from './fields.js';
|
|
5
|
-
/**
|
|
6
|
-
* Represents a field element in a prime finite field with modulus defined by the constant MODULUS.
|
|
7
|
-
* @remarks Called GrumpkinScalar because it is used to represent elements in Grumpkin's scalar field as defined in
|
|
8
|
-
* the Aztec Yellow Paper.
|
|
9
|
-
*/
|
|
10
|
-
export class GrumpkinScalar {
|
|
11
|
-
constructor(
|
|
12
|
-
/**
|
|
13
|
-
* The element's value as a bigint in the finite field.
|
|
14
|
-
*/
|
|
15
|
-
value) {
|
|
16
|
-
this.value = value;
|
|
17
|
-
if (value > GrumpkinScalar.MAX_VALUE) {
|
|
18
|
-
throw new Error(`GrumpkinScalar out of range ${value}.`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
get low() {
|
|
22
|
-
return new Fr(this.value & GrumpkinScalar.LOW_MASK);
|
|
23
|
-
}
|
|
24
|
-
get high() {
|
|
25
|
-
return new Fr(this.value >> GrumpkinScalar.HIGH_SHIFT);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Deserialize a grumpkin scalar serialized in 2 Fr.
|
|
29
|
-
* @param high - The high Fr element.
|
|
30
|
-
* @param low - The low Fr element.
|
|
31
|
-
* @returns A GrumpkinScalar instance with the value of the two Fr elements.
|
|
32
|
-
*/
|
|
33
|
-
static fromHighLow(high, low) {
|
|
34
|
-
return new GrumpkinScalar((high.value << GrumpkinScalar.HIGH_SHIFT) + low.value);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Generates a random GrumpkinScalar.
|
|
38
|
-
*
|
|
39
|
-
* @returns A new GrumpkinScalar instance with a randomly generated value.
|
|
40
|
-
*/
|
|
41
|
-
static random() {
|
|
42
|
-
const r = toBigIntBE(randomBytes(64)) % GrumpkinScalar.MODULUS;
|
|
43
|
-
return new this(r);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Create an instance of GrumpkinScalar from a given buffer or BufferReader.
|
|
47
|
-
* @remarks Reads SIZE_IN_BYTES from the provided buffer and converts it to a bigint, then creates a new instance
|
|
48
|
-
* with that value. Throws an error if the value is out of range for the calling class.
|
|
49
|
-
*
|
|
50
|
-
* @param buffer - The input buffer or BufferReader containing the bytes representing the value.
|
|
51
|
-
* @returns A GrumpkinScalar instance.
|
|
52
|
-
*/
|
|
53
|
-
static fromBuffer(buffer) {
|
|
54
|
-
const reader = BufferReader.asReader(buffer);
|
|
55
|
-
return new this(toBigIntBE(reader.readBytes(this.SIZE_IN_BYTES)));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Like fromBuffer, but reduces the value modulo MODULUS.
|
|
59
|
-
*
|
|
60
|
-
* @param buffer - The Buffer or BufferReader containing the bytes representing the value.
|
|
61
|
-
* @returns GrumpkinScalar with the decoded value.
|
|
62
|
-
*/
|
|
63
|
-
static fromBufferWithReduction(buffer) {
|
|
64
|
-
const reader = BufferReader.asReader(buffer);
|
|
65
|
-
const value = toBigIntBE(reader.readBytes(GrumpkinScalar.SIZE_IN_BYTES)) % GrumpkinScalar.MODULUS;
|
|
66
|
-
return new GrumpkinScalar(value);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Create a GrumpkinScalar instance from a hex-encoded string.
|
|
70
|
-
* The input 'address' can be either prefixed with '0x' or not, and should have exactly 64 hex characters.
|
|
71
|
-
* Throws an error if the input length is invalid or the address value is out of range.
|
|
72
|
-
*
|
|
73
|
-
* @param address - The hex-encoded string representing the field element.
|
|
74
|
-
* @returns A GrumpkinScalar instance.
|
|
75
|
-
*/
|
|
76
|
-
static fromString(address) {
|
|
77
|
-
return GrumpkinScalar.fromBuffer(Buffer.from(address.replace(/^0x/i, ''), 'hex'));
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Converts the bigint value of the instance to a Buffer representation.
|
|
81
|
-
* The output buffer has a fixed size, determined by the 'SIZE_IN_BYTES' constant.
|
|
82
|
-
*
|
|
83
|
-
* @returns A Buffer containing the byte representation of the instance's value.
|
|
84
|
-
*/
|
|
85
|
-
toBuffer() {
|
|
86
|
-
return toBufferBE(this.value, GrumpkinScalar.SIZE_IN_BYTES);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Converts the GrumpkinScalar value to a hexadecimal string representation.
|
|
90
|
-
* The resulting string is prefixed with '0x' and contains the exact number of hex characters required
|
|
91
|
-
* to represent the numeric value of this instance.
|
|
92
|
-
*
|
|
93
|
-
* @param padTo32 - Whether to pad the resulting string to 32 bytes.
|
|
94
|
-
* @returns A hexadecimal string representing the GrumpkinScalar value.
|
|
95
|
-
*/
|
|
96
|
-
toString(padTo32 = false) {
|
|
97
|
-
return toHex(this.value, padTo32);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Check if the value of the current instance is zero.
|
|
101
|
-
* This function compares the internal 'value' property with 0n (BigInt representation of zero).
|
|
102
|
-
* Returns true if the value is zero, otherwise returns false.
|
|
103
|
-
*
|
|
104
|
-
* @returns A boolean indicating whether the value is zero or not.
|
|
105
|
-
*/
|
|
106
|
-
isZero() {
|
|
107
|
-
return this.value === 0n;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Converts the value of the GrumpkinScalar instance to a friendly JSON format.
|
|
111
|
-
* The output is a hexadecimal string representation of the value with '0x' prefix.
|
|
112
|
-
*
|
|
113
|
-
* @returns A string representing the value in the JSON format.
|
|
114
|
-
*/
|
|
115
|
-
toFriendlyJSON() {
|
|
116
|
-
return this.toString();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
GrumpkinScalar.MODULUS = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n;
|
|
120
|
-
GrumpkinScalar.MAX_VALUE = GrumpkinScalar.MODULUS - 1n;
|
|
121
|
-
GrumpkinScalar.SIZE_IN_BYTES = 32;
|
|
122
|
-
// The following constants are used to split a GrumpkinScalar into two Fr elements.
|
|
123
|
-
GrumpkinScalar.HIGH_SHIFT = BigInt((GrumpkinScalar.SIZE_IN_BYTES / 2) * 8);
|
|
124
|
-
GrumpkinScalar.LOW_MASK = (1n << GrumpkinScalar.HIGH_SHIFT) - 1n;
|
|
125
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3J1bXBraW5fc2NhbGFyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZpZWxkcy9ncnVtcGtpbl9zY2FsYXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxVQUFVLEVBQUUsS0FBSyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDMUUsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUM3RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBRWpDOzs7O0dBSUc7QUFDSCxNQUFNLE9BQU8sY0FBYztJQVN6QjtJQUNFOztPQUVHO0lBQ2EsS0FBYTtRQUFiLFVBQUssR0FBTCxLQUFLLENBQVE7UUFFN0IsSUFBSSxLQUFLLEdBQUcsY0FBYyxDQUFDLFNBQVMsRUFBRTtZQUNwQyxNQUFNLElBQUksS0FBSyxDQUFDLCtCQUErQixLQUFLLEdBQUcsQ0FBQyxDQUFDO1NBQzFEO0lBQ0gsQ0FBQztJQUVELElBQUksR0FBRztRQUNMLE9BQU8sSUFBSSxFQUFFLENBQUMsSUFBSSxDQUFDLEtBQUssR0FBRyxjQUFjLENBQUMsUUFBUSxDQUFDLENBQUM7SUFDdEQsQ0FBQztJQUVELElBQUksSUFBSTtRQUNOLE9BQU8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