From 2ba63f8c27aad560e6d8c32e5d5014950cd6b661 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Sat, 25 Aug 2018 00:41:42 +0200 Subject: [PATCH] xmr: bp - minor cleanup, optimizations, scalarmultH --- src/apps/monero/xmr/bulletproof.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/apps/monero/xmr/bulletproof.py b/src/apps/monero/xmr/bulletproof.py index 7668242d5..3c94b7c8a 100644 --- a/src/apps/monero/xmr/bulletproof.py +++ b/src/apps/monero/xmr/bulletproof.py @@ -480,8 +480,6 @@ def const_vector(val, elems=BP_N): def vector_exponent_custom(A, B, a, b, dst=None): dst = _ensure_dst_key(dst) - - crypto.identity_into(tmp_pt_1) crypto.identity_into(tmp_pt_2) for i in range(len(a)): @@ -897,12 +895,8 @@ def prove_s1(self, V, A, S, T1, T2, taux, mu, t, x_ip, y, hash_cache, l, r): tau1 = sc_gen() tau2 = sc_gen() - add_keys( - T1, scalarmult_key(tmp_bf_1, XMR_H, t1), scalarmult_base(tmp_bf_2, tau1) - ) - add_keys( - T2, scalarmult_key(tmp_bf_1, XMR_H, t2), scalarmult_base(tmp_bf_2, tau2) - ) + add_keys(T1, scalarmultH(tmp_bf_1, t1), scalarmult_base(tmp_bf_2, tau1)) + add_keys(T2, scalarmultH(tmp_bf_1, t2), scalarmult_base(tmp_bf_2, tau2)) # PAPER LINES 49-51 x = _ensure_dst_key() @@ -1455,7 +1449,7 @@ def verify_testnet(self, proof): add_keys( L61Left, scalarmult_base(_tmp_k_1, proof.taux), - scalarmult_key(_tmp_k_2, XMR_H, proof.t), + scalarmultH(_tmp_k_2, proof.t), ) k = _ensure_dst_key() @@ -1475,7 +1469,7 @@ def verify_testnet(self, proof): sc_muladd(tmp, z, ip1y, k) L61Right = _ensure_dst_key() - scalarmult_key(L61Right, XMR_H, tmp) + scalarmultH(L61Right, tmp) scalarmult_key(tmp, proof.V[0], zsq) add_keys(L61Right, L61Right, tmp) @@ -1569,11 +1563,11 @@ def verify_testnet(self, proof): add_keys(pprime, pprime, tmp) sc_mul(tmp, proof.t, x_ip) - add_keys(pprime, pprime, scalarmult_key(_tmp_k_1, XMR_H, tmp)) + add_keys(pprime, pprime, scalarmultH(_tmp_k_1, tmp)) sc_mul(tmp, proof.a, proof.b) sc_mul(tmp, tmp, x_ip) - scalarmult_key(tmp, XMR_H, tmp) + scalarmultH(tmp, tmp) add_keys(tmp, tmp, inner_prod) self.gc(64) @@ -1776,7 +1770,7 @@ def verify_batch(self, proofs): # now check all proofs at once check1 = _ensure_dst_key() scalarmult_base(check1, y0) - add_keys(check1, check1, scalarmult_key(None, XMR_H, y1)) + add_keys(check1, check1, scalarmultH(None, y1)) sub_keys(check1, check1, Y2) sub_keys(check1, check1, Y3) sub_keys(check1, check1, Y4)