"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Bytes_1 = require("@wireio/sdk-core/chain/Bytes");
const Checksum_1 = require("@wireio/sdk-core/chain/Checksum");
const KeyType_1 = require("@wireio/sdk-core/chain/KeyType");
const PrivateKey_1 = require("@wireio/sdk-core/chain/PrivateKey");
const Signature_1 = require("@wireio/sdk-core/chain/Signature");
const SignerProvider_1 = require("@wireio/sdk-core/signing/SignerProvider");
const Utils_1 = require("@wireio/sdk-core/Utils");
describe("SignerProvider", () => {
    describe("createClassicSigner", () => {
        test("creates from private key string and signs digest bytes and hex", async () => {
            const privateKey = PrivateKey_1.PrivateKey.generate(KeyType_1.KeyType.K1);
            const signer = (0, SignerProvider_1.createClassicSigner)(privateKey.toString());
            const digest = Checksum_1.Checksum256.hash(Bytes_1.Bytes.from("classic signer", "utf8")).array;
            const sigFromBytes = await signer.sign(digest);
            const sigFromHex = await signer.sign((0, Utils_1.arrayToHex)(digest));
            expect(sigFromBytes).toEqual(sigFromHex);
            expect(sigFromHex.length).toBe(65);
            const signature = Signature_1.Signature.fromRaw(sigFromHex, KeyType_1.KeyType.K1);
            expect(signature.verifyDigest(digest, signer.pubKey)).toBe(true);
        });
    });
});
//# sourceMappingURL=SignerProvider.test.js.map