Phase B: identifier+key on the wire, JCS envelope signing (FRX/0.5), registry binding

This commit is contained in:
George Coles
2026-09-15 05:54:52 -04:00
parent 559c260639
commit d30e612be8
12 changed files with 159 additions and 89 deletions
+5 -3
View File
@@ -22,6 +22,7 @@ pub struct Envelope {
#[serde(rename = "type")]
pub msg_type: String,
pub from: String,
pub key: String,
pub ts: u64,
pub nonce: String,
pub body: Value,
@@ -29,10 +30,11 @@ pub struct Envelope {
}
impl Envelope {
pub fn new(key: &Keypair, msg_type: &str, body: Value) -> Self {
pub fn new(key: &Keypair, identifier: &str, msg_type: &str, body: Value) -> Self {
let mut envelope = Self {
msg_type: msg_type.to_string(),
from: key.public_hex(),
from: identifier.to_string(),
key: key.public_hex(),
ts: now_ts(),
nonce: random_nonce(),
body,
@@ -183,7 +185,7 @@ mod tests {
#[test]
fn envelope_rejects_wrong_type() {
let key = Keypair::generate();
let envelope = Envelope::new(&key, TYPE_RESPONSE, json!({}));
let envelope = Envelope::new(&key, "bob.example", TYPE_RESPONSE, json!({}));
assert!(require_type(&envelope, TYPE_QUERY).is_err());
}
}