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

@ctrlc03/eddsa-poseidon

v0.5.2

Published

A JavaScript EdDSA library for secure signing and verification using Poseidon the Baby Jubjub elliptic curve.

Downloads

3

Readme

| This package offers a simplified JavaScript codebase essential for creating and validating digital signatures using EdDSA and Poseidon. It's built upon the Baby Jubjub elliptic curve, ensuring seamless integration with Circom and enhancing the developer experience. | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

[!WARNING]
This library has not been audited.

  • Super lightweight: ~33kB (minified)
  • Compatible with browsers and NodeJS
  • TS type support
  • Comprehensive code documentation
  • Full test coverage

👾 Would you like to try it now? Explore it now on Ceditor!

References

  1. Barry WhiteHat, Marta Bellés, Jordi Baylina. ERC-2494: Baby Jubjub Elliptic Curve. 2020-01-29. https://eips.ethereum.org/EIPS/eip-2494.
  2. Lorenzo Grassi, Dmitry Khovratovich, Christian Rechberger, Arnab Roy, and Markus Schofnegger. POSEIDON: A New Hash Function for Zero-Knowledge Proof Systems. 2019. https://eprint.iacr.org/2019/458.pdf.

🛠 Install

npm or yarn

Install the @zk-kit/eddsa-poseidon package and its peer dependencies with npm:

npm i @zk-kit/eddsa-poseidon

or yarn:

yarn add @zk-kit/eddsa-poseidon

CDN

You can also load it using a script tag using unpkg:

<script src="https://unpkg.com/@zk-kit/eddsa-poseidon"></script>

or JSDelivr:

<script src="https://cdn.jsdelivr.net/npm/@zk-kit/eddsa-poseidon"></script>

📜 Usage

import {
    derivePublicKey,
    signMessage,
    verifySignature,
    deriveSecretScalar,
    packPublicKey,
    unpackPublicKey
} from "@zk-kit/eddsa-poseidon"

// Your private key (secret).
const privateKey = "secret"
// The message you want to sign.
const message = "message"

// Derive a public key from the private key.
const publicKey = derivePublicKey(privateKey)

/*
[
    '17191193026255111087474416516591393721975640005415762645730433950079177536248',
    '13751717961795090314625781035919035073474308127816403910435238282697898234143'
]
*/
console.log(publicKey)

// Sign the message.
const signature = signMessage(privateKey, message)

/*
{    
    R8: [
        '12949573675545142400102669657964360005184873166024880859462384824349649539693',
        '18253636630408169174294927826710424418689461166073329946402765380454102840608'
    ],
    S: '701803947557694254685424075312408605924670918868054593580245088593184746870'
}
*/
console.log(signature)

const response = verifySignature(message, signature, publicKey)

// true.
console.log(response)

// Use this value as the input for your Circom circuit.
const secretScalar = deriveSecretScalar(privateKey)

/* 
6544992227624943856419766050818315045047569225455760139072025985369615672473
14277921624107172450683599157880963081763136590946434672207840996093731170206
*/
console.log(secretScalar)

// Pack the public key into a compressed format.
const packedPublicKey = packPublicKey(publicKey)

// 52359937820999550851358128406546520360380553803646081112576207882956925379784n
console.log(packedPublicKey)

// Unpack the compressed public key back into its original form.
const unpackedPublicKey = unpackPublicKey(packedPublicKey)

/*
[
    '17191193026255111087474416516591393721975640005415762645730433950079177536248',
    '13751717961795090314625781035919035073474308127816403910435238282697898234143'
]
*/
console.log(unpackedPublicKey)

if (unpackedPublicKey) {
    console.log(publicKey[0] === unpackedPublicKey[0]) // true
    console.log(publicKey[1] === unpackedPublicKey[1]) // true
}