Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@transmute/secp256k1-key-pair

Package Overview
Dependencies
Maintainers
3
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@transmute/secp256k1-key-pair - npm Package Compare versions

Comparing version 0.6.1-unstable.37 to 0.7.0-unstable.0

60

dist/secp256k1-key-pair.cjs.development.js

@@ -1636,30 +1636,2 @@ 'use strict';

_proto.toJsonWebKeyPair = /*#__PURE__*/function () {
var _toJsonWebKeyPair = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(exportPrivateKey) {
return runtime_1.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
if (exportPrivateKey === void 0) {
exportPrivateKey = false;
}
console.warn("DEPRECATION WARNING: .toJsonWebKeyPair should be replaced with .export({type:'JsonWebKey2020'}).");
return _context7.abrupt("return", exportableTypes['JsonWebKey2020'](this.id, this.controller, this.publicKey, exportPrivateKey ? this.privateKey : undefined));
case 3:
case "end":
return _context7.stop();
}
}
}, _callee7, this);
}));
function toJsonWebKeyPair(_x6) {
return _toJsonWebKeyPair.apply(this, arguments);
}
return toJsonWebKeyPair;
}();
return Secp256k1KeyPair;

@@ -1669,15 +1641,15 @@ }();

exports.Secp256k1KeyPair.generate = /*#__PURE__*/function () {
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(_ref4) {
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(_ref4) {
var secureRandom, _yield$_generate, publicKey, privateKey, fingerprint, controller, id;
return runtime_1.wrap(function _callee8$(_context8) {
return runtime_1.wrap(function _callee7$(_context7) {
while (1) {
switch (_context8.prev = _context8.next) {
switch (_context7.prev = _context7.next) {
case 0:
secureRandom = _ref4.secureRandom;
_context8.next = 3;
_context7.next = 3;
return _generate(secureRandom);
case 3:
_yield$_generate = _context8.sent;
_yield$_generate = _context7.sent;
publicKey = _yield$_generate.publicKey;

@@ -1688,3 +1660,3 @@ privateKey = _yield$_generate.privateKey;

id = controller + "#" + fingerprint;
return _context8.abrupt("return", new Secp256k1KeyPair_1({
return _context7.abrupt("return", new Secp256k1KeyPair_1({
id: id,

@@ -1699,9 +1671,9 @@ type: 'JsonWebKey2020',

case "end":
return _context8.stop();
return _context7.stop();
}
}
}, _callee8);
}, _callee7);
}));
return function (_x7) {
return function (_x6) {
return _ref5.apply(this, arguments);

@@ -1712,11 +1684,11 @@ };

exports.Secp256k1KeyPair.from = /*#__PURE__*/function () {
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(k) {
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(k) {
var _importableTypes$k$ty, publicKey, privateKey;
return runtime_1.wrap(function _callee9$(_context9) {
return runtime_1.wrap(function _callee8$(_context8) {
while (1) {
switch (_context9.prev = _context9.next) {
switch (_context8.prev = _context8.next) {
case 0:
_importableTypes$k$ty = importableTypes[k.type](k), publicKey = _importableTypes$k$ty.publicKey, privateKey = _importableTypes$k$ty.privateKey;
return _context9.abrupt("return", new Secp256k1KeyPair_1({
return _context8.abrupt("return", new Secp256k1KeyPair_1({
id: k.id,

@@ -1731,9 +1703,9 @@ type: k.type,

case "end":
return _context9.stop();
return _context8.stop();
}
}
}, _callee9);
}, _callee8);
}));
return function (_x8) {
return function (_x7) {
return _ref6.apply(this, arguments);

@@ -1740,0 +1712,0 @@ };

@@ -1,2 +0,2 @@

"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=r(require("secp256k1")),n=require("@transmute/ld-key-pair"),o=r(require("crypto")),i=require("@bitauth/libauth");function a(r,e,t,n,o,i,a){try{var c=r[i](a),u=c.value}catch(r){return void t(r)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(r){return function(){var e=this,t=arguments;return new Promise((function(n,o){var i=r.apply(e,t);function c(r){a(i,n,o,c,u,"next",r)}function u(r){a(i,n,o,c,u,"throw",r)}c(void 0)}))}}function u(){return(u=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}var s,f=(function(r){var e=function(r){var e=Object.prototype,t=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(r,e,t){return Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}),r[e]}try{c({},"")}catch(r){c=function(r,e,t){return r[e]=t}}function u(r,e,t,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new k(n||[]);return o._invoke=function(r,e,t){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(t.method=o,t.arg=i;;){var a=t.delegate;if(a){var c=m(a,t);if(c){if(c===f)continue;return c}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var u=s(r,e,t);if("normal"===u.type){if(n=t.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:t.done}}"throw"===u.type&&(n="completed",t.method="throw",t.arg=u.arg)}}}(r,t,i),o}function s(r,e,t){try{return{type:"normal",arg:r.call(e,t)}}catch(r){return{type:"throw",arg:r}}}r.wrap=u;var f={};function p(){}function h(){}function l(){}var y={};y[o]=function(){return this};var v=Object.getPrototypeOf,d=v&&v(v(E([])));d&&d!==e&&t.call(d,o)&&(y=d);var w=l.prototype=p.prototype=Object.create(y);function g(r){["next","throw","return"].forEach((function(e){c(r,e,(function(r){return this._invoke(e,r)}))}))}function b(r,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=s(r[o],r,i);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&t.call(p,"__await")?e.resolve(p.__await).then((function(r){n("next",r,a,c)}),(function(r){n("throw",r,a,c)})):e.resolve(p).then((function(r){f.value=r,a(f)}),(function(r){return n("throw",r,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function m(r,e){var t=r.iterator[e.method];if(void 0===t){if(e.delegate=null,"throw"===e.method){if(r.iterator.return&&(e.method="return",e.arg=void 0,m(r,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(t,r.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[r.resultName]=o.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function K(r){var e={tryLoc:r[0]};1 in r&&(e.catchLoc=r[1]),2 in r&&(e.finallyLoc=r[2],e.afterLoc=r[3]),this.tryEntries.push(e)}function x(r){var e=r.completion||{};e.type="normal",delete e.arg,r.completion=e}function k(r){this.tryEntries=[{tryLoc:"root"}],r.forEach(K,this),this.reset(!0)}function E(r){if(r){var e=r[o];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(t.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=w.constructor=l,l.constructor=h,h.displayName=c(l,a,"GeneratorFunction"),r.isGeneratorFunction=function(r){var e="function"==typeof r&&r.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,c(r,a,"GeneratorFunction")),r.prototype=Object.create(w),r},r.awrap=function(r){return{__await:r}},g(b.prototype),b.prototype[i]=function(){return this},r.AsyncIterator=b,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var a=new b(u(e,t,n,o),i);return r.isGeneratorFunction(t)?a:a.next().then((function(r){return r.done?r.value:a.next()}))},g(w),c(w,a,"Generator"),w[o]=function(){return this},w.toString=function(){return"[object Generator]"},r.keys=function(r){var e=[];for(var t in r)e.push(t);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=E,k.prototype={constructor:k,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!r)for(var e in this)"t"===e.charAt(0)&&t.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var r=this.tryEntries[0].completion;if("throw"===r.type)throw r.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(t,n){return a.type="throw",a.arg=r,e.next=t,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=t.call(i,"catchLoc"),u=t.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(r,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===r||"continue"===r)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=r,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(r,e){if("throw"===r.type)throw r.arg;return"break"===r.type||"continue"===r.type?this.next=r.arg:"return"===r.type?(this.rval=this.arg=r.arg,this.method="return",this.next="end"):"normal"===r.type&&e&&(this.next=e),f},finish:function(r){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.finallyLoc===r)return this.complete(t.completion,t.afterLoc),x(t),f}},catch:function(r){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.tryLoc===r){var n=t.completion;if("throw"===n.type){var o=n.arg;x(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,e,t){return this.delegate={iterator:E(r),resultName:e,nextLoc:t},"next"===this.method&&(this.arg=void 0),f}},r}(r.exports);try{regeneratorRuntime=e}catch(r){Function("r","regeneratorRuntime = r")(e)}}(s={exports:{}}),s.exports);function p(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),i=o.charCodeAt(0);if(255!==e[i])throw new TypeError(o+" is ambiguous");e[i]=n}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),s=Math.log(256)/Math.log(a);function f(r){if("string"!=typeof r)throw new TypeError("Expected String");if(0===r.length)return Buffer.alloc(0);var t=0;if(" "!==r[t]){for(var n=0,o=0;r[t]===c;)n++,t++;for(var i=(r.length-t)*u+1>>>0,s=new Uint8Array(i);r[t];){var f=e[r.charCodeAt(t)];if(255===f)return;for(var p=0,h=i-1;(0!==f||p<o)&&-1!==h;h--,p++)s[h]=(f+=a*s[h]>>>0)%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=p,t++}if(" "!==r[t]){for(var l=i-o;l!==i&&0===s[l];)l++;var y=Buffer.allocUnsafe(n+(i-l));y.fill(0,0,n);for(var v=n;l!==i;)y[v++]=s[l++];return y}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=Buffer.from(e)),!Buffer.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var t=0,n=0,o=0,i=e.length;o!==i&&0===e[o];)o++,t++;for(var u=(i-o)*s+1>>>0,f=new Uint8Array(u);o!==i;){for(var p=e[o],h=0,l=u-1;(0!==p||h<n)&&-1!==l;l--,h++)f[l]=(p+=256*f[l]>>>0)%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");n=h,o++}for(var y=u-n;y!==u&&0===f[y];)y++;for(var v=c.repeat(t);y<u;++y)v+=r.charAt(f[y]);return v},decodeUnsafe:f,decode:function(r){var e=f(r);if(e)return e;throw new Error("Non-base"+a+" character")}}}var h,l=p("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),y=function(r){return function(r){return Buffer.from(r||"").toString("base64")}(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},v=function(r,e){void 0===e&&(e="base58btc");var t=new Uint8Array(2+r.length);if(t[0]=231,t[1]=1,t.set(r,2),"base58btc"===e)return"z"+l.encode(t);if("base64url"===e)return"u"+y(t);throw new Error("Unsupported encoding: "+e)},d=function(r){var e=Buffer.concat([Buffer.from("04","hex"),Buffer.from(r.x,"base64"),Buffer.from(r.y,"base64")]);return t.publicKeyConvert(e,!0,new Uint8Array(33))},w={JsonWebKey2020:function(r){var e,t,n=d(r.publicKeyJwk),o=void 0;return r.privateKeyJwk&&(o=(e=r.privateKeyJwk,(t=Buffer.from(e.d,"base64").toString("hex")).padStart(64,"0"),{publicKey:d(e),privateKey:Uint8Array.from(Buffer.from(t,"hex"))}).privateKey),{publicKey:n,privateKey:o}},EcdsaSecp256k1VerificationKey2020:function(r){throw new Error("EcdsaSecp256k1VerificationKey2020 cannot be imported becuase it does not support private keys.")},EcdsaSecp256k1VerificationKey2019:function(r){return{publicKey:l.decode(r.publicKeyBase58),privateKey:r.privateKeyBase58?l.decode(r.privateKeyBase58):void 0}}},g={JsonWebKey2020:function(r,e,n,o){var i=t.publicKeyConvert(n,!1,new Uint8Array(65)),a=Buffer.from(i).toString("hex").substr(2,65),c=Buffer.from(i).toString("hex").substr(66),s={kty:"EC",crv:"secp256k1",x:y(Buffer.from(a,"hex")),y:y(Buffer.from(c,"hex"))},f={id:r,type:"JsonWebKey2020",controller:e,publicKeyJwk:s};return o&&(f.privateKeyJwk=u({},s,{d:y(o)})),f},EcdsaSecp256k1VerificationKey2020:function(r,e,t,n){var o={id:r,type:"EcdsaSecp256k1VerificationKey2020",controller:e,publicKeyMultibase:v(t)};if(n)throw new Error("Unable to represent secp256k1 private key in multibase. See https://github.com/multiformats/multicodec/pull/210");return o},EcdsaSecp256k1VerificationKey2019:function(r,e,t,n){var o={id:r,type:"EcdsaSecp256k1VerificationKey2019",controller:e,publicKeyBase58:l.encode(t)};return n&&(o.privateKeyBase58=l.encode(n)),o}},b={Ecdsa:{__proto__:null,signer:function(r){return{sign:function(e){return c(f.mark((function n(){var i,a,c;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=e.data,a=o.createHash("sha256").update(i).digest(),c=t.ecdsaSign(a,new Uint8Array(r)),n.abrupt("return",c.signature);case 4:case"end":return n.stop()}}),n)})))()}}},verifier:function(r){return{verify:function(e){return c(f.mark((function n(){var i,a,c,u;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:i=e.data,a=e.signature,c=o.createHash("sha256").update(i).digest(),u=!1;try{u=t.ecdsaVerify(a,c,new Uint8Array(r))}catch(r){}return n.abrupt("return",u);case 5:case"end":return n.stop()}}),n)})))()}}}},EcRecover:{__proto__:null,signer:function(r){return{sign:function(e){return c(f.mark((function n(){var i,a,c,u;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=e.data,a=o.createHash("sha256").update(i).digest(),c=t.ecdsaSign(a,r),u=c.recid,n.abrupt("return",Uint8Array.from(Buffer.concat([Buffer.from(c.signature),Buffer.from(new Uint8Array([u]))])));case 4:case"end":return n.stop()}}),n)})))()}}},verifier:function(r){return{verify:function(e){return c(f.mark((function n(){var i,a,c,u,s;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:i=e.data,a=e.signature,c=o.createHash("sha256").update(i).digest(),u=!1,s=t.ecdsaRecover(a.slice(0,64),a[64],c);try{u=Buffer.from(r).toString("hex")===Buffer.from(s).toString("hex")}catch(r){console.error("An error occurred when verifying signature: ",r)}return n.abrupt("return",u);case 6:case"end":return n.stop()}}),n)})))()}}}},Schnorr:{__proto__:null,signer:function(r){return{sign:function(e){return c(f.mark((function t(){var n,a,c;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.data,t.next=3,i.instantiateSecp256k1();case 3:return a=t.sent,c=o.createHash("sha256").update(n).digest(),t.abrupt("return",a.signMessageHashSchnorr(r,c));case 6:case"end":return t.stop()}}),t)})))()}}},verifier:function(r){return{verify:function(e){return c(f.mark((function t(){var n,a,c,u,s;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.data,a=e.signature,t.next=3,i.instantiateSecp256k1();case 3:c=t.sent,u=o.createHash("sha256").update(n).digest(),s=!1;try{s=c.verifySignatureSchnorr(a,r,u)}catch(r){console.error("An error occurred when verifying signature: ",r)}return t.abrupt("return",s);case 8:case"end":return t.stop()}}),t)})))()}}}}},m=function(){var r=c(f.mark((function r(e){var n,o;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:do{n=e()}while(!t.privateKeyVerify(n));return o=t.publicKeyCreate(n),r.abrupt("return",{publicKey:o,privateKey:new Uint8Array(n)});case 3:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();exports.Secp256k1KeyPair=h=function(){function r(r){this.type="JsonWebKey2020",this.id=r.id,this.type=r.type||"JsonWebKey2020",this.controller=r.controller,this.publicKey=r.publicKey,this.privateKey=r.privateKey}r.fromFingerprint=function(){var r=c(f.mark((function r(e){var t,n,o,i;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(231!==(n=l.decode((t=e.fingerprint).substring(1)))[0]||1!==n[1]){r.next=12;break}return r.next=5,h.from({id:"",controller:"",type:"EcdsaSecp256k1VerificationKey2019",publicKeyBase58:l.encode(n.slice(2))});case 5:return o=r.sent,r.next=8,o.fingerprint();case 8:return o.id="did:key:"+(i=r.sent)+"#"+i,o.controller="did:key:"+i,r.abrupt("return",o);case 12:throw new Error("Unsupported fingerprint type: "+t);case 13:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),r.fingerprintFromPublicKey=function(){var r=c(f.mark((function r(e){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.from(e);case 2:return r.abrupt("return",v(r.sent.publicKey));case 5:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();var e=r.prototype;return e.fingerprint=function(){var r=c(f.mark((function r(){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",v(this.publicKey));case 1:case"end":return r.stop()}}),r,this)})));return function(){return r.apply(this,arguments)}}(),e.signer=function(r){if(void 0===r&&(r="Ecdsa"),!this.privateKey)throw new Error("No private key to sign with.");if(b[r])return b[r].signer(this.privateKey);throw new Error("Unsupported suite type "+r)},e.verifier=function(r){if(void 0===r&&(r="Ecdsa"),!this.publicKey)throw new Error("No public key to verify with.");if(b[r])return b[r].verifier(this.publicKey);throw new Error("Unsupported suite type "+r)},e.deriveSecret=function(){var r=c(f.mark((function r(e){var n;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.publicKey,r.next=3,h.from(n);case 3:return r.abrupt("return",t.ecdh(r.sent.publicKey,this.privateKey));case 5:case"end":return r.stop()}}),r,this)})));return function(e){return r.apply(this,arguments)}}(),e.export=function(){var r=c(f.mark((function r(e){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!g[e.type]){r.next=3;break}return r.abrupt("return",g[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return r.stop()}}),r,this)})));return function(e){return r.apply(this,arguments)}}(),e.toJsonWebKeyPair=function(){var r=c(f.mark((function r(e){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return void 0===e&&(e=!1),console.warn("DEPRECATION WARNING: .toJsonWebKeyPair should be replaced with .export({type:'JsonWebKey2020'})."),r.abrupt("return",g.JsonWebKey2020(this.id,this.controller,this.publicKey,e?this.privateKey:void 0));case 3:case"end":return r.stop()}}),r,this)})));return function(e){return r.apply(this,arguments)}}(),r}(),exports.Secp256k1KeyPair.generate=function(){var r=c(f.mark((function r(e){var t,n,o,i,a,c;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=e.secureRandom,r.next=3,m(t);case 3:return i=(n=r.sent).privateKey,a=v(o=n.publicKey),r.abrupt("return",new h({id:(c="did:key:"+a)+"#"+a,type:"JsonWebKey2020",controller:c,publicKey:o,privateKey:i}));case 10:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),exports.Secp256k1KeyPair.from=function(){var r=c(f.mark((function r(e){var t;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=w[e.type](e),r.abrupt("return",new h({id:e.id,type:e.type,controller:e.controller,publicKey:t.publicKey,privateKey:t.privateKey}));case 2:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),exports.Secp256k1KeyPair=h=e.__decorate([n.staticImplements()],exports.Secp256k1KeyPair);
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=r(require("secp256k1")),n=require("@transmute/ld-key-pair"),o=r(require("crypto")),i=require("@bitauth/libauth");function a(r,e,t,n,o,i,a){try{var c=r[i](a),u=c.value}catch(r){return void t(r)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(r){return function(){var e=this,t=arguments;return new Promise((function(n,o){var i=r.apply(e,t);function c(r){a(i,n,o,c,u,"next",r)}function u(r){a(i,n,o,c,u,"throw",r)}c(void 0)}))}}function u(){return(u=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}var s,f=(function(r){var e=function(r){var e=Object.prototype,t=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(r,e,t){return Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}),r[e]}try{c({},"")}catch(r){c=function(r,e,t){return r[e]=t}}function u(r,e,t,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new k(n||[]);return o._invoke=function(r,e,t){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(t.method=o,t.arg=i;;){var a=t.delegate;if(a){var c=b(a,t);if(c){if(c===f)continue;return c}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var u=s(r,e,t);if("normal"===u.type){if(n=t.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:t.done}}"throw"===u.type&&(n="completed",t.method="throw",t.arg=u.arg)}}}(r,t,i),o}function s(r,e,t){try{return{type:"normal",arg:r.call(e,t)}}catch(r){return{type:"throw",arg:r}}}r.wrap=u;var f={};function p(){}function h(){}function l(){}var y={};y[o]=function(){return this};var v=Object.getPrototypeOf,d=v&&v(v(E([])));d&&d!==e&&t.call(d,o)&&(y=d);var g=l.prototype=p.prototype=Object.create(y);function w(r){["next","throw","return"].forEach((function(e){c(r,e,(function(r){return this._invoke(e,r)}))}))}function m(r,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=s(r[o],r,i);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&t.call(p,"__await")?e.resolve(p.__await).then((function(r){n("next",r,a,c)}),(function(r){n("throw",r,a,c)})):e.resolve(p).then((function(r){f.value=r,a(f)}),(function(r){return n("throw",r,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(r,e){var t=r.iterator[e.method];if(void 0===t){if(e.delegate=null,"throw"===e.method){if(r.iterator.return&&(e.method="return",e.arg=void 0,b(r,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(t,r.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[r.resultName]=o.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function x(r){var e={tryLoc:r[0]};1 in r&&(e.catchLoc=r[1]),2 in r&&(e.finallyLoc=r[2],e.afterLoc=r[3]),this.tryEntries.push(e)}function K(r){var e=r.completion||{};e.type="normal",delete e.arg,r.completion=e}function k(r){this.tryEntries=[{tryLoc:"root"}],r.forEach(x,this),this.reset(!0)}function E(r){if(r){var e=r[o];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(t.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=g.constructor=l,l.constructor=h,h.displayName=c(l,a,"GeneratorFunction"),r.isGeneratorFunction=function(r){var e="function"==typeof r&&r.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,c(r,a,"GeneratorFunction")),r.prototype=Object.create(g),r},r.awrap=function(r){return{__await:r}},w(m.prototype),m.prototype[i]=function(){return this},r.AsyncIterator=m,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,t,n,o),i);return r.isGeneratorFunction(t)?a:a.next().then((function(r){return r.done?r.value:a.next()}))},w(g),c(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},r.keys=function(r){var e=[];for(var t in r)e.push(t);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=E,k.prototype={constructor:k,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(K),!r)for(var e in this)"t"===e.charAt(0)&&t.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var r=this.tryEntries[0].completion;if("throw"===r.type)throw r.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(t,n){return a.type="throw",a.arg=r,e.next=t,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=t.call(i,"catchLoc"),u=t.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(r,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===r||"continue"===r)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=r,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(r,e){if("throw"===r.type)throw r.arg;return"break"===r.type||"continue"===r.type?this.next=r.arg:"return"===r.type?(this.rval=this.arg=r.arg,this.method="return",this.next="end"):"normal"===r.type&&e&&(this.next=e),f},finish:function(r){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.finallyLoc===r)return this.complete(t.completion,t.afterLoc),K(t),f}},catch:function(r){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.tryLoc===r){var n=t.completion;if("throw"===n.type){var o=n.arg;K(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,e,t){return this.delegate={iterator:E(r),resultName:e,nextLoc:t},"next"===this.method&&(this.arg=void 0),f}},r}(r.exports);try{regeneratorRuntime=e}catch(r){Function("r","regeneratorRuntime = r")(e)}}(s={exports:{}}),s.exports);function p(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),i=o.charCodeAt(0);if(255!==e[i])throw new TypeError(o+" is ambiguous");e[i]=n}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),s=Math.log(256)/Math.log(a);function f(r){if("string"!=typeof r)throw new TypeError("Expected String");if(0===r.length)return Buffer.alloc(0);var t=0;if(" "!==r[t]){for(var n=0,o=0;r[t]===c;)n++,t++;for(var i=(r.length-t)*u+1>>>0,s=new Uint8Array(i);r[t];){var f=e[r.charCodeAt(t)];if(255===f)return;for(var p=0,h=i-1;(0!==f||p<o)&&-1!==h;h--,p++)s[h]=(f+=a*s[h]>>>0)%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=p,t++}if(" "!==r[t]){for(var l=i-o;l!==i&&0===s[l];)l++;var y=Buffer.allocUnsafe(n+(i-l));y.fill(0,0,n);for(var v=n;l!==i;)y[v++]=s[l++];return y}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=Buffer.from(e)),!Buffer.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var t=0,n=0,o=0,i=e.length;o!==i&&0===e[o];)o++,t++;for(var u=(i-o)*s+1>>>0,f=new Uint8Array(u);o!==i;){for(var p=e[o],h=0,l=u-1;(0!==p||h<n)&&-1!==l;l--,h++)f[l]=(p+=256*f[l]>>>0)%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");n=h,o++}for(var y=u-n;y!==u&&0===f[y];)y++;for(var v=c.repeat(t);y<u;++y)v+=r.charAt(f[y]);return v},decodeUnsafe:f,decode:function(r){var e=f(r);if(e)return e;throw new Error("Non-base"+a+" character")}}}var h,l=p("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),y=function(r){return function(r){return Buffer.from(r||"").toString("base64")}(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},v=function(r,e){void 0===e&&(e="base58btc");var t=new Uint8Array(2+r.length);if(t[0]=231,t[1]=1,t.set(r,2),"base58btc"===e)return"z"+l.encode(t);if("base64url"===e)return"u"+y(t);throw new Error("Unsupported encoding: "+e)},d=function(r){var e=Buffer.concat([Buffer.from("04","hex"),Buffer.from(r.x,"base64"),Buffer.from(r.y,"base64")]);return t.publicKeyConvert(e,!0,new Uint8Array(33))},g={JsonWebKey2020:function(r){var e,t,n=d(r.publicKeyJwk),o=void 0;return r.privateKeyJwk&&(o=(e=r.privateKeyJwk,(t=Buffer.from(e.d,"base64").toString("hex")).padStart(64,"0"),{publicKey:d(e),privateKey:Uint8Array.from(Buffer.from(t,"hex"))}).privateKey),{publicKey:n,privateKey:o}},EcdsaSecp256k1VerificationKey2020:function(r){throw new Error("EcdsaSecp256k1VerificationKey2020 cannot be imported becuase it does not support private keys.")},EcdsaSecp256k1VerificationKey2019:function(r){return{publicKey:l.decode(r.publicKeyBase58),privateKey:r.privateKeyBase58?l.decode(r.privateKeyBase58):void 0}}},w={JsonWebKey2020:function(r,e,n,o){var i=t.publicKeyConvert(n,!1,new Uint8Array(65)),a=Buffer.from(i).toString("hex").substr(2,65),c=Buffer.from(i).toString("hex").substr(66),s={kty:"EC",crv:"secp256k1",x:y(Buffer.from(a,"hex")),y:y(Buffer.from(c,"hex"))},f={id:r,type:"JsonWebKey2020",controller:e,publicKeyJwk:s};return o&&(f.privateKeyJwk=u({},s,{d:y(o)})),f},EcdsaSecp256k1VerificationKey2020:function(r,e,t,n){var o={id:r,type:"EcdsaSecp256k1VerificationKey2020",controller:e,publicKeyMultibase:v(t)};if(n)throw new Error("Unable to represent secp256k1 private key in multibase. See https://github.com/multiformats/multicodec/pull/210");return o},EcdsaSecp256k1VerificationKey2019:function(r,e,t,n){var o={id:r,type:"EcdsaSecp256k1VerificationKey2019",controller:e,publicKeyBase58:l.encode(t)};return n&&(o.privateKeyBase58=l.encode(n)),o}},m={Ecdsa:{__proto__:null,signer:function(r){return{sign:function(e){return c(f.mark((function n(){var i,a,c;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=e.data,a=o.createHash("sha256").update(i).digest(),c=t.ecdsaSign(a,new Uint8Array(r)),n.abrupt("return",c.signature);case 4:case"end":return n.stop()}}),n)})))()}}},verifier:function(r){return{verify:function(e){return c(f.mark((function n(){var i,a,c,u;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:i=e.data,a=e.signature,c=o.createHash("sha256").update(i).digest(),u=!1;try{u=t.ecdsaVerify(a,c,new Uint8Array(r))}catch(r){}return n.abrupt("return",u);case 5:case"end":return n.stop()}}),n)})))()}}}},EcRecover:{__proto__:null,signer:function(r){return{sign:function(e){return c(f.mark((function n(){var i,a,c,u;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=e.data,a=o.createHash("sha256").update(i).digest(),c=t.ecdsaSign(a,r),u=c.recid,n.abrupt("return",Uint8Array.from(Buffer.concat([Buffer.from(c.signature),Buffer.from(new Uint8Array([u]))])));case 4:case"end":return n.stop()}}),n)})))()}}},verifier:function(r){return{verify:function(e){return c(f.mark((function n(){var i,a,c,u,s;return f.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:i=e.data,a=e.signature,c=o.createHash("sha256").update(i).digest(),u=!1,s=t.ecdsaRecover(a.slice(0,64),a[64],c);try{u=Buffer.from(r).toString("hex")===Buffer.from(s).toString("hex")}catch(r){console.error("An error occurred when verifying signature: ",r)}return n.abrupt("return",u);case 6:case"end":return n.stop()}}),n)})))()}}}},Schnorr:{__proto__:null,signer:function(r){return{sign:function(e){return c(f.mark((function t(){var n,a,c;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.data,t.next=3,i.instantiateSecp256k1();case 3:return a=t.sent,c=o.createHash("sha256").update(n).digest(),t.abrupt("return",a.signMessageHashSchnorr(r,c));case 6:case"end":return t.stop()}}),t)})))()}}},verifier:function(r){return{verify:function(e){return c(f.mark((function t(){var n,a,c,u,s;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.data,a=e.signature,t.next=3,i.instantiateSecp256k1();case 3:c=t.sent,u=o.createHash("sha256").update(n).digest(),s=!1;try{s=c.verifySignatureSchnorr(a,r,u)}catch(r){console.error("An error occurred when verifying signature: ",r)}return t.abrupt("return",s);case 8:case"end":return t.stop()}}),t)})))()}}}}},b=function(){var r=c(f.mark((function r(e){var n,o;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:do{n=e()}while(!t.privateKeyVerify(n));return o=t.publicKeyCreate(n),r.abrupt("return",{publicKey:o,privateKey:new Uint8Array(n)});case 3:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();exports.Secp256k1KeyPair=h=function(){function r(r){this.type="JsonWebKey2020",this.id=r.id,this.type=r.type||"JsonWebKey2020",this.controller=r.controller,this.publicKey=r.publicKey,this.privateKey=r.privateKey}r.fromFingerprint=function(){var r=c(f.mark((function r(e){var t,n,o,i;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(231!==(n=l.decode((t=e.fingerprint).substring(1)))[0]||1!==n[1]){r.next=12;break}return r.next=5,h.from({id:"",controller:"",type:"EcdsaSecp256k1VerificationKey2019",publicKeyBase58:l.encode(n.slice(2))});case 5:return o=r.sent,r.next=8,o.fingerprint();case 8:return o.id="did:key:"+(i=r.sent)+"#"+i,o.controller="did:key:"+i,r.abrupt("return",o);case 12:throw new Error("Unsupported fingerprint type: "+t);case 13:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),r.fingerprintFromPublicKey=function(){var r=c(f.mark((function r(e){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.from(e);case 2:return r.abrupt("return",v(r.sent.publicKey));case 5:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();var e=r.prototype;return e.fingerprint=function(){var r=c(f.mark((function r(){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",v(this.publicKey));case 1:case"end":return r.stop()}}),r,this)})));return function(){return r.apply(this,arguments)}}(),e.signer=function(r){if(void 0===r&&(r="Ecdsa"),!this.privateKey)throw new Error("No private key to sign with.");if(m[r])return m[r].signer(this.privateKey);throw new Error("Unsupported suite type "+r)},e.verifier=function(r){if(void 0===r&&(r="Ecdsa"),!this.publicKey)throw new Error("No public key to verify with.");if(m[r])return m[r].verifier(this.publicKey);throw new Error("Unsupported suite type "+r)},e.deriveSecret=function(){var r=c(f.mark((function r(e){var n;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.publicKey,r.next=3,h.from(n);case 3:return r.abrupt("return",t.ecdh(r.sent.publicKey,this.privateKey));case 5:case"end":return r.stop()}}),r,this)})));return function(e){return r.apply(this,arguments)}}(),e.export=function(){var r=c(f.mark((function r(e){return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!w[e.type]){r.next=3;break}return r.abrupt("return",w[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return r.stop()}}),r,this)})));return function(e){return r.apply(this,arguments)}}(),r}(),exports.Secp256k1KeyPair.generate=function(){var r=c(f.mark((function r(e){var t,n,o,i,a,c;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=e.secureRandom,r.next=3,b(t);case 3:return i=(n=r.sent).privateKey,a=v(o=n.publicKey),r.abrupt("return",new h({id:(c="did:key:"+a)+"#"+a,type:"JsonWebKey2020",controller:c,publicKey:o,privateKey:i}));case 10:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),exports.Secp256k1KeyPair.from=function(){var r=c(f.mark((function r(e){var t;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=g[e.type](e),r.abrupt("return",new h({id:e.id,type:e.type,controller:e.controller,publicKey:t.publicKey,privateKey:t.privateKey}));case 2:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),exports.Secp256k1KeyPair=h=e.__decorate([n.staticImplements()],exports.Secp256k1KeyPair);
//# sourceMappingURL=secp256k1-key-pair.cjs.production.min.js.map

@@ -1630,30 +1630,2 @@ import { __decorate } from 'tslib';

_proto.toJsonWebKeyPair = /*#__PURE__*/function () {
var _toJsonWebKeyPair = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(exportPrivateKey) {
return runtime_1.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
if (exportPrivateKey === void 0) {
exportPrivateKey = false;
}
console.warn("DEPRECATION WARNING: .toJsonWebKeyPair should be replaced with .export({type:'JsonWebKey2020'}).");
return _context7.abrupt("return", exportableTypes['JsonWebKey2020'](this.id, this.controller, this.publicKey, exportPrivateKey ? this.privateKey : undefined));
case 3:
case "end":
return _context7.stop();
}
}
}, _callee7, this);
}));
function toJsonWebKeyPair(_x6) {
return _toJsonWebKeyPair.apply(this, arguments);
}
return toJsonWebKeyPair;
}();
return Secp256k1KeyPair;

@@ -1663,15 +1635,15 @@ }();

Secp256k1KeyPair.generate = /*#__PURE__*/function () {
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(_ref4) {
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(_ref4) {
var secureRandom, _yield$_generate, publicKey, privateKey, fingerprint, controller, id;
return runtime_1.wrap(function _callee8$(_context8) {
return runtime_1.wrap(function _callee7$(_context7) {
while (1) {
switch (_context8.prev = _context8.next) {
switch (_context7.prev = _context7.next) {
case 0:
secureRandom = _ref4.secureRandom;
_context8.next = 3;
_context7.next = 3;
return _generate(secureRandom);
case 3:
_yield$_generate = _context8.sent;
_yield$_generate = _context7.sent;
publicKey = _yield$_generate.publicKey;

@@ -1682,3 +1654,3 @@ privateKey = _yield$_generate.privateKey;

id = controller + "#" + fingerprint;
return _context8.abrupt("return", new Secp256k1KeyPair_1({
return _context7.abrupt("return", new Secp256k1KeyPair_1({
id: id,

@@ -1693,9 +1665,9 @@ type: 'JsonWebKey2020',

case "end":
return _context8.stop();
return _context7.stop();
}
}
}, _callee8);
}, _callee7);
}));
return function (_x7) {
return function (_x6) {
return _ref5.apply(this, arguments);

@@ -1706,11 +1678,11 @@ };

Secp256k1KeyPair.from = /*#__PURE__*/function () {
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(k) {
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(k) {
var _importableTypes$k$ty, publicKey, privateKey;
return runtime_1.wrap(function _callee9$(_context9) {
return runtime_1.wrap(function _callee8$(_context8) {
while (1) {
switch (_context9.prev = _context9.next) {
switch (_context8.prev = _context8.next) {
case 0:
_importableTypes$k$ty = importableTypes[k.type](k), publicKey = _importableTypes$k$ty.publicKey, privateKey = _importableTypes$k$ty.privateKey;
return _context9.abrupt("return", new Secp256k1KeyPair_1({
return _context8.abrupt("return", new Secp256k1KeyPair_1({
id: k.id,

@@ -1725,9 +1697,9 @@ type: k.type,

case "end":
return _context9.stop();
return _context8.stop();
}
}
}, _callee9);
}, _callee8);
}));
return function (_x8) {
return function (_x7) {
return _ref6.apply(this, arguments);

@@ -1734,0 +1706,0 @@ };

@@ -38,3 +38,2 @@ import { LdKeyPairInstance } from '@transmute/ld-key-pair';

}): Promise<JsonWebKey2020 | EcdsaSecp256k1VerificationKey2020 | EcdsaSecp256k1VerificationKey2019>;
toJsonWebKeyPair(exportPrivateKey?: boolean): Promise<JsonWebKey2020>;
}

@@ -5,3 +5,3 @@ {

"module": "dist/secp256k1-key-pair.esm.js",
"version": "0.6.1-unstable.37",
"version": "0.7.0-unstable.0",
"license": "Apache-2.0",

@@ -65,3 +65,3 @@ "homepage": "https://github.com/transmute-industries/verifiable-data/tree/main/packages/secp256k1-key-pair",

},
"gitHead": "8eaf1f57fc984fd199e279c441b21597b0193e00"
"gitHead": "c4de441d76ec467a6549bfa8b823d15243c6b19a"
}

@@ -74,3 +74,7 @@ import crypto from 'crypto';

});
const k1 = await kn.toJsonWebKeyPair(true);
const k1 = (await kn.export({
type: 'JsonWebKey2020',
privateKey: true,
})) as JsonWebKey2020;
expect(k1.privateKeyJwk).toEqual({

@@ -77,0 +81,0 @@ kty: 'EC',

@@ -185,13 +185,3 @@ import secp256k1 from 'secp256k1';

async toJsonWebKeyPair(exportPrivateKey = false) {
console.warn(
"DEPRECATION WARNING: .toJsonWebKeyPair should be replaced with .export({type:'JsonWebKey2020'})."
);
return exportableTypes['JsonWebKey2020'](
this.id,
this.controller,
this.publicKey,
exportPrivateKey ? this.privateKey : undefined
);
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc