1.3.1 • Published 1 year ago

@jeswr/rdfjs-sign v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

RDFJS Sign

A set of utilities for signing RDF. :warning: Not for production use :warning:

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.

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago