Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove temp-signatures, use forked repo for fix Secp256k1KeyPair #46

Merged
merged 3 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"ecdsa-secp256k1-signature-2019": "^1.0.0",
"elliptic": "^6.5.2",
"ethr-did-resolver": "^2.2.0",
"secp256k1-key-pair": "https://github.com/SamHellawell/secp256k1-key-pair",
cykoder marked this conversation as resolved.
Show resolved Hide resolved
"vc-js": "^0.5.0"
}
}
3 changes: 2 additions & 1 deletion src/modules/vc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import documentLoader from '../utils/vc/document-loader';
import {issue, verifyCredential, createPresentation, signPresentation, verify} from 'vc-js';
import {Ed25519KeyPair, suites} from 'jsonld-signatures';
const {Ed25519Signature2018} = suites;
import {EcdsaSepc256k1Signature2019, Secp256k1KeyPair} from '../utils/vc/temp-signatures';
import Secp256k1KeyPair from 'secp256k1-key-pair';
import {EcdsaSepc256k1Signature2019} from '../utils/vc/signatures';


/** Class to sign and verify Verifiable Credentials */
Expand Down
38 changes: 38 additions & 0 deletions src/utils/vc/signatures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Secp256k1KeyPair from 'secp256k1-key-pair';
import {suites} from 'jsonld-signatures';

// TODO: use this package https://github.com/digitalbazaar/ecdsa-secp256k1-signature-2019
// once this PR is merged: https://github.com/digitalbazaar/secp256k1-key-pair/pull/8
export class EcdsaSepc256k1Signature2019 extends suites.JwsLinkedDataSignature {
/**
* @param type {string} Provided by subclass.
*
* One of these parameters is required to use a suite for signing:
*
* @param [creator] {string} A key id URL to the paired public key.
* @param [verificationMethod] {string} A key id URL to the paired public key.
*
* This parameter is required for signing:
*
* @param [signer] {function} an optional signer.
*
* Advanced optional parameters and overrides:
*
* @param [proof] {object} a JSON-LD document with options to use for
* the `proof` node (e.g. any other custom fields can be provided here
* using a context different from security-v2).
* @param [date] {string|Date} signing date to use if not passed.
* @param [key] {LDKeyPair} an optional crypto-ld KeyPair.
* @param [useNativeCanonize] {boolean} true to use a native canonize
* algorithm.
*/
constructor({
signer, key, creator, verificationMethod, proof, date, useNativeCanonize
} = {}) {
super({
type: 'EcdsaSecp256k1Signature2019', alg: 'ES256K',
LDKeyClass: Secp256k1KeyPair, creator, verificationMethod, signer, key,
proof, date, useNativeCanonize});
this.requiredKeyType = 'EcdsaSecp256k1VerificationKey2019';
}
}
310 changes: 0 additions & 310 deletions src/utils/vc/temp-signatures.js

This file was deleted.

7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5163,6 +5163,13 @@ secp256k1-key-pair@^1.0.0:
elliptic "^6.5.0"
node-forge "^0.8.5"

"secp256k1-key-pair@https://github.com/SamHellawell/secp256k1-key-pair":
version "1.1.1-0"
resolved "https://github.com/SamHellawell/secp256k1-key-pair#da66af97da3944b864406ebe5a8aec96cb6152a5"
dependencies:
elliptic "^6.5.0"
node-forge "^0.8.5"

security-context@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/security-context/-/security-context-4.0.0.tgz#e73f5d22bee9c7699a02eaaced359d001dc948e9"
Expand Down