@textile/crypto
Advanced tools
Comparing version 2.1.1 to 4.0.0
@@ -27,3 +27,8 @@ /** | ||
*/ | ||
export declare type Private = Identity; | ||
export interface Private extends Identity { | ||
/** | ||
* Return the protobuf-encoded bytes of this private key. | ||
*/ | ||
bytes: Uint8Array; | ||
} | ||
/** | ||
@@ -30,0 +35,0 @@ * Public is any entity associated with a given {@link Identity} that is |
import 'fastestsmallesttextencoderdecoder'; | ||
export { Identity, Private, Public } from './identity'; | ||
export { PrivateKey, PublicKey } from './keypair'; | ||
export { decrypt, encrypt, extractPublicKeyBytes, privateKeyFromString, publicKeyBytesFromString, publicKeyBytesToString, publicKeyToString, } from './utils'; | ||
export { decrypt, encrypt, extractPublicKeyBytes, privateKeyBytesToString, privateKeyFromString, privateKeyToString, publicKeyBytesFromString, publicKeyBytesToString, publicKeyToString, } from './utils'; |
@@ -11,3 +11,5 @@ "use strict"; | ||
Object.defineProperty(exports, "extractPublicKeyBytes", { enumerable: true, get: function () { return utils_1.extractPublicKeyBytes; } }); | ||
Object.defineProperty(exports, "privateKeyBytesToString", { enumerable: true, get: function () { return utils_1.privateKeyBytesToString; } }); | ||
Object.defineProperty(exports, "privateKeyFromString", { enumerable: true, get: function () { return utils_1.privateKeyFromString; } }); | ||
Object.defineProperty(exports, "privateKeyToString", { enumerable: true, get: function () { return utils_1.privateKeyToString; } }); | ||
Object.defineProperty(exports, "publicKeyBytesFromString", { enumerable: true, get: function () { return utils_1.publicKeyBytesFromString; } }); | ||
@@ -14,0 +16,0 @@ Object.defineProperty(exports, "publicKeyBytesToString", { enumerable: true, get: function () { return utils_1.publicKeyBytesToString; } }); |
import { Private, Public } from './identity'; | ||
/** | ||
* Encode the given PrivateKey to its base-32 encoded multibase representation. | ||
* @param key The input PrivateKey. | ||
*/ | ||
export declare function privateKeyToString(key: PrivateKey): string; | ||
/** | ||
* Default implementation of the {@link Public} interface, with encryption | ||
@@ -9,0 +4,0 @@ * support. |
@@ -15,4 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PrivateKey = exports.PublicKey = exports.privateKeyToString = void 0; | ||
const multibase_1 = __importDefault(require("multibase")); | ||
exports.PrivateKey = exports.PublicKey = void 0; | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
@@ -22,11 +21,2 @@ const proto_keys_1 = require("./proto.keys"); | ||
/** | ||
* Encode the given PrivateKey to its base-32 encoded multibase representation. | ||
* @param key The input PrivateKey. | ||
*/ | ||
function privateKeyToString(key) { | ||
const encoded = multibase_1.default.encode('base32', key.bytes); | ||
return new TextDecoder().decode(encoded); | ||
} | ||
exports.privateKeyToString = privateKeyToString; | ||
/** | ||
* Default implementation of the {@link Public} interface, with encryption | ||
@@ -277,3 +267,3 @@ * support. | ||
toString() { | ||
return privateKeyToString(this); | ||
return utils_1.privateKeyToString(this); | ||
} | ||
@@ -280,0 +270,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { Public } from './identity'; | ||
import type { Private, Public } from './identity'; | ||
/** | ||
@@ -29,2 +29,8 @@ * Decrypts the given `data` using a Curve25519 variant of the private key. | ||
/** | ||
* Encode the given privateKey's protobuf-encoded bytes to its base-32 encoded | ||
* multibase representation. | ||
* @param bytes The protobuf-encoded bytes of a {@link Private} key. | ||
*/ | ||
export declare function privateKeyBytesToString(bytes: Uint8Array): string; | ||
/** | ||
* Encode the given PublicKey to its base-32 encoded multibase representation. | ||
@@ -35,2 +41,7 @@ * @param key The {@link Public} key to encode. | ||
/** | ||
* Encode the given PrivateKey to its base-32 encoded multibase representation. | ||
* @param key The input PrivateKey. | ||
*/ | ||
export declare function privateKeyToString(key: Private): string; | ||
/** | ||
* Decode the given base-32 encoded multibase string into a {@link Public} key. | ||
@@ -37,0 +48,0 @@ * @param str The base-32 encoded multibase string. |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractPublicKeyBytes = exports.privateKeyFromString = exports.publicKeyBytesFromString = exports.publicKeyToString = exports.publicKeyBytesToString = exports.encrypt = exports.decrypt = void 0; | ||
exports.extractPublicKeyBytes = exports.privateKeyFromString = exports.publicKeyBytesFromString = exports.privateKeyToString = exports.publicKeyToString = exports.privateKeyBytesToString = exports.publicKeyBytesToString = exports.encrypt = exports.decrypt = void 0; | ||
const ed2curve_1 = require("ed2curve"); | ||
@@ -99,2 +99,12 @@ const multibase_1 = __importDefault(require("multibase")); | ||
/** | ||
* Encode the given privateKey's protobuf-encoded bytes to its base-32 encoded | ||
* multibase representation. | ||
* @param bytes The protobuf-encoded bytes of a {@link Private} key. | ||
*/ | ||
function privateKeyBytesToString(bytes) { | ||
const encoded = multibase_1.default.encode('base32', bytes); | ||
return new TextDecoder().decode(encoded); | ||
} | ||
exports.privateKeyBytesToString = privateKeyBytesToString; | ||
/** | ||
* Encode the given PublicKey to its base-32 encoded multibase representation. | ||
@@ -108,2 +118,10 @@ * @param key The {@link Public} key to encode. | ||
/** | ||
* Encode the given PrivateKey to its base-32 encoded multibase representation. | ||
* @param key The input PrivateKey. | ||
*/ | ||
function privateKeyToString(key) { | ||
return privateKeyBytesToString(key.bytes); | ||
} | ||
exports.privateKeyToString = privateKeyToString; | ||
/** | ||
* Decode the given base-32 encoded multibase string into a {@link Public} key. | ||
@@ -110,0 +128,0 @@ * @param str The base-32 encoded multibase string. |
@@ -27,3 +27,8 @@ /** | ||
*/ | ||
type Private = Identity; | ||
interface Private extends Identity { | ||
/** | ||
* Return the protobuf-encoded bytes of this private key. | ||
*/ | ||
bytes: Uint8Array; | ||
} | ||
/** | ||
@@ -287,2 +292,8 @@ * Public is any entity associated with a given {@link Identity} that is | ||
/** | ||
* Encode the given privateKey's protobuf-encoded bytes to its base-32 encoded | ||
* multibase representation. | ||
* @param bytes The protobuf-encoded bytes of a {@link Private} key. | ||
*/ | ||
declare function privateKeyBytesToString(bytes: Uint8Array): string; | ||
/** | ||
* Encode the given PublicKey to its base-32 encoded multibase representation. | ||
@@ -293,2 +304,7 @@ * @param key The {@link Public} key to encode. | ||
/** | ||
* Encode the given PrivateKey to its base-32 encoded multibase representation. | ||
* @param key The input PrivateKey. | ||
*/ | ||
declare function privateKeyToString(key: Private): string; | ||
/** | ||
* Decode the given base-32 encoded multibase string into a {@link Public} key. | ||
@@ -308,2 +324,2 @@ * @param str The base-32 encoded multibase string. | ||
declare function extractPublicKeyBytes(key: Public): Uint8Array; | ||
export { Identity, Private, Public, PrivateKey, PublicKey, decrypt, encrypt, extractPublicKeyBytes, privateKeyFromString, publicKeyBytesFromString, publicKeyBytesToString, publicKeyToString }; | ||
export { Identity, Private, Public, PrivateKey, PublicKey, decrypt, encrypt, extractPublicKeyBytes, privateKeyBytesToString, privateKeyFromString, privateKeyToString, publicKeyBytesFromString, publicKeyBytesToString, publicKeyToString }; |
{ | ||
"name": "@textile/crypto", | ||
"version": "2.1.1", | ||
"version": "4.0.0", | ||
"description": "Various crypto modules for use with Textile tools/libraries.", | ||
@@ -34,3 +34,3 @@ "main": "dist/cjs/index.js", | ||
}, | ||
"gitHead": "6b64b21189f1b19bddfb81f5eab5dee6ca5ef95c" | ||
"gitHead": "be0b7b39158c3ab240cfd3d9495527f1ee670bab" | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
251579
5792