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

@peculiar/asn1-x509-post-quantum

v2.3.8

Published

Provides ASN.1 schema definitions for composite public and private keys and composite signatures used in Internet Public Key Infrastructure (PKI), as specified in the following IETF drafts: Composite Public and Private Keys For Use In Internet PKI, Compos

Downloads

2,083

Readme

@peculiar/asn1-x509-post-quantum

License npm version

NPM

This package provides ASN.1 schema definitions for composite public and private keys and composite signatures used in Internet Public Key Infrastructure (PKI), as specified in the following IETF drafts:

The schema definitions are based on the @peculiar/asn1-schema library and can be used to encode and decode composite keys and signatures in ASN.1 DER format.

Installation

To install this module, use the following command:

npm install @peculiar/asn1-x509-post-quantum

Usage

The @peculiar/asn1-x509-post-quantum package exports several classes and constants that can be used to encode and decode composite keys and signatures. Here is an example of encoding a composite public key:

import { AsnConvert } from "@peculiar/asn1-schema";
import { CompositePublicKey, id_composite_key } from "@peculiar/asn1-x509-post-quantum";

const pem = [
  "MIIBmDAMBgpghkgBhvprUAQBA4IBhgAwggGBMFkwEwYHKoZIzj0CAQYIKoZIzj0D",
  "AQcDQgAExGPhrnuSG/fGyw1FN+l5h4p4AGRQCS0LBXnBO+djhcI6qnF2TvrQEaIY",
  "GGpQT5wHS+7y5iJJ+dE5qjxcv8loRDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC",
  "AQoCggEBANsVQK1fcLQObL4ZYtczWbObECAFSsng0OLpRTPr9VGV3SsS/VoMRZqX",
  "F+sszz6I2UcFTaMF9CwNRbWLuIBczzuhbHSjn65OuoN+Om2wsPo+okw46RTekB4a",
  "d9QQvYRVzPlILUQ8NvZ4W0BKLviXTXWIggjtp/Y1pKRHKz8n35J6OmFWz4TKGNth",
  "n87D28kmdwQYH5NLsDePHbfdw3AyLrPvQLlQw/hRPz/9Txf7yi9Djg9HtJ88ES6+",
  "ZbfE1ZHxLYLSDt25tSL8A2pMuGMD3P81nYWO+gJ0vYV2WcRpXHRkjmliGqiCg4eB",
  "mC4//tm0J4r9Ll8b/pp6xyOMI7jppVUCAwEAAQ==",
].join("");

const keyInfo = AsnConvert.parse(Buffer.from(pem, "base64"), SubjectPublicKeyInfo);
assert.strictEqual(keyInfo.algorithm.algorithm, id_composite_key);

const compositeKeys = AsnConvert.parse(keyInfo.subjectPublicKey, CompositePublicKey);
for (const key of compositeKeys) {
  console.log(key.algorithm.algorithm);
}

To use this module, you can import the CompositePublicKey, CompositeSignature, and CompositePrivateKey classes from the module, as follows:

import { CompositePublicKey, CompositePrivateKey, CompositeSignature } from "@peculiar/asn1-x509-post-quantum";

You can then use these classes to encode and decode composite public keys, private keys, and signatures using the ASN.1 format specified in the RFC 8391 specification.

For example, to encode a composite public key, you can create an instance of the CompositePublicKey class and set its fields as follows:

const publicKey = new CompositePublicKey({
  algorithmIdentifier: {
    algorithm: "1.2.840.113549.1.1.12",
    parameters: new Uint8Array([0x02, 0x03, 0x04])
  },
  keys: [
    {
      algorithm: "1.2.840.113549.1.1.11",
      publicKey: new Uint8Array([0x01, 0x02, 0x03])
    },
    {
      algorithm: "1.2.840.113549.1.1.11",
      publicKey: new Uint8Array([0x04, 0x05, 0x06])
    }
  ]
});

const encodedPublicKey = CompositePublicKey.encode(publicKey);

Similarly, you can decode an encoded composite public key as follows:

const decodedPublicKey = CompositePublicKey.decode(encodedPublicKey);

You can also encode and decode composite private keys and signatures in a similar way.