mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-24 01:58:01 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.encodePair = encodePair;
|
||||
const util_1 = require("@pezkuwi/util");
|
||||
const util_crypto_1 = require("@pezkuwi/util-crypto");
|
||||
const defaults_js_1 = require("./defaults.js");
|
||||
/**
|
||||
* Encode a pair with the latest generation format (generation 3)
|
||||
**/
|
||||
function encodePair({ publicKey, secretKey }, passphrase) {
|
||||
if (!secretKey) {
|
||||
throw new Error('Expected a valid secretKey to be passed to encode');
|
||||
}
|
||||
const encoded = (0, util_1.u8aConcat)(defaults_js_1.PAIR_HDR, secretKey, defaults_js_1.PAIR_DIV, publicKey);
|
||||
if (!passphrase) {
|
||||
return encoded;
|
||||
}
|
||||
// this is only for generation 3 (previous generations are only handled in decoding)
|
||||
const { params, password, salt } = (0, util_crypto_1.scryptEncode)(passphrase);
|
||||
const { encrypted, nonce } = (0, util_crypto_1.naclEncrypt)(encoded, password.subarray(0, 32));
|
||||
return (0, util_1.u8aConcat)((0, util_crypto_1.scryptToU8a)(salt, params), nonce, encrypted);
|
||||
}
|
||||
Reference in New Issue
Block a user