Two ways to say no
Bad XML or a bad signature gets an HTTP status. A valid message that breaks a rule gets 200 and a signed Rejected response, with the specification's reason.
Receiving →UFTP 3.1 · Shapeshifter · Rust · Apache-2.0 OR MIT
Trade grid flexibility between distribution system operators and aggregators: all 26 messages of UFTP 3.1, CS1 signatures, DST-correct ISPs, and a receiver that answers the way the specification says. Tested against LF Energy's own reference library.
cargo add uftpWhen a feeder is about to overload, a distribution system operator (DSO) can upgrade the cable, or pay someone to use less power at the right time. UFTP is the protocol for the second: the DSO sends a FlexRequest for a congestion point, an aggregator (AGR) that controls batteries, heat pumps or chargers there answers with a FlexOffer, the DSO orders it, and a monthly FlexSettlement pays for what was delivered. A Common Reference Operator (CRO) keeps the register of who is connected where.
UFTP was written by the USEF Foundation; since version 3 it is maintained by LF Energy as Shapeshifter. Every message is XML, signed with Ed25519, and posted over HTTPS. The protocol in ten minutes →
Bad XML or a bad signature gets an HTTP status. A valid message that breaks a rule gets 200 and a signed Rejected response, with the specification's reason.
Receiving →Endpoint::receive verifies, decodes and checks the rules, the market, the clock, the outbox and replays, in that order.
In CI, LF Energy's Java library verifies and re-signs every type uftp writes, and its 39 validators judge 51 rule cases next to uftp.
Interoperability →Every refusal is one sentence: what is wrong, where, and which rule. Received text in it is escaped and bounded.
Rejections →use uftp::*;
// The DSO asks for 500 kW less consumption tomorrow, 17:00–19:00 (ISPs 69–76).
let meta = Metadata::new(dso_domain, agr_domain, now, new_id());
let header = FlexHeader::new(meta, "Europe/Amsterdam".parse()?, day, congestion_point);
let isps = vec![FlexRequestIsp::requested(IspSpan::new(69, 8)?, -500_000, 0)];
let request = FlexRequest::new(header, expires, isps);
let document = seal(&request.into(), Role::Dso, &dso_key)?.to_xml(); // what it POSTs
// The aggregator receives it: every check, in the order the protocol needs.
match endpoint.receive(document.as_bytes(), now, directory.lookup()) {
Ok(opened) => { /* offer, or answer */ }
Err(e) => if let Some(answer) = e.response(new_id(), now) { /* seal and send */ },
}The library does no I/O: ids, clocks and keys come from you, and the network is yours. With the http feature it maps onto the http crate's types, so a handler in axum, hyper or any framework on http 1.x is a few lines. Without default features it is the messages and their rules alone, with no signing stack.