MCPcopy Create free account
hub / github.com/bcndev/bytecoin / proof_step

Function proof_step

tests/crypto/test_crypto.cpp:206–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206void proof_step(
207 Proof *proof, const P3Vec &g, const P3Vec &h, const EllipticCurvePoint &P, const SVec &a, const SVec &b) {
208 if (a.size() == 1 && b.size() == 1) {
209 proof->a = a[0];
210 proof->b = b[0];
211 return;
212 }
213 const size_t n2 = a.size() / 2;
214 const SVec half_zeroes(n2, EllipticCurveScalar{});
215 const SVec a1 = first_half(a);
216 const SVec a2 = second_half(a);
217 const SVec b1 = first_half(b);
218 const SVec b2 = second_half(b);
219
220 const auto ip = inner_product(a, b);
221 const auto P1 = crypto::to_bytes(big_p(g, h, a1, a2, b1, b2, ip));
222 std::cout << "P =" << P << std::endl;
223 std::cout << "P1=" << P1 << std::endl;
224 const auto L = crypto::to_bytes(big_p(g, h, half_zeroes, a1, b2, half_zeroes, inner_product(a1, b2)));
225 const auto R = crypto::to_bytes(big_p(g, h, a2, half_zeroes, half_zeroes, b1, inner_product(a2, b1)));
226 proof->L.push_back(L);
227 proof->R.push_back(R);
228 KeccakStream str;
229 str << L << R;
230 const auto x = str.hash_to_scalar();
231 std::cout << "x=" << x << std::endl;
232 const auto invx = crypto::sc_invert(x);
233 const auto as = add(mul(a1, x), mul(a2, invx));
234 const auto bs = add(mul(b1, invx), mul(b2, x));
235 const auto PS1 = P3(L) * (x * x) + P3(P) + P3(R) * (invx * invx);
236 const auto PS2 = big_p(g, h, mul(as, invx), mul(as, x), mul(bs, x), mul(bs, invx), inner_product(as, bs));
237 std::cout << "PS1=" << crypto::to_bytes(PS1) << std::endl;
238 std::cout << "PS2=" << crypto::to_bytes(PS2) << std::endl;
239 P3Vec gnew(n2);
240 P3Vec hnew(n2);
241 for (size_t i = 0; i != n2; ++i) {
242 gnew[i] = g[i] * invx + g.at(n2 + i) * x;
243 hnew[i] = h[i] * x + h.at(n2 + i) * invx;
244 }
245 proof_step(proof, gnew, hnew, crypto::to_bytes(PS1), as, bs);
246}
247
248bool verify_step(const Proof &proof, const P3Vec &g, const P3Vec &h, const EllipticCurvePoint &P, size_t step) {
249 std::cout << "verify P=" << P << std::endl;

Callers 1

create_proofFunction · 0.85

Calls 12

first_halfFunction · 0.85
second_halfFunction · 0.85
inner_productFunction · 0.85
to_bytesFunction · 0.85
big_pFunction · 0.85
addFunction · 0.85
P3Class · 0.85
atMethod · 0.80
mulFunction · 0.70
sc_invertFunction · 0.50
sizeMethod · 0.45
hash_to_scalarMethod · 0.45

Tested by

no test coverage detected