From 2c34db8b8e599fe1e68113474ce16ecb3c4b250b Mon Sep 17 00:00:00 2001 From: dapplion Date: Sat, 28 Nov 2020 19:30:56 +0000 Subject: [PATCH] Remove unnecessary casting of Buffer to Unit8Array --- src/constants.ts | 4 ++-- test/benchmark/index.ts | 2 +- test/util.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 1169bdd..9da09d2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,5 +3,5 @@ export const SIGNATURE_LENGTH = 96; export const FP_POINT_LENGTH = 48; export const PUBLIC_KEY_LENGTH = FP_POINT_LENGTH; export const G2_HASH_PADDING = 16; -export const EMPTY_PUBLIC_KEY = Uint8Array.from(Buffer.alloc(PUBLIC_KEY_LENGTH)); -export const EMPTY_SIGNATURE = Uint8Array.from(Buffer.alloc(SIGNATURE_LENGTH)); +export const EMPTY_PUBLIC_KEY = new Uint8Array(PUBLIC_KEY_LENGTH); +export const EMPTY_SIGNATURE = new Uint8Array(SIGNATURE_LENGTH); diff --git a/test/benchmark/index.ts b/test/benchmark/index.ts index e2a4c5d..9136baa 100644 --- a/test/benchmark/index.ts +++ b/test/benchmark/index.ts @@ -98,5 +98,5 @@ function range(n: number): number[] { } function randomMsg(): Uint8Array { - return Uint8Array.from(randomBytes(32)); + return randomBytes(32); } diff --git a/test/util.ts b/test/util.ts index 6741237..a122ed7 100644 --- a/test/util.ts +++ b/test/util.ts @@ -1,7 +1,7 @@ import {randomBytes} from "../src/helpers"; export function fromHexString(hex: string): Uint8Array { - return Uint8Array.from(Buffer.from(hex.replace("0x", ""), "hex")); + return Buffer.from(hex.replace("0x", ""), "hex"); } export function toHexString(bytes: Buffer | Uint8Array): string {