Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
hash / hash-argon2idOpenRuns on Liberas

Argon2id

Argon2id, version 0x13 (RFC 9106): a length-byte tag from password (P), salt (S), secret (K) and associated data (X) with t passes, m KiB of memory and p lanes, exactly as RFC 9106 defines it (H0 over all parameters and inputs; data-independent addressing for the first two slices of the first pass, data-dependent after; lanes are part of the addressing, computed in any order, so the result is deterministic), lowercase hex. The memory used is m rounded down to a multiple of 4 × p blocks of 1 KiB. Checked in this order, each failure an error with nothing derived: salt at least 8 bytes; ad at most 32 bytes; p 1 to 16; t ≥ 1; m ≥ 8 × p; t × m ≤ 65,536 (so at most 64 MiB of memory, or fewer with more passes); length 4 to 1,024. password, salt, secret and ad are bytes (base64 in JSON); secret and ad may be empty.

From your terminal

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

world root {
  export liberas:hash/argon@0.1.0;
}
package liberas:hash@0.1.0 {
  interface argon {
    derive: func(password: list<u8>, salt: list<u8>, secret: list<u8>, ad: list<u8>, t: u32, m: u32, p: u32, length: u32) -> result<string, string>;
  }
}
Test vectors17›
hash-argon2id.cases.json
[
  {
    "args": {
      "m": 32,
      "p": 4,
      "t": 3,
      "ad": "BAQEBAQEBAQEBAQE",
      "salt": "AgICAgICAgICAgICAgICAg==",
      "length": 32,
      "secret": "AwMDAwMDAwM=",
      "password": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE="
    }
  },
  {
    "args": {
      "m": 64,
      "p": 1,
      "t": 2,
      "ad": "",
      "salt": "c29tZXNhbHQ=",
      "length": 32,
      "secret": "",
      "password": "cGFzc3dvcmQ="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 1,
      "t": 1,
      "ad": "",
      "salt": "c29tZXNhbHQ=",
      "length": 4,
      "secret": "",
      "password": "cGFzc3dvcmQ="
    }
  },
  {
    "args": {
      "m": 35,
      "p": 2,
      "t": 1,
      "ad": "",
      "salt": "c29tZXNhbHQ=",
      "length": 16,
      "secret": "",
      "password": "cGFzc3dvcmQ="
    }
  },
  {
    "args": {
      "m": 65536,
      "p": 1,
      "t": 1,
      "ad": "",
      "salt": "c2FsdHNhbHQ=",
      "length": 32,
      "secret": "",
      "password": "cGFzc3dvcmQ="
    }
  },
  {
    "args": {
      "m": 16384,
      "p": 16,
      "t": 4,
      "ad": "",
      "salt": "c2FsdHNhbHQ=",
      "length": 64,
      "secret": "",
      "password": "cGFzc3dvcmQ="
    }
  },
  {
    "args": {
      "m": 128,
      "p": 16,
      "t": 1,
      "ad": "",
      "salt": "c2FsdHNhbHQ=",
      "length": 1024,
      "secret": "",
      "password": ""
    }
  },
  {
    "args": {
      "m": 1000,
      "p": 3,
      "t": 3,
      "ad": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
      "salt": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
      "length": 100,
      "secret": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==",
      "password": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiYw=="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 1,
      "t": 1,
      "ad": "",
      "salt": "MTIzNDU2Nw==",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 1,
      "t": 1,
      "ad": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8g",
      "salt": "MTIzNDU2Nzg=",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 0,
      "t": 1,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 136,
      "p": 17,
      "t": 1,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 1,
      "t": 0,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 15,
      "p": 2,
      "t": 1,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 32769,
      "p": 1,
      "t": 2,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 32,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 1,
      "t": 1,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 3,
      "secret": "",
      "password": "cA=="
    }
  },
  {
    "args": {
      "m": 8,
      "p": 1,
      "t": 1,
      "ad": "",
      "salt": "MTIzNDU2Nzg=",
      "length": 1025,
      "secret": "",
      "password": "cA=="
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 17 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 5,000,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.