___|  _ \   |  |    |   |_ _|\ \     / ____|
 |     |   |  |  |    |   |  |  \ \   /  __|
 |   | |   | ___ __|  ___ |  |   \ \ /   |
\____|\___/     _|   _|  _|___|   \_/   _____| 

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

All tests successfuly completed.

BY: @fernandosoder | CREATED: March 19, 2026, 1:12 p.m. | VOTES: 22 | PAYOUT: $0.49 | [ VOTE ]

Another step in the right direction.

Generated Keys

Keys generated using Hivetasks Key Generator

My Tests:

void TestFullCrypto::fullPipeline()
{
    QString wif =
        "5KLeD3gMsQZxgEDRp11mQzDdHvExSDgRudw1aCWt9gCwVpEhca7";

    QByteArray expectedPriv =
        QByteArray::fromHex(
            "c89f4e0d981acfdaa6c5049ffe21da2ce207fea6b2869df20abf6d780b4d866e"
            );

    QString expectedPub =
        "STM7tUu4Gy4p8UpeQUAFVCD7q8CJuEVyyEXJkCEjb4f1RL54YKt4w";

    PrivateKey priv = PrivateKey::fromWif(wif);
    QCOMPARE(priv.raw(), expectedPriv);

    PublicKey pub = priv.toPublicKey();

    QString result = pub.toString();

    QCOMPARE(result, expectedPub);
}

void TestFullCrypto::fullSecondPipeline()
{
    QString wif =
        "5KG5mB72Q7pFRPGmoy9rpfh2yXtd4cMsJeusZauqiHp2o3AV8DE";

    QString expectedPub =
        "STM6aqHre1tyTkUfBFmR5AyZfBXnUKYgR6axhME6xU6QdZpxYN2YK";

    PrivateKey priv = PrivateKey::fromWif(wif);
    PublicKey pub = priv.toPublicKey();
    QString result = pub.toString();
    QCOMPARE(result, expectedPub);
}

void TestFullCrypto::roundtrip()
{
    QString wif = "5KLeD3gMsQZxgEDRp11mQzDdHvExSDgRudw1aCWt9gCwVpEhca7";

    PrivateKey priv = PrivateKey::fromWif(wif);
    PublicKey pub = priv.toPublicKey();

    QString stm = pub.toString();

    QVERIFY(stm.startsWith("STM"));
    QCOMPARE(pub.compressed().size(), 33);
}

void TestFullCrypto::keyDerivationPipeline()
{
    QString account  = "alice";
    QString password = "supersecret";

    PrivateKey priv =
        derivePrivateKey(
            account,
            password,
            KeyRole::Active
            );

    QVERIFY(priv.raw().size() == 32);

    PublicKey pub = priv.toPublicKey();

    QByteArray compressed = pub.compressed();

    QCOMPARE(compressed.size(), 33);
    QVERIFY(
        compressed[0] == 0x02 ||
        compressed[0] == 0x03
        );

    QString stm = pub.toString();

    QVERIFY(stm.startsWith("STM"));
    QVERIFY(stm.size() > 10); // sanity
}

void TestFullCrypto::keyDerivation_knownVector()
{
    QString account  = "alice";
    QString password = "supersecret";

    PrivateKey priv =
        derivePrivateKey(
            account,
            password,
            KeyRole::Owner
            );

    QCOMPARE(
        priv.raw().toHex(),
        QByteArray("21bd739d1f6ba16b913a9bb5985741c482cea69d291844609b86566987a11059")
        );

    QString stm =
        priv.toPublicKey().toString();

    QCOMPARE(
        stm,
        QString("STM5ZkV8bAURHtU2TVVK4apWyZUkjadqRcgTV2BVny9vcP33DA7Pr")
        );
}

If you trust my capability to run a stable and updated Hive Witness...
Vote for me as your Hive Witness

If you want to support Brazilian creators...
Vote curator @perfilbrasil for Hive Witness
Delegations to @perfilbrasil are rewarded here.

TAGS: [ #hive ] [ #development ] [ #qt ] [ #crypto ] [ #library ]

Replies

NO REPLIES FOUND.

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>