MCPcopy Create free account
hub / github.com/coinbase/cb-mpc / expected_Q

Function expected_Q

tests/unit/c_api/test_pve_batch.cpp:17–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15using coinbase::mem_t;
16
17static buf_t expected_Q(cbmpc_curve_id_t curve_id, mem_t x) {
18 const coinbase::crypto::ecurve_t curve = (curve_id == CBMPC_CURVE_P256) ? coinbase::crypto::curve_p256
19 : (curve_id == CBMPC_CURVE_SECP256K1) ? coinbase::crypto::curve_secp256k1
20 : (curve_id == CBMPC_CURVE_ED25519) ? coinbase::crypto::curve_ed25519
21 : coinbase::crypto::ecurve_t();
22 cb_assert(curve.valid());
23
24 const coinbase::crypto::bn_t bn_x = coinbase::crypto::bn_t::from_bin(x) % curve.order();
25 const coinbase::crypto::ecc_point_t Q = bn_x * curve.generator();
26 return Q.to_compressed_bin();
27}
28
29static void expect_eq(cmem_t a, cmem_t b) {
30 ASSERT_EQ(a.size, b.size);

Callers 1

TESTFunction · 0.70

Calls 4

from_binFunction · 0.85
ecurve_tClass · 0.50
validMethod · 0.45
to_compressed_binMethod · 0.45

Tested by

no test coverage detected