Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency: eliminate legacy openssl provider #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var aes = require('browserify-aes')
var assert = require('assert')
var Buffer = require('safe-buffer').Buffer
var bs58check = require('bs58check')
var createHash = require('create-hash')
var { sha256 } = require('@noble/hashes/sha256')
var { ripemd160 } = require('@noble/hashes/ripemd160')
var scrypt = require('scryptsy')
var xor = require('buffer-xor/inplace')

Expand All @@ -20,21 +21,18 @@ var SCRYPT_PARAMS = {
var NULL = Buffer.alloc(0)

function hash160 (buffer) {
var hash
try {
hash = createHash('rmd160')
} catch (e) {
hash = createHash('ripemd160')
}
return hash.update(
createHash('sha256').update(buffer).digest()
var hash = ripemd160.create()
var uint8Arr = hash.update(
sha256.create().update(buffer).digest()
).digest()
return Buffer.from(uint8Arr)
}

function hash256 (buffer) {
return createHash('sha256').update(
createHash('sha256').update(buffer).digest()
var uint8Arr = sha256.create().update(
sha256.create().update(buffer).digest()
).digest()
return Buffer.from(uint8Arr)
}

function getAddress (d, compressed) {
Expand Down Expand Up @@ -213,11 +211,11 @@ function decryptRaw (buffer, passphrase, progressCallback, scryptParams) {
}

async function decryptAsync (string, passphrase, progressCallback, scryptParams, promiseInterval) {
return decryptRawAsync(bs58check.decode(string), passphrase, progressCallback, scryptParams, promiseInterval)
return decryptRawAsync(Buffer.from(bs58check.decode(string)), passphrase, progressCallback, scryptParams, promiseInterval)
}

function decrypt (string, passphrase, progressCallback, scryptParams) {
return decryptRaw(bs58check.decode(string), passphrase, progressCallback, scryptParams)
return decryptRaw(Buffer.from(bs58check.decode(string)), passphrase, progressCallback, scryptParams)
}

function prepareDecryptECMult (buffer, passphrase, progressCallback, scryptParams) {
Expand Down Expand Up @@ -363,8 +361,10 @@ function decryptECMult (buffer, passphrase, progressCallback, scryptParams) {
}

function verify (string) {
var decoded = bs58check.decodeUnsafe(string)
if (!decoded) return false
var unsafe = bs58check.decodeUnsafe(string)
if (!unsafe) return false

var decoded = Buffer.from(unsafe)

if (decoded.length !== 39) return false
if (decoded.readUInt8(0) !== 0x01) return false
Expand Down
Loading