Skip to content

Commit

Permalink
xmr: bp - minor cleanup, optimizations, scalarmultH
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Aug 24, 2018
1 parent 31c9ca2 commit 2ba63f8
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/apps/monero/xmr/bulletproof.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2ba63f8

Please sign in to comment.