acdream/src/AcDream.Core.Net/NOTICE.md
Erik 293584d6e8 feat(net): AcDream.Core.Net scaffold + ISAAC keystream (Phase 4.1)
First step of Phase 4 (networking). Adds a new AcDream.Core.Net project
for the AC UDP protocol implementation and a matching AcDream.Core.Net.Tests
project. Keeps networking isolated from rendering and the dat layer,
which also keeps the AGPL-reference-material hygiene cleaner.

AcDream.Core.Net/NOTICE.md documents the attribution policy: we read
ACE's AGPL network code (and holtburger's Rust ac-protocol crate) to
understand AC's wire format, but we reimplement everything in acdream's
own style. Wire-format facts aren't copyrightable; specific code is.

This commit adds one component: IsaacRandom — AC's variant of Bob
Jenkins' ISAAC PRNG, used to XOR a keystream into the CRC field of
every outbound packet for authentication. Clean-room reimplementation
based on reading:
  - references/ACE/Source/ACE.Common/Cryptography/ISAAC.cs (AGPL oracle)
  - Bob Jenkins' public ISAAC algorithm description

Implementation notes:
  - 256 uint32 mm[] state, 256 uint32 rsl[] output buffer, a/b/c regs
  - Initialize() runs 4 golden-ratio Mix() warmup rounds then two fold-in
    passes over rsl[] and mm[] (fresh instance → both start as zeroes)
  - AC variant: seed is exactly 4 bytes, interpreted as little-endian
    uint32 assigned to a = b = c before the first Scramble()
  - Scramble() produces 256 output words in one pass; Next() consumes
    them backwards from offset 255 → 0, re-scrambling at offset -1
  - Test seed 0x12345678 matches ACE's reference output byte-for-byte
    across the first 16 values (golden vectors transcribed from a
    throwaway oracle harness that compiled ACE's ISAAC.cs and printed
    its output; the harness was deleted after extracting the values)

Tests (5, all passing):
  - Next_Seed12345678_MatchesAceGoldenVectors: 16 golden uint32 values
  - Next_TwoInstancesSameSeed_ProduceIdenticalSequence: 1000 outputs
  - Next_DifferentSeeds_ProduceDifferentFirstOutput
  - Next_512Calls_SpansTwoScrambleBatches: >400 distinct values in 512
    outputs (catches all-zero / stuck-at-one bugs at scramble boundary)
  - Ctor_ShortSeed_Throws

Both test projects still green: 77 core + 5 net = 82/82.

Phase 4.2 (packet framing + checksum) next.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 14:14:28 +02:00

1.3 KiB

AcDream.Core.Net — Protocol Reference Attribution

This project implements the Asheron's Call network protocol for acdream. The wire format is a fact about the retail AC client/server and cannot be copyrighted, but the specific implementation details and structure conventions are informed by reading the following open-source projects:

  • ACE (ACEmulator / references/ACE/Source/ACE.Server/Network/ and references/ACE/Source/ACE.Common/Cryptography/ISAAC.cs) — AGPL-3.0. The authoritative server-side reference for packet framing, ISAAC keystream generation, fragment reassembly, and GameMessage opcodes.

  • ac-protocol (holtburger's Rust crate) — AGPL-3.0. Confirms the handshake works in practice.

No code is copied from these sources. Algorithms are reimplemented from scratch in acdream's own style after reading and understanding the reference. Where golden test vectors are derived from running the reference implementations, those vectors are factual outputs of the algorithm, not copyrighted expression, and appear only in test code.

If you plan to redistribute acdream outside personal use, consult a lawyer about the interaction between our chosen license and the AGPL heritage of the references we read. (We didn't at the time of writing — see the project-level licensing notes.)