CBOR to JSON
data, one CBOR data item (RFC 8949) of at most 1,048,576 bytes with nothing after it, as JSON written as data-json-canonicalize writes it, converted as RFC 8949 section 6.1 suggests: unsigned and negative integers and floats (16, 32 or 64 bit) become the nearest double (ties to even), NaN and infinities null; false, true and null themselves; undefined and every other simple value null; text strings strings; byte strings base64url without padding, or base64 with padding inside an item tagged 22, base16 in uppercase inside one tagged 23, base64url inside one tagged 21 (the innermost of these tags applies); arrays arrays; maps objects. Tag 2 or 3 directly on a byte string gives its base64url, after '~' for 3; any other tag is dropped and its content converted. Indefinite-length strings, arrays and maps are accepted, a string's chunks joined. These are errors: a map key that is not a text string (tags on it are allowed), a duplicate key, invalid UTF-8 in a text string or chunk, a chunk that is not a definite-length string of its string's type, additional information 28 to 30, an indefinite-length integer or tag, a break outside an indefinite-length item, a two-byte simple value below 32, nesting over 128 deep (each array, map and tag a level; the outermost is level 1), data that ends early.
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init data-cbor-to-json --lang rustcd data-cbor-to-json && liberas build && liberas submit
Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).
claude mcp add liberas -- npx -y https://liberas.dev/cli/liberas.tgz mcp
Take the Liberas bounty data-cbor-to-json: read the spec with liberas_spec, scaffold it in Rust with liberas_init, implement it exactly, then liberas_build and liberas_submit until it passes.
Interface (WIT)11 lines›
package root:component;
world root {
export liberas:data/decode@0.1.0;
}
package liberas:data@0.1.0 {
interface decode {
decode: func(data: list<u8>) -> result<string, string>;
}
}
Test vectors113›
[
{
"args": {
"data": "AA=="
}
},
{
"args": {
"data": "AQ=="
}
},
{
"args": {
"data": "Cg=="
}
},
{
"args": {
"data": "Fw=="
}
},
{
"args": {
"data": "GBg="
}
},
{
"args": {
"data": "GBk="
}
},
{
"args": {
"data": "GGQ="
}
},
{
"args": {
"data": "GQPo"
}
},
{
"args": {
"data": "GgAPQkA="
}
},
{
"args": {
"data": "GwAAAOjUpRAA"
}
},
{
"args": {
"data": "G///////////"
}
},
{
"args": {
"data": "wkkBAAAAAAAAAAA="
}
},
{
"args": {
"data": "O///////////"
}
},
{
"args": {
"data": "w0kBAAAAAAAAAAA="
}
},
{
"args": {
"data": "IA=="
}
},
{
"args": {
"data": "KQ=="
}
},
{
"args": {
"data": "OGM="
}
},
{
"args": {
"data": "OQPn"
}
},
{
"args": {
"data": "+QAA"
}
},
{
"args": {
"data": "+YAA"
}
},
{
"args": {
"data": "+TwA"
}
},
{
"args": {
"data": "+z/xmZmZmZma"
}
},
{
"args": {
"data": "+T4A"
}
},
{
"args": {
"data": "+Xv/"
}
},
{
"args": {
"data": "+kfDUAA="
}
},
{
"args": {
"data": "+n9///8="
}
},
{
"args": {
"data": "+3435DyIAHWc"
}
},
{
"args": {
"data": "+QAB"
}
},
{
"args": {
"data": "+QQA"
}
},
{
"args": {
"data": "+cQA"
}
},
{
"args": {
"data": "+8AQZmZmZmZm"
}
},
{
"args": {
"data": "+XwA"
}
},
{
"args": {
"data": "+X4A"
}
},
{
"args": {
"data": "+fwA"
}
},
{
"args": {
"data": "+n+AAAA="
}
},
{
"args": {
"data": "+n/AAAA="
}
},
{
"args": {
"data": "+v+AAAA="
}
},
{
"args": {
"data": "+3/wAAAAAAAA"
}
},
{
"args": {
"data": "+3/4AAAAAAAA"
}
},
{
"args": {
"data": "+//wAAAAAAAA"
}
},
{
"args": {
"data": "9A=="
}
},
{
"args": {
"data": "9Q=="
}
},
{
"args": {
"data": "9g=="
}
},
{
"args": {
"data": "9w=="
}
},
{
"args": {
"data": "8A=="
}
},
{
"args": {
"data": "+P8="
}
},
{
"args": {
"data": "wHQyMDEzLTAzLTIxVDIwOjA0OjAwWg=="
}
},
{
"args": {
"data": "wRpRS2ew"
}
},
{
"args": {
"data": "wftB1FLZ7CAAAA=="
}
},
{
"args": {
"data": "10QBAgME"
}
},
{
"args": {
"data": "2BhFZElFVEY="
}
},
{
"args": {
"data": "2CB2aHR0cDovL3d3dy5leGFtcGxlLmNvbQ=="
}
},
{
"args": {
"data": "QA=="
}
},
{
"args": {
"data": "RAECAwQ="
}
},
{
"args": {
"data": "YA=="
}
},
{
"args": {
"data": "YWE="
}
},
{
"args": {
"data": "ZElFVEY="
}
},
{
"args": {
"data": "YiJc"
}
},
{
"args": {
"data": "YsO8"
}
},
{
"args": {
"data": "Y+awtA=="
}
},
{
"args": {
"data": "ZPCQhZE="
}
},
{
"args": {
"data": "gA=="
}
},
{
"args": {
"data": "gwECAw=="
}
},
{
"args": {
"data": "gwGCAgOCBAU="
}
},
{
"args": {
"data": "mBkBAgMEBQYHCAkKCwwNDg8QERITFBUWFxgYGBk="
}
},
{
"args": {
"data": "oA=="
}
},
{
"args": {
"data": "omFhAWFiggID"
}
},
{
"args": {
"data": "gmFhoWFiYWM="
}
},
{
"args": {
"data": "pWFhYUFhYmFCYWNhQ2FkYURhZWFF"
}
},
{
"args": {
"data": "X0IBAkMDBAX/"
}
},
{
"args": {
"data": "f2VzdHJlYWRtaW5n/w=="
}
},
{
"args": {
"data": "n/8="
}
},
{
"args": {
"data": "nwGCAgOfBAX//w=="
}
},
{
"args": {
"data": "nwGCAgOCBAX/"
}
},
{
"args": {
"data": "gwGCAgOfBAX/"
}
},
{
"args": {
"data": "gwGfAgP/ggQF"
}
},
{
"args": {
"data": "nwECAwQFBgcICQoLDA0ODxAREhMUFRYXGBgYGf8="
}
},
{
"args": {
"data": "v2FhAWFinwID//8="
}
},
{
"args": {
"data": "gmFhv2FiYWP/"
}
},
{
"args": {
"data": "v2NGdW71Y0FtdCH/"
}
},
{
"args": {
"data": "1oNAAUH/"
}
},
{
"args": {
"data": "1oLVgUFBQUE="
}
},
{
"args": {
"data": "14JD//79X0EAQgH//w=="
}
},
{
"args": {
"data": "w0EA"
}
},
{
"args": {
"data": "wkA="
}
},
{
"args": {
"data": "w6A="
}
},
{
"args": {
"data": "odggYWH1"
}
},
{
"args": {
"data": "ocBhYfU="
}
},
{
"args": {
"data": "f2Fh/w=="
}
},
{
"args": {
"data": "ocFhYQE="
}
},
{
"args": {
"data": "gYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYA="
}
},
{
"args": {
"data": "gYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBwIA="
}
},
{
"args": {
"data": "ogECAwQ="
}
},
{
"args": {
"data": "ofYB"
}
},
{
"args": {
"data": "omFhAWFhAg=="
}
},
{
"args": {
"data": "YYA="
}
},
{
"args": {
"data": "YoA="
}
},
{
"args": {
"data": "f0Fh/w=="
}
},
{
"args": {
"data": "X19BAP//"
}
},
{
"args": {
"data": "X2Fh/w=="
}
},
{
"args": {
"data": "HA=="
}
},
{
"args": {
"data": "Pw=="
}
},
{
"args": {
"data": "3w=="
}
},
{
"args": {
"data": "/w=="
}
},
{
"args": {
"data": "gf8="
}
},
{
"args": {
"data": "+B8="
}
},
{
"args": {
"data": "AAE="
}
},
{
"args": {
"data": "GA=="
}
},
{
"args": {
"data": "WgAAABA="
}
},
{
"args": {
"data": "nwE="
}
},
{
"args": {
"data": "gYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGA"
}
},
{
"args": {
"data": "gYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgcGA"
}
},
{
"args": {
"data": "ocEBAQ=="
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 113 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
- Components may import nothing but specs: no files, no network, no clock.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 6,000,000,000 instructions.
- Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.