Skip to content

Refactor KeyPair raw byte handling - #117

Merged
davidatwhiletrue merged 1 commit into
masterfrom
keypair-refactor
Aug 4, 2026
Merged

Refactor KeyPair raw byte handling#117
davidatwhiletrue merged 1 commit into
masterfrom
keypair-refactor

Conversation

@davidatwhiletrue

@davidatwhiletrue davidatwhiletrue commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Refactors KeyPair creation and serialization behavior around raw private-key bytes.

  • Adds KeyPair.Create(...) while keeping CreateNew(...) as an obsolete compatibility wrapper.
  • Adds KeyPair.FromBytes(...) and RawBytes for private-key byte round trips.
  • Derives public keys from private key material instead of storing a separate public key parameter.
  • Writes public-key PEMs through PublicKey.WriteToPem(...).
  • Normalizes secp256k1 signatures without producing intermittently invalid signatures.
  • Enforces 32-byte private-key input for both ED25519 and SECP256K1.
  • Updates internal tests/docs to use KeyPair.Create(...) instead of CreateNew(...).

Validation

  • dotnet test Casper.Network.SDK.Test/Casper.Network.SDK.Test.csproj --no-restore --filter "FullyQualifiedName~NetCasperTest.KeysTest"
  • dotnet build Casper.Network.SDK.Test/Casper.Network.SDK.Test.csproj --no-restore
  • dotnet build Casper.Network.SDK/Casper.Network.SDK.csproj --no-restore
  • rg "KeyPair\\.CreateNew" -n

Note: full git diff --check still reports an unrelated pre-existing trailing whitespace line in Casper.Network.SDK.Test/NctlQueryGlobalStateTest.cs:27, outside the keypair branch scope.

…bytes.

Signed-off-by: David Hernando <david.hernando@make.services>
@davidatwhiletrue
davidatwhiletrue marked this pull request as ready for review August 4, 2026 13:44

@alexmyshchyshyn alexmyshchyshyn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidatwhiletrue
davidatwhiletrue merged commit f162ad6 into master Aug 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants