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

@iota/signing

v1.0.0-beta.30

Published

IOTA Signing Scheme

Downloads

9,105

Readme

@iota/signing

IOTA Signing Scheme

Installation

Install using npm:

npm install @iota/signing

or using yarn:

yarn add @iota/signing

API Reference

signing.subseed(seed, index)

Summary: Generates a subseed.
Throws:

  • errors.ILLEGAL_SUBSEED_INDEX : Make sure that the index argument is a number greater than 0.

| Param | Type | Description | | --- | --- | --- | | seed | Int8Array | A 243-trit seed to use to derive the subseed | | index | number | The private key index to use to derive the subseed |

This method derives a subseed from a seed and a private key index.

You can use the subseed to derive private keys and their addresses.

Note: If the given seed is less then 243 trits, 0 trits are appended to it until it is 243 trits long.

Related methods

To convert a seed from trytes to trits, use the trytesToTrits() method.

To derive a private key from the subseed, use the key() method.

Returns: Int8Array - subseed - A subseed in trits
Example

const seed = 'MYSUPERSECRETSEED...';
const subseed = Sign.subseed(Converter.trytesToTrits(seed), 0);

signing.key(subseedTrits, numberOfFragments)

Summary: Generates a private key.
Throws:

  • errors.ILLEGAL_SUBSEED_LENGTH : Make sure that the subseedTrits argument contains 243 trits.
  • errors.ILLEGAL_NUMBER_OF_FRAGMENTS : Make sure that the numberOfFragments argument is a valid security level (between 1 and 3).

| Param | Type | Description | | --- | --- | --- | | subseedTrits | Int8Array | A subseed in trits | | numberOfFragments | number | The security level that you want the private key to have |

This method derives a private key from a subseed.

You can use the private key to derive an address and to sign bundles that withdraw from that address.

Related methods

To generate a subseed, use the subseed() method.

Returns: Int8Array - privateKey - A private key in trits.
Example

const seed = 'MYSUPERSECRETSEED...';
const subseed = Signing.subseed(Converter.trytesToTrits(seed), 0);

const privateKey = Signing.key(subseed, 2);

signing.digests(key)

Summary: Generates key digests for a given private key.
Throws:

  • errors.ILLEGAL_KEY_LENGTH : Make sure that the key argument contains 2,187, 4,374, or 6,561 trits.

| Param | Type | Description | | --- | --- | --- | | key | Int8Array | Private key in trits |

This method derives key digests from a private key.

You can use the key digests to generate an address.

Related methods

To generate a private key, use the key() method.

Returns: Int8Array - digests - Key digests in trits
Example

const seed = 'MYSUPERSECRETSEED...';
const subseed = Signing.subseed(Converter.trytesToTrits(seed), 0);

const privateKey = Signing.key(subseed, 2);

const digests = Signing.digests(privateKey);

signing.address(digests)

Summary: Derives an address from the given key digests.
Throws:

  • errors.ILLEGAL_DIGESTS_LENGTH : Make sure that the digests argument contains a multiple of 243 trits.

| Param | Type | Description | | --- | --- | --- | | digests | Int8Array | Key digests in trits |

This method derives a 243-trit address from the given key digests.

Related methods

To generate a private key, use the key() method.

Returns: Int8Array - address - Address in trits
Example

const seed = 'MYSUPERSECRETSEED...';
const subseed = Signing.subseed(Converter.trytesToTrits(seed), 0);

const privateKey = Signing.key(subseed, 2);

const digests = Signing.digests(privateKey);

const address = Signing.address(digests);

signing.validateSignatures(expectedAddress, signatureFragments, bundle)

Summary: Validates the given signature, using the given bundle and address.
Throws:

  • errors.ILLEGAL_BUNDLE_HASH_LENGTH : Make sure that the bundle argument contains a 243-trit bundle hash.

| Param | Type | Description | | --- | --- | --- | | expectedAddress | Int8Array | Input address in trits | | signatureFragments | Array.<Int8Array> | Signature fragments in trits | | bundle | Int8Array | Bundle hash in trits |

This method validates a signature by doing the following:

  • Normalizing the bundle hash
  • Deriving the key digests of the address, using the normalized bundle hash and the signature -.Deriving an address from the key digests
  • Comparing the derived address to the expectedAddress argument to find out if they match

If the addresses match, the signature is valid.

For more information about signatures see the documentation portal.

Related methods

To convert trytes such as bundle hashes and addresses to trits, use the trytesToTrits() method.

Returns: boolean - valid - Whether the signatures are valid.
Example

let valid = Signing.validateSignatures(expectedAddress, signatureFragments, bundle);

signing.normalizedBundle(bundle)

Summary: Normalizes the bundle hash.
Throws:

  • errors.ILLEGAL_BUNDLE_HASH_LENGTH : Make sure that the bundle argument contains a 243-trit bundle hash.

| Param | Type | Description | | --- | --- | --- | | bundle | Int8Array | Bundle hash in trits |

This method normalizes the given bundle hash to make sure that only around half of the private key is revealed when the bundle hash is signed.

For more information about signatures see the documentation portal.

To find out more about why the bundle hash is normalized, see this answer on StackExchange.

Related methods

To convert a bundle hash from trytes to trits, use the trytesToTrits() method.

Returns: Int8Array - Normalized bundle hash in trits
Example

let normalizedBundleHash = Signing.normalizedBundle(bundle);