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

ton-crypto

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ton-crypto - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

dist/hd/ed25519.d.ts

2

dist/index.d.ts

@@ -12,1 +12,3 @@ export { sha256, sha256_sync } from './primitives/sha256';

export { newSecurePassphrase } from './passwords/newSecurePassphrase';
export { HDKeysState } from './hd/state';
export { getED25519MasterKeyFromSeed, deriveED25519HardenedKey, deriveEd25519Path } from './hd/ed25519';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newSecurePassphrase = exports.newSecureWords = exports.signVerify = exports.sign = exports.keyPairFromSecretKey = exports.keyPairFromSeed = exports.openBox = exports.sealBox = exports.mnemonicWordList = exports.mnemonicToSeed = exports.mnemonicToWalletKey = exports.mnemonicToPrivateKey = exports.mnemonicValidate = exports.mnemonicNew = exports.getSecureRandomNumber = exports.getSecureRandomWords = exports.getSecureRandomBytes = exports.hmac_sha512 = exports.pbkdf2_sha512 = exports.sha512_sync = exports.sha512 = exports.sha256_sync = exports.sha256 = void 0;
exports.deriveEd25519Path = exports.deriveED25519HardenedKey = exports.getED25519MasterKeyFromSeed = exports.newSecurePassphrase = exports.newSecureWords = exports.signVerify = exports.sign = exports.keyPairFromSecretKey = exports.keyPairFromSeed = exports.openBox = exports.sealBox = exports.mnemonicWordList = exports.mnemonicToSeed = exports.mnemonicToWalletKey = exports.mnemonicToPrivateKey = exports.mnemonicValidate = exports.mnemonicNew = exports.getSecureRandomNumber = exports.getSecureRandomWords = exports.getSecureRandomBytes = exports.hmac_sha512 = exports.pbkdf2_sha512 = exports.sha512_sync = exports.sha512 = exports.sha256_sync = exports.sha256 = void 0;
var sha256_1 = require("./primitives/sha256");

@@ -38,1 +38,5 @@ Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha256_1.sha256; } });

Object.defineProperty(exports, "newSecurePassphrase", { enumerable: true, get: function () { return newSecurePassphrase_1.newSecurePassphrase; } });
var ed25519_1 = require("./hd/ed25519");
Object.defineProperty(exports, "getED25519MasterKeyFromSeed", { enumerable: true, get: function () { return ed25519_1.getED25519MasterKeyFromSeed; } });
Object.defineProperty(exports, "deriveED25519HardenedKey", { enumerable: true, get: function () { return ed25519_1.deriveED25519HardenedKey; } });
Object.defineProperty(exports, "deriveEd25519Path", { enumerable: true, get: function () { return ed25519_1.deriveEd25519Path; } });

5

dist/mnemonic/mnemonic.js

@@ -59,4 +59,3 @@ "use strict";

const entropy = await mnemonicToEntropy(mnemonicArray, password);
const res = await (0, pbkdf2_sha512_1.pbkdf2_sha512)(entropy, seed, PBKDF_ITERATIONS, 64);
return res.slice(0, 32);
return await (0, pbkdf2_sha512_1.pbkdf2_sha512)(entropy, seed, PBKDF_ITERATIONS, 64);
}

@@ -77,3 +76,3 @@ exports.mnemonicToSeed = mnemonicToSeed;

const seed = (await mnemonicToSeed(mnemonicArray, 'TON default seed', password));
let keyPair = tweetnacl_1.default.sign.keyPair.fromSeed(seed);
let keyPair = tweetnacl_1.default.sign.keyPair.fromSeed(seed.slice(0, 32));
return {

@@ -80,0 +79,0 @@ publicKey: Buffer.from(keyPair.publicKey),

@@ -5,2 +5,62 @@ "use strict";

const mnemonic_1 = require("./mnemonic");
const testVectors = [
{
mnemonics: ['hospital', 'stove', 'relief', 'fringe', 'tongue', 'always', 'charge', 'angry', 'urge',
'sentence', 'again', 'match', 'nerve', 'inquiry', 'senior', 'coconut', 'label', 'tumble',
'carry', 'category', 'beauty', 'bean', 'road', 'solution'],
key: '9d659a6c2234db7f6e4f977e6e8653b9f5946d557163f31034011375d8f3f97df6c450a16bb1c514e22f1977e390a3025599aa1e7b00068a6aacf2119484c1bd'
},
{
mnemonics: [
'dose', 'ice', 'enrich',
'trigger', 'test', 'dove',
'century', 'still', 'betray',
'gas', 'diet', 'dune',
'use', 'other', 'base',
'gym', 'mad', 'law',
'immense', 'village', 'world',
'example', 'praise', 'game'
],
key: '119dcf2840a3d56521d260b2f125eedc0d4f3795b9e627269a4b5a6dca8257bdc04ad1885c127fe863abb00752fa844e6439bb04f264d70de7cea580b32637ab'
},
{
mnemonics: [
'hobby', 'coil', 'wisdom',
'mechanic', 'fossil', 'pretty',
'enough', 'attract', 'since',
'choice', 'exhaust', 'hazard',
'kit', 'oven', 'damp',
'flip', 'hawk', 'tribe',
'spice', 'glare', 'step',
'hammer', 'apple', 'number'
],
key: '764c63ecdc92b331caf3c5a81c483da8444d4ac87d87af9e3cd36ae207d94e5199ac861b19db16bc0f01adfc6897f4760dfc44f9415284c78689d4fcc28b94f7'
},
{
mnemonics: [
'now', 'wide', 'tag',
'purity', 'diamond', 'coin',
'unit', 'rack', 'device',
'replace', 'cheap', 'deposit',
'mention', 'fence', 'elite',
'elder', 'city', 'measure',
'reward', 'lion', 'chef',
'promote', 'depart', 'connect'
],
key: '2a8a63e0467f1f4148e0be0cc13e922d726f0b1c29272d6743eb83cf5549128f313abf58635fd310310d1debd54f4fe1fd63631ced044ba0af96b67b85eed31b'
},
{
mnemonics: [
'clinic', 'toward', 'wedding',
'category', 'tip', 'spin',
'purity', 'absent', 'army',
'gun', 'brain', 'happy',
'move', 'company', 'that',
'cheap', 'tank', 'way',
'shoe', 'awkward', 'pole',
'protect', 'wear', 'crystal'
],
key: 'e5e78a8e1e509da180bc5aeb8af1a37d4311c5110402842925760a4035119362b1f8a0b9b4c2353ddfad8937ed396fb7670e88e8b72128b15006839a2a86be47'
}
];
describe('mnemonic', () => {

@@ -18,2 +78,19 @@ it('should generate mnemonics', async () => {

});
for (let i = 0; i < testVectors.length; i++) {
it('should match vector #' + i, async () => {
let key = await (0, mnemonic_1.mnemonicToPrivateKey)(testVectors[i].mnemonics);
let wk = await (0, mnemonic_1.mnemonicToWalletKey)(testVectors[i].mnemonics);
expect(key.secretKey.toString('hex')).toEqual(testVectors[i].key);
expect(wk.secretKey.toString('hex')).toEqual(testVectors[i].key);
});
}
it('should generate same keys for mnemonicToPrivateKey and mnemonicToWalletKey', async () => {
for (let i = 0; i < 10; i++) {
let k = await (0, __1.mnemonicNew)();
let key = await (0, mnemonic_1.mnemonicToPrivateKey)(k);
let wk = await (0, mnemonic_1.mnemonicToWalletKey)(k);
expect(key.secretKey.toString('hex')).toEqual(wk.secretKey.toString('hex'));
expect(key.publicKey.toString('hex')).toEqual(wk.publicKey.toString('hex'));
}
});
});
{
"name": "ton-crypto",
"version": "2.1.0",
"version": "3.0.0",
"repository": "https://github.com/ex3ndr/ton-crypto.git",

@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>",

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