New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

boxdjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boxdjs - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "boxdjs",
"version": "1.0.2",
"version": "1.0.3",
"description": "A Javascript implementation of BOX Payout blockchain on NodeJS or Browser.",

@@ -5,0 +5,0 @@ "main": "dist/boxd/boxd.js",

@@ -6,2 +6,3 @@ import Account from './account/account'

import TokenUtil from '../boxd/core/token/util'
import Util from '../boxd/util/util'

@@ -13,2 +14,3 @@ const boxd = {

Feature,
Util,
util: TokenUtil

@@ -15,0 +17,0 @@ }

@@ -63,7 +63,7 @@ import BN from 'bn.js'

.reset('')
.add(CommonUtil.getHexStrFromNumber(op.OP_DUP))
.add(CommonUtil.getHexStrFromNumber(op.OP_HASH_160))
.add(CommonUtil.to16StrFromNumber(op.OP_DUP))
.add(CommonUtil.to16StrFromNumber(op.OP_HASH_160))
.add(pub_hash)
.add(CommonUtil.getHexStrFromNumber(op.OP_EQUAL_VERIFY))
.add(CommonUtil.getHexStrFromNumber(op.OP_CHECK_SIG))
.add(CommonUtil.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(CommonUtil.to16StrFromNumber(op.OP_CHECK_SIG))
.getCode()

@@ -97,7 +97,7 @@ // console.log('script :', script.toString('base64'))

.reset('')
.add(CommonUtil.getHexStrFromNumber(op.OP_DUP))
.add(CommonUtil.getHexStrFromNumber(op.OP_HASH_160))
.add(CommonUtil.to16StrFromNumber(op.OP_DUP))
.add(CommonUtil.to16StrFromNumber(op.OP_HASH_160))
.add(pub_hash)
.add(CommonUtil.getHexStrFromNumber(op.OP_EQUAL_VERIFY))
.add(CommonUtil.getHexStrFromNumber(op.OP_CHECK_SIG))
.add(CommonUtil.to16StrFromNumber(op.OP_EQUAL_VERIFY))
.add(CommonUtil.to16StrFromNumber(op.OP_CHECK_SIG))
.getCode()

@@ -104,0 +104,0 @@ // console.log('script :', script.toString('base64'))

@@ -17,3 +17,3 @@ import scrypt from 'scrypt.js'

namespace CryptoJson {
/**
/**
* @export get-DerivedKey-by-Passphrase

@@ -28,16 +28,15 @@ * @param [passphrase] string

*/
export const getDerivedKey = (
passphrase: string,
salt: Buffer,
n: number,
r: number,
p: number,
dklen: number
) => {
return scrypt(Buffer.from(passphrase), salt, n, r, p, dklen, progress => {
console.log('progress:', progress)
})
}
export const getDerivedKey = (
passphrase: string,
salt: Buffer,
n: number,
r: number,
p: number,
dklen: number
) => {
return scrypt(Buffer.from(passphrase), salt, n, r, p, dklen)
// delete progress
}
/**
/**
* @export get-Crypto-by-PrivateKey&Passphrase

@@ -48,60 +47,60 @@ * @param [privateKey] privateKey

*/
export const getCryptoByPrivKey = (
privateKey: {
toString: (arg0: string) => void;
toP2PKHAddress;
},
passphrase: string
): UtilInterface.Crypto => {
if (!privateKey) {
throw new Error('PrivateKey is require!')
}
export const getCryptoByPrivKey = (
privateKey: {
toString: (arg0: string) => void;
toP2PKHAddress;
},
passphrase: string
): UtilInterface.Crypto => {
if (!privateKey) {
throw new Error('PrivateKey is require!')
}
if (!passphrase) {
throw new Error('Passphrase is require!')
}
if (!passphrase) {
throw new Error('Passphrase is require!')
}
try {
const privateKeyHexStr = privateKey.toString(_STRING_ENC_)
const address = privateKey.toP2PKHAddress
try {
const privateKeyHexStr = privateKey.toString(_STRING_ENC_)
const address = privateKey.toP2PKHAddress
const salt = randomBytes(32)
const iv = randomBytes(aesBlockSize).toString(_STRING_ENC_)
const derivedKey = getDerivedKey(
passphrase,
salt,
scryptOpt.n,
scryptOpt.r,
scryptOpt.p,
scryptOpt.dklen
)
const salt = randomBytes(32)
const iv = randomBytes(aesBlockSize).toString(_STRING_ENC_)
const derivedKey = getDerivedKey(
passphrase,
salt,
scryptOpt.n,
scryptOpt.r,
scryptOpt.p,
scryptOpt.dklen
)
const aesKey = derivedKey.slice(0, 16).toString(_STRING_ENC_)
const sha256Key = derivedKey.slice(16).toString(_STRING_ENC_)
const cipherText = Aes.getCiphertext(aesKey, privateKeyHexStr, iv)
const mac = Aes.getMac(sha256Key, cipherText)
const aesKey = derivedKey.slice(0, 16).toString(_STRING_ENC_)
const sha256Key = derivedKey.slice(16).toString(_STRING_ENC_)
const cipherText = Aes.getCiphertext(aesKey, privateKeyHexStr, iv)
const mac = Aes.getMac(sha256Key, cipherText)
return {
id: '',
address,
crypto: {
cipher: 'aes-128-ctr',
ciphertext: cipherText,
cipherparams: {
iv
},
mac,
kdfparams: {
salt: salt.toString(_STRING_ENC_),
...scryptOpt
}
return {
id: '',
address,
crypto: {
cipher: 'aes-128-ctr',
ciphertext: cipherText,
cipherparams: {
iv
},
mac,
kdfparams: {
salt: salt.toString(_STRING_ENC_),
...scryptOpt
}
}
} catch (err) {
err.message += '[Err:getCryptoJSON]'
throw new Error(err)
}
} catch (err) {
err.message += '[Err:getCryptoJSON]'
throw new Error(err)
}
}
/**
/**
* @export unlock-PrivateKey-by-Passphrase

@@ -112,3 +111,3 @@ * @param [ksJSON] object

*/
/* export const unlockPrivateKeyWithPassphrase = (
/* export const unlockPrivateKeyWithPassphrase = (
ksJSON: { crypto },

@@ -115,0 +114,0 @@ passphrase: string

@@ -24,3 +24,4 @@ import bs58 from 'bs58'

b2: Buffer.from([0x13, 0x28]),
b3: Buffer.from([0x13, 0x2a])
b3: Buffer.from([0x13, 0x2a]),
b5: Buffer.from([0x13, 0x30])
}

@@ -81,3 +82,3 @@

namespace Util {
export const getHexStrFromNumber = (num: number) => (num & 255).toString(16)
export const to16StrFromNumber = (num: number) => (num & 255).toString(16)

@@ -137,12 +138,13 @@ export const getBufFromNumber = (num: number) => num & 255

const and_len = and_buf.length
const and_len_str = getHexStrFromNumber(and_len)
const and_len_str = to16StrFromNumber(and_len)
// console.log('and_len_str :', and_len_str)
if (and_len < OP_PUSH_DATA_1) {
this.opcode = Buffer.from(
this.opcode.toString(OPCODE_TYPE) + and_len_str,
OPCODE_TYPE
)
this.opcode = Buffer.concat([
this.opcode,
Buffer.from(and_len_str, OPCODE_TYPE)
])
} else if (and_len <= 0xff) {
this.opcode = Buffer.concat([
this.opcode,
Buffer.from(getHexStrFromNumber(OP_PUSH_DATA_1), OPCODE_TYPE),
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_1), OPCODE_TYPE),
Buffer.from(and_len_str, OPCODE_TYPE)

@@ -155,3 +157,3 @@ ])

this.opcode,
Buffer.from(getHexStrFromNumber(OP_PUSH_DATA_2), OPCODE_TYPE),
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_2), OPCODE_TYPE),
buf

@@ -164,3 +166,3 @@ ])

this.opcode,
Buffer.from(getHexStrFromNumber(OP_PUSH_DATA_4), OPCODE_TYPE),
Buffer.from(to16StrFromNumber(OP_PUSH_DATA_4), OPCODE_TYPE),
buf

@@ -286,3 +288,3 @@ ])

export const hex2BoxAddr = (prefix: string, hexAddr: string) => {
if (prefix !== ('b1' || 'b2' || 'b3')) {
if (!['b1', 'b2', 'b3', 'b5'].includes(prefix)) {
throw new Error('Incorrect address prefix !')

@@ -289,0 +291,0 @@ }

@@ -42,3 +42,3 @@ import tinySecp from 'tiny-secp256k1'

export const isAddr = (addr: string) => {
if (addr.substring(0, 2) !== ('b1' || 'b2' || 'b3')) {
if (!['b1', 'b2', 'b3', 'b5'].includes(addr.substring(0, 2))) {
throw new Error('Incorrect address format !')

@@ -45,0 +45,0 @@ }

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