All Projects → decentralized-identity → lds-ecdsa-secp256k1-2019.js

decentralized-identity / lds-ecdsa-secp256k1-2019.js

Licence: Apache-2.0 License
EcdsaSecp256k1Signature2019 JSON-LD Signature Suite

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to lds-ecdsa-secp256k1-2019.js

tiny-secp256k1
A tiny secp256k1 native/JS wrapper
Stars: ✭ 41 (+173.33%)
Mutual labels:  wasm, secp256k1
learn-wasm
🎲 Learning WebAssembly
Stars: ✭ 57 (+280%)
Mutual labels:  wasm
wasm-nginx-module
Run Wasm in OpenResty/Nginx
Stars: ✭ 55 (+266.67%)
Mutual labels:  wasm
runno
Browser-based code runner that can be embedded as an iframe or used as a library.
Stars: ✭ 211 (+1306.67%)
Mutual labels:  wasm
interp
Interpreter experiment. Testing dispatch methods: Switching, Direct/Indirect Threaded Code, Tail-Calls and Inlining
Stars: ✭ 32 (+113.33%)
Mutual labels:  wasm
rustexp
A Rust regular expression editor and tester that runs entirely within the browser!
Stars: ✭ 59 (+293.33%)
Mutual labels:  wasm
rustwasmc
Tool for building Rust functions for Node.js. Combine the performance of Rust, safety and portability of WebAssembly, and ease of use of JavaScript.
Stars: ✭ 97 (+546.67%)
Mutual labels:  wasm
ECDSA secp256k1 JordonMatrix nodejs
javascript ecdsa generator, specifically secp256k1 properties, using jordon form matrices
Stars: ✭ 15 (+0%)
Mutual labels:  secp256k1
idris-codegen-wasm
WebAssembly Code Generation Backend for Idris Compiler
Stars: ✭ 79 (+426.67%)
Mutual labels:  wasm
go-wasm-examples
Some small examples of using Go and WebAssembly
Stars: ✭ 22 (+46.67%)
Mutual labels:  wasm
screeps-starter-rust
Starter Rust AI for Screeps, the JavaScript-based MMO game
Stars: ✭ 55 (+266.67%)
Mutual labels:  wasm
facade
Facade Framework - autogenerated embedded live dashboards for Rust apps
Stars: ✭ 95 (+533.33%)
Mutual labels:  wasm
secp256k1-ml
Elliptic curve library secp256k1 wrapper for Ocaml
Stars: ✭ 18 (+20%)
Mutual labels:  secp256k1
warpy
WebAssembly interpreter in RPython
Stars: ✭ 54 (+260%)
Mutual labels:  wasm
wecty
Frontend ToolKit for Go and TinyGo.
Stars: ✭ 34 (+126.67%)
Mutual labels:  wasm
blazor-ui
A collection of examples related to Telerik UI for Blazor Components: https://www.telerik.com/blazor-ui
Stars: ✭ 182 (+1113.33%)
Mutual labels:  wasm
use-ammojs
ammo.js physics for use with react-three-fiber
Stars: ✭ 16 (+6.67%)
Mutual labels:  wasm
wapc-rust
Rust-based WebAssembly Host Runtime for waPC-compliant modules
Stars: ✭ 75 (+400%)
Mutual labels:  wasm
monolith-of-web
A chrome extension to make a single static HTML file of the web page using a WebAssembly port of monolith CLI
Stars: ✭ 92 (+513.33%)
Mutual labels:  wasm
wasm-fizzbuzz
WebAssembly from Scratch: From FizzBuzz to DooM.
Stars: ✭ 1,364 (+8993.33%)
Mutual labels:  wasm

EcdsaSecp256k1Signature2019

This library is no longer maintained, please use JsonWebSignature2020 instead.

Build Status codecov

🚧 This library is experimental / under development / not audited. Use at your own risk.

This project relies on:

Usage

Install

npm i @transmute/lds-ecdsa-secp256k1-2019 --save

Issue and Verify with vc-js

const {
  EcdsaSecp256k1KeyClass2019,
  EcdsaSecp256k1Signature2019,
  defaultDocumentLoader,
} = require('@transmute/lds-ecdsa-secp256k1-2019');

const vc = require('vc-js');

const key = new EcdsaSecp256k1KeyClass2019({
  id:
    'did:elem:EiChaglAoJaBq7bGWp6bA5PAQKaOTzVHVXIlJqyQbljfmg#qfknmVDhMi3Uc190IHBRfBRqMgbEEBRzWOj1E9EmzwM',
  controller: 'did:elem:EiChaglAoJaBq7bGWp6bA5PAQKaOTzVHVXIlJqyQbljfmg',
  privateKeyJwk: {
    kty: 'EC',
    crv: 'secp256k1',
    d: 'wNZx20zCHoOehqaBOFsdLELabfv8sX0612PnuAiyc-g',
    x: 'NbASvplLIO_XTzP9R69a3MuqOO0DQw2LGnhJjirpd4w',
    y: 'EiZOvo9JWPz1yGlNNW66IV8uA44EQP_Yv_E7OZl1NG0',
    kid: 'qfknmVDhMi3Uc190IHBRfBRqMgbEEBRzWOj1E9EmzwM',
  },
});

const suite = new EcdsaSecp256k1Signature2019({
  key,
});

// Sample unsigned credential
const credential = {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    'https://www.w3.org/2018/credentials/examples/v1',
  ],
  id: 'https://example.com/credentials/1872',
  type: ['VerifiableCredential', 'AlumniCredential'],
  issuer: key.controller,
  issuanceDate: '2010-01-01T19:23:24Z',
  credentialSubject: {
    id: 'did:example:ebfeb1f712ebc6f1c276e12ec21',
    alumniOf: 'Example University',
  },
};

const signedVC = await vc.issue({ credential, suite });
const result = await vc.verify({
  credential: signedVC,
  suite,
  documentLoader: defaultDocumentLoader,
});
```

### Sign

```ts
const jsigs = require('jsonld-signatures');

const { AssertionProofPurpose } = jsigs.purposes;

const {
  EcdsaSecp256k1KeyClass2019,
  EcdsaSecp256k1Signature2019,
  defaultDocumentLoader,
} = require('@transmute/lds-ecdsa-secp256k1-2019');

const key = new EcdsaSecp256k1KeyClass2019({
  id:
    'did:elem:EiChaglAoJaBq7bGWp6bA5PAQKaOTzVHVXIlJqyQbljfmg#qfknmVDhMi3Uc190IHBRfBRqMgbEEBRzWOj1E9EmzwM',
  controller: 'did:elem:EiChaglAoJaBq7bGWp6bA5PAQKaOTzVHVXIlJqyQbljfmg',
  privateKeyJwk: {
    kty: 'EC',
    crv: 'secp256k1',
    d: 'wNZx20zCHoOehqaBOFsdLELabfv8sX0612PnuAiyc-g',
    x: 'NbASvplLIO_XTzP9R69a3MuqOO0DQw2LGnhJjirpd4w',
    y: 'EiZOvo9JWPz1yGlNNW66IV8uA44EQP_Yv_E7OZl1NG0',
    kid: 'qfknmVDhMi3Uc190IHBRfBRqMgbEEBRzWOj1E9EmzwM',
  },
});
const signed = await jsigs.sign(
  {
    '@context': [
      {
        schema: 'http://schema.org/',
        name: 'schema:name',
        homepage: 'schema:url',
        image: 'schema:image',
      },
    ],
    name: 'Manu Sporny',
    homepage: 'https://manu.sporny.org/',
    image: 'https://manu.sporny.org/images/manu.png',
  },
  {
    compactProof: false,
    documentLoader: defaultDocumentLoader,
    purpose: new AssertionProofPurpose(),
    suite: new EcdsaSecp256k1Signature2019({
      key,
    }),
  }
);
// see verify for example.

Verify

const res = await jsigs.verify(signed, {
  suite: new EcdsaSecp256k1Signature2019({
    key,
  }),

  compactProof: false,
  documentLoader: defaultDocumentLoader,
  purpose: new AssertionProofPurpose(),
});
// Leave for development purposes
if (!res.verified) {
  // tslint:disable-next-line:no-console
  console.log(res);
}
expect(res.verified).toBe(true);

Motivation

ES256K is currently a DRAFT, however, it has been implemented and is being used by companies. Node 12 supports ES256K out of the box, but browser support requires custom implementations. This library attempts to provide a Node/Web implementation of ES256K as well as a JSON-LD Signature Suite, EcdsaSecp256k1Signature2019, built on detached ES256K JWS according to rfc7797.

Our approach is based on lds-ed25519-2018 and jsonld-signatures.

Development

This monorepo uses lerna, most of the scripts in the root directory just call lerna.

npm i
npm run build
npm run test
npm run coverage
npm run docs

Releases

npm run release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].