Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/test/assembly_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func Test_AsmBench_Add(t *testing.T) {
util.CheckWithFields(t, false, "asm/bench/add", util.ASM_MAX_PADDING, field.BLS12_377, field.KOALABEAR_16)
}

func Test_AsmBench_Euc(t *testing.T) {
util.CheckWithFields(t, false, "asm/bench/euc", util.ASM_MAX_PADDING, field.BLS12_377)
}
func Test_AsmBench_Exp(t *testing.T) {
util.CheckWithFields(t, false, "asm/bench/exp", util.ASM_MAX_PADDING, field.BLS12_377)
}
Expand Down
Binary file added testdata/asm/bench/euc.accepts.bz2
Binary file not shown.
30 changes: 30 additions & 0 deletions testdata/asm/bench/euc.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
;; The Tiny Euclidean Division Module (EUC) is used for checking small
;; (64-bit) divisions are correct. In addition, the function computes
;; a ceiling for the quotient. NOTE: the function does not permit a
;; zero divisor
fn euc(DIVIDEND u64, DIVISOR=1 u64, QUOTIENT u64, REMAINDER u64) -> (CEIL u64)
;; PRE: DIVISOR!=0
{
var val_hi, val_lo u64
var tmp u64
var b, c u1
;; assert divisor is non-zero
if DIVISOR == 0 goto exit_f
;; reconstruct value from quotient / remainder
val_hi,val_lo = (QUOTIENT * DIVISOR) + REMAINDER
;; assert value is consistent
if val_hi != 0 goto exit_f
if val_lo != DIVIDEND goto exit_f
;; assert remainder < divisor
b, tmp = DIVISOR - REMAINDER - 1
if b == 1 goto exit_f
;; Compute ceiling
if REMAINDER == 0 goto exit_0
c, CEIL = QUOTIENT + 1
return
exit_0:
CEIL = QUOTIENT
return
exit_f:
fail
}
Loading