{"size": 1675, "ext": "js", "max_stars_repo_path": "src/__tests__/signatureOptions.spec.js", "max_stars_repo_name": "transmute-industries/EcdsaKoblitzSignature2016", "max_stars_repo_stars_event_min_datetime": "2019-04-19T01:43:18.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-19T01:43:18.000Z", "max_issues_repo_path": "src/__tests__/signatureOptions.spec.js", "max_issues_repo_name": "transmute-industries/EcdsaKoblitzSignature2016", "max_issues_repo_issues_event_min_datetime": "2019-03-05T16:26:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T03:15:13.000Z", "max_forks_repo_path": "src/__tests__/signatureOptions.spec.js", "max_forks_repo_name": "transmute-industries/EcdsaKoblitzSignature2016", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 29.3859649123, "max_line_length": 65, "alphanum_fraction": 0.5773134328}
const { linkedData, bitcoinKeypair } = require("./__fixtures__");

const { sign, verify } = require("../index");

describe("EcdsaKoblitzSignature2016", () => {
  describe("nonce", () => {
    it("can sign and verify with nonce", async () => {
      const nonce = "235187631";
      const signed = await sign({
        data: { ...linkedData },
        nonce,
        privateKeyWIF: bitcoinKeypair.privateKey,
        creator: `ecdsa-koblitz-pubkey:${bitcoinKeypair.address}`
      });
      const verified = await verify({
        data: signed
      });
      expect(verified).toBe(true);
      expect(signed.signature.nonce).toBe(nonce);
    });
  });

  describe("domain", () => {
    it("can sign and verify with domain", async () => {
      const domain = "example.com";
      const signed = await sign({
        data: { ...linkedData },
        domain,
        privateKeyWIF: bitcoinKeypair.privateKey,
        creator: `ecdsa-koblitz-pubkey:${bitcoinKeypair.address}`
      });
      const verified = await verify({
        data: signed
      });
      expect(verified).toBe(true);
      expect(signed.signature.domain).toBe(domain);
    });
  });

  describe("created", () => {
    it("can sign and verify with created", async () => {
      const created = new Date().toISOString();
      const signed = await sign({
        data: { ...linkedData },
        created,
        privateKeyWIF: bitcoinKeypair.privateKey,
        creator: `ecdsa-koblitz-pubkey:${bitcoinKeypair.address}`
      });
      const verified = await verify({
        data: signed
      });
      expect(verified).toBe(true);
      expect(signed.signature.created).toBe(created);
    });
  });
});
