Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
validate / validate-leiOpenRuns on Liberas

LEI

Validates a Legal Entity Identifier (ISO 17442-1:2020) on input as it is: no trimming, separators or case folding. format: exactly 20 characters, 18 of A-Z or 0-9 then 2 of 0-9 (lowercase, non-ASCII and input over 65,536 bytes are format). checksum: ISO 7064 MOD 97-10: with each letter replaced by its two-digit value (A=10 … Z=35), the 20 characters read as one decimal number must be 1 mod 97, else checksum. Valid gives lou (characters 1-4, the issuing LOU's prefix), entity (5-18) and check-digits (19-20). Whether GLEIF issued or still lists the LEI is not checked.

From your terminal

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

world root {
  export liberas:validate/lei@0.1.0;
}
package liberas:validate@0.1.0 {
  interface lei {
    record lei-parts {
      lou: string,
      entity: string,
      check-digits: string,
    }

    enum lei-error {
      format,
      checksum,
    }

    variant lei-check {
      valid(lei-parts),
      invalid(lei-error),
    }

    check: func(input: string) -> lei-check;
  }
}
Test vectors13›
validate-lei.cases.json
[
  {
    "args": {
      "input": "5493001KJTIIGC8Y1R12"
    }
  },
  {
    "args": {
      "input": "HWUPKR0MPOU8FGXBT394"
    }
  },
  {
    "args": {
      "input": "7LTWFZYICNSX8D621K86"
    }
  },
  {
    "args": {
      "input": "529900T8BM49AURSDO55"
    }
  },
  {
    "args": {
      "input": "213800D1EI4B9WTWWD28"
    }
  },
  {
    "args": {
      "input": "5493001KJTIIGC8Y1R13"
    }
  },
  {
    "args": {
      "input": "HWUPKR0MPOU8FGXBT349"
    }
  },
  {
    "args": {
      "input": "5493001kjtiigc8y1r12"
    }
  },
  {
    "args": {
      "input": "5493001KJTIIGC8Y1R1"
    }
  },
  {
    "args": {
      "input": "5493001KJTIIGC8Y1R123"
    }
  },
  {
    "args": {
      "input": "5493001KJTIIGC8Y1RA2"
    }
  },
  {
    "args": {
      "input": "5493 001KJTIIGC8Y1R12"
    }
  },
  {
    "args": {
      "input": ""
    }
  }
]
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 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.