Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
encode / encode-z85-decodeOpenRuns on Liberas

Z85 decode

Decodes Z85 (ZeroMQ RFC 32): the length must be a multiple of 5; each 5 characters of the Z85 alphabet (0–9 a–z A–Z . - : + = ^ ! / * ? & < > ( ) [ ] { } @ % $ #, digit 0 to 84 in that order) are base-85 digits, most significant first, whose value must be at most 2^32 − 1 (else an error) and gives 4 bytes big-endian. Any other character, including whitespace, quotes, "," ";" and non-ASCII, is an error ("HelloWorld" → 0x86 0x4F 0xD2 0x6F 0xB5 0x59 0xF7 0x5B, "%nSc0" → 0xFF 0xFF 0xFF 0xFF, "%nSc1" is an error). The empty string decodes to no bytes. text is a string of at most 16 MiB (16,777,216 bytes of UTF-8); more is an error. The result is bytes (base64 in JSON).

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init encode-z85-decode --lang rust
cd encode-z85-decode && 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).

Interface (WIT)11 lines›
encode-z85-decode.wit
package root:component;

world root {
  export liberas:encode/decoder@0.1.0;
}
package liberas:encode@0.1.0 {
  interface decoder {
    decode: func(text: string) -> result<list<u8>, string>;
  }
}
Test vectors13›
encode-z85-decode.cases.json
[
  {
    "args": {
      "text": ""
    }
  },
  {
    "args": {
      "text": "HelloWorld"
    }
  },
  {
    "args": {
      "text": "00000"
    }
  },
  {
    "args": {
      "text": "%nSc0"
    }
  },
  {
    "args": {
      "text": "#####"
    }
  },
  {
    "args": {
      "text": "%nSc1"
    }
  },
  {
    "args": {
      "text": "Hello"
    }
  },
  {
    "args": {
      "text": "Hello World"
    }
  },
  {
    "args": {
      "text": "HelloWorl"
    }
  },
  {
    "args": {
      "text": "Hell\""
    }
  },
  {
    "args": {
      "text": "Hel,o"
    }
  },
  {
    "args": {
      "text": "helloworld"
    }
  },
  {
    "args": {
      "text": "한글한글한"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 13 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 2,200,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.