Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
barcode / barcode-itf14OpenRuns on Liberas

ITF-14

ITF-14 (GS1) of text: 13 digits, to which the check digit is added, or 14 digits whose last is the right check digit; anything else (another character, another length, a wrong check digit) is an error. Check digit: weights 3, 1, 3, … from the rightmost data digit leftward, then (10 − sum mod 10) mod 10. text: the 14 digits. modules: exactly barcode-itf's of the 14 digits (Interleaved 2 of 5: start 1010; each pair's first digit as bars and second as spaces, interleaved bar first, narrow = 1 module, wide = 3, digit patterns 0 NNWWN, 1 WNNNW, 2 NWNNW, 3 WWNNN, 4 NNWNW, 5 WNWNN, 6 NWWNN, 7 NNNWW, 8 WNNWN, 9 NWNWN; stop 11101); no bearer bars, no quiet zones.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init barcode-itf14 --lang rust
cd barcode-itf14 && 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)21 lines›
barcode-itf14.wit
package root:component;

world root {
  import liberas:barcode/types@0.1.0;

  export liberas:barcode/linear-encode@0.1.0;
}
package liberas:barcode@0.1.0 {
  interface types {
    record linear {
      text: string,
      modules: string,
    }
  }
  interface linear-encode {
    use types.{linear};

    encode: func(text: string) -> result<linear, string>;
  }
}
Test vectors14›
barcode-itf14.cases.json
[
  {
    "args": {
      "text": "1540014128876"
    }
  },
  {
    "args": {
      "text": "15400141288763"
    }
  },
  {
    "args": {
      "text": "0001234560001"
    }
  },
  {
    "args": {
      "text": "00012345600012"
    }
  },
  {
    "args": {
      "text": "9876543210921"
    }
  },
  {
    "args": {
      "text": "1234567890123"
    }
  },
  {
    "args": {
      "text": "5012345678900"
    }
  },
  {
    "args": {
      "text": "0000000000000"
    }
  },
  {
    "args": {
      "text": "9999999999999"
    }
  },
  {
    "args": {
      "text": "15400141288764"
    }
  },
  {
    "args": {
      "text": ""
    }
  },
  {
    "args": {
      "text": "154001412887"
    }
  },
  {
    "args": {
      "text": "154001412887630"
    }
  },
  {
    "args": {
      "text": "15400141288a7"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 14 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 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.