SecByteBlock 到 ECDSA<ECP, SHA256>::PublicKey 并在 CryptoPP 中反转

SecByteBlock to ECDSA<ECP, SHA256>::PublicKey and reverse in CryptoPP

正如标题所说,有没有办法将 SecByteBlock 中的密钥转换为 ECDSA::PublicKey 以及反之?

根据我所阅读的内容,我刚刚成功地将 PublicKey 转换为 strin 使用:

    PubicKey pubKey;
    string s;
    StringSink ss(s);
    pubKey.Save(ss);
 //To string

 string encoded;


    // Pretty print key
    encoded.clear();

      
        StringSource(key, key.size(), true,
                     new HexEncoder(
                             new StringSink(encoded)
                     ) // HexEncoder
        ); // StringSource

PublicKey string_to_publicKey(string keyInHex){
    string decodedKey;
    HexDecoder decoder;
    decoder.Put( (byte*)keyInHex.data(), keyInHex.size() );
    decoder.MessageEnd();

    word64 size = decoder.MaxRetrievable();
    if(size && size <= SIZE_MAX)
    {
        decodedKey.resize(size);
        decoder.Get((byte*)&decodedKey[0], decodedKey.size());
    }
    cout << "Decoded : " << decodedKey << endl;
    StringSource ss(decodedKey, true);
    PublicKey pubKey;
    pubKey.Load(ss);

    return pubKey;
}
string public_key_to_string(PublicKey publicKey){
    string ss;
    StringSink sink(ss);
    publicKey.Save(sink);
    string encoded;
    HexEncoder encoder;
    encoder.Put((byte*)ss.data(), ss.size());
    encoder.MessageEnd();
    word64 size = encoder.MaxRetrievable();
    if(size)
    {
        encoded.resize(size);
        encoder.Get((byte*)&encoded[0], encoded.size());
    }
    std::cout << "key in hex: " << encoded;

    return encoded;
}