Skip to main content

compute_legs_hash_from_legs

Function compute_legs_hash_from_legs 

Source
pub(crate) fn compute_legs_hash_from_legs(
    legs: &[RfqLegRequest],
) -> Result<[u8; 32], String>
Expand description

Compute the canonical legs hash from a slice of RfqLegRequest.

Canonical encoding: each leg is “instrument|side|size” joined by “;”. size is parsed to Decimal and formatted back to its canonical Decimal::to_string() form so the hash matches what QPs later compute after receiving the same legs as parsed Decimals (l.size.to_string() in rfq_responder::price_rfq). Without this canonicalization, a taker that signs “01.0” or “+5” would have the submission accepted, then every QP quote would fail signature verification at accept time because the QP’s legs_hash is over “1.0” / “5”. Fail loudly at submit instead.