Remove unnecessary casting of Buffer to Unit8Array

This commit is contained in:
dapplion 2020-11-28 19:30:56 +00:00
parent b507ed28c0
commit 2c34db8b8e
3 changed files with 4 additions and 4 deletions

View File

@ -3,5 +3,5 @@ export const SIGNATURE_LENGTH = 96;
export const FP_POINT_LENGTH = 48; export const FP_POINT_LENGTH = 48;
export const PUBLIC_KEY_LENGTH = FP_POINT_LENGTH; export const PUBLIC_KEY_LENGTH = FP_POINT_LENGTH;
export const G2_HASH_PADDING = 16; export const G2_HASH_PADDING = 16;
export const EMPTY_PUBLIC_KEY = Uint8Array.from(Buffer.alloc(PUBLIC_KEY_LENGTH)); export const EMPTY_PUBLIC_KEY = new Uint8Array(PUBLIC_KEY_LENGTH);
export const EMPTY_SIGNATURE = Uint8Array.from(Buffer.alloc(SIGNATURE_LENGTH)); export const EMPTY_SIGNATURE = new Uint8Array(SIGNATURE_LENGTH);

View File

@ -98,5 +98,5 @@ function range(n: number): number[] {
} }
function randomMsg(): Uint8Array { function randomMsg(): Uint8Array {
return Uint8Array.from(randomBytes(32)); return randomBytes(32);
} }

View File

@ -1,7 +1,7 @@
import {randomBytes} from "../src/helpers"; import {randomBytes} from "../src/helpers";
export function fromHexString(hex: string): Uint8Array { 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 { export function toHexString(bytes: Buffer | Uint8Array): string {