Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken key generation in Test.Shelley.Spec.Ledger.Utils #1770

Closed
mrBliss opened this issue Aug 11, 2020 · 1 comment
Closed

Broken key generation in Test.Shelley.Spec.Ledger.Utils #1770

mrBliss opened this issue Aug 11, 2020 · 1 comment
Labels
💳 technical-debt Issues related to technical debt we introduced

Comments

@mrBliss
Copy link
Contributor

mrBliss commented Aug 11, 2020

In Test.Shelley.Spec.Ledger.Utils, the mkGenKey, mkKeyPair, ..., functions, which use mkSeedFromWords are broken for some instantiations of crypto. I believe they work fine for mock crypto, which is what they're mostly used for, but not for all crypto, e.g., real crypto.

For example:

-- type DSIGN TPraosStandardCrypto = Ed25519DSIGN
> mkKeyPair @TPraosStandardCrypto (0, 0, 0, 0, 0)
(SignKeyEd25519DSIGN (SecretKey <scrubbed-bytes>),VKey (VerKeyEd25519DSIGN (PublicKey "*** Exception: SeedBytesExhausted {seedBytesSupplied = 16}

The problem is that some crypto algorithms need bigger seeds than mkSeedFromWords gives. mkSeedFromWords uses the MD5 algorithm to create hashes, which means these hashes are always 16 bytes. But Ed25519DSIGN needs a 32-byte seed.

The solution would be to use seedSizeDSIGN, seedSizeKES, seedSizeVRF, ..., to generate a seed of the right size, e.g., by repeating/concatenating/rehashing until the right size has been reached.

@JaredCorduan JaredCorduan added the 💳 technical-debt Issues related to technical debt we introduced label Jun 15, 2022
@JaredCorduan
Copy link
Contributor

mkSeedFromWords is now hard coded to Blake2b_256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💳 technical-debt Issues related to technical debt we introduced
Projects
None yet
Development

No branches or pull requests

2 participants