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

@penumbra-zone/keys

v4.2.1

Published

Tool to download proving keys for Penumbra

Downloads

242

Readme

@penumbra-zone/keys

This package contains cryptographic keys relevant to the Penumbra blockchain, and checksums to validate the integrity of those keys.

The default export is a JSON mapping of Penumbra Action names to their relevant key, necessary for building cryptographic proofs for those actions. Keys are exported as [key_name]_pk.bin.

A basic shell script penumbra-download-keys is provided, if you have specific versioning, bundling, or copying needs. Most users can use the keys exported from the package.

Using Keys

If your bundler supports import.meta.resolve, you can handle the raw key material like this:

const res: Result = await fetch(import.meta.resolve('@penumbra-zone/keys/convert_pk.bin'));
const keyBuf: ArrayBuffer = await res.arrayBuffer();
const convertPk = new Uint8Array(keyBuf);

A More Complex Example

If your bundler doesn't support import.meta.resolve, or you rely on customized bundling, you might want to just handle URLs. Our @penumbra-zone/wasm package expects you to input key URL strings when building Actions.

Here's a simplified example of how we use the packages together in our reference wallet extension:

import actionKeys from '@penumbra-zone/keys';

import type { FullViewingKey } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/keys/v1/keys_pb';
import type {
  Action,
  TransactionPlan,
  WitnessData,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/transaction/v1/transaction_pb';

// map filenames to bundled key asset URLs
const keyUrls = actionKeys.map(keyFileName => new URL(`keys/${keyFileName}`, PRAX_ORIGIN));

async function buildAction(
  txPlan: TransactionPlan,
  witness: WitnessData,
  fvk: FullViewingKey,
  actionIndex: number,
): Promise<Action> {
  // Dynamically load wasm module
  const builder = await import('@penumbra-zone/wasm/build');

  // Identify action type
  const actionType: Action['value']['case'] = transactionPlan.actions[actionPlanIndex]!.action.case;

  // Identify key url, if present
  const keyUrl: string | undefined = keyUrls[actionType]?.href;

  // Build action
  return builder.buildActionParallel(txPlan, witness, fvk, actionIndex, keyUrl);
}

Using the management script

An executable penumbra-download-keys is included. It can checksum the keys included in this package, and download other versions referenced by git tag if you are working with a testnet or other custom chain with its own proving keys.

In any workspace where this package is installed, you can use

[npm|pnpm|yarn] exec penumbra-download-keys [output-path] [git tag] [sha256 manifest]

Which will acquire the default keys and display checksum validation, if a key manifest is already present. You can further specify a version and custom manifest file.

Updating the keys

If new keys are released by core, change the defaultKeysVersion variable in the download-keys script to the new version of the keys. Then:

  1. Run the download-keys script (per the instructions above)
  2. cd keys
  3. shasum -a 256 *.bin > ../shasums/vX.X.X.shasum (change vX.X.X to the actual version number of the keys)
  4. Commit your changes.