From 4d9214b729acd7af24cdd7982cc508ea504dd39b Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Thu, 13 Jun 2024 15:17:55 +0200 Subject: [PATCH] bindings/emscripten: add EIP-2537 serialization. --- bindings/emscripten/build.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/bindings/emscripten/build.py b/bindings/emscripten/build.py index eb76504f..1bb7dea2 100755 --- a/bindings/emscripten/build.py +++ b/bindings/emscripten/build.py @@ -184,6 +184,20 @@ { return wrapPointer(_P1_Affine_to_jacobian_0(this.ptr), P1); };; """ p1_cpp += """ +byte* EMSCRIPTEN_KEEPALIVE P1_Affine_serialize_eip2537_0(const P1_Affine* self) +{ byte out[128*1]; + self->serialize_eip2537(out); + return out; +} +""" +p1_js += """ +P1_Affine.prototype['serialize_eip2537'] = P1_Affine.prototype.serialize_eip2537 = /** @this{Object} */ +function() +{ var out = _P1_Affine_serialize_eip2537_0(this.ptr); + return new Uint8Array(HEAPU8.subarray(out, out + 128*1)); +};; +""" +p1_cpp += """ byte* EMSCRIPTEN_KEEPALIVE P1_Affine_serialize_0(const P1_Affine* self) { byte out[96*1]; self->serialize(out); @@ -340,6 +354,20 @@ { return wrapPointer(_P1_to_affine_0(this.ptr), P1_Affine); };; """ p1_cpp += """ +byte* EMSCRIPTEN_KEEPALIVE P1_serialize_eip2537_0(const P1* self) +{ byte out[128*1]; + self->serialize_eip2537(out); + return out; +} +""" +p1_js += """ +P1.prototype['serialize_eip2537'] = P1.prototype.serialize_eip2537 = /** @this{Object} */ +function() +{ var out = _P1_serialize_eip2537_0(this.ptr); + return new Uint8Array(HEAPU8.subarray(out, out + 96*1)); +};; +""" +p1_cpp += """ byte* EMSCRIPTEN_KEEPALIVE P1_serialize_0(const P1* self) { byte out[96*1]; self->serialize(out); @@ -1151,7 +1179,7 @@ def xchg_1vs2(matchobj): print("//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", file=fd) print(common_cpp, file=fd) print(p1_cpp, file=fd) -print(re.sub(r'((?