Giving the same result as dh.Agree(...). Beautiful.

For strangers who wants to obtain the same shared from field theory:
unsigned long modulus,a_element,b_element;
CryptoPP::Integer m, a, b;


string m_str(
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF");
vector<unsigned char> m_vec = hex_to_bytes(m_str);
m.Decode(&(m_vec.at(0)), m_vec.size(), CryptoPP::Integer::UNSIGNED);
bool is_odd = m.IsOdd();


string a_str(
"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC");
vector<unsigned char> a_vec = hex_to_bytes(a_str);
a.Decode(&(a_vec.at(0)), a_vec.size(), CryptoPP::Integer::UNSIGNED);


string b_str(
"5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B");
vector<unsigned char> b_vec = hex_to_bytes(b_str);
b.Decode(&(b_vec.at(0)), b_vec.size(), CryptoPP::Integer::UNSIGNED);


//field init
CryptoPP::ECP field(m,a,b);
//multiplying over this field google_ephemeral_point * our_privatekey_int
CryptoPP::ECPPoint p_result = field.ScalarMultiply(p_eph, priv_int);


//obtaining shared from result:
CryptoPP::byte x_res[32];
CryptoPP::byte y_res[32];
p_result.x.Encode(&(x_res[0]), 32,CryptoPP::Integer::UNSIGNED);
p_result.y.Encode(&(y_res[0]), 32, CryptoPP::Integer::UNSIGNED);

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to