Added option to read hashed private key as input in softsign feature #742
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
As a temporary solution for networks like Injective that require faster signing turnaround than what the YubiHSM key can provide, the softsign feature was extended with the option to read the "expanded secret key" from the file system instead of the regular seed key (or private key as people call it).
The
yubihsm-unwrap
command's output file can be directly fed into the definedpath
field in the configuration and the key-loading mechanism will automatically see which type of key was presented.It also verifies the private key for good measure in cases where this is possible and prints an entry into the log for the end-user.
yubihsm-unwrap
command PR: Yubico/yubihsm-shell#323 .How it is done
I've replaced the private key loading mechanism's return type from
ed25519::KeyPair
to a custom-madeKeyPair
that can hold either the regular seed key or the expanded secret key with the corresponding private key. The custom struct has enough conversion traits that throughout the codebase only minimal modifications were needed to integrate it.Why not just use the expanded key and completely get rid of the seed key?
This is a valid question since the seed key is not necessary for signing. (RFC8032 defines the first 32 bytes of the hash of the seed key as the private key.)
In the codebase, the Ed25519 seed key loading mechanism is used elsewhere too. For example, while opening the TCP connection, the code uses an Ed25519 seed key as the hub secret connection key. There was no point in upsetting parts of the code that work well and it was easier to implement enough
From
traits to overcome the different use.