IntersectMBO / IntersectMBO/cardano-base
Remove `key_material` in `cardano-crypto-wallet`
- Dominant language
- Haskell
- Stars
- 105
- Forks
- 54
- Avg merge
- 9d 2h
- Merged PRs (30d)
- 4
Description
We need to get rid of `key_material` struct. Reason for this is that current implementation allocates the whole of struct in libsodium's mlocked memory, which is scarce resource. We really only need `skey` in mlocked memory, while allocating `pkey` and `cc` in regular memory. For this to happen, we need to get rid of this struct.
For this to work we need to switch every C function that is used with `withKeyMaterialPtr` to accept three arguments, instead of one struct.
This will remove redundant allocation in mlocked memory and avoid unnecessary memcopy of the whole of KeyMaterial
~In the process `KeyMaterial` could be renamed to `ExtKeyMaterial`, for extended key material, since it also contains chain code~ Done in #689
_Originally posted by @lehins in https://github.com/IntersectMBO/cardano-base/pull/667#discussion_r3537307964_
Contributor guide
Research direction
Start by locating the key_material struct and every use of withKeyMaterialPtr, then trace the C functions that currently accept the struct. Update the affected interfaces to use separate arguments for skey, pkey, and cc. Done means only skey remains in mlocked memory and the redundant allocation and whole-KeyMaterial copy are removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, haskell
- Domain
- cryptography, security
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100