Remove unused key types

This commit is contained in:
Nathan Hourt 2019-05-01 12:50:00 -05:00 committed by Nathan Hourt
parent 3a15577617
commit 35d864e269
No known key found for this signature in database
GPG key ID: B4344309A110851E
3 changed files with 0 additions and 212 deletions

View file

@ -217,56 +217,12 @@ public:
}
};
struct extended_public_key_type {
struct binary_key {
binary_key() = default;
uint32_t check = 0;
fc::ecc::extended_key_data data;
};
fc::ecc::extended_key_data key_data;
extended_public_key_type();
extended_public_key_type(const fc::ecc::extended_key_data& data);
extended_public_key_type(const fc::ecc::extended_public_key& extpubkey);
explicit extended_public_key_type(const std::string& base58str);
operator fc::ecc::extended_public_key() const;
explicit operator std::string() const;
friend bool operator == (const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2);
friend bool operator == (const extended_public_key_type& p1, const extended_public_key_type& p2);
friend bool operator != (const extended_public_key_type& p1, const extended_public_key_type& p2);
};
struct extended_private_key_type {
struct binary_key {
binary_key() = default;
uint32_t check = 0;
fc::ecc::extended_key_data data;
};
fc::ecc::extended_key_data key_data;
extended_private_key_type();
extended_private_key_type(const fc::ecc::extended_key_data& data);
extended_private_key_type(const fc::ecc::extended_private_key& extprivkey);
explicit extended_private_key_type(const std::string& base58str);
operator fc::ecc::extended_private_key() const;
explicit operator std::string() const;
friend bool operator == (const extended_private_key_type& p1, const fc::ecc::extended_private_key& p);
friend bool operator == (const extended_private_key_type& p1, const extended_private_key_type& p);
friend bool operator != (const extended_private_key_type& p1, const extended_private_key_type& p);
};
struct fee_schedule;
} } // graphene::protocol
namespace fc {
void to_variant(const graphene::protocol::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2);
void from_variant(const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth = 2);
void to_variant(const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2);
void from_variant(const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth = 2);
void to_variant(const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2);
void from_variant(const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth = 2);
template<>
@ -349,10 +305,6 @@ FC_REFLECT_TYPENAME(graphene::protocol::nft_id_type)
FC_REFLECT(graphene::protocol::public_key_type, (key_data))
FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check))
FC_REFLECT(graphene::protocol::extended_public_key_type, (key_data))
FC_REFLECT(graphene::protocol::extended_public_key_type::binary_key, (check)(data))
FC_REFLECT(graphene::protocol::extended_private_key_type, (key_data))
FC_REFLECT(graphene::protocol::extended_private_key_type::binary_key, (check)(data))
FC_REFLECT_TYPENAME(graphene::protocol::share_type)
FC_REFLECT(graphene::protocol::void_t,)

View file

@ -136,114 +136,6 @@ namespace graphene { namespace protocol {
return p1.key_data != p2.key_data;
}
// extended_public_key_type
extended_public_key_type::extended_public_key_type():key_data(){};
extended_public_key_type::extended_public_key_type( const fc::ecc::extended_key_data& data )
:key_data( data ){};
extended_public_key_type::extended_public_key_type( const fc::ecc::extended_public_key& extpubkey )
{
key_data = extpubkey.serialize_extended();
};
extended_public_key_type::extended_public_key_type( const std::string& base58str )
{
std::string prefix( GRAPHENE_ADDRESS_PREFIX );
const size_t prefix_len = prefix.size();
FC_ASSERT( base58str.size() > prefix_len );
FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) );
auto bin = fc::from_base58( base58str.substr( prefix_len ) );
auto bin_key = fc::raw::unpack<binary_key>(bin);
FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0].value() == bin_key.check );
key_data = bin_key.data;
}
extended_public_key_type::operator fc::ecc::extended_public_key() const
{
return fc::ecc::extended_public_key::deserialize( key_data );
}
extended_public_key_type::operator std::string() const
{
binary_key k;
k.data = key_data;
k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value();
auto data = fc::raw::pack( k );
return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() );
}
bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2)
{
return p1.key_data == p2.serialize_extended();
}
bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2)
{
return p1.key_data == p2.key_data;
}
bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2)
{
return p1.key_data != p2.key_data;
}
// extended_private_key_type
extended_private_key_type::extended_private_key_type() = default;
extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data )
:key_data( data ){};
extended_private_key_type::extended_private_key_type( const fc::ecc::extended_private_key& extprivkey )
{
key_data = extprivkey.serialize_extended();
};
extended_private_key_type::extended_private_key_type( const std::string& base58str )
{
std::string prefix( GRAPHENE_ADDRESS_PREFIX );
const size_t prefix_len = prefix.size();
FC_ASSERT( base58str.size() > prefix_len );
FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) );
auto bin = fc::from_base58( base58str.substr( prefix_len ) );
auto bin_key = fc::raw::unpack<binary_key>(bin);
FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0].value() == bin_key.check );
key_data = bin_key.data;
}
extended_private_key_type::operator fc::ecc::extended_private_key() const
{
return fc::ecc::extended_private_key::deserialize( key_data );
}
extended_private_key_type::operator std::string() const
{
binary_key k;
k.data = key_data;
k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value();
auto data = fc::raw::pack( k );
return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() );
}
bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_public_key& p2)
{
return p1.key_data == p2.serialize_extended();
}
bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2)
{
return p1.key_data == p2.key_data;
}
bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2)
{
return p1.key_data != p2.key_data;
}
} } // graphene::protocol
namespace fc
@ -259,26 +151,6 @@ namespace fc
vo = graphene::protocol::public_key_type( var.as_string() );
}
void to_variant( const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth )
{
vo = std::string( var );
}
void from_variant( const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth )
{
vo = graphene::protocol::extended_public_key_type( var.as_string() );
}
void to_variant( const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth )
{
vo = std::string( var );
}
void from_variant( const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth )
{
vo = graphene::protocol::extended_private_key_type( var.as_string() );
}
void from_variant( const fc::variant& var, std::shared_ptr<const graphene::protocol::fee_schedule>& vo,
uint32_t max_depth ) {
// If it's null, just make a new one

View file

@ -86,42 +86,6 @@ BOOST_AUTO_TEST_CASE( json_tests )
}
}
BOOST_AUTO_TEST_CASE( extended_private_key_type_test )
{
try
{
fc::ecc::extended_private_key key = fc::ecc::extended_private_key( fc::ecc::private_key::generate(),
fc::sha256(),
0, 0, 0 );
extended_private_key_type type = extended_private_key_type( key );
std::string packed = std::string( type );
extended_private_key_type unpacked = extended_private_key_type( packed );
BOOST_CHECK( type == unpacked );
} catch ( const fc::exception& e )
{
edump((e.to_detail_string()));
throw;
}
}
BOOST_AUTO_TEST_CASE( extended_public_key_type_test )
{
try
{
fc::ecc::extended_public_key key = fc::ecc::extended_public_key( fc::ecc::private_key::generate().get_public_key(),
fc::sha256(),
0, 0, 0 );
extended_public_key_type type = extended_public_key_type( key );
std::string packed = std::string( type );
extended_public_key_type unpacked = extended_public_key_type( packed );
BOOST_CHECK( type == unpacked );
} catch ( const fc::exception& e )
{
edump((e.to_detail_string()));
throw;
}
}
BOOST_AUTO_TEST_CASE( extension_serialization_test )
{
try