# Metadata-driven SCALE encode/decode for the Quantus chain, compiled to WASM. # # A separate crate from `quantus-crypto` for the same reason that one is separate # from `wasm-crypto`: different dependency graphs, built independently. They ship # as sibling packages and the extension uses both — this one decides *what bytes* # get signed, that one signs them. # # Why this exists at all rather than `@polkadot/api`: quantus/api#1. In short, # polkadot-js cannot decode a Quantus block (it reads the extrinsic preamble byte # as a version when the top two bits are a type tag), it refuses fixed arrays # longer than 2048 (ML-DSA signatures are 5261 and 7219 bytes), and — the part # that matters after those are patched — it *guesses* that signed extensions it # does not recognise contribute nothing to the signed payload. On a chain whose # encoding has already changed between runtimes, a guess like that produces a # valid signature over the wrong bytes, which arrives as `BadProof` and looks # exactly like a wrong key. See quantus/wasm#3. [package] authors = ["Quantus Network Developers "] description = "Metadata-driven SCALE codec for the Quantus chain, as WASM bindings." edition = "2021" license = "Apache-2.0" name = "quantus_codec" publish = false repository = "https://git.lair.cafe/quantus/wasm" resolver = "2" version = "0.0.0" [lib] crate-type = ["cdylib", "rlib"] [dependencies] # Versions match blackbeard.observer's, which is the other consumer decoding this # chain against its own metadata and the reference implementation for this crate. frame-metadata = { version = "23", default-features = false, features = ["current", "decode"] } parity-scale-codec = { version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2", default-features = false } scale-value = { version = "0.18", default-features = false } # Only for `IgnoreVisitor`. `scale_value` sizes a sequence's Vec from the length # prefix *before* decoding an item, so a blob that disagrees with the registry can # ask for an allocation of any size and abort the process — there is no Err to # catch. Pinned to the version `scale-value` itself resolves so both see one # registry. blackbeard.observer took a 76 GiB allocation to find this. scale-decode = { version = "0.16", default-features = false } serde_json = "1" wasm-bindgen = "0.2" # Storage keys. Substrate hashes a pallet prefix and an item name with twox128 # and each map key with whatever hasher the metadata declares for it. blake2 = { version = "0.10", default-features = false } twox-hash = { version = "2", default-features = false, features = ["xxhash64"] } # SS58. An account id rendered as 32 bytes of hex is a correct description of the # value and unreadable to the person being asked to approve it. bs58 = { version = "0.5", default-features = false, features = ["alloc"] } [profile.release] codegen-units = 1 debug = false debug-assertions = false incremental = false lto = true opt-level = "z" panic = "abort" rpath = false