mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 11:48:52 +02:00
IT'S WORKING!!!
This commit is contained in:
parent
e963673409
commit
73eb258e79
5 changed files with 8 additions and 6 deletions
|
@ -61,7 +61,7 @@ void Ledger::send(const QString& endpoint, const QString& success, const QString
|
||||||
|
|
||||||
void Ledger::signedSend(const QString& propertyName, const QByteArray& text, const QString& key, const QString& endpoint, const QString& success, const QString& fail, const bool controlled_failure) {
|
void Ledger::signedSend(const QString& propertyName, const QByteArray& text, const QString& key, const QString& endpoint, const QString& success, const QString& fail, const bool controlled_failure) {
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
QString signature = wallet->signWithKey(text, key);
|
QString signature = wallet->signWithKey(text, key);
|
||||||
QJsonObject request;
|
QJsonObject request;
|
||||||
request[propertyName] = QString(text);
|
request[propertyName] = QString(text);
|
||||||
if (!controlled_failure) {
|
if (!controlled_failure) {
|
||||||
|
|
|
@ -556,7 +556,7 @@ QString Wallet::signWithKey(const QByteArray& text, const QString& key) {
|
||||||
|
|
||||||
unsigned int signatureBytes = 0;
|
unsigned int signatureBytes = 0;
|
||||||
|
|
||||||
qCInfo(commerce) << "Signing text" << text << "with key at" << ecPrivateKey;
|
qCInfo(commerce) << "Hashing and signing plaintext" << text << "with key at address" << ecPrivateKey;
|
||||||
|
|
||||||
QByteArray hashedPlaintext = QCryptographicHash::hash(text, QCryptographicHash::Sha256);
|
QByteArray hashedPlaintext = QCryptographicHash::hash(text, QCryptographicHash::Sha256);
|
||||||
|
|
||||||
|
|
|
@ -1190,13 +1190,14 @@ bool EntityTree::verifyNonce(const QString& certID, const QString& nonce, Entity
|
||||||
}
|
}
|
||||||
|
|
||||||
QString annotatedKey = "-----BEGIN PUBLIC KEY-----\n" + key.insert(64, "\n") + "\n-----END PUBLIC KEY-----\n";
|
QString annotatedKey = "-----BEGIN PUBLIC KEY-----\n" + key.insert(64, "\n") + "\n-----END PUBLIC KEY-----\n";
|
||||||
QByteArray hashedActualNonce = QCryptographicHash::hash(QByteArray::fromBase64(actualNonce.toUtf8()), QCryptographicHash::Sha256);
|
QByteArray hashedActualNonce = QCryptographicHash::hash(QByteArray(actualNonce.toUtf8()), QCryptographicHash::Sha256);
|
||||||
bool verificationSuccess = EntityItemProperties::verifySignature(annotatedKey.toUtf8(), hashedActualNonce, QByteArray::fromBase64(nonce.toUtf8()));
|
bool verificationSuccess = EntityItemProperties::verifySignature(annotatedKey.toUtf8(), hashedActualNonce, QByteArray::fromBase64(nonce.toUtf8()));
|
||||||
|
|
||||||
if (verificationSuccess) {
|
if (verificationSuccess) {
|
||||||
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "succeeded.";
|
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "succeeded.";
|
||||||
} else {
|
} else {
|
||||||
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "failed.\nHashed actual nonce (digest):" << hashedActualNonce << "\nSent nonce (signature)" << nonce << "\nKey" << key;
|
qCDebug(entities) << "Ownership challenge for Cert ID" << certID << "failed. Actual nonce:" << actualNonce <<
|
||||||
|
"\nHashed actual nonce (digest):" << hashedActualNonce << "\nSent nonce (signature)" << nonce << "\nKey" << key;
|
||||||
}
|
}
|
||||||
|
|
||||||
return verificationSuccess;
|
return verificationSuccess;
|
||||||
|
|
|
@ -30,7 +30,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::EntityEdit:
|
case PacketType::EntityEdit:
|
||||||
case PacketType::EntityData:
|
case PacketType::EntityData:
|
||||||
case PacketType::EntityPhysics:
|
case PacketType::EntityPhysics:
|
||||||
return static_cast<PacketVersion>(EntityVersion::StaticCertJsonVersionOne);
|
return static_cast<PacketVersion>(EntityVersion::OwnershipChallengeFix);
|
||||||
|
|
||||||
case PacketType::EntityQuery:
|
case PacketType::EntityQuery:
|
||||||
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConnectionIdentifier);
|
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConnectionIdentifier);
|
||||||
|
|
|
@ -200,7 +200,8 @@ enum class EntityVersion : PacketVersion {
|
||||||
StrokeColorProperty = 77,
|
StrokeColorProperty = 77,
|
||||||
HasDynamicOwnershipTests,
|
HasDynamicOwnershipTests,
|
||||||
HazeEffect,
|
HazeEffect,
|
||||||
StaticCertJsonVersionOne
|
StaticCertJsonVersionOne,
|
||||||
|
OwnershipChallengeFix,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EntityScriptCallMethodVersion : PacketVersion {
|
enum class EntityScriptCallMethodVersion : PacketVersion {
|
||||||
|
|
Loading…
Reference in a new issue