From 34b4b7ca83ffe891ecf3f79647a2cd8713d3bba1 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Fri, 24 Apr 2020 00:28:02 -0700 Subject: [PATCH] Remove setLength (alias for setLengthLeft) --- src/bytes.ts | 1 - src/hash.ts | 4 ++-- src/signature.ts | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/bytes.ts b/src/bytes.ts index 5d85cdf4..04bc6c74 100644 --- a/src/bytes.ts +++ b/src/bytes.ts @@ -35,7 +35,6 @@ export const setLengthLeft = function(msg: Buffer, length: number, right: boolea return msg.slice(-length) } } -export const setLength = setLengthLeft /** * Right Pads a `Buffer` with leading zeros till it has `length` bytes. diff --git a/src/hash.ts b/src/hash.ts index 4faff40f..3184af5e 100644 --- a/src/hash.ts +++ b/src/hash.ts @@ -2,7 +2,7 @@ const createKeccakHash = require('keccak') const createHash = require('create-hash') const ethjsUtil = require('ethjs-util') import * as rlp from 'rlp' -import { toBuffer, setLength } from './bytes' +import { toBuffer, setLengthLeft } from './bytes' /** * Creates Keccak hash of the input @@ -54,7 +54,7 @@ export const ripemd160 = function(a: any, padded: boolean): Buffer { .update(a) .digest() if (padded === true) { - return setLength(hash, 32) + return setLengthLeft(hash, 32) } else { return hash } diff --git a/src/signature.ts b/src/signature.ts index 23e09e37..e6c0783b 100644 --- a/src/signature.ts +++ b/src/signature.ts @@ -1,6 +1,6 @@ import * as secp256k1 from 'secp256k1' import * as BN from 'bn.js' -import { toBuffer, setLength, setLengthLeft, bufferToHex } from './bytes' +import { toBuffer, setLengthLeft, bufferToHex } from './bytes' import { keccak } from './hash' export interface ECDSASignature { @@ -40,7 +40,7 @@ export const ecrecover = function( s: Buffer, chainId?: number, ): Buffer { - const signature = Buffer.concat([setLength(r, 32), setLength(s, 32)], 64) + const signature = Buffer.concat([setLengthLeft(r, 32), setLengthLeft(s, 32)], 64) const recovery = calculateSigRecovery(v, chainId) if (!isValidSigRecovery(recovery)) { throw new Error('Invalid signature v value')