From e23f480651bc17dd674d13e536d2991b6ee84b9a Mon Sep 17 00:00:00 2001 From: dark64 Date: Tue, 13 Jun 2023 12:43:20 +0200 Subject: [PATCH] remove extra asm assignments --- zokrates_stdlib/stdlib/algebra/biginteger.zok | 11 +++++++---- zokrates_stdlib/stdlib/algebra/biginteger_util.zok | 7 +++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/zokrates_stdlib/stdlib/algebra/biginteger.zok b/zokrates_stdlib/stdlib/algebra/biginteger.zok index 0660baf8..3a801210 100644 --- a/zokrates_stdlib/stdlib/algebra/biginteger.zok +++ b/zokrates_stdlib/stdlib/algebra/biginteger.zok @@ -27,7 +27,8 @@ def bigint_from_u32_limbs(u32[N] limbs) -> BigInteger { // Expand big integer from `N` limbs to `M` limbs def bigint_expand(BigInteger input) -> BigInteger { - return bigint_from_limbs(input.limbs); + BigInteger r = bigint_from_limbs(input.limbs); + return r; } // Big integer addition (a + b) @@ -104,9 +105,11 @@ def bigint_mul(BigInteger a, BigInteger b) -> BigInteger { field[K][3] mut split = [[0; 3]; K]; for u32 i in 0..K { asm { - split[i][0] <-- ovf[i] % (1 << LIMB_BITWIDTH); - split[i][1] <-- (ovf[i] \ (1 << LIMB_BITWIDTH)) % (1 << LIMB_BITWIDTH); - split[i][2] <-- (ovf[i] \ (1 << LIMB_BITWIDTH * 2)) % (1 << LIMB_BITWIDTH); + split[i] <-- [ + (ovf[i] % (1 << LIMB_BITWIDTH)), + (ovf[i] \ (1 << LIMB_BITWIDTH)) % (1 << LIMB_BITWIDTH), + (ovf[i] \ (1 << LIMB_BITWIDTH * 2)) % (1 << LIMB_BITWIDTH) + ]; } } diff --git a/zokrates_stdlib/stdlib/algebra/biginteger_util.zok b/zokrates_stdlib/stdlib/algebra/biginteger_util.zok index 97d8099f..371eca6d 100644 --- a/zokrates_stdlib/stdlib/algebra/biginteger_util.zok +++ b/zokrates_stdlib/stdlib/algebra/biginteger_util.zok @@ -19,12 +19,11 @@ def ilog2(u32 x) -> u32 { } def split(field input) -> field[2] { - field[2] mut r = [0; 2]; + field[2] mut res = [0; 2]; asm { - r[0] <-- input % (1 << N); - r[1] <-- (input \ (1 << N)) % (1 << N); + res <-- [input % (1 << N), (input \ (1 << N)) % (1 << N)]; } - return r; + return res; } def split2(field[K] mut limbs, field[K] mut carry, field[K][3] split) -> (field[K], field[K]) {