PublicKeyType withdraw_with_escrow::encrypt_memo_data( const fc::ecc::private_key& one_time_private_key, const fc::ecc::public_key& to_public_key, const fc::ecc::private_key& from_private_key, const std::string& memo_message, const fc::ecc::public_key& memo_pub_key, MemoFlagsEnum memo_type) { memo = TransferMemo(); const auto secret = one_time_private_key.get_shared_secret(to_public_key); const auto ext_to_public_key = ExtendedPublicKey(to_public_key); const auto secret_ext_public_key = ext_to_public_key.child(fc::sha256::hash(secret)); const auto secret_public_key = secret_ext_public_key.get_pub_key(); sender = Address(one_time_private_key.get_public_key()); receiver = Address(secret_public_key); fc::sha512 check_secret; if (from_private_key.get_secret() != fc::ecc::private_key().get_secret()) check_secret = from_private_key.get_shared_secret(secret_public_key); MemoData memo_content; memo_content.set_message(memo_message); memo_content.from = memo_pub_key; memo_content.from_signature = check_secret._hash[0]; memo_content.memo_flags = memo_type; memo->one_time_key = one_time_private_key.get_public_key(); encrypt_memo_data(secret, memo_content); return secret_public_key; }
public_key_type withdraw_with_signature::encrypt_memo_data( const fc::ecc::private_key& one_time_private_key, const fc::ecc::public_key& to_public_key, const fc::ecc::private_key& from_private_key, const std::string& memo_message, const fc::ecc::public_key& memo_pub_key, memo_flags_enum memo_type ) { memo = titan_memo(); const auto secret = one_time_private_key.get_shared_secret( to_public_key ); const auto ext_to_public_key = extended_public_key( to_public_key ); const auto secret_ext_public_key = ext_to_public_key.child( fc::sha256::hash( secret ) ); const auto secret_public_key = secret_ext_public_key.get_pub_key(); owner = address( secret_public_key ); fc::sha512 check_secret; if( from_private_key.get_secret() != fc::ecc::private_key().get_secret() ) check_secret = from_private_key.get_shared_secret( secret_public_key ); memo_data memo_content; memo_content.set_message( memo_message ); memo_content.from = memo_pub_key; memo_content.from_signature = check_secret._hash[0]; memo_content.memo_flags = memo_type; memo->one_time_key = one_time_private_key.get_public_key(); encrypt_memo_data( secret, memo_content ); return secret_public_key; }