Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new did:tdw #13

Closed
marlonbaeten opened this issue Jul 30, 2024 · 4 comments
Closed

Create a new did:tdw #13

marlonbaeten opened this issue Jul 30, 2024 · 4 comments

Comments

@marlonbaeten
Copy link

Hi! I'm trying to create a new did:tdw, but it seems that generating a fresh keypair triggers an error.

I created the following testcase:

import { expect, test } from "bun:test";
import { generate } from '@digitalbazaar/ed25519-multikey';
import { createDID, resolveDID } from "../src/method";
import { createSigner } from "../src/signing";

test("shit", async () => {
  const ed25519 = await generate();

  const authKey = {
    type: "authentication"as const,
    publicKeyMultibase: ed25519.publicKeyMultibase,
    secretKeyMultibase: ed25519.secretKeyMultibase
  };

  const result = await createDID({
    domain: 'example.com',
    signer: createSigner(authKey),
    updateKeys: [
      `did:key:${authKey.publicKeyMultibase}`,
    ],
    verificationMethods: [authKey],
    created: new Date(),
  });

  const resolveResult = await resolveDID(result.log, {versionId: 1});
  expect(resolveResult).toBeObject();
});

I think the resolveDID step should succeed, but instead it throws an error:

error: version 1 failed verification of the proof.

If I do not generate the key material but use one of the keys defined in test/fixtures/keys.json the above test case succeeds.
Maybe @digitalbazaar/ed25519-multikey is not the correct tool to create the key material? How was the content of test/fixtures/keys.json created?

@brianorwhatever
Copy link
Contributor

brianorwhatever commented Aug 1, 2024

yeah, this issue is the reason I ended up creating the fixture keys. It appears their is something interacting in the @digitalbazaar/ed25519-multikey library and bun. If you log the publicKey that is generated you'll notice it is always the same.. We will either need to resolve the root cause of this issue or drop bun..

thanks for creating this issue. Will keep it open until one of the above options has been completed

@brianorwhatever
Copy link
Contributor

I managed to get your test to pass without using the digitalbazaar library. Here is the code that uses @noble/ed25519

import { expect, test } from "bun:test";
import * as ed from '@noble/ed25519';
import { createDID, resolveDID } from "../src/method";
import { createSigner } from "../src/signing";
import { base58btc } from "multiformats/bases/base58";

test("shit", async () => {
  const privKey = ed.utils.randomPrivateKey();
  const pubKey = await ed.getPublicKeyAsync(privKey);

  const publicKeyMultibase = base58btc.encode(Buffer.concat([new Uint8Array([0xed, 0x01]), pubKey]));
  const secretKeyMultibase = base58btc.encode(Buffer.concat([new Uint8Array([0x80, 0x26]), privKey]));

  const authKey = {
    type: "authentication"as const,
    publicKeyMultibase,
    secretKeyMultibase
  };

  const result = await createDID({
    domain: 'example.com',
    signer: createSigner(authKey),
    updateKeys: [
      `did:key:${authKey.publicKeyMultibase}`,
    ],
    verificationMethods: [authKey],
    created: new Date(),
  });

  const resolveResult = await resolveDID(result.log, {versionId: 1});
  expect(resolveResult).toBeObject();
});

I will remove the digitalbazaar library from the dependency list

@brianorwhatever
Copy link
Contributor

I'm working on a PR that removes the dependency and removes the key fixtures here #14

@marlonbaeten
Copy link
Author

Works - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants