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

@jmcanterafonseca-iota/anchoring-channels

v0.1.5

Published

Powered by IOTA Streams, Anchor Channels is an easy to be used library that allows to anchor messages to the Tangle.

Downloads

16

Readme

iota-anchoring-channels

Powered by IOTA Streams, iota-anchoring-channels is an easy to be used library that allows to anchor messages to the Tangle and later verify their anchoring if needed.

How it works

The main purpose is to be able to anchor messages to the IOTA Tangle so that their integrity, authenticity and immutability is preserved. Different applications can benefit from this feature. One of the applications (implemented by the library itself) is the generation of Linked Data Proofs for JSON-LD documents.

The library allows you create "Anchoring Channels". An Anchoring Channel is just an IOTA Streams Channel which can contain as many anchorages as needed. The first anchorage is the announce message of such an IOTA Streams Channel. Anchorages are identified by an ID (the ID of the message that is actually the anchorage).

After anchoring a message to an anchorage, such anchored message can turn itself into another anchorage (like if it were "on top" of the previous message).

You can imagine an Anchoring Channel as a port's dock where different ships can be anchored and where multiple anchorages are available. The library allows anchoring the ships and once a ship is anchored that ship itself becomes another anchorage . When you anchor new ships you anchor them both to the dock and to another ship acting as an anchorage.

The entities anchoring the messages (the ship owners metaphorically speaking) are authenticated by means of EdDSA (Ed25519).

API

Anchoring messages

const anchoringChannel = await IotaAnchoringChannel.create(node, seed).bind(channelID?);

anchoringChannel.seed
anchoringChannel.channelID
anchoringChannel.channelAddr
anchoringChannel.firstAnchorageID

const message = "my message";
// Obtain your anchorageID (it could be the first anchorageID of the channel)
const result = await anchoringChannel.anchor(anchorageID, message);
console.log("msg ID", result.msgID);

Fetching messages

const result = await anchoringChannel.fetch(anchorageID, msgID);

Signing messages (EdDSA)

const node = "https://chrysalis-nodes.iota.org";
const did = "did:iota:2pu42SstXrg7uMEGHS5qkBDEJ1hrbrYtWQReMUvkCrDP";
const signer = await IotaSigner.create(node, did);

const message = "hello";
// Method declared on the DID document
const method = "key";
// Private Key in base58
const privateKey = "privateKeybase58";

const signature = (await signer.sign(Buffer.from(message), method, privateKey)).signatureValue;

Verifying messages

const request: IVerificationRequest = {
    type: "",
    message: "Hello",
    signatureValue,
    verificationMethod: "did:iota:2pu42SstXrg7uMEGHS5qkBDEJ1hrbrYtWQReMUvkCrDP#key",
    node: "https://chrysalis-nodes.iota.org"
};

const verified = await IotaVerifier.verify(request);

Linked Data Signatures generation (Ed25519 over JSON(-LD))

const node = "https://chrysalis-nodes.iota.org";
const did = "did:iota:2pu42SstXrg7uMEGHS5qkBDEJ1hrbrYtWQReMUvkCrDP";
const signer = await IotaSigner.create(node, did);

const jsonLdDocument = {
    "@context": "https://schema.org",
    "type": "Organization",
    "name": "IOTA Foundation"
};

// Obtains a Linked Data Signature
const proof = signer.signJsonLd(jsonLdDocument, method, privateKey);

Linked Data Signatures verification (Ed25519 over JSON(-LD) objects)

// The document includes the former document and the Linked Data Signature
const signedDoc = {
    "@context": "https://schema.org",
    "type": "Organization",
    "name": "IOTA Foundation",

    "proofValue": "3JTS3UaJc2aS2rxkQ1Z4GEs9HjvASnm3e2s5VT5pS8voGEBodWBBd6P7YUmq8eN92H9v1u2gmqER7Y6wXhgcywYX",
    "type": "Ed25519Signature2018",
    "verificationMethod": "did:iota:2pu42SstXrg7uMEGHS5qkBDEJ1hrbrYtWQReMUvkCrDP#key",
    "proofPurpose": "dataVerification",
    "created": "2021-06-21T13:29:25.976Z"
};

const verified = await IotaVerifier.verifyJsonLd({
    document: signedDoc
});

Linked Data Proofs generation (anchored to the Tangle) .- To be implemented

const anchorChannel = /* Instantiate an anchor channel */
const signer = /* Instantiate a signer */
const ldProofGenerator = new IotaLdProofGenerator(anchoringChannel, signer)
await ldProofGenerator.generate(jsonLdDocument, anchorageID)

Linked Data Proofs verification (To be implemented)

const verifier = new IotaAnchorVerifier(node, seed);
await verifier.verify(jsonDocument);

await verifier.verify(jsonDocument[]);