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

@ngraveio/bc-ur-registry-crypto-coin-identity

v0.3.1

Published

Provides BC UR type that uniquely identifies a crypto coin.

Downloads

12

Readme

BC-UR-Registry-sync

This repository is the Crypto Coin Identity extension of bc-ur-registry

Definition document: https://github.com/ngraveio/Research/blob/main/papers/nbcr-2023-001-coin-identity.md

Installing

To install, run:

yarn add @ngraveio/bc-ur-registry-crypto-coin-identity
npm install --save @ngraveio/bc-ur-registry-crypto-coin-identity

CDDL

The following specification of crypto-coin-identity is written in CDDL. When used embedded in another CBOR structure, this structure should be tagged #6.1401.

; Table should always be updated according to IANA registry 
; https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
; https://www.rfc-editor.org/rfc/rfc9053.html#name-elliptic-curve-keys

P256=1	            ; NIST P-256 also known as secp256r1
P384=2	            ; NIST P-384 also known as secp384r1	
P521=3	            ; EC2	NIST P-521 also known as secp521r1		
X25519=4            ; X25519 for use w/ ECDH only		
X448=5              ; X448 for use w/ ECDH only		
Ed25519=6           ; Ed25519 for use w/ EdDSA only		
Ed448=7             ; Ed448 for use w/ EdDSA only		
secp256k1=8         ; SECG secp256k1 curve	IESG	

elliptic_curve = P256 / P384 / P521 / X25519 / X448 / Ed25519 / Ed448 / secp256k1

; Subtypes specific to some coins (e.g. ChainId for EVM chains)
hex_string = #6.263(bstr) ; byte string is a hexadecimal string no need for decoding
sub_type_exp = uint32 / str / hex_string

coin-identity = {
    curve: elliptic_curve,
    type: uint31, ; values from [SLIP44] with high bit turned off,
    ? subtype: [ sub_type_exp + ]  ; Compatible with the definition of several subtypes if necessary
}

curve = 1
type = 2
subtype = 3

Usages Examples

[CryptoCoinIdentity] Construct a crypto coin identity

Add additional information to a specific hdkey. It contains the following information:

  1. Curve of the coin (e.g. *_** _["secp256k1", "ed25519", "secp256r1”, “sr25519”] ).* This information is mandatory in the case of some blockchain (e.g. Tezos) supporting multiple elliptic curves.
  2. BIP44 coin type as defined in [SLIP44].
  3. Subtype to define additional information to identify the coin (e.g. the chain ID for an EVM chain).

The URI format is as follows: bc-coin://{subtype2.subtype1.subtype0}.{curve}/type

Below the coinIdentity of Polygon (MATIC) as an example: "bc-coin://137.secp256k1/60"

import {CryptoCoinIdentity, EllipticCurve } from from '@ngraveio/bc-ur-registry';

const curve = EllipticCurve.secp256k1 // 8
const type = 60
const chainId = '137'
const subTypes = [chainId]

const coinIdentity = new CryptoCoinIdentity(curve, type, subTypes)

console.log(coinIdentity.toCBOR().toString('hex'));
// "a3010802183c038163313337"
const ur = coinIdentity.toUREncoder().nextPart();
console.log(ur);
// :ur:crypto-coin-identity/otadayaocsfnaxlyiaeheoemaojsbajy"