Skip to content

How a direct file send works

Jeffrey Walter Mixon edited this page Nov 12, 2026 · 1 revision

An attachment in Knit is capped at 8 MiB, because every phone that carries a message may hold its attachment for up to a day. That suits a photo. It rules out the 2 GB video from your camera, even when the person you want to give it to is standing next to you.

Direct file send covers that case. In a one-to-one chat with someone nearby, it moves one file of up to 8 GiB from your phone to theirs over a Wi-Fi Direct connection the two phones set up for that file and take down afterwards. The mesh carries the conversation about the file. The file itself never touches the mesh, and no other phone sees or keeps it.

Checked against Knit 2.11.0.

How it differs from an attachment

An attachment rides the mesh. Your message names it by hash, and the bytes follow on request from whichever phone holds them, which may be a carrier that met you hours ago. How pictures and files cross the mesh follows that trip. A direct send skips all of it:

Attachment Direct file send
Largest file 8 MiB 8 GiB
Chats Direct, group, and the Nearby room for pictures and short videos One-to-one only
Who has to be in range Nobody. Carriers bring it to the recipient later Both phones, linked to each other, for the whole transfer
Path Bluetooth or Wi-Fi Aware, hop by hop, or a relay if you use one One Wi-Fi Direct link between the two phones
Who holds a copy Every phone that carries it, sealed, for up to 24 hours Only the two phones
Speed Seconds over Wi-Fi Aware, about half a minute for a photo over Bluetooth About 70 MB/s on 5 GHz, a gigabyte in 15 seconds
What Knit changes Photos and videos are shrunk and their metadata stripped Nothing. The file goes byte for byte
Screened for harmful content Pictures and videos, on the phone No
Where it ends up Inside Knit's encrypted storage The Download/Knit folder, as an ordinary file

Direct sends also run Android to Android only, since Knit for iPhone doesn't offer them.

The trade is reach for size. An attachment gets to someone you'll never be in range of, slowly and in small pieces. A direct send moves a lot, fast, but only between two phones that can see each other.

How a send works

Direct file send is in the menu of a one-to-one chat. Here's what happens when Alice sends Bob a video:

sequenceDiagram
    participant A as Alice (sender)
    participant B as Bob (receiver)
    A->>B: Offer: name, size, type (over the mesh)
    B->>A: Accept (over the mesh)
    A->>B: READY: network name, passphrase, key (over the mesh)
    Note over A: Pauses Wi-Fi Aware, starts a Wi-Fi Direct group
    Note over B: Pauses Wi-Fi Aware, joins the group
    B->>A: Connects and proves it holds the key
    A->>B: The file, in encrypted 256 KiB chunks
    A->>B: A checksum over everything sent
    B->>A: One byte: arrived intact, or didn't
    Note over A,B: The group comes down and Wi-Fi Aware resumes
Loading

When Alice picks a file, her phone sends Bob an offer naming the file, its size and its type. Bob gets a notification and a card in the chat with Accept and Decline. Every message the two phones exchange about the transfer, from this offer on, is an end-to-end encrypted direct message carried by the mesh like any other.

When Bob accepts, Alice's phone makes up a network name (DIRECT-kn- followed by 8 random characters), a 24-character passphrase and a 32-byte key for encrypting the file. All three are new for this transfer and never reused. They go to Bob in a message called READY.

Alice's phone then starts a Wi-Fi Direct group under that name, and Bob's phone joins it with the name and passphrase. Since Bob's phone already has both, neither phone shows Android's pairing dialog, and Accept is the only thing Bob taps. Joining takes about 6 seconds, most of it Android's own.

Both phones pause Wi-Fi Aware first. Android won't run Knit's Wi-Fi Direct group beside Knit's own Wi-Fi Aware session, and it gives no signal when one is blocking the other, so Knit pauses Wi-Fi Aware itself. Bluetooth keeps running on both phones the whole time. That keeps them on the mesh, so other messages still arrive, a little slower, and either person can cancel.

READY is the one message the transfer can't do without, so Alice's phone takes care with it. It waits half a second after sending READY before pausing Wi-Fi Aware, since a message counts as sent once it's queued and pausing too soon once cut READY off halfway. Then it sends READY again every 5 seconds, over Bluetooth, until Bob's phone connects. Bob's phone ignores the copies.

Once Bob's phone is connected, the file streams across in 256 KiB chunks. It's written to Bob's Download/Knit folder as it arrives, marked as pending so other apps can't see it yet. After the last chunk Bob's phone checks the final checksum, tells Alice's phone whether everything arrived intact, and only then marks the file complete. If the transfer fails partway, the partial file is deleted. Either way, both phones take the group down and resume Wi-Fi Aware.

The security around it

The Wi-Fi Direct group uses WPA2 with the single-use passphrase from READY, so only Bob's phone can join it. Because READY travels as an end-to-end encrypted message, a phone that carries it on the mesh can't read the passphrase or the key.

Knit encrypts the file inside the group anyway. WPA2 implementations have had serious bugs (KRACK, in 2017, was the best known), and the file's safety shouldn't depend on both phones' Wi-Fi software being free of the next one. On top of the Wi-Fi encryption, the stream has its own protection:

  • Bob's phone has to prove it holds the transfer key before Alice's phone sends anything, so a stray connection from another device gets no part of the file.
  • The key from READY is never used directly. Knit derives two keys from it with HKDF-SHA256, one to encrypt the file and one to authenticate the stream.
  • Each 256 KiB chunk is encrypted with AES-256-GCM, and Bob's phone checks each one before writing it, so nothing unverified reaches storage.
  • Each chunk's check also covers its position in the file and whether it's the last chunk. Bob's phone works those out from the size it agreed to rather than reading them off the connection, so a chunk moved out of order, a chunk copied in from another transfer, or a file cut short at a chunk boundary all fail.
  • A final HMAC-SHA256 over the whole stream, and Bob's one-byte answer, let Alice's phone tell you whether the file really arrived intact.

All of that costs 20 bytes per chunk, under a hundredth of a percent, and the encryption runs far faster than the link, so it doesn't slow the transfer down.

The protection ends where the file lands. The received file is an ordinary file in Downloads, without Knit's encryption, and any app that can read your Downloads can read it. Knit doesn't screen it for harmful content either, so accept files only from people you trust. Knit says both of these on the sheet it shows the first time you send or receive one.

Someone nearby can tell a transfer is happening. While the file moves, a Wi-Fi network named DIRECT-kn- plus 8 characters is on the air, and any phone or laptop scanning for Wi-Fi can see it, its signal strength and its channel. The DIRECT-kn- prefix tells them it belongs to Knit. They can't join it without the passphrase, the file inside it is encrypted as well, and the network disappears when the transfer ends.

Going deeper