Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Remove setLength (alias for setLengthLeft)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke committed Apr 27, 2020
1 parent d2578df commit 34b4b7c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/signature.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 34b4b7c

Please sign in to comment.