@jeswr/rdfjs-sign
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

RDFJS Sign

A set of utilities for signing RDF. ⚠️ Not for production use ⚠️

GitHub license npm version build Dependabot semantic-release

Usage

import { DataFactory } from 'n3';
import {
  generateKeyPair, exportKey, signQuads, verifyQuads, importKey,
} from '@jeswr/rdfjs-sign';

const { quad, namedNode } = DataFactory;

const q1 = quad(namedNode('http://example.org/s'), namedNode('http://example.org/p'), namedNode('http://example.org/o1'));
const q2 = quad(namedNode('http://example.org/s'), namedNode('http://example.org/p'), namedNode('http://example.org/o2'));
const q3 = quad(namedNode('http://example.org/s'), namedNode('http://example.org/p'), namedNode('http://example.org/o3'));
const keyPair = await generateKeyPair();
const signature = await signQuads([q1, q2], keyPair.privateKey);

// true
await verifyQuads([q2, q1], signature, keyPair.publicKey);

// false
await verifyQuads([q1, q3], signature, keyPair.publicKey);

// true
await verifyQuads([q2, q1], signature, await importKey(await exportKey(keyPair.publicKey)));

CLI Usage

To sign data with a private key

npx @jeswr/rdfjs-sign --private-key ./key.json --hash "abc123"

To sign a hash with a private key

npx @jeswr/rdfjs-sign --private-key ./key.json --data ./data.ttl

License

©2024–present Jesse Wright, MIT License.

This is based on code written in this prototype in collaboration with Ruben Dedecker and Wout Slabbinck.

Package Sidebar

Install

npm i @jeswr/rdfjs-sign

Weekly Downloads

123

Version

1.3.1

License

MIT

Unpacked Size

12.6 kB

Total Files

9

Last publish

Collaborators

  • jeswr