Commit graph

29 commits

Author SHA1 Message Date
bitromortac
6d89f07037 firewall: fix 32-bit int truncation
Upgrade the randIntn function signature from int to int64 to prevent
unpredictable integer truncation on 32-bit systems (e.g., Raspberry Pi).
This ensures UnixNano timestamps in hideTimestamp and large amounts in
hideAmount do not cause unexpected runtime failures when calling
ForwardingHistory.
2026-07-21 12:04:33 +00:00
ffranr
a0e63124c0
multi: reformat long lines for readability
- Replace occurrences of `// nolint:lll` with `// nolint:ll` across
  files for consistency.
- Reformat multiline strings, comments, and function parameters to
  improve clarity and adhere to style guidelines.
- Add `// nolint:ll` comments where necessary to prevent linter
  warnings.
2025-12-09 16:12:03 +00:00
Elle Mouton
a89b3502e4
firewall: extract SessionID from gRPC metadata
In this commit, we update our various firewall interceptors so that they
rely on the session ID passed via gRPC metadata to extract a session ID.
For the PrivacyMapper and RuleEnforcer, these _MUST_ always contain a
session ID and so we error out if one was not found. For the request
logger, the session ID is optional and so we pass it to the new
SessionID field in the AddActionReq - our bbolt actions DB will not make
use of this field on persistence (but our incoming SQL version will).
2025-05-16 11:57:39 +02:00
Elle Mouton
b9ad66471d
multi+refactor: remove unnecessary type alias
Remove the `NewPrivacyMapDB` type alias. It is not needed.
2025-04-22 06:10:48 +02:00
Elle Mouton
ef93611489
firewalldb: thread contexts to FetchAllPairs
Update the FetchAllPairs method of the PrivacyMapTx interface to take a
context.
2025-03-25 18:10:52 +02:00
Elle Mouton
5b31f16446
firewalldb: thread context to RealToPseudo
Update the RealToPseudo method of the PrivacyMapTx interface to take a
context.
2025-03-25 18:10:52 +02:00
Elle Mouton
7e8e4a9920
firewalldb: thread context to PseudoToReal
Update the PseudoToReal method of the PrivacyMapTx interface to take a
context.
2025-03-25 18:10:52 +02:00
Elle Mouton
197ee3b5ba
firewalldb: thread context to PrivMap NewPair
Update the NewPair method of the PrivacyMapTx interface to take a
context.
2025-03-25 18:10:52 +02:00
Elle Mouton
7ce36d7e7d
multi: thread contexts through privacy map interfaces
Update the PrivacyMapDB interface methods to take contexts (both the
methods themselves and the call-back params) and then ensure all
implementations are updated and all call-sites pass contexts through
correctly.
2025-03-25 18:10:52 +02:00
Elle Mouton
a22689ce16
golangci: enable line length linter 2025-02-13 15:50:48 +02:00
bitromortac
66e6d63349
firewall: obfuscate ConnectPeer
Also adds a privacy flag that controls obfuscation of network addresses.
2024-07-02 18:21:42 +02:00
bitromortac
bca729a5af
firewall: obfuscate OpenChannelSync 2024-07-02 18:21:42 +02:00
bitromortac
275a882e96
firewall: obfuscate BatchOpenChannel
We obfuscate fields from the batch channel open requests and
responses.
2024-07-02 18:21:42 +02:00
bitromortac
e797abd2a8
firewall: obfuscate PendingChannels
Only obfuscate pending open channels for now.
2024-07-02 18:21:42 +02:00
bitromortac
ef84753f6b
firewall: obfuscate ClosedChannels
For closes we need to know the close type and settle balances to know
which peers should be avoided in the future.
2024-07-02 18:21:42 +02:00
bitromortac
a7246e1dae
firewall: obfuscate WalletBalance 2024-07-02 18:21:41 +02:00
bitromortac
203d0b7234
firewall: refactor privacy mapper tests
Pull out transaction related constants to the top of the test.
Adds a debug comment that is useful for this code. It is often needed to
check the human readable representation of a message.
2024-07-02 18:21:41 +02:00
bitromortac
07bcfe19c0
firewall: intercept with privacy flags
gRPC message interception depends now on privacy flags.
2024-04-25 14:49:46 +02:00
bitromortac
c961472789
firewall: obfuscate config depending on flags 2024-04-25 14:49:46 +02:00
bitromortac
cb542a5015
firewall+firewalldb: add SessionDB interface
SessionDB is an interface that gives helper methods for how privacy
mapping should be done. A mock for SessionDB is added to save on some
code repetition, the privacy flags functionality is used in a later
test.
2024-04-25 14:49:45 +02:00
shuoer86
ab47cd64f7
firewall+firewalldb: fix typos 2023-11-25 10:31:03 +08:00
bitromortac
eb58941e76
rpcserver+firewall: obfuscate configuration
We obfuscate pubkeys, channel points and ids entered in configurations.

The channel id lengths for different block heights can be checked with:
```python
len(str(1 << 40 | 2923 << 16 | 30))
len(str(10_000_000 << 40 | 2923 << 16 | 30))
```
2023-09-05 13:03:58 +02:00
bitromortac
5580d6861d
firewalldb: export DecodeChannelPoint and restrict 2023-09-01 08:03:21 +02:00
Elle Mouton
d0bc3c37f1
firewalldb: add FetchAllPairs to PrivacyMapTx interface
This commit adds a new FetchAllPairs to the PrivacyMapTx interface. This
method returns a new PrivacyMapPairs struct which is an in-memory
privacy map DB. The PrivacyMapPairs struct implements a new
PrivacyMapReader interface which can be used to pass around read only
access to the PrivacyMapPairs struct.
2023-08-31 16:56:59 +02:00
Elle Mouton
a14d7ae17b
firewall: map session ID to group ID in privacy mapper interceptor 2023-08-30 12:34:29 +02:00
bitromortac
2d57c25850
firewall: redefine obfuscation interval 2023-02-13 19:33:55 +02:00
bitromortac
a74ae880c4
firewall: randomize responses with PrivacyMapper
Adds amount, timestamp, and channel initiator obfuscation to the two
response handlers `handleFwdHistoryResponse` and
`handleListChannelsResponse`.

In order to preserve privacy and still ensure functioning of algorithms
that rely on the randomized data, a trade-off between randomization and
accuracy needs to be found.

We choose ten minutes for forwarding timestamps as this breaks time
correlation of payments.

The amount obfuscation is chosen to be 5% and applies to the forwarding
amount and channel details to hide balances. We also remove details of
pending HTLCs in channels. Random obfuscation for amounts is chosen here
instead of rounding to have non-deterministic alteration of amounts,
which is especially important for forwardings to also break amount
correlation. Randomly varying around a certain value will statistically
skew averages less than rounding for algorithms that rely on
aggregation of individual data.

The privacy mapper is chosen to accept a randomness input in order to
ensure deterministic testing even when other handlers are changed in the
future.
2023-02-13 19:33:34 +02:00
bitromortac
5a453cd36c
firewall: add amount fuzzing
Adds helper functions to randomize amounts, timestamps, and booleans.
Amounts are randomized based on a percentage and timestamps based on an
absolute scale.
2023-01-27 06:47:14 +02:00
Elle Mouton
3d669d6ac3
firewall: Add Privacy Mapper interceptor 2023-01-27 06:47:13 +02:00