- Add GETTING_STARTED.md with quick start guide and development modes - Add INSTALL.sh automated installation script - Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md - Add QUICK_REFERENCE.md for common commands - Add SETUP_GUIDE.md with detailed setup instructions - Update README.md with improved project overview - Add did-wallet app dependencies and node_modules
58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.PublicKey = void 0;
|
|
var utils_1 = require("@noble/ciphers/utils");
|
|
var config_1 = require("../config");
|
|
var utils_2 = require("../utils");
|
|
var PublicKey = /** @class */ (function () {
|
|
function PublicKey(data) {
|
|
this.data = (0, utils_2.convertPublicKeyFormat)(data, true);
|
|
}
|
|
PublicKey.fromHex = function (hex) {
|
|
return new PublicKey((0, utils_2.hexToPublicKey)(hex));
|
|
};
|
|
Object.defineProperty(PublicKey.prototype, "uncompressed", {
|
|
get: function () {
|
|
// TODO: Uint8Array
|
|
return Buffer.from((0, utils_2.convertPublicKeyFormat)(this.data, false));
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(PublicKey.prototype, "compressed", {
|
|
get: function () {
|
|
// TODO: Uint8Array
|
|
return Buffer.from(this.data);
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
PublicKey.prototype.toHex = function (compressed) {
|
|
if (compressed === void 0) { compressed = true; }
|
|
if (compressed) {
|
|
return (0, utils_1.bytesToHex)(this.data);
|
|
}
|
|
else {
|
|
return (0, utils_1.bytesToHex)(this.uncompressed);
|
|
}
|
|
};
|
|
PublicKey.prototype.decapsulate = function (sk) {
|
|
var senderPoint;
|
|
var sharedPoint;
|
|
if ((0, config_1.isHkdfKeyCompressed)()) {
|
|
senderPoint = this.data;
|
|
sharedPoint = sk.multiply(this, true);
|
|
}
|
|
else {
|
|
senderPoint = this.uncompressed;
|
|
sharedPoint = sk.multiply(this, false);
|
|
}
|
|
return (0, utils_2.getSharedKey)(senderPoint, sharedPoint);
|
|
};
|
|
PublicKey.prototype.equals = function (other) {
|
|
return (0, utils_1.equalBytes)(this.data, other.data);
|
|
};
|
|
return PublicKey;
|
|
}());
|
|
exports.PublicKey = PublicKey;
|