Skip to content

Conversation

@heifner
Copy link
Contributor

@heifner heifner commented Jan 9, 2026

This PR changes standardized string serialization and deserialization for Solana Ed25519 (ED) and Ethereum (EM) cryptographic types. It enables conversion between native string formats (e.g., Solana-style Base58 for ED25519 and Hex for Ethereum) and the project's internal public_key, private_key, and signature storage types.

Changes

fc::crypto type changes

  • fc::crypto public_key, private_key, signature types now have a from_string() instead of constructors for converting from a string. The from_string takes an optional type for specification of the type of key/signature to create. If the default unknown is provided then the prefix strings like PUB_ED_ is required so that the type can be inferred from the string.
  • to_string() now takes a bool include_prefix defaulting to false. If true then the type prefix, e.g. PUB_ED_ is added to the string. This is useful for knowing how to parse the string according to its type. If the default false is provided then the prefix is not included. This currently only affects ED and EM as other existing Wire types like R1 and BLS always provide the prefix since that is part of their "native" string representation.

Ed25519 String Formatting

  • Implementation: Added to_string and from_string methods to public_key_shim, private_key_shim, and signature_shim using standard Ed25519 Base58 encoding.
  • Native Support: Integrated Solana-compatible native string parsing through from_native_string_to_signature<chain_key_type_solana> in key_serdes.hpp.

Ethereum (EM) String Formatting

  • Hex Support: Implemented to_string and from_string for Ethereum types, supporting standard hexadecimal representations for keys and signatures.
  • Routing: Updated signature.cpp and private_key.cpp to correctly route em types to Ethereum-specific hex utilities via key_serdes.hpp.

Unified Prefix Support

Updated parsing logic to support the following project-standardized prefixes:

  • Ed25519: PVT_ED_, PUB_ED_, and SIG_ED_.
  • Ethereum: PVT_EM_, PUB_EM_, and SIG_EM_.
  • These prefixes are added to unmolested ED base58 and EM hex strings. Clients can simply remove the prefixes. For example, PUB_EM_0x04e68a... => 0x04e68a....

clio updates

  • Add new option clio create key --k1 which will generate K1 keys with PUB_K1_ & PVT_K1_ prefix.
  • Add new option clio convert k1_public_key which will read either form of K1 key and output both.
  • Add new option clio convert k1_private_key which will read either form of K1 key and output private key and public key in both formats.

PR also removes unneeded padding from ED signature_shim.

…Ethereum norm.

Use a from_string instead of a constructor.
Optionally allow for string prefixes on EM strings to encode the type.
ED string format not implemented yet.
… signature.

Remove unneeded padding of ED25519 signature_shim.
@heifner heifner requested a review from jglanz January 9, 2026 19:01
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