mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
buildasm field finished
This commit is contained in:
@@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
<% function binOp(op) { %>
|
<% function binOp(op) { %>
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; <%= op %>
|
; b<%= op %>
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; Adds two elements of any kind
|
; Adds two elements of any kind
|
||||||
; Params:
|
; Params:
|
||||||
@@ -176,3 +176,42 @@
|
|||||||
<%= binOp("xor") %>
|
<%= binOp("xor") %>
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; bnot
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Adds two elements of any kind
|
||||||
|
; Params:
|
||||||
|
; rsi <= Pointer to element 1
|
||||||
|
; rdi <= Pointer to result
|
||||||
|
; Modified Registers:
|
||||||
|
; r8, r9, 10, r11, rax, rcx
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
<%=name%>_bnot:
|
||||||
|
<%= global.setTypeDest("0x80"); %>
|
||||||
|
|
||||||
|
mov r8, [rsi]
|
||||||
|
bt r8, 63 ; Check if is long operand
|
||||||
|
jc bnot_l1
|
||||||
|
bnot_s:
|
||||||
|
<%= global.toLong_a() %>
|
||||||
|
jmp bnot_l1n
|
||||||
|
|
||||||
|
bnot_l1:
|
||||||
|
bt r8, 62 ; check if montgomery first
|
||||||
|
jnc bnot_l1n
|
||||||
|
|
||||||
|
bnot_l1m:
|
||||||
|
<%= global.fromMont_a() %>
|
||||||
|
|
||||||
|
bnot_l1n:
|
||||||
|
<% for (let i=0; i<n64; i++) { %>
|
||||||
|
mov rax, [rsi + <%= i*8 + 8 %>]
|
||||||
|
not rax
|
||||||
|
<% if (i== n64-1) { %>
|
||||||
|
and rax, [lboMask]
|
||||||
|
<% } %>
|
||||||
|
mov [rdi + <%= i*8 + 8 %>], rax
|
||||||
|
<% } %>
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ class ZqBuilder {
|
|||||||
this.bigInt = bigInt;
|
this.bigInt = bigInt;
|
||||||
this.lastTmp=0;
|
this.lastTmp=0;
|
||||||
this.global = {};
|
this.global = {};
|
||||||
this.global.tmpLabel = function() {
|
this.global.tmpLabel = function(label) {
|
||||||
self.lastTmp++;
|
self.lastTmp++;
|
||||||
return "tmp"+self.lastTmp;
|
label = label || "tmp";
|
||||||
|
return label+"_"+self.lastTmp;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4854
c/buildasm/fr.asm
4854
c/buildasm/fr.asm
File diff suppressed because it is too large
Load Diff
@@ -4,15 +4,20 @@
|
|||||||
global <%=name%>_sub
|
global <%=name%>_sub
|
||||||
global <%=name%>_neg
|
global <%=name%>_neg
|
||||||
global <%=name%>_mul
|
global <%=name%>_mul
|
||||||
|
global <%=name%>_square
|
||||||
global <%=name%>_band
|
global <%=name%>_band
|
||||||
global <%=name%>_bor
|
global <%=name%>_bor
|
||||||
global <%=name%>_bxor
|
global <%=name%>_bxor
|
||||||
|
global <%=name%>_bnot
|
||||||
global <%=name%>_eq
|
global <%=name%>_eq
|
||||||
global <%=name%>_neq
|
global <%=name%>_neq
|
||||||
global <%=name%>_lt
|
global <%=name%>_lt
|
||||||
global <%=name%>_gt
|
global <%=name%>_gt
|
||||||
global <%=name%>_leq
|
global <%=name%>_leq
|
||||||
global <%=name%>_geq
|
global <%=name%>_geq
|
||||||
|
global <%=name%>_land
|
||||||
|
global <%=name%>_lor
|
||||||
|
global <%=name%>_lnot
|
||||||
global <%=name%>_toNormal
|
global <%=name%>_toNormal
|
||||||
global <%=name%>_toMontgomery
|
global <%=name%>_toMontgomery
|
||||||
global <%=name%>_q
|
global <%=name%>_q
|
||||||
@@ -28,6 +33,7 @@
|
|||||||
<%- include('mul.asm.ejs'); %>
|
<%- include('mul.asm.ejs'); %>
|
||||||
<%- include('binops.asm.ejs'); %>
|
<%- include('binops.asm.ejs'); %>
|
||||||
<%- include('cmpops.asm.ejs'); %>
|
<%- include('cmpops.asm.ejs'); %>
|
||||||
|
<%- include('logicalops.asm.ejs'); %>
|
||||||
|
|
||||||
section .data
|
section .data
|
||||||
<%=name%>_q:
|
<%=name%>_q:
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
#include "fr.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gmp.h>
|
|
||||||
|
|
||||||
void Fr_str2element(PFrElement pE, char *s) {
|
|
||||||
mpz_t r;
|
|
||||||
mpz_init(r);
|
|
||||||
mpz_set_str(r, s, 10);
|
|
||||||
pE->type = Fr_LONG;
|
|
||||||
for (int i=0; i<Fr_N64; i++) pE->longVal[i] = 0;
|
|
||||||
mpz_export((void *)pE->longVal, NULL, -1, 8, -1, 0, r);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Fr_element2str(PFrElement pE) {
|
|
||||||
mpz_t r;
|
|
||||||
mpz_t q;
|
|
||||||
if (pE->type == Fr_SHORT) {
|
|
||||||
if (pE->shortVal>=0) {
|
|
||||||
char *r = new char[32];
|
|
||||||
sprintf(r, "%d", pE->shortVal);
|
|
||||||
return r;
|
|
||||||
} else {
|
|
||||||
mpz_init(q);
|
|
||||||
mpz_import(q, Fr_N64, -1, 8, -1, 0, (const void *)Fr_q.longVal);
|
|
||||||
mpz_init_set_si(r, pE->shortVal);
|
|
||||||
mpz_add(r, r, q);
|
|
||||||
mpz_clear(q);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Fr_toNormal(pE);
|
|
||||||
mpz_init(r);
|
|
||||||
mpz_import(r, Fr_N64, -1, 8, -1, 0, (const void *)pE->longVal);
|
|
||||||
}
|
|
||||||
char *res = mpz_get_str (0, 10, r);
|
|
||||||
mpz_clear(r);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ void <%=name%>_str2element(P<%=name%>Element pE, char *s) {
|
|||||||
char *<%=name%>_element2str(P<%=name%>Element pE) {
|
char *<%=name%>_element2str(P<%=name%>Element pE) {
|
||||||
mpz_t r;
|
mpz_t r;
|
||||||
mpz_t q;
|
mpz_t q;
|
||||||
if (pE->type == <%=name%>_SHORT) {
|
if (!(pE->type & <%=name%>_LONG)) {
|
||||||
if (pE->shortVal>=0) {
|
if (pE->shortVal>=0) {
|
||||||
char *r = new char[32];
|
char *r = new char[32];
|
||||||
sprintf(r, "%d", pE->shortVal);
|
sprintf(r, "%d", pE->shortVal);
|
||||||
@@ -37,3 +37,70 @@ char *<%=name%>_element2str(P<%=name%>Element pE) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void <%=name%>_toMpz(mpz_t r, P<%=name%>Element pE) {
|
||||||
|
mpz_t q;
|
||||||
|
<%=name%>_toNormal(pE);
|
||||||
|
if (!(pE->type & <%=name%>_LONG)) {
|
||||||
|
mpz_set_si(r, pE->shortVal);
|
||||||
|
if (pE->shortVal<0) {
|
||||||
|
mpz_init(q);
|
||||||
|
mpz_import(q, <%=name%>_N64, -1, 8, -1, 0, (const void *)Fr_q.longVal);
|
||||||
|
mpz_add(r, r, q);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mpz_import(r, <%=name%>_N64, -1, 8, -1, 0, (const void *)pE->longVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void <%=name%>_fromMpz(P<%=name%>Element pE, mpz_t v) {
|
||||||
|
if (mpz_fits_sint_p(v)) {
|
||||||
|
pE->type = <%=name%>_SHORT;
|
||||||
|
pE->shortVal = mpz_get_si(v);
|
||||||
|
} else {
|
||||||
|
pE->type = <%=name%>_LONG;
|
||||||
|
for (int i=0; i<<%=name%>_N64; i++) pE->longVal[i] = 0;
|
||||||
|
mpz_export((void *)(pE->longVal), NULL, -1, 8, -1, 0, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void <%=name%>_idiv(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b) {
|
||||||
|
mpz_t ma;
|
||||||
|
mpz_t mb;
|
||||||
|
mpz_t mr;
|
||||||
|
mpz_init(ma);
|
||||||
|
mpz_init(mb);
|
||||||
|
mpz_init(mr);
|
||||||
|
|
||||||
|
<%=name%>_toMpz(ma, a);
|
||||||
|
// char *s1 = mpz_get_str (0, 10, ma);
|
||||||
|
// printf("s1 %s\n", s1);
|
||||||
|
<%=name%>_toMpz(mb, b);
|
||||||
|
// char *s2 = mpz_get_str (0, 10, mb);
|
||||||
|
// printf("s2 %s\n", s2);
|
||||||
|
mpz_fdiv_q(mr, ma, mb);
|
||||||
|
// char *sr = mpz_get_str (0, 10, mr);
|
||||||
|
// printf("r %s\n", sr);
|
||||||
|
<%=name%>_fromMpz(r, mr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void <%=name%>_inv(P<%=name%>Element r, P<%=name%>Element a) {
|
||||||
|
mpz_t ma;
|
||||||
|
mpz_t mr;
|
||||||
|
mpz_t q;
|
||||||
|
mpz_init(ma);
|
||||||
|
mpz_init(mr);
|
||||||
|
|
||||||
|
mpz_init(q);
|
||||||
|
mpz_import(q, <%=name%>_N64, -1, 8, -1, 0, (const void *)Fr_q.longVal);
|
||||||
|
|
||||||
|
<%=name%>_toMpz(ma, a);
|
||||||
|
mpz_invert(mr, ma, q);
|
||||||
|
<%=name%>_fromMpz(r, mr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void <%=name%>_div(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b) {
|
||||||
|
<%=name%>Element tmp;
|
||||||
|
<%=name%>_inv(&tmp, b);
|
||||||
|
<%=name%>_mul(r, a, &tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,18 +14,27 @@ extern "C" void <%=name%>_add(P<%=name%>Element r, P<%=name%>Element a, P<%=name
|
|||||||
extern "C" void <%=name%>_sub(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_sub(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_neg(P<%=name%>Element r, P<%=name%>Element a);
|
extern "C" void <%=name%>_neg(P<%=name%>Element r, P<%=name%>Element a);
|
||||||
extern "C" void <%=name%>_mul(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_mul(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
extern "C" void <%=name%>_square(P<%=name%>Element r, P<%=name%>Element a);
|
||||||
extern "C" void <%=name%>_band(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_band(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_bor(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_bor(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_bxor(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_bxor(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
extern "C" void <%=name%>_bnot(P<%=name%>Element r, P<%=name%>Element a);
|
||||||
extern "C" void <%=name%>_eq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_eq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_neq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_neq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_lt(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_lt(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_gt(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_gt(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_leq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_leq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
extern "C" void <%=name%>_geq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
extern "C" void <%=name%>_geq(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
extern "C" void <%=name%>_land(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
extern "C" void <%=name%>_lor(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
extern "C" void <%=name%>_lnot(P<%=name%>Element r, P<%=name%>Element a);
|
||||||
extern "C" void <%=name%>_toNormal(P<%=name%>Element pE);
|
extern "C" void <%=name%>_toNormal(P<%=name%>Element pE);
|
||||||
extern "C" void <%=name%>_toMontgomery(P<%=name%>Element pE);
|
extern "C" void <%=name%>_toMontgomery(P<%=name%>Element pE);
|
||||||
void <%=name%>_str2element(P<%=name%>Element pE, char *s);
|
void <%=name%>_str2element(P<%=name%>Element pE, char *s);
|
||||||
char *<%=name%>_element2str(P<%=name%>Element pE);
|
char *<%=name%>_element2str(P<%=name%>Element pE);
|
||||||
|
void <%=name%>_idiv(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
void <%=name%>_inv(P<%=name%>Element r, P<%=name%>Element a);
|
||||||
|
void <%=name%>_div(P<%=name%>Element r, P<%=name%>Element a, P<%=name%>Element b);
|
||||||
|
|
||||||
extern <%=name%>Element <%=name%>_q;
|
extern <%=name%>Element <%=name%>_q;
|
||||||
|
|
||||||
|
|||||||
BIN
c/buildasm/fr.o
BIN
c/buildasm/fr.o
Binary file not shown.
82
c/buildasm/logicalops.asm.ejs
Normal file
82
c/buildasm/logicalops.asm.ejs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<% function isTrue(resReg, srcPtrReg) { %>
|
||||||
|
<% const longIsZero = global.tmpLabel() %>
|
||||||
|
<% const retOne = global.tmpLabel("retOne") %>
|
||||||
|
<% const retZero = global.tmpLabel("retZero") %>
|
||||||
|
<% const done = global.tmpLabel("done") %>
|
||||||
|
|
||||||
|
mov rax, [<%=srcPtrReg%>]
|
||||||
|
bt rax, 63
|
||||||
|
jc <%= longIsZero %>
|
||||||
|
|
||||||
|
test eax, eax
|
||||||
|
jz <%= retZero %>
|
||||||
|
jmp <%= retOne %>
|
||||||
|
|
||||||
|
<%= longIsZero %>:
|
||||||
|
<% for (let i=0; i<n64; i++) { %>
|
||||||
|
mov rax, [<%= srcPtrReg + " + " +(i*8+8) %>]
|
||||||
|
test rax, rax
|
||||||
|
jnz <%= retOne %>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<%= retZero %>:
|
||||||
|
mov qword <%=resReg%>, 0
|
||||||
|
jmp <%= done %>
|
||||||
|
|
||||||
|
<%= retOne %>:
|
||||||
|
mov qword <%=resReg%>, 1
|
||||||
|
|
||||||
|
<%= done %>:
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% function logicalOp(op) { %>
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; l<%= op %>
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Logical <%= op %> between two elements
|
||||||
|
; Params:
|
||||||
|
; rsi <= Pointer to element 1
|
||||||
|
; rdx <= Pointer to element 2
|
||||||
|
; rdi <= Pointer to result zero or one
|
||||||
|
; Modified Registers:
|
||||||
|
; rax, rcx, r8
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
<%=name%>_l<%=op%>:
|
||||||
|
<%= isTrue("r8", "rsi") %>
|
||||||
|
<%= isTrue("rcx", "rdx") %>
|
||||||
|
<%=op%> rcx, r8
|
||||||
|
mov [rdi], rcx
|
||||||
|
ret
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% logicalOp("and"); %>
|
||||||
|
<% logicalOp("or"); %>
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; lnot
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Do the logical not of an element
|
||||||
|
; Params:
|
||||||
|
; rsi <= Pointer to element to be tested
|
||||||
|
; rdi <= Pointer to result one if element1 is zero and zero otherwise
|
||||||
|
; Modified Registers:
|
||||||
|
; rax, rax, r8
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
<%=name%>_lnot:
|
||||||
|
<%= isTrue("rcx", "rsi") %>
|
||||||
|
test rcx, rcx
|
||||||
|
|
||||||
|
jz lnot_retOne
|
||||||
|
lnot_retZero:
|
||||||
|
mov qword [rdi], 0
|
||||||
|
ret
|
||||||
|
lnot_retOne:
|
||||||
|
mov qword [rdi], 1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
BIN
c/buildasm/main
BIN
c/buildasm/main
Binary file not shown.
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>English</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>com.apple.xcode.dsym.main</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>dSYM</string>
|
|
||||||
<key>CFBundleSignature</key>
|
|
||||||
<string>????</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>1</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
Binary file not shown.
@@ -144,6 +144,47 @@ montgomeryTemplate("rawMontgomeryMul", function(i, r0, r1, r2) {
|
|||||||
})
|
})
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; rawMontgomerySquare
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Square an element
|
||||||
|
; Params:
|
||||||
|
; rsi <= Pointer to the long data of element 1
|
||||||
|
; rdi <= Pointer to the long data of result
|
||||||
|
; Modified registers:
|
||||||
|
; r8, r9, 10, r11, rax, rcx
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
<%
|
||||||
|
montgomeryTemplate("rawMontgomerySquare", function(i, r0, r1, r2) {
|
||||||
|
// Same Digit
|
||||||
|
for (let o1=Math.max(0, i-n64+1); (o1<((i+1)>>1) )&&(o1<n64); o1++) {
|
||||||
|
const o2= i-o1;
|
||||||
|
%>
|
||||||
|
mov rax, [rsi + <%= 8*o1 %>]
|
||||||
|
mul qword [rsi + <%= 8*o2 %>]
|
||||||
|
add <%= r0 %>, rax
|
||||||
|
adc <%= r1 %>, rdx
|
||||||
|
adc <%= r2 %>, 0x0
|
||||||
|
add <%= r0 %>, rax
|
||||||
|
adc <%= r1 %>, rdx
|
||||||
|
adc <%= r2 %>, 0x0
|
||||||
|
<%
|
||||||
|
} // Same digit
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if (i%2 == 0) { %>
|
||||||
|
mov rax, [rsi + <%= 8*(i/2) %>]
|
||||||
|
mul rax
|
||||||
|
add <%= r0 %>, rax
|
||||||
|
adc <%= r1 %>, rdx
|
||||||
|
adc <%= r2 %>, 0x0
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
})
|
||||||
|
%>
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; rawMontgomeryMul1
|
; rawMontgomeryMul1
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
@@ -16,6 +16,24 @@ mul_manageOverflow: ; Do the operation in 64 bits
|
|||||||
pop rsi
|
pop rsi
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<% function squareS1() { %>
|
||||||
|
xor rax, rax
|
||||||
|
mov eax, r8d
|
||||||
|
imul eax
|
||||||
|
jo square_manageOverflow ; rsi already is the 64bits result
|
||||||
|
|
||||||
|
mov [rdi], rax ; not necessary to adjust so just save and return
|
||||||
|
|
||||||
|
square_manageOverflow: ; Do the operation in 64 bits
|
||||||
|
push rsi
|
||||||
|
movsx rax, r8d
|
||||||
|
imul rax
|
||||||
|
mov rsi, rax
|
||||||
|
call rawCopyS2L
|
||||||
|
pop rsi
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
<% function mulL1S2(t) { %>
|
<% function mulL1S2(t) { %>
|
||||||
push rsi
|
push rsi
|
||||||
add rsi, 8
|
add rsi, 8
|
||||||
@@ -73,6 +91,15 @@ mul_manageOverflow: ; Do the operation in 64 bits
|
|||||||
sub rsi, 8
|
sub rsi, 8
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
<% function squareL1() { %>
|
||||||
|
add rdi, 8
|
||||||
|
add rsi, 8
|
||||||
|
call rawMontgomerySquare
|
||||||
|
sub rdi, 8
|
||||||
|
sub rsi, 8
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<% function mulR3() { %>
|
<% function mulR3() { %>
|
||||||
push rsi
|
push rsi
|
||||||
add rdi, 8
|
add rdi, 8
|
||||||
@@ -84,6 +111,43 @@ mul_manageOverflow: ; Do the operation in 64 bits
|
|||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; square
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Squares a field element
|
||||||
|
; Params:
|
||||||
|
; rsi <= Pointer to element 1
|
||||||
|
; rdi <= Pointer to result
|
||||||
|
; [rdi] = [rsi] * [rsi]
|
||||||
|
; Modified Registers:
|
||||||
|
; r8, r9, 10, r11, rax, rcx
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
<%=name%>_square:
|
||||||
|
mov r8, [rsi]
|
||||||
|
bt r8, 63 ; Check if is short first operand
|
||||||
|
jc square_l1
|
||||||
|
|
||||||
|
square_s1: ; Both operands are short
|
||||||
|
<%= squareS1() %>
|
||||||
|
ret
|
||||||
|
|
||||||
|
square_l1:
|
||||||
|
bt r8, 62 ; check if montgomery first
|
||||||
|
jc square_l1m
|
||||||
|
square_l1n:
|
||||||
|
<%= global.setTypeDest("0xC0"); %>
|
||||||
|
<%= squareL1() %>
|
||||||
|
<%= mulR3() %>
|
||||||
|
ret
|
||||||
|
|
||||||
|
square_l1m:
|
||||||
|
<%= global.setTypeDest("0xC0"); %>
|
||||||
|
<%= squareL1() %>
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; mul
|
; mul
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
@@ -1,219 +0,0 @@
|
|||||||
# Path: main
|
|
||||||
# Arch: x86_64
|
|
||||||
# Object files:
|
|
||||||
[ 0] linker synthesized
|
|
||||||
[ 1] /var/folders/g_/74y0ll3503d4sm0c64jw432r0000gn/T//cczqYl2H.o
|
|
||||||
[ 2] fr.o
|
|
||||||
[ 3] /var/folders/g_/74y0ll3503d4sm0c64jw432r0000gn/T//cc5nHggh.o
|
|
||||||
[ 4] /usr/local/lib/libgmp.dylib
|
|
||||||
[ 5] /usr/local/Cellar/gcc/9.2.0_2/lib/gcc/9/libstdc++.dylib
|
|
||||||
[ 6] /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd
|
|
||||||
# Sections:
|
|
||||||
# Address Size Segment Section
|
|
||||||
0x1000011BD 0x00001C99 __TEXT __text
|
|
||||||
0x100002E56 0x00000042 __TEXT __stubs
|
|
||||||
0x100002E98 0x00000074 __TEXT __stub_helper
|
|
||||||
0x100002F0C 0x0000001B __TEXT __cstring
|
|
||||||
0x100002F28 0x000000D8 __TEXT __eh_frame
|
|
||||||
0x100003000 0x00000008 __DATA_CONST __got
|
|
||||||
0x100004000 0x00000058 __DATA __la_symbol_ptr
|
|
||||||
0x100004058 0x00000078 __DATA __data
|
|
||||||
# Symbols:
|
|
||||||
# Address Size File Name
|
|
||||||
0x1000011BD 0x000000E2 [ 1] _main
|
|
||||||
0x10000129F 0x00000023 [ 2] rawCopyS2L
|
|
||||||
0x1000012C2 0x0000003D [ 2] u64toLong_adjust_neg
|
|
||||||
0x1000012FF 0x00000301 [ 2] rawMontgomeryMul
|
|
||||||
0x100001600 0x0000002B [ 2] rawMontgomeryMul_mulM_sq
|
|
||||||
0x10000162B 0x00000005 [ 2] rawMontgomeryMul_mulM_done
|
|
||||||
0x100001630 0x0000022C [ 2] rawMontgomeryMul1
|
|
||||||
0x10000185C 0x0000002B [ 2] rawMontgomeryMul1_mulM_sq
|
|
||||||
0x100001887 0x00000005 [ 2] rawMontgomeryMul1_mulM_done
|
|
||||||
0x10000188C 0x00000218 [ 2] rawFromMontgomery
|
|
||||||
0x100001AA4 0x0000002B [ 2] rawFromMontgomery_mulM_sq
|
|
||||||
0x100001ACF 0x00000005 [ 2] rawFromMontgomery_mulM_done
|
|
||||||
0x100001AD4 0x00000011 [ 2] _Fr_toMontgomery
|
|
||||||
0x100001AE5 0x00000018 [ 2] toMontgomeryShort
|
|
||||||
0x100001AFD 0x0000000B [ 2] posMontgomeryShort
|
|
||||||
0x100001B08 0x00000016 [ 2] negMontgomeryShort
|
|
||||||
0x100001B1E 0x0000001C [ 2] toMontgomeryLong
|
|
||||||
0x100001B3A 0x00000001 [ 2] toMontgomery_doNothing
|
|
||||||
0x100001B3B 0x00000011 [ 2] _Fr_toNormal
|
|
||||||
0x100001B4C 0x00000010 [ 2] fromMontgomeryLong
|
|
||||||
0x100001B5C 0x00000001 [ 2] fromMontgomery_doNothing
|
|
||||||
0x100001B5D 0x00000018 [ 2] _Fr_add
|
|
||||||
0x100001B75 0x0000000D [ 2] add_s1s2
|
|
||||||
0x100001B82 0x00000011 [ 2] add_manageOverflow
|
|
||||||
0x100001B93 0x0000000B [ 2] add_l1
|
|
||||||
0x100001B9E 0x00000007 [ 2] add_l1s2
|
|
||||||
0x100001BA5 0x0000002C [ 2] add_l1ns2
|
|
||||||
0x100001BD1 0x0000000E [ 2] tmp1
|
|
||||||
0x100001BDF 0x00000007 [ 2] add_l1ms2
|
|
||||||
0x100001BE6 0x00000031 [ 2] add_l1ms2n
|
|
||||||
0x100001C17 0x00000024 [ 2] add_l1ms2m
|
|
||||||
0x100001C3B 0x00000007 [ 2] add_s1l2
|
|
||||||
0x100001C42 0x0000002C [ 2] add_s1l2n
|
|
||||||
0x100001C6E 0x0000000E [ 2] tmp2
|
|
||||||
0x100001C7C 0x00000007 [ 2] add_s1l2m
|
|
||||||
0x100001C83 0x00000037 [ 2] add_s1nl2m
|
|
||||||
0x100001CBA 0x00000024 [ 2] add_s1ml2m
|
|
||||||
0x100001CDE 0x00000007 [ 2] add_l1l2
|
|
||||||
0x100001CE5 0x00000007 [ 2] add_l1nl2
|
|
||||||
0x100001CEC 0x00000024 [ 2] add_l1nl2n
|
|
||||||
0x100001D10 0x00000037 [ 2] add_l1nl2m
|
|
||||||
0x100001D47 0x00000007 [ 2] add_l1ml2
|
|
||||||
0x100001D4E 0x00000031 [ 2] add_l1ml2n
|
|
||||||
0x100001D7F 0x00000024 [ 2] add_l1ml2m
|
|
||||||
0x100001DA3 0x00000066 [ 2] rawAddLL
|
|
||||||
0x100001E09 0x0000002B [ 2] rawAddLL_sq
|
|
||||||
0x100001E34 0x00000001 [ 2] rawAddLL_done
|
|
||||||
0x100001E35 0x0000006A [ 2] rawAddLS
|
|
||||||
0x100001E9F 0x0000002B [ 2] rawAddLS_sq
|
|
||||||
0x100001ECA 0x00000001 [ 2] rawAddLS_done
|
|
||||||
0x100001ECB 0x00000018 [ 2] _Fr_sub
|
|
||||||
0x100001EE3 0x0000000D [ 2] sub_s1s2
|
|
||||||
0x100001EF0 0x00000011 [ 2] sub_manageOverflow
|
|
||||||
0x100001F01 0x0000000B [ 2] sub_l1
|
|
||||||
0x100001F0C 0x00000007 [ 2] sub_l1s2
|
|
||||||
0x100001F13 0x0000002C [ 2] sub_l1ns2
|
|
||||||
0x100001F3F 0x0000000E [ 2] tmp3
|
|
||||||
0x100001F4D 0x00000007 [ 2] sub_l1ms2
|
|
||||||
0x100001F54 0x00000031 [ 2] sub_l1ms2n
|
|
||||||
0x100001F85 0x00000024 [ 2] sub_l1ms2m
|
|
||||||
0x100001FA9 0x00000007 [ 2] sub_s1l2
|
|
||||||
0x100001FB0 0x00000026 [ 2] sub_s1l2n
|
|
||||||
0x100001FD6 0x0000001A [ 2] tmp4
|
|
||||||
0x100001FF0 0x00000007 [ 2] sub_s1l2m
|
|
||||||
0x100001FF7 0x00000037 [ 2] sub_s1nl2m
|
|
||||||
0x10000202E 0x00000024 [ 2] sub_s1ml2m
|
|
||||||
0x100002052 0x00000007 [ 2] sub_l1l2
|
|
||||||
0x100002059 0x00000007 [ 2] sub_l1nl2
|
|
||||||
0x100002060 0x00000024 [ 2] sub_l1nl2n
|
|
||||||
0x100002084 0x00000037 [ 2] sub_l1nl2m
|
|
||||||
0x1000020BB 0x00000007 [ 2] sub_l1ml2
|
|
||||||
0x1000020C2 0x00000031 [ 2] sub_l1ml2n
|
|
||||||
0x1000020F3 0x00000024 [ 2] sub_l1ml2m
|
|
||||||
0x100002117 0x00000031 [ 2] rawSubLS
|
|
||||||
0x100002148 0x0000002B [ 2] rawSubLS_aq
|
|
||||||
0x100002173 0x00000001 [ 2] rawSubLS_done
|
|
||||||
0x100002174 0x0000002F [ 2] rawSubSL
|
|
||||||
0x1000021A3 0x0000002B [ 2] rawSubSL_aq
|
|
||||||
0x1000021CE 0x00000001 [ 2] rawSubSL_done
|
|
||||||
0x1000021CF 0x0000002F [ 2] rawSubLL
|
|
||||||
0x1000021FE 0x0000002B [ 2] rawSubLL_aq
|
|
||||||
0x100002229 0x00000001 [ 2] rawSubLL_done
|
|
||||||
0x10000222A 0x0000009C [ 2] rawNegLS
|
|
||||||
0x1000022C6 0x00000001 [ 2] rawNegSL_done
|
|
||||||
0x1000022C7 0x0000000A [ 2] _Fr_neg
|
|
||||||
0x1000022D1 0x00000008 [ 2] neg_s
|
|
||||||
0x1000022D9 0x0000000E [ 2] neg_manageOverflow
|
|
||||||
0x1000022E7 0x00000019 [ 2] neg_l
|
|
||||||
0x100002300 0x0000002A [ 2] rawNegL
|
|
||||||
0x10000232A 0x0000003B [ 2] doNegate
|
|
||||||
0x100002365 0x00000018 [ 2] _Fr_mul
|
|
||||||
0x10000237D 0x0000000E [ 2] mul_s1s2
|
|
||||||
0x10000238B 0x00000014 [ 2] mul_manageOverflow
|
|
||||||
0x10000239F 0x0000000B [ 2] mul_l1
|
|
||||||
0x1000023AA 0x0000000B [ 2] mul_l1s2
|
|
||||||
0x1000023B5 0x00000007 [ 2] mul_l1ns2
|
|
||||||
0x1000023BC 0x00000033 [ 2] mul_l1ns2n
|
|
||||||
0x1000023EF 0x0000000A [ 2] tmp5
|
|
||||||
0x1000023F9 0x0000001A [ 2] tmp6
|
|
||||||
0x100002413 0x00000024 [ 2] mul_l1ns2m
|
|
||||||
0x100002437 0x00000007 [ 2] mul_l1ms2
|
|
||||||
0x10000243E 0x00000033 [ 2] mul_l1ms2n
|
|
||||||
0x100002471 0x0000000A [ 2] tmp7
|
|
||||||
0x10000247B 0x00000001 [ 2] tmp8
|
|
||||||
0x10000247C 0x00000024 [ 2] mul_l1ms2m
|
|
||||||
0x1000024A0 0x0000000B [ 2] mul_s1l2
|
|
||||||
0x1000024AB 0x00000007 [ 2] mul_s1nl2
|
|
||||||
0x1000024B2 0x00000033 [ 2] mul_s1nl2n
|
|
||||||
0x1000024E5 0x0000000A [ 2] tmp9
|
|
||||||
0x1000024EF 0x0000001A [ 2] tmp10
|
|
||||||
0x100002509 0x00000033 [ 2] mul_s1nl2m
|
|
||||||
0x10000253C 0x0000000A [ 2] tmp11
|
|
||||||
0x100002546 0x00000001 [ 2] tmp12
|
|
||||||
0x100002547 0x00000007 [ 2] mul_s1ml2
|
|
||||||
0x10000254E 0x00000024 [ 2] mul_s1ml2n
|
|
||||||
0x100002572 0x00000024 [ 2] mul_s1ml2m
|
|
||||||
0x100002596 0x00000007 [ 2] mul_l1l2
|
|
||||||
0x10000259D 0x00000007 [ 2] mul_l1nl2
|
|
||||||
0x1000025A4 0x0000003D [ 2] mul_l1nl2n
|
|
||||||
0x1000025E1 0x00000024 [ 2] mul_l1nl2m
|
|
||||||
0x100002605 0x00000007 [ 2] mul_l1ml2
|
|
||||||
0x10000260C 0x00000024 [ 2] mul_l1ml2n
|
|
||||||
0x100002630 0x00000024 [ 2] mul_l1ml2m
|
|
||||||
0x100002654 0x0000001C [ 2] _Fr_band
|
|
||||||
0x100002670 0x00000019 [ 2] and_s1s2
|
|
||||||
0x100002689 0x00000012 [ 2] tmp13
|
|
||||||
0x10000269B 0x00000054 [ 2] tmp14
|
|
||||||
0x1000026EF 0x0000000B [ 2] and_l1
|
|
||||||
0x1000026FA 0x0000000B [ 2] and_l1s2
|
|
||||||
0x100002705 0x00000044 [ 2] and_l1ns2
|
|
||||||
0x100002749 0x00000054 [ 2] tmp15
|
|
||||||
0x10000279D 0x00000059 [ 2] and_l1ms2
|
|
||||||
0x1000027F6 0x00000054 [ 2] tmp16
|
|
||||||
0x10000284A 0x0000000B [ 2] and_s1l2
|
|
||||||
0x100002855 0x00000044 [ 2] and_s1l2n
|
|
||||||
0x100002899 0x00000054 [ 2] tmp17
|
|
||||||
0x1000028ED 0x00000053 [ 2] and_s1l2m
|
|
||||||
0x100002940 0x00000054 [ 2] tmp18
|
|
||||||
0x100002994 0x00000016 [ 2] and_l1l2
|
|
||||||
0x1000029AA 0x00000044 [ 2] and_l1nl2n
|
|
||||||
0x1000029EE 0x00000054 [ 2] tmp19
|
|
||||||
0x100002A42 0x00000053 [ 2] and_l1nl2m
|
|
||||||
0x100002A95 0x00000054 [ 2] tmp20
|
|
||||||
0x100002AE9 0x0000000B [ 2] and_l1ml2
|
|
||||||
0x100002AF4 0x00000059 [ 2] and_l1ml2n
|
|
||||||
0x100002B4D 0x00000054 [ 2] tmp21
|
|
||||||
0x100002BA1 0x00000068 [ 2] and_l1ml2m
|
|
||||||
0x100002C09 0x00000054 [ 2] tmp22
|
|
||||||
0x100002C5D 0x0000009F [ 3] __Z14Fr_str2elementP9FrElementPc
|
|
||||||
0x100002CFC 0x0000015A [ 3] __Z14Fr_element2strP9FrElement
|
|
||||||
0x100002E56 0x00000006 [ 5] __Znam
|
|
||||||
0x100002E5C 0x00000006 [ 4] ___gmpz_add
|
|
||||||
0x100002E62 0x00000006 [ 4] ___gmpz_clear
|
|
||||||
0x100002E68 0x00000006 [ 4] ___gmpz_export
|
|
||||||
0x100002E6E 0x00000006 [ 4] ___gmpz_get_str
|
|
||||||
0x100002E74 0x00000006 [ 4] ___gmpz_import
|
|
||||||
0x100002E7A 0x00000006 [ 4] ___gmpz_init
|
|
||||||
0x100002E80 0x00000006 [ 4] ___gmpz_init_set_si
|
|
||||||
0x100002E86 0x00000006 [ 4] ___gmpz_set_str
|
|
||||||
0x100002E8C 0x00000006 [ 6] _printf
|
|
||||||
0x100002E92 0x00000006 [ 6] _sprintf
|
|
||||||
0x100002E98 0x00000010 [ 0] helper helper
|
|
||||||
0x100002EA8 0x0000000A [ 4] ___gmpz_add
|
|
||||||
0x100002EB2 0x0000000A [ 4] ___gmpz_clear
|
|
||||||
0x100002EBC 0x0000000A [ 4] ___gmpz_export
|
|
||||||
0x100002EC6 0x0000000A [ 4] ___gmpz_get_str
|
|
||||||
0x100002ED0 0x0000000A [ 4] ___gmpz_import
|
|
||||||
0x100002EDA 0x0000000A [ 4] ___gmpz_init
|
|
||||||
0x100002EE4 0x0000000A [ 4] ___gmpz_init_set_si
|
|
||||||
0x100002EEE 0x0000000A [ 4] ___gmpz_set_str
|
|
||||||
0x100002EF8 0x0000000A [ 6] _printf
|
|
||||||
0x100002F02 0x0000000A [ 6] _sprintf
|
|
||||||
0x100002F0C 0x00000018 [ 1] literal string: %llu, %llu, %llu, %llu\n
|
|
||||||
0x100002F24 0x00000003 [ 3] literal string: %d
|
|
||||||
0x100002F28 0x00000018 [ 1] CIE
|
|
||||||
0x100002F40 0x00000038 [ 1] FDE for: _main
|
|
||||||
0x100002F78 0x00000018 [ 3] CIE
|
|
||||||
0x100002F90 0x00000038 [ 3] FDE for: __Z14Fr_str2elementP9FrElementPc
|
|
||||||
0x100002FC8 0x00000038 [ 3] FDE for: __Z14Fr_element2strP9FrElement
|
|
||||||
0x100003000 0x00000008 [ 0] non-lazy-pointer-to-local: dyld_stub_binder
|
|
||||||
0x100004000 0x00000008 [ 5] __Znam
|
|
||||||
0x100004008 0x00000008 [ 4] ___gmpz_add
|
|
||||||
0x100004010 0x00000008 [ 4] ___gmpz_clear
|
|
||||||
0x100004018 0x00000008 [ 4] ___gmpz_export
|
|
||||||
0x100004020 0x00000008 [ 4] ___gmpz_get_str
|
|
||||||
0x100004028 0x00000008 [ 4] ___gmpz_import
|
|
||||||
0x100004030 0x00000008 [ 4] ___gmpz_init
|
|
||||||
0x100004038 0x00000008 [ 4] ___gmpz_init_set_si
|
|
||||||
0x100004040 0x00000008 [ 4] ___gmpz_set_str
|
|
||||||
0x100004048 0x00000008 [ 6] _printf
|
|
||||||
0x100004050 0x00000008 [ 6] _sprintf
|
|
||||||
0x100004058 0x00000008 [ 0] __dyld_private
|
|
||||||
0x100004060 0x00000008 [ 2] _Fr_q
|
|
||||||
0x100004068 0x00000020 [ 2] q
|
|
||||||
0x100004088 0x00000020 [ 2] R2
|
|
||||||
0x1000040A8 0x00000020 [ 2] R3
|
|
||||||
0x1000040C8 0x00000008 [ 2] lboMask
|
|
||||||
Binary file not shown.
@@ -39,15 +39,23 @@ void fillMap() {
|
|||||||
addFunction("sub", (FuncAny)Fr_sub, 2);
|
addFunction("sub", (FuncAny)Fr_sub, 2);
|
||||||
addFunction("neg", (FuncAny)Fr_neg, 1);
|
addFunction("neg", (FuncAny)Fr_neg, 1);
|
||||||
addFunction("mul", (FuncAny)Fr_mul, 2);
|
addFunction("mul", (FuncAny)Fr_mul, 2);
|
||||||
|
addFunction("square", (FuncAny)Fr_square, 1);
|
||||||
|
addFunction("idiv", (FuncAny)Fr_idiv, 2);
|
||||||
|
addFunction("inv", (FuncAny)Fr_inv, 1);
|
||||||
|
addFunction("div", (FuncAny)Fr_div, 2);
|
||||||
addFunction("band", (FuncAny)Fr_band, 2);
|
addFunction("band", (FuncAny)Fr_band, 2);
|
||||||
addFunction("bor", (FuncAny)Fr_bor, 2);
|
addFunction("bor", (FuncAny)Fr_bor, 2);
|
||||||
addFunction("bxor", (FuncAny)Fr_bxor, 2);
|
addFunction("bxor", (FuncAny)Fr_bxor, 2);
|
||||||
|
addFunction("bnot", (FuncAny)Fr_bnot, 1);
|
||||||
addFunction("eq", (FuncAny)Fr_eq, 2);
|
addFunction("eq", (FuncAny)Fr_eq, 2);
|
||||||
addFunction("neq", (FuncAny)Fr_neq, 2);
|
addFunction("neq", (FuncAny)Fr_neq, 2);
|
||||||
addFunction("lt", (FuncAny)Fr_lt, 2);
|
addFunction("lt", (FuncAny)Fr_lt, 2);
|
||||||
addFunction("gt", (FuncAny)Fr_gt, 2);
|
addFunction("gt", (FuncAny)Fr_gt, 2);
|
||||||
addFunction("leq", (FuncAny)Fr_leq, 2);
|
addFunction("leq", (FuncAny)Fr_leq, 2);
|
||||||
addFunction("geq", (FuncAny)Fr_geq, 2);
|
addFunction("geq", (FuncAny)Fr_geq, 2);
|
||||||
|
addFunction("land", (FuncAny)Fr_land, 2);
|
||||||
|
addFunction("lor", (FuncAny)Fr_lor, 2);
|
||||||
|
addFunction("lnot", (FuncAny)Fr_lnot, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int64_t readInt(std::string &s) {
|
u_int64_t readInt(std::string &s) {
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>English</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>com.apple.xcode.dsym.tester</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>dSYM</string>
|
|
||||||
<key>CFBundleSignature</key>
|
|
||||||
<string>????</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>1</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
Binary file not shown.
112
test/fieldasm.js
112
test/fieldasm.js
@@ -79,7 +79,6 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(bn128r, "bor");
|
const tv = buildTestVector2(bn128r, "bor");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("secp256k1q binary or", async () => {
|
it("secp256k1q binary or", async () => {
|
||||||
const tv = buildTestVector2(secp256k1q, "bor");
|
const tv = buildTestVector2(secp256k1q, "bor");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
@@ -100,6 +99,18 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(mnt6753q, "bxor");
|
const tv = buildTestVector2(mnt6753q, "bxor");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
|
it("bn128r binary not", async () => {
|
||||||
|
const tv = buildTestVector1(bn128r, "bnot");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q binary not", async () => {
|
||||||
|
const tv = buildTestVector1(secp256k1q, "bnot");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q binary not", async () => {
|
||||||
|
const tv = buildTestVector1(mnt6753q, "bnot");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
it("bn128r eq", async () => {
|
it("bn128r eq", async () => {
|
||||||
const tv = buildTestVector2(bn128r, "eq");
|
const tv = buildTestVector2(bn128r, "eq");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
@@ -108,12 +119,10 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(secp256k1q, "eq");
|
const tv = buildTestVector2(secp256k1q, "eq");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
it("mnt6753q eq", async () => {
|
it("mnt6753q eq", async () => {
|
||||||
const tv = buildTestVector2(mnt6753q, "eq");
|
const tv = buildTestVector2(mnt6753q, "eq");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
it("bn128r neq", async () => {
|
it("bn128r neq", async () => {
|
||||||
const tv = buildTestVector2(bn128r, "neq");
|
const tv = buildTestVector2(bn128r, "neq");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
@@ -122,12 +131,10 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(secp256k1q, "neq");
|
const tv = buildTestVector2(secp256k1q, "neq");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
it("mnt6753q neq", async () => {
|
it("mnt6753q neq", async () => {
|
||||||
const tv = buildTestVector2(mnt6753q, "neq");
|
const tv = buildTestVector2(mnt6753q, "neq");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
it("bn128r lt", async () => {
|
it("bn128r lt", async () => {
|
||||||
const tv = buildTestVector2(bn128r, "lt");
|
const tv = buildTestVector2(bn128r, "lt");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
@@ -136,12 +143,10 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(secp256k1q, "lt");
|
const tv = buildTestVector2(secp256k1q, "lt");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
it("mnt6753q lt", async () => {
|
it("mnt6753q lt", async () => {
|
||||||
const tv = buildTestVector2(mnt6753q, "lt");
|
const tv = buildTestVector2(mnt6753q, "lt");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
it("bn128r gt", async () => {
|
it("bn128r gt", async () => {
|
||||||
const tv = buildTestVector2(bn128r, "gt");
|
const tv = buildTestVector2(bn128r, "gt");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
@@ -150,12 +155,10 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(secp256k1q, "gt");
|
const tv = buildTestVector2(secp256k1q, "gt");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
it("mnt6753q gt", async () => {
|
it("mnt6753q gt", async () => {
|
||||||
const tv = buildTestVector2(mnt6753q, "gt");
|
const tv = buildTestVector2(mnt6753q, "gt");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
it("bn128r leq", async () => {
|
it("bn128r leq", async () => {
|
||||||
const tv = buildTestVector2(bn128r, "leq");
|
const tv = buildTestVector2(bn128r, "leq");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
@@ -164,12 +167,10 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(secp256k1q, "leq");
|
const tv = buildTestVector2(secp256k1q, "leq");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
it("mnt6753q leq", async () => {
|
it("mnt6753q leq", async () => {
|
||||||
const tv = buildTestVector2(mnt6753q, "leq");
|
const tv = buildTestVector2(mnt6753q, "leq");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
it("bn128r geq", async () => {
|
it("bn128r geq", async () => {
|
||||||
const tv = buildTestVector2(bn128r, "geq");
|
const tv = buildTestVector2(bn128r, "geq");
|
||||||
await tester(bn128r, tv);
|
await tester(bn128r, tv);
|
||||||
@@ -178,11 +179,96 @@ describe("field asm test", function () {
|
|||||||
const tv = buildTestVector2(secp256k1q, "geq");
|
const tv = buildTestVector2(secp256k1q, "geq");
|
||||||
await tester(secp256k1q, tv);
|
await tester(secp256k1q, tv);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
it("mnt6753q geq", async () => {
|
it("mnt6753q geq", async () => {
|
||||||
const tv = buildTestVector2(mnt6753q, "geq");
|
const tv = buildTestVector2(mnt6753q, "geq");
|
||||||
await tester(mnt6753q, tv);
|
await tester(mnt6753q, tv);
|
||||||
});
|
});
|
||||||
|
it("bn128r logical and", async () => {
|
||||||
|
const tv = buildTestVector2(bn128r, "land");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q logical and", async () => {
|
||||||
|
const tv = buildTestVector2(secp256k1q, "land");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q logical and", async () => {
|
||||||
|
const tv = buildTestVector2(mnt6753q, "land");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
it("bn128r logical or", async () => {
|
||||||
|
const tv = buildTestVector2(bn128r, "lor");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q logical or", async () => {
|
||||||
|
const tv = buildTestVector2(secp256k1q, "lor");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q logical or", async () => {
|
||||||
|
const tv = buildTestVector2(mnt6753q, "lor");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
it("bn128r logical not", async () => {
|
||||||
|
const tv = buildTestVector1(bn128r, "lnot");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q logical not", async () => {
|
||||||
|
const tv = buildTestVector1(secp256k1q, "lnot");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q logical not", async () => {
|
||||||
|
const tv = buildTestVector1(mnt6753q, "lnot");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
it("bn128r idiv", async () => {
|
||||||
|
const tv = buildTestVector2(bn128r, "idiv");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q idiv", async () => {
|
||||||
|
const tv = buildTestVector2(secp256k1q, "idiv");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q idiv", async () => {
|
||||||
|
const tv = buildTestVector2(mnt6753q, "idiv");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
it("bn128r inv", async () => {
|
||||||
|
const tv = buildTestVector1(bn128r, "inv");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q inv", async () => {
|
||||||
|
const tv = buildTestVector1(secp256k1q, "inv");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q inv", async () => {
|
||||||
|
const tv = buildTestVector1(mnt6753q, "inv");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
it("bn128r div", async () => {
|
||||||
|
const tv = buildTestVector2(bn128r, "div");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q div", async () => {
|
||||||
|
const tv = buildTestVector2(secp256k1q, "div");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q div", async () => {
|
||||||
|
const tv = buildTestVector2(mnt6753q, "div");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
it("bn128r square", async () => {
|
||||||
|
const tv = buildTestVector1(bn128r, "square");
|
||||||
|
await tester(bn128r, tv);
|
||||||
|
});
|
||||||
|
it("secp256k1q square", async () => {
|
||||||
|
const tv = buildTestVector1(secp256k1q, "square");
|
||||||
|
await tester(secp256k1q, tv);
|
||||||
|
});
|
||||||
|
it("mnt6753q square", async () => {
|
||||||
|
const tv = buildTestVector1(mnt6753q, "square");
|
||||||
|
await tester(mnt6753q, tv);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function buildTestVector2(p, op) {
|
function buildTestVector2(p, op) {
|
||||||
@@ -190,7 +276,7 @@ function buildTestVector2(p, op) {
|
|||||||
const tv = [];
|
const tv = [];
|
||||||
const nums = getCriticalNumbers(p, 2);
|
const nums = getCriticalNumbers(p, 2);
|
||||||
|
|
||||||
const excludeZero = ["div", "mod"].indexOf(op) >= 0;
|
const excludeZero = ["div", "mod", "idiv"].indexOf(op) >= 0;
|
||||||
|
|
||||||
for (let i=0; i<nums.length; i++) {
|
for (let i=0; i<nums.length; i++) {
|
||||||
for (let j=0; j<nums.length; j++) {
|
for (let j=0; j<nums.length; j++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user