From cfafdda9f7cf9a6f40145b7f2b26b5ccaedf25b0 Mon Sep 17 00:00:00 2001 From: Antoine FONDEUR Date: Tue, 28 May 2024 15:52:17 +0200 Subject: [PATCH] camelCase fixing and builtin folder --- src/{ => builtins}/pedersen/constants.ts | 0 src/{ => builtins}/pedersen/pedersen.ts | 2 +- src/ui/Code.ts | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) rename src/{ => builtins}/pedersen/constants.ts (100%) rename src/{ => builtins}/pedersen/pedersen.ts (98%) diff --git a/src/pedersen/constants.ts b/src/builtins/pedersen/constants.ts similarity index 100% rename from src/pedersen/constants.ts rename to src/builtins/pedersen/constants.ts diff --git a/src/pedersen/pedersen.ts b/src/builtins/pedersen/pedersen.ts similarity index 98% rename from src/pedersen/pedersen.ts rename to src/builtins/pedersen/pedersen.ts index febdee0..422a308 100644 --- a/src/pedersen/pedersen.ts +++ b/src/builtins/pedersen/pedersen.ts @@ -1,7 +1,7 @@ //The hash function implementation comes from the rust one of Lambdawork: //https://github.com/lambdaclass/lambdaworks/blob/main/crypto/src/hash/pedersen/mod.rs#L43 -function PEDERSEN(x: bigint, y: bigint): bigint { +function pedersen(x: bigint, y: bigint): bigint { var xBool: boolean[] = toBitsLe(x); var yBool: boolean[] = toBitsLe(y); var hash: AffinePoint = SHIFT_POINT; diff --git a/src/ui/Code.ts b/src/ui/Code.ts index 6487961..32b368c 100644 --- a/src/ui/Code.ts +++ b/src/ui/Code.ts @@ -65,3 +65,7 @@ function DECODE_INSTRUCTION(encodedInstruction: string): [any[]] { return [[""]]; } } + +function PEDERSEN(x: number | string, y: number | string): number | string { + return pedersen(BigInt(x), BigInt(y)).toString(16); +}