我正在翻轉CryptoPP,無法找到這個特定問題的答案。這裏是示例源代碼(部分)有點壓縮的公鑰初始化API嗎?
AutoSeededRandomPool prng;
//Generate a private key
ECDSA<ECP, CryptoPP::SHA256>::PrivateKey privateKey;
privateKey.Initialize(prng, CryptoPP::ASN1::secp256r1());
// Generate publicKey
ECDSA<ECP, CryptoPP::SHA256>::PublicKey publicKey;
privateKey.MakePublicKey(publicKey);
// Extract Component values
Integer p = privateKey.GetGroupParameters().GetCurve().GetField().GetModulus();
Integer a = privateKey.GetGroupParameters().GetCurve().GetA();
Integer b = privateKey.GetGroupParameters().GetCurve().GetB();
Integer Gx = privateKey.GetGroupParameters().GetSubgroupGenerator().x;
Integer Gy = privateKey.GetGroupParameters().GetSubgroupGenerator().y;
Integer n = privateKey.GetGroupParameters().GetSubgroupOrder();
Integer h = privateKey.GetGroupParameters().GetCofactor();
Integer Qx = publicKey.GetPublicElement().x;
Integer Qy = publicKey.GetPublicElement().y;
Integer x = privateKey.GetPrivateExponent();
// Construct Point elelemt;
ECP curve(p,a,b);
ECP::Point G(Gx,Gy);
ECP::Point Q(Qx,Qy);
//Build publicKey using elements (no point compression)
ECDSA<ECP, CryptoPP::SHA256>::PublicKey GeneratedPublicKey;
GeneratedPublicKey.Initialize(curve,G,n,Q);
assert(GeneratedPublicKey.Validate(prng, 3));
//Build publicKey using elements (with point compression)?
用這種方法,我可以使用組件值生成publicKey。然而,我不能 使它與點壓縮 - 這意味着我沒有QY值 - 有沒有一種 方式來做到這一點?初始化方法有兩個重載,但沒有一個是針對點數爲 的壓縮情況。
我的問題是關於「PublicKey.Initialize(curve,G,n,Q)」上的Crypto ++的特定問題。由於我無法將整個publicKey與我當前的項目進行傳輸 - 我強制將參數域 指定爲索引值,並且只能傳輸Qx值。所以我應該使用類似「PublicKey.Initialize(curve,G,n,Q)」初始化publicKey 「但是,我找不到有關點壓縮的初始化API。
所以,這不是關於「如何做點壓縮」,而是「有沒有方法來初始化沒有Qy值的 公鑰?」
請準確告訴我們你有什麼。你從來沒有告訴你正在使用的參數//使用元素(使用點壓縮)構建publicKey?'。如果它的ASN.1編碼值,用'dumpasn1'顯示給我們。如果原始表單是二進制的,則將其顯示給我們以十六進制編碼。 – jww