MCPcopy Create free account
hub / github.com/CommE2E/comm / isPrekeySignatureValid

Method isPrekeySignatureValid

native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp:110–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110bool CryptoModule::isPrekeySignatureValid() {
111 try {
112 const std::string signingPublicKey =
113 getSigningPublicKey(this->getIdentityKeys());
114
115 const std::string prekey = this->getPrekey();
116 const std::string prekeySignature = this->getPrekeySignature();
117
118 // Use the dedicated prekey verification function that decodes base64
119 ::verify_prekey_signature(signingPublicKey, prekey, prekeySignature);
120 return true;
121 } catch (const std::exception &e) {
122 std::string rawMessage{e.what()};
123 if (rawMessage.find("The signature was invalid") != std::string::npos) {
124 return false;
125 }
126
127 std::string errorMessage{
128 "prekey signature verification failed with: " + rawMessage};
129 Logger::log(errorMessage);
130 throw std::runtime_error(errorMessage);
131 }
132}
133
134std::string CryptoModule::getIdentityKeys() {
135 this->exposePublicIdentityKeys();

Callers 1

validatePrekeyMethod · 0.95

Calls 5

getIdentityKeysMethod · 0.95
getPrekeyMethod · 0.95
getPrekeySignatureMethod · 0.95
getSigningPublicKeyFunction · 0.85
verify_prekey_signatureFunction · 0.50

Tested by

no test coverage detected