ton-crypto
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -6,5 +6,5 @@ export { sha256 } from './primitives/sha256'; | ||
export { getSecureRandomBytes, getSecureRandomWords } from './primitives/getSecureRandom'; | ||
export { mnemonicNew, mnemonicValidate, mnemonicToPrivateKey, mnemonicToWalletKey } from './mnemonic/mnemonic'; | ||
export { mnemonicNew, mnemonicValidate, mnemonicToPrivateKey, mnemonicToWalletKey, mnemonicToSeed } from './mnemonic/mnemonic'; | ||
export { wordlist as mnemonicWordList } from './mnemonic/wordlist'; | ||
export { KeyPair, sealBox, openBox } from './primitives/nacl'; | ||
export { keyPairFromSecretKey, sign } from './primitives/nacl'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sign = exports.keyPairFromSecretKey = exports.openBox = exports.sealBox = exports.mnemonicWordList = exports.mnemonicToWalletKey = exports.mnemonicToPrivateKey = exports.mnemonicValidate = exports.mnemonicNew = exports.getSecureRandomWords = exports.getSecureRandomBytes = exports.hmac_sha512 = exports.pbkdf2_sha512 = exports.sha512 = exports.sha256 = void 0; | ||
exports.sign = exports.keyPairFromSecretKey = exports.openBox = exports.sealBox = exports.mnemonicWordList = exports.mnemonicToSeed = exports.mnemonicToWalletKey = exports.mnemonicToPrivateKey = exports.mnemonicValidate = exports.mnemonicNew = exports.getSecureRandomWords = exports.getSecureRandomBytes = exports.hmac_sha512 = exports.pbkdf2_sha512 = exports.sha512 = exports.sha256 = void 0; | ||
var sha256_1 = require("./primitives/sha256"); | ||
@@ -20,2 +20,3 @@ Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha256_1.sha256; } }); | ||
Object.defineProperty(exports, "mnemonicToWalletKey", { enumerable: true, get: function () { return mnemonic_1.mnemonicToWalletKey; } }); | ||
Object.defineProperty(exports, "mnemonicToSeed", { enumerable: true, get: function () { return mnemonic_1.mnemonicToSeed; } }); | ||
var wordlist_1 = require("./mnemonic/wordlist"); | ||
@@ -22,0 +23,0 @@ Object.defineProperty(exports, "mnemonicWordList", { enumerable: true, get: function () { return wordlist_1.wordlist; } }); |
@@ -0,2 +1,5 @@ | ||
/// <reference types="node" /> | ||
import { KeyPair } from '../primitives/nacl'; | ||
export declare function mnemonicToEntropy(mnemonicArray: string[], password?: string | null | undefined): Promise<Buffer>; | ||
export declare function mnemonicToSeed(mnemonicArray: string[], seed: string, password?: string | null | undefined): Promise<Buffer>; | ||
/** | ||
@@ -3,0 +6,0 @@ * Extract private key from mnemonic |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mnemonicNew = exports.mnemonicValidate = exports.mnemonicToWalletKey = exports.mnemonicToPrivateKey = void 0; | ||
exports.mnemonicNew = exports.mnemonicValidate = exports.mnemonicToWalletKey = exports.mnemonicToPrivateKey = exports.mnemonicToSeed = exports.mnemonicToEntropy = void 0; | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
@@ -51,3 +51,4 @@ const getSecureRandom_1 = require("../primitives/getSecureRandom"); | ||
} | ||
async function mnemonicToSeed(mnemonicArray, password) { | ||
exports.mnemonicToEntropy = mnemonicToEntropy; | ||
async function mnemonicToSeed(mnemonicArray, seed, password) { | ||
// https://github.com/ton-blockchain/ton/blob/24dc184a2ea67f9c47042b4104bbb4d82289fac1/tonlib/tonlib/keys/Mnemonic.cpp#L58 | ||
@@ -60,5 +61,6 @@ // td::SecureString Mnemonic::to_seed() const { | ||
const entropy = await mnemonicToEntropy(mnemonicArray, password); | ||
const seed = await (0, pbkdf2_sha512_1.pbkdf2_sha512)(entropy, "TON default seed", PBKDF_ITERATIONS, 64); | ||
return seed.slice(0, 32); | ||
const res = await (0, pbkdf2_sha512_1.pbkdf2_sha512)(entropy, seed, PBKDF_ITERATIONS, 64); | ||
return res.slice(0, 32); | ||
} | ||
exports.mnemonicToSeed = mnemonicToSeed; | ||
/** | ||
@@ -76,3 +78,3 @@ * Extract private key from mnemonic | ||
mnemonicArray = normalizeMnemonic(mnemonicArray); | ||
const seed = (await mnemonicToSeed(mnemonicArray, password)); | ||
const seed = (await mnemonicToSeed(mnemonicArray, 'TON default seed', password)); | ||
let keyPair = tweetnacl_1.default.sign.keyPair.fromSeed(seed); | ||
@@ -79,0 +81,0 @@ return { |
{ | ||
"name": "ton-crypto", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"repository": "https://github.com/ex3ndr/ton-crypto.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46376
592
17260