Skip to content

[#790] Straighten out detSecretKey's behavior

Nikolay Yakimov requested to merge lierdakil/#790-less-weird-detsecretkey into master

NB: I've introduced KeyType instead of reusing HashTag for two reasons:

  • Semantically, this seems more correct
  • HashTag is a GADT which makes Bounded and Enum instances un-deriveable, and writing those by hand is a huge chore and frankly not worth the effort.

Description

Problem: Morley.Tezos.Crypto.detSecretKey chooses the type of key it generates based on seed length, which can lead to subtle bugs wrt key generation.

Solution: Rewrite it to use seed value instead. Add a couple simple tests. Introduce a variant function detSecretKey' that accepts explicit key type as argument. Introduce KeyType enum for key types.

Problem: KeyType and HashTag duplicate key types between them.

Solution: Replace all key HashTag constructors with a single constructor accepting KeyType as argument.

Related issue(s)

Resolves #790 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Nikolay Yakimov

Merge request reports