npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pcd/eddsa-pcd

v0.10.0

Published

Install the `@pcd/eddsa-pcd` package with npm:

Downloads

607

Readme

| This package defines a PCD designed to verify the authenticity of a message signed using an EdDSA key. | | ------------------------------------------------------------------------------------------------------ |

🛠 Install

Install the @pcd/eddsa-pcd package with npm:

npm i @pcd/eddsa-pcd

or yarn:

yarn add @pcd/eddsa-pcd

📜 Usage

Prove

import { getEdDSAPublicKey, newEdDSAPrivateKey, prove } from "@pcd/eddsa-pcd"
import { ArgumentTypeName } from "@pcd/pcd-types"

// Generate a new EdDSA private key.
const privateKey = newEdDSAPrivateKey()

// Prepare the message to sign.
// It must be a list of hexadicimal strings.
const message = ["0xc", "0x7a", "0x8f"]

// Create a PCD with the required attributes and their types.
const pcd = await prove({
    // The id is optional and if you don't pass it a random value will be automatically created.
    id: {
        argumentType: ArgumentTypeName.String
    },
    message: {
        argumentType: ArgumentTypeName.StringArray,
        value: message
    },
    privateKey: {
        argumentType: ArgumentTypeName.String,
        value: privateKey
    }
})

console.log(pcd)
/*
EdDSAPCD {
  type: 'eddsa-pcd',
  id: '4c80affc-12c3-4d93-8983-cc38295ad31b',
  claim: {
    message: [ 12n, 122n, 143n ],
    publicKey: [
      '1d5ac1f31407018b7d413a4f52c8f74463b30e6ac2238220ad8b254de4eaa3a2',
      '1e1de8a908826c3f9ac2e0ceee929ecd0caf3b99b3ef24523aaab796a6f733c4'
    ]
  },
  proof: {
    signature: '39166dd6187378e2ef24d183bffe5bd1b2114344fcd5a56db562a12859c03b9a53b2f98de0b7d4f23dc49979d0e8f919f428a37e736163f7426259c13ecb7000'
  }
}
*/

Verify

import { verify } from "@pcd/eddsa-pcd"

const isValid = await verify(pcd)

console.log(isValid) // true

Serialize

import { serialize } from "@pcd/eddsa-pcd"

const serialized = await serialize(pcd)

console.log(serialized)
/*
{
  type: 'eddsa-pcd',
  pcd: '{"type":"eddsa-pcd","id":"15bcc6ec-3482-4772-8a67-27630f8641c5","claim":{"message":["c","7a","8f"],"publicKey":["1d5ac1f31407018b7d413a4f52c8f74463b30e6ac2238220ad8b254de4eaa3a2","1e1de8a908826c3f9ac2e0ceee929ecd0caf3b99b3ef24523aaab796a6f733c4"]},"proof":{"signature":"71907bb4a1b5e27b2b9df54ac5cbebb45958f673b97030a79a3799e54ed3779eb499e710bb02231d9f9b6bb621375de7a68ad53bc3e5cef35c6531f9440d8d05"}}'
}
*/

Deserialize

import { deserialize } from "@pcd/eddsa-pcd"

const deserialized = await deserialize(serialized.pcd)

console.log(deserialized)
/*
EdDSAPCD {
  type: 'eddsa-pcd',
  id: '4c80affc-12c3-4d93-8983-cc38295ad31b',
  claim: {
    message: [ 12n, 122n, 143n ],
    publicKey: [
      '1d5ac1f31407018b7d413a4f52c8f74463b30e6ac2238220ad8b254de4eaa3a2',
      '1e1de8a908826c3f9ac2e0ceee929ecd0caf3b99b3ef24523aaab796a6f733c4'
    ]
  },
  proof: {
    signature: '39166dd6187378e2ef24d183bffe5bd1b2114344fcd5a56db562a12859c03b9a53b2f98de0b7d4f23dc49979d0e8f919f428a37e736163f7426259c13ecb7000'
  }
}
*/