Skip to content

Commit

Permalink
refactor(eddsa-poseidon): removes unnecessary check
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahredler committed Oct 24, 2024
1 parent 6a9535b commit 8e67348
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/eddsa-poseidon/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ export function checkPrivateKey(privateKey: Buffer | Uint8Array | string): Buffe
export function checkMessage(message: BigNumberish): bigint {
requireTypes(message, "message", ["bignumberish", "string"])

const bigIntMessage =
isBigNumberish(message) && message
? bigNumberishToBigInt(message)
: bufferToBigInt(Buffer.from(message as string))
const bigIntMessage = isBigNumberish(message)
? bigNumberishToBigInt(message)
: bufferToBigInt(Buffer.from(message as string))

const maxLength = 2n ** 256n / 2n - 1n
if (bigIntMessage > maxLength) throw new Error(`Message length is larger than 32 bytes`)
Expand Down

0 comments on commit 8e67348

Please sign in to comment.