pub struct Signed {
pub body: Value,
pub sig: String,
}Expand description
A signed message: a JSON body and the Ed25519 signature over its canonical bytes under the message’s domain. The body stays JSON so that fields a newer peer adds survive verification here unchanged.
Keeping the body as JSON rather than as the bytes that were signed is what makes the protocol extensible: a field a newer peer added is carried through verification untouched, because the signature is checked over the canonical form of whatever is there rather than over a shape this version knows.
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::link::{sign, verify_signed, Domain, Signed};
let node = NodeIdentity::ephemeral().unwrap();
let signed: Signed = sign(&node, Domain::SyncRequest, serde_json::json!({ "b": 2, "a": 1 }));
assert_eq!(signed.sig.len(), 128, "hex Ed25519");
// key order is not content, so a round trip through JSON still verifies
let wire = serde_json::to_string(&signed).unwrap();
let back: Signed = serde_json::from_str(&wire).unwrap();
assert!(verify_signed(&node.public.public_key, Domain::SyncRequest, &back));Fields§
§body: ValueThe message.
sig: StringHex Ed25519 over the domain and the canonical JSON of body.
Trait Implementations§
Source§impl BenchmarkCases for Signed
impl BenchmarkCases for Signed
Source§fn benchmark_cases(_: &CaseContext<'_>) -> Vec<NamedCase<Self>>
fn benchmark_cases(_: &CaseContext<'_>) -> Vec<NamedCase<Self>>
The cases, in a stable order. An empty list means “nothing to benchmark in this
repository”, which the coverage check reports as missing.
Source§fn benchmark_cases_json(ctx: &CaseContext<'_>) -> Vec<NamedCase<Value>>
fn benchmark_cases_json(ctx: &CaseContext<'_>) -> Vec<NamedCase<Value>>
The cases as JSON, the shape every runner serialises from.
Source§impl<'de> Deserialize<'de> for Signed
impl<'de> Deserialize<'de> for Signed
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for Signed
impl JsonSchema for Signed
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Signed
Auto Trait Implementations§
impl Freeze for Signed
impl RefUnwindSafe for Signed
impl Send for Signed
impl Sync for Signed
impl Unpin for Signed
impl UnsafeUnpin for Signed
impl UnwindSafe for Signed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more