Newfoundland Pitbull Mix

    @sphereon/ed25519-signature-2018
    TypeScript icon, indicating that this package has built-in type declarations

    0.7.0-unstable.2 • Public • Published

    @transmute/ed25519-signature-2018

    npm i @transmute/ed25519-signature-2018 --save
    

    Usage

    import {
      Ed25519VerificationKey2018,
      Ed25519Signature2018,
    } from "@transmute/ed25519-signature-2018";
    import { documentLoader } from "path/somewhere";
    import { verifiable } from "@transmute/vc.js";
    
    const key = await Ed25519VerificationKey2018.from({
      id:
        "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC#z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
      type: "Ed25519VerificationKey2018",
      controller: "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
      publicKeyBase58: "FEkRBiL3GfrG2m1yh5mrxds8vTkRwYzwgBKWSH33J64p",
      privateKeyBase58:
        "4ywHegJBWnGAu3ZTtMX3Jtu1XUMtJJdmzEoqMk8RS2Fkv5W9hnJpyooY5qNFBTWEPHT5uSjakt2rJodp4DundZvg",
    });
    
    const result = await verifiable.credential.create({
      credential: {
        "@context": ["https://www.w3.org/2018/credentials/v1"],
        id: "https://example.com/credentials/123",
        type: ["VerifiableCredential"],
        issuer: "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
        issuanceDate: "2019-12-03T12:19:52Z",
        credentialSubject: {
          id: "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
        },
      },
      format: ["vc"],
      documentLoader: documentLoader,
      suite: new Ed25519Signature2018({
        key,
      }),
    });
    
    const result2 = await verifiable.credential.verify({
      credential: result.items[0],
      format: ["vc"],
      documentLoader: (iri: string) => {
        if (iri.startsWith("did:key:z6Mkth1Tmxa")) {
          return {
            documentUrl: iri,
            document: {
              "@context": [
                "https://www.w3.org/ns/did/v1",
                "https://w3id.org/security/suites/ed25519-2018/v1",
              ],
              id: "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
              assertionMethod: [
                {
                  id:
                    "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC#z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
                  type: "Ed25519VerificationKey2018",
                  controller:
                    "did:key:z6Mkth1TmxaUcDLj9FrgNejhojR8k32HMSFJNCESGZ14DJrC",
                  publicKeyBase58: "FEkRBiL3GfrG2m1yh5mrxds8vTkRwYzwgBKWSH33J64p",
                },
              ],
            },
          };
        }
        return documentLoader(iri);
      },
      suite: [new Ed25519Signature2018()],
    });

    About

    This typescript module has been built to support direct substitutability with digitalbazaar/jsonld-signatures for Linked Data Proofs.

    However, some changes were made to support typescript, and no defaultDocumentLoader is provided.

    Keywords

    none

    Install

    npm i @sphereon/ed25519-signature-2018

    DownloadsWeekly Downloads

    2

    Version

    0.7.0-unstable.2

    License

    Apache-2.0

    Unpacked Size

    555 kB

    Total Files

    199

    Last publish

    Collaborators

    • nklomp78
    • nklomp
    • spostma
    • bramtencate