iwlink 0.1.1

IntelliWallet Link - encrypted phone to computer protocol for IntelliWallet for Browser
Documentation
# iwlink

[![Crates.io](https://img.shields.io/crates/v/iwlink.svg)](https://crates.io/crates/iwlink)
[![Documentation](https://img.shields.io/docsrs/iwlink)](https://docs.rs/iwlink/latest/iwlink/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/intellisoftalpin/iwlink/actions/workflows/ci.yml/badge.svg)](https://github.com/intellisoftalpin/iwlink/actions/workflows/ci.yml)

**IntelliWallet Link** (`iwlink`) is the encrypted protocol between the **[IntelliWallet](https://intelliwallet.io/)** phone app and **IntelliWallet for Browser**, the helper app that lets a browser extension fill and save passwords while the phone is nearby.

The phone keeps the vault. The computer never stores it. When the browser needs a login, the helper asks the phone over Bluetooth Low Energy, the user approves on the phone, and only the chosen login travels back, end to end encrypted.

It is the companion of [`iwcore`](https://crates.io/crates/iwcore), the IntelliWallet storage and cryptography engine, and is open for the same reason: anyone can audit exactly what crosses the air between a phone and a computer.

## What is in the crate

- **Pairing QR code** (`pairing`): the helper's static key, a one-time pre-shared key valid for two minutes, and the computer's name, in a compact binary payload.
- **Noise handshakes** (`noise`): `Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s` for the first pairing and `Noise_KK_25519_ChaChaPoly_BLAKE2s` for every reconnect, via the [`snow`]https://crates.io/crates/snow crate.
- **Confirmation code**: six digits derived from the handshake hash, compared by the user on both screens.
- **Framing** (`frame`): splits sealed messages into Bluetooth-sized fragments and reassembles them, in order, with strict size limits.
- **Messages** (`message`): typed JSON messages with length limits on every field. Sites travel as origins only, never full URLs. Passwords are wiped from memory when a message is dropped.
- **Version negotiation** (`version`) and **timing rules** (`grant`) that both sides share.

## Design rules

- **No platform code.** No Bluetooth, files, Keychain or clock. Callers pass bytes and the current time in and get bytes out, so the same code runs on the phone and on the computer, and tests control time.
- **Bluetooth is an open radio.** Nothing relies on Bluetooth pairing or link encryption for security.
- **Fail closed.** A lost, reordered, replayed or tampered message ends the session; the phone reconnects with a fresh handshake.
- **Standard cryptography only**, from the Noise protocol framework.

## Quick look

```rust
use iwlink::{Handshake, HelperId, PairingOffer, StaticKeypair};

let now = 1_800_000_000;

// Helper: show a QR code.
let helper = StaticKeypair::generate()?;
let offer = PairingOffer::create(HelperId::generate()?, helper.public(), "Studio Mac", now)?;
let qr_text = offer.to_uri();

// Phone: scan it and start pairing.
let phone = StaticKeypair::generate()?;
let scanned = PairingOffer::parse(&qr_text)?;
let mut initiator = Handshake::pairing_initiator(&phone, &scanned, 1, now)?;
let mut responder = Handshake::pairing_responder(&helper, &offer.psk, 1)?;

let first = initiator.write(b"")?;
responder.read(&first)?;
let second = responder.write(b"")?;
initiator.read(&second)?;

let mut phone_side = initiator.finish()?;
let mut helper_side = responder.finish()?;
let sealed = phone_side.session.seal(b"hello")?;
assert_eq!(helper_side.session.open(&sealed)?.as_slice(), b"hello");
# Ok::<(), iwlink::LinkError>(())
```

## License

MIT