Skip to main content

px_native/cipher/
secret.rs

1//! `vL()` — secret-feed builder. JS reference:
2//!
3//! ```text
4//! function vL() { return jw(hP(pf() || gC(365)), vJ); }   // vJ = 10
5//! ```
6//!
7//! In JS, `pf()` returns the page fingerprint; here the caller passes
8//! whatever bytes the runtime would have collected. The fallback
9//! string is tenant-specific (decoded as `gC(365)` in the captured
10//! init.js) — clients select the right fallback via the tenant
11//! profile (ADR-0024 N5).
12
13use crate::cipher::b64::h_p;
14use crate::cipher::xor::{VJ, jw};
15
16pub fn v_l(pf_or_fallback: &[u8]) -> Vec<u8> {
17    jw(h_p(pf_or_fallback).as_bytes(), VJ)
18}
19
20#[cfg(test)]
21mod tests {
22    use super::*;
23
24    #[test]
25    fn empty_input_yields_empty_feed() {
26        assert!(v_l(b"").is_empty());
27    }
28
29    #[test]
30    fn deterministic_for_same_input() {
31        assert_eq!(v_l(b"pedidosya"), v_l(b"pedidosya"));
32    }
33}