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

fi-verifiable-data

v0.0.6

Published

VC and VP wrapper for rust and WASM. fi-digital-signatures crate is used to sign and verify the data objects.

Downloads

12

Readme

fi-verifiable-data

crates.io Test Package publish

fi-verifiable-data library is focused on the representation and validation for Verifiable Credential and Verifiable Presentation. fi-digital-signatures crate is used to sign and verify VP and VC proofs. API documentation on docs.rs

Verifiable Credential

Rust

Sign

let mut vc = VC::new(
    id,
    Value::from(issuer),
    Some(Value::from(name)),
    Some(Value::from(description)),
    Some(Value::from(valid_until))
);

let private_key_bytes = hex::decode(PRIVATE_KEY_HEX).expect("Private key hex decode failed"); 

let mut eddsa_doc = VerificationDocument::new(
    String::from("doc_id"),
    Some(private_key_bytes),
    None,
);

let proof = FiProof::new(
    fi_digital_signatures::algorithms::Algorithm::EdDSA,
    String::from("ESig"),
);

match vc.sign(&mut eddsa_doc, proof) {
    Err(error) => {
        eprintln!("{}", error);
        assert!(false);
    }
    Ok(_) => {}
};

Verify

let public_key_bytes = hex::decode(PUBLIC_KEY_HEX).expect("Public key hex decode failed");

let mut eddsa_doc = VerificationDocument::new(
    String::from("doc_id"),
    None,
    Some(public_key_bytes),
);

let result = match vc.verify(&mut eddsa_doc) {
        Ok(val) => val,
        Err(error) => {
            eprintln!("{}", error);
            assert!(false);
            return;
        }
    };

WASM

Sign

const fiVerifiableData = await import("fi-verifiable-data");

let vc = new fiVerifiableData.VC("id:1", "issuer", "name", "description", new Date().toString(), [
  "https://www.w3.org/2018/credentials/v1", 
]);
 
const privateKeyBytes = Uint8Array.from(
  Buffer.from(
    "7b6df71975950d5ea15ac090c57d462f73d3a48644fbcf2c6d5db838adf136b5",
    "hex"
  )
);
let verificationDocument = new fiVerifiableData.VerificationDocument(
  "",
  privateKeyBytes,
  null
);

vc.sign(
  fiVerifiableData.Algorithm.EdDSA,
  "purpose",
  verificationDocument,
  fiVerifiableData.ProofType.FiProof
);
console.log(vc.toObject());

Verify

const fiVerifiableData = await import("fi-verifiable-data");
 
const publicKeyBytes = Uint8Array.from(
  Buffer.from(
    "aa7f263d0a1a671a4c06ea22800c1391dd8974174f01d0e5a848fe51bdd1bcf8",
    "hex"
  )
); 
let verificationDocument = new fiVerifiableData.VerificationDocument(
  "",
  null,
  publicKeyBytes
);

let result = vc.verify( 
  verificationDocument
); 

Verifiable Presentation

Rust

Sign

let private_key_bytes = hex::decode(PRIVATE_KEY_HEX).expect("rivate key hex decode failed"); 

let mut eddsa_doc = VerificationDocument::new(
    String::from("doc_id"),
    Some(private_key_bytes),
    None,
);

let mut vp = VP::new(vp_id, Some(String::from(vp_issuer)));
vp.add_verifiable_credentials(vc1);
vp.add_verifiable_credentials(vc2);

let proof = FiProof::new(
    fi_digital_signatures::algorithms::Algorithm::EdDSA,
    String::from("ESig"),
);

match vp.sign(&mut eddsa_doc, proof) {
    Err(error) => {
        eprintln!("{}", error);
        assert!(false);
    }
    Ok(_) => {}
};

Verify

let public_key_bytes = hex::decode(PUBLIC_KEY_HEX).expect("Public key hex decode failed");

let mut eddsa_doc = VerificationDocument::new(
    String::from("doc_id"),
    None,
    Some(public_key_bytes),
);

let result = match vp.verify(&mut eddsa_doc) {
        Ok(val) => val,
        Err(error) => {
            eprintln!("{}", error);
            assert!(false);
            return;
        }
    };

WASM

Sign

const fiVerifiableData = await import("fi-verifiable-data");

let vp = new fiVerifiableData.VP("id:1", "holder");
vp.addVerifiableCredential(vc1);
vp.addVerifiableCredential(vc2);
 
const privateKeyBytes = Uint8Array.from(
  Buffer.from(
    "7b6df71975950d5ea15ac090c57d462f73d3a48644fbcf2c6d5db838adf136b5",
    "hex"
  )
);
let verificationDocument = new fiVerifiableData.VerificationDocument(
  "",
  privateKeyBytes,
  null
);

vp.sign(
  fiVerifiableData.Algorithm.EdDSA,
  "purpose",
  verificationDocument,
  fiVerifiableData.ProofType.FiProof
);
console.log(vp.toObject());

Verify

const fiVerifiableData = await import("fi-verifiable-data");
 
const publicKeyBytes = Uint8Array.from(
  Buffer.from(
    "aa7f263d0a1a671a4c06ea22800c1391dd8974174f01d0e5a848fe51bdd1bcf8",
    "hex"
  )
); 
let verificationDocument = new fiVerifiableData.VerificationDocument(
  "",
  null,
  publicKeyBytes
);

let result = vp.verify( 
  verificationDocument
);