Skip to content

Commit 2090a05

Browse files
committed
push-seal: hand-seal examples, so tonight's milestone needs no new code
CKIOS proposes the right milestone for tonight: ONE notification, sealed by hand, that opens on the phone. Not the feature. It exercises every unknown -- key custody across two processes, seal/open agreement, the APNs environment (which is currently operator testimony rather than a measurement), and the deep link -- while each piece is small enough that a failure has one candidate cause. The room listed the sealer as STARTED and the corpus as NOT STARTED, and read that as blocking. It is not: sealing one payload needs the crate, not the corpus. The corpus proves CONFORMANCE between two implementations, which is a later question than whether a blob opens. So these three examples close that gap with no new library code: kp generate an X25519 recipient keypair handseal seal a payload to a public key, print hex, report the size delta handopen open one, or print the refusal AND its wire code MEASURED RATHER THAN ESTIMATED, on a realistic ask payload: 111 bytes plaintext -> 160 bytes sealed. 49 bytes of overhead: 1 version + 32 encapsulated key + 16 authentication tag. That number retires a question I had left open in the spec deliberately -- I refused to state a derived sealed-size figure before measuring one, because a derived number stated early becomes normative by accident. Now it is measured: the 2048-byte plaintext cap yields ~2097 sealed, comfortably inside APNs' 4KB ceiling, so the cap needs no revision. Round trip verified with its control: the correct key opens to the exact plaintext; a wrong recipient refuses as Aead, wire code `malformed`, which is the three-into-one collapse the spec requires rather than a leak about which part of the envelope was wrong. Examples rather than a binary or a script, so they live beside the crate they exercise and cannot drift from it.
1 parent a850151 commit 2090a05

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn main() {
2+
let a: Vec<String> = std::env::args().collect();
3+
let hx = |s: &str| {
4+
(0..s.len())
5+
.step_by(2)
6+
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap())
7+
.collect::<Vec<u8>>()
8+
};
9+
match cortexkit_push_seal::open(&hx(&a[1]), &hx(&a[2])) {
10+
Ok(p) => println!("OPENED: {}", String::from_utf8_lossy(&p)),
11+
Err(e) => println!("REFUSED: {:?} wire={}", e, e.wire_code()),
12+
}
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Proves the crate can seal a real payload to a real recipient key TODAY.
2+
// Run: cargo run -p cortexkit-push-seal --example handseal -- <recipient_pk_hex> '<json>'
3+
fn main() {
4+
let a: Vec<String> = std::env::args().collect();
5+
let pk = (0..a[1].len())
6+
.step_by(2)
7+
.map(|i| u8::from_str_radix(&a[1][i..i + 2], 16).unwrap())
8+
.collect::<Vec<u8>>();
9+
let sealed = cortexkit_push_seal::seal(&pk, a[2].as_bytes()).expect("seal");
10+
println!(
11+
"{}",
12+
sealed
13+
.iter()
14+
.map(|b| format!("{b:02x}"))
15+
.collect::<String>()
16+
);
17+
eprintln!(
18+
"plaintext {} bytes -> sealed {} bytes",
19+
a[2].len(),
20+
sealed.len()
21+
);
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
use hpke::{Kem, Serializable};
3+
let (sk, pk) = hpke::kem::X25519HkdfSha256::gen_keypair();
4+
let h = |b: &[u8]| b.iter().map(|x| format!("{x:02x}")).collect::<String>();
5+
println!("SK {}", h(&sk.to_bytes()));
6+
println!("PK {}", h(&pk.to_bytes()));
7+
}

0 commit comments

Comments
 (0)