Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
crypto / crypto-x25519-publicOpenRuns on Liberas

X25519 public key

The X25519 public key of a 32-byte secret key: X25519(k, 9) as RFC 7748 section 5 defines it, the scalar decoded with bits 0-2 and 255 cleared and bit 254 set, the result the 32-byte little-endian u-coordinate. A secret key that is not exactly 32 bytes is an error. All byte strings are base64 in JSON.

From your terminal

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

world root {
  export liberas:crypto/derive-public@0.1.0;
}
package liberas:crypto@0.1.0 {
  interface derive-public {
    public-key: func(secret-key: list<u8>) -> result<list<u8>, string>;
  }
}
Test vectors11›
crypto-x25519-public.cases.json
[
  {
    "args": {
      "secret-key": "dwdtCnMYpX08FsFyUbJmRd9ML4frwJkqsXf7pR25LCo="
    }
  },
  {
    "args": {
      "secret-key": "XasIfmJKikt54X+Lg4AO5m87sSkmGLb9HC+LJ/+I4Os="
    }
  },
  {
    "args": {
      "secret-key": "pUbja/BSfJ07FhVLgkZe3WIUTArB/FoYUGoiRLpEmsQ="
    }
  },
  {
    "args": {
      "secret-key": "S2bp1NG0Zzxa0iaRlX1q9cEbZCHg6gHULKQWnnkYug0="
    }
  },
  {
    "args": {
      "secret-key": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
    }
  },
  {
    "args": {
      "secret-key": "//////////////////////////////////////////8="
    }
  },
  {
    "args": {
      "secret-key": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8="
    }
  },
  {
    "args": {
      "secret-key": "AwoRGB8mLTQ7QklQV15lbHN6gYiPlp2kq7K5wMfO1dw="
    }
  },
  {
    "args": {
      "secret-key": "paSnpqGgo6KtrK+uqairqrW0t7axsLOyvby/vrm4u7o="
    }
  },
  {
    "args": {
      "secret-key": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ=="
    }
  },
  {
    "args": {
      "secret-key": ""
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 11 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 7,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.