Commit Graph

7914 Commits

Author SHA1 Message Date
Nick Mathewson 848d329c09 Merge branch 'changelog_117' into 'main'
First draft of a changelog for 1.1.7

See merge request tpo/core/arti!1454
2023-08-01 14:16:02 +00:00
gabi-250 5d1a3575ae Merge branch 'update_20230801' into 'main'
Run cargo update in preparation for a release.

See merge request tpo/core/arti!1455
2023-08-01 13:19:58 +00:00
gabi-250 55a12bee85 Apply 1 suggestion(s) to 1 file(s) 2023-08-01 13:11:23 +00:00
Nick Mathewson 9ce6f0a0eb Run "fixup features" in preparation for a release. 2023-08-01 08:32:20 -04:00
Nick Mathewson f37915587e Run cargo update in preparation for a release. 2023-08-01 08:10:44 -04:00
Nick Mathewson 2085e43cfc Changelog: add breaking changes from semver.md 2023-08-01 08:02:34 -04:00
Nick Mathewson 17f6074850 Begin work on a changelog for 1.1.7. 2023-08-01 07:57:49 -04:00
Nick Mathewson 7dc24f38e0 hsservice: Add a sketched API for HsDir publishers.
As with the other APIs here, I'd expect that the implementors will
need to refactor this a lot.

Closes #972.
2023-07-31 13:47:44 -04:00
Nick Mathewson 16fef0057b A couple of notes on intropoint establisher API. 2023-07-31 13:47:44 -04:00
Nick Mathewson 982bfcba06 hsservice: Add a draft API for intropoint establisher.
Taken from @diziet's !1439 and lightly cleaned up so that it
compiles.

Closes #971.
2023-07-31 13:47:44 -04:00
Nick Mathewson 20afc76c0a hsservice: Adapt API sketches from onion-service-notes.md 2023-07-31 13:47:44 -04:00
Nick Mathewson 20b3679dbb hsservice: Adapt data structures from onion-service-notes.md
Also, removed some older structures that don't make sense in the
current design.

Closes #970
2023-07-31 13:47:44 -04:00
Ian Jackson 0c9b2eb4af key-management.md: Use scenarios 2023-07-28 18:05:11 +01:00
Ian Jackson 0aa5810246 key-management.md: Fix pandoc formatting
Add a missing blank line.
2023-07-28 18:04:50 +01:00
Ian Jackson e798f8e322 dev notes: Draft IPT algorithm: Make IPT persistence optional
As per current version of torpsec!154
2023-07-28 15:22:08 +01:00
Ian Jackson ec63468606 dev notes: Draft IPT algorithm: Reuse relays when cycling IPT 2023-07-28 15:13:08 +01:00
Ian Jackson 476846d73c dev notes: Draft IPT algorithm: Maintain k*N, not 2N
Make this a separate parameter.
2023-07-28 15:08:24 +01:00
Nick Mathewson 5906c2c92e Merge branch 'ticket889_prototype' into 'main'
Rust implementation of onion service client puzzles (Proposal 327)

See merge request tpo/core/arti!1368
2023-07-28 12:33:22 +00:00
Micah Elizabeth Scott 61bf60d177 check_licenses: Whitelist for crates that may use LGPL-3.0-only
Narrows the previous check, allowing this particular LGPL
only for the hashx and equix crates.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 13:23:26 -07:00
Micah Elizabeth Scott 9257949b80 equix, hashx: Additional comment tweaks
More review feedback. Thanks nickm!

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 13:17:23 -07:00
Micah Elizabeth Scott fdba82100f equix, hashx: Prepare for an initial LGPL release
This replaces the 'TODO' marker from earlier commits, using tevador's
copyright and license (LGPL 3.0 only) for the hashx and equix crates.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 4affddaa08 tor-hspow, equix, hashx: Comment tweaks
Making a few comment tweaks suggested in review feedback.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott bd48c23a40 tor-hspow: Simplify and optimize Challenge::new
Challenges are now built using try_extend_from_slice instead of
iterators. There's no CPU benchmark in this crate yet, but I can confirm
that the resulting code is shorter. With this patch, the entirety of
Challenge:new() is automatically inlined at call sites.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 7579febb46 hashx: Simplify RegisterWriterMap
I originally wrote this in an overcomplicated way, to avoid
frequent initialization of a RegisterWriter array. It turns out
that RegisterWriter can be fairly compact, so this extra level of
indirection isn't necessary or measurably helpful.

This still manages to avoid declaring RegisterWriter as Copy, by
using Default to initialize the array instead of an array constructor.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott f4939a5fd8 tor-hspow, equix, hashx: Make all error types Clone
This uses an Arc to hold std::io::Error for low-level HashX runtime
errors.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 10b7352c98 hashx: Simplify hash_to_bytes, only support fixed output width
In response to review feedback. The byte output is only needed
for unit tests right now, since Equi-X uses u64 output exclusively.

The optimization for shorter output widths can shave tiny amounts of
time off hash benchmarks, but in this case it's more helpful to avoid
introducing APIs that offer parameters with incomplete compile-time
range checking.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott d17c12b152 hashx: use RngCore for HashX's internal PRNG
This refactors the random number generator used within HashX's program
generator so that it uses the rand::RngCore trait. The basic SipHash
powered u64 generator now implements RngCore, while a buffer layer
wraps this and provides u8 and u32 values as needed by the generator.

Some of this new RngCore layer is now exposed to the hashx crate's
public API. The intent is to allow external code to test, benchmark, or
fuzz the program generator by supplying its own random number stream.

Benchmarks show a small but confusing performance improvement
associated with this patch. About a 2% improvement in generation.
This could be due to the Rng changes. No change in compiled hash
execution performance. Even though this patch only touches program
generation, benchmarks show a 4% speedup in interpreted execution.
This seems most likely explained by instruction cache effects,
but I'm not sure.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 2c20b46921 hashx: Implement Default for RuntimeOption 2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott c5976c6675 equix: Refactoring for bucket_array
This splits up bucket_array into two smaller modules, one for the hash
table behavior and one for the MaybeUninit memory management.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 8a79021f38 Update equix, hashx, tor-hspow for new clippy defaults
Just running maint/add_warning after the rebase
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott fdfe3ce55f hashx: register set optimizations, 20% faster generator
I was hoping most of the program generator would get inlined, so we can
resolve a lot of the edge cases at compile-time. This patch gets us
close to that, adding many inline attrs and rewriting RegisterSet with
explicit unrolling and storage types that are easier for the optimizer
to reason about.

From the disassembly of the program generator, it's now mostly one big
function with a jump table. From callgrind instruction profiles, there
are no longer obvious hotspots in register set scanning loops. It also
looks like we're often keeping per-register schedule information all
loaded into machine registers now.

Keeping the Rng entry points non-inlined for now seems to be slightly
better, by a percent or two.

There's some work left to do in compiled programs, and maybe room for
improvement in the Program representation too. That will be in a future
patch.

Benchmark shows about 20% improvement on my machine,

generate-interp         time:   [75.440 µs 75.551 µs 75.684 µs]
                        change: [-24.083% -23.775% -23.483%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  5 (5.00%) high mild
  6 (6.00%) high severe

generate-x86_64         time:   [96.068 µs 96.273 µs 96.540 µs]
                        change: [-18.699% -18.381% -18.013%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  4 (4.00%) high mild
  6 (6.00%) high severe

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 3e8b8d035a Include debug symbols in "bench" profile
Including full debug symbols makes the benchmark builds useful for
profiling too.
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott e7aa1d6b62 Start implementing Proposal 327
This adds a new tor-hspow crate with the first layers of support in
place for onion service client puzzles as described in Proposal 327.

The API here is experimental, and it's currently only implementing
the self-contained parts of the client puzzle. So, it can verify and
solve puzzles, but it has no event loop integration or nonce replay
tracking or prioritization code yet. These things seem like they would
eventually live in the same crate.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott 16c9bdf178 Reimplement Equi-X in Rust
This is a new pure Rust implementation of the Equi-X algorithm
designed by tevador for Tor's onion service proof of work puzzle v1.

Equi-X is an asymmetric puzzle algorithm based on Equihash, with
N=60, K=3, the XOR replaced with modular addition, a 16-bit index
space, and HashX as the inner hash function.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:14 -07:00
Micah Elizabeth Scott a8756f2bce Reimplement HashX in Rust
This is a new pure Rust implementation of the HashX algorithm
designed by tevador for Tor's onion service proof of work puzzle v1.

HashX is a lightweight family of randomly generated hash functions.
A seed, via blake2 and siphash, drives a program generation model
which randomly selects opcodes and registers while following some
constraints that avoid timing stalls or insufficient hash mixing.

The execution of these hash funcions can be done using a pure Rust
interpreter, or about 20x faster using a very simple just in time
compiler based on the dynasm assembler crate. This has been
implemented for x86_64 and aarch64.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-27 07:20:06 -07:00
Nick Mathewson 3b9cc6b4e7 Merge branch 'circuit-reactor-first-hop' into 'main'
tor-proto: Extract Create message handling from Reactor::run_once()

See merge request tpo/core/arti!1441
2023-07-27 11:56:14 +00:00
gabi-250 d4fff19ec9 Merge branch 'keymgr-api-updates-gen-key' into 'main'
keymgr: Add KeyMgr::generate() for generating new keys.

See merge request tpo/core/arti!1433
2023-07-27 11:12:12 +00:00
Gabriela Moldovan 0fbd96df82
keymgr: Add TODO regarding generate() being racy. 2023-07-27 11:46:38 +01:00
Gabriela Moldovan 74a2a7937b
keymgr: Document the TOCTOU issue with generate(). 2023-07-27 11:45:05 +01:00
Gabriela Moldovan 249149d4ce
keymgr: Make the return value of generate() indicate if a new key was created. 2023-07-27 11:13:24 +01:00
Gabriela Moldovan 44f6d1c827
keymgr: Make Keystore::generate() return a Result. 2023-07-27 11:03:06 +01:00
Gabriela Moldovan ecfec3b827
tor-proto: Rename create_firsthop() to wait_for_create(). 2023-07-27 10:56:18 +01:00
Gabriela Moldovan 6f22c16ecc
tor-proto: Update handle_control docs. 2023-07-26 19:36:54 +01:00
Gabriela Moldovan 331ec1033a
tor-proto: Add functions for handling Shutdown and AddFakeHop messages.
This helps reduce code duplication, as `CtrlMsg::Shutdown` and
`CtrlMsg::AddFakeHop` are now handled in multiple places.
2023-07-26 19:36:50 +01:00
Gabriela Moldovan fee4baa17f
tor-proto: Extract first-hop creation to a separate function.
I think it's safe to handle `ChanMsg::Create` separately, because
there's nothing for the reactor to do until the first hop of the circuit
is created (so blocking on this _should_ be alright).
2023-07-26 19:36:47 +01:00
Gabriela Moldovan 98b9be0f2d
tor-proto: Create a function for handling the initial CREATE cell.
This logic from `create_firsthop()` was extracted (copied) from
`Reactor::run_once()`. A future commit will update `Reactor::run_once()`
to use `create_firsthop()`.
2023-07-26 19:35:04 +01:00
Ian Jackson 86ee2193b1 dev notes: Draft IPT algorithm: Minor clarifications 2023-07-26 16:14:45 +01:00
Ian Jackson 9966627479 Merge branch 'ipts' into 'main'
dev notes: Draft IPT algorithm: note re intro pt verification (followup)

See merge request tpo/core/arti!1438
2023-07-26 15:14:18 +00:00
Ian Jackson 869df2817a dev notes: Draft IPT algorithm: Added TODO re previous descriptor semantics
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1429#note_2924491
2023-07-26 12:21:34 +01:00
Ian Jackson be31effcae dev notes: Draft IPT algorithm: Added TODO/xref re tuning
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1429#note_2924530
2023-07-26 12:21:34 +01:00