コード例 #1
0
ファイル: AccountID.cpp プロジェクト: E-LLP/rippled
std::string
toBase58 (AccountID const& v)
{
    return base58EncodeToken(
        TOKEN_ACCOUNT_ID,
            v.data(), v.size());
}
コード例 #2
0
ファイル: AccountID.cpp プロジェクト: E-LLP/rippled
/*
    Calculation of the Account ID

    The AccountID is a 160-bit identifier that uniquely
    distinguishes an account. The account may or may not
    exist in the ledger. Even for accounts that are not in
    the ledger, cryptographic operations may be performed
    which affect the ledger. For example, designating an
    account not in the ledger as a regular key for an
    account that is in the ledger.

    Why did we use half of SHA512 for most things but then
    SHA256 followed by RIPEMD160 for account IDs? Why didn't
    we do SHA512 half then RIPEMD160? Or even SHA512 then RIPEMD160?
    For that matter why RIPEMD160 at all why not just SHA512 and keep
    only 160 bits?

    Answer (David Schwartz):

        The short answer is that we kept Bitcoin's behavior.
        The longer answer was that:
            1) Using a single hash could leave ripple
               vulnerable to length extension attacks.
            2) Only RIPEMD160 is generally considered safe at 160 bits.

        Any of those schemes would have been acceptable. However,
        the one chosen avoids any need to defend the scheme chosen.
        (Against any criticism other than unnecessary complexity.)

        "The historical reason was that in the very early days,
        we wanted to give people as few ways to argue that we were
        less secure than Bitcoin. So where there was no good reason
        to change something, it was not changed."
*/
AccountID
calcAccountID (PublicKey const& pk)
{
    ripesha_hasher rsh;
    rsh(pk.data(), pk.size());
    auto const d = static_cast<
        ripesha_hasher::result_type>(rsh);
    AccountID id;
    static_assert(sizeof(d) == sizeof(id), "");
    std::memcpy(id.data(), d.data(), d.size());
    return id;
}
コード例 #3
0
// DEPRECATED
AccountID
calcAccountID (RippleAddress const& publicKey)
{
    auto const& pk =
        publicKey.getAccountPublic();
    ripesha_hasher rsh;
    rsh(pk.data(), pk.size());
    auto const d = static_cast<
        ripesha_hasher::result_type>(rsh);
    AccountID id;
    static_assert(sizeof(d) == sizeof(id), "");
    std::memcpy(id.data(), d.data(), d.size());
    return id;
}
コード例 #4
0
ファイル: AccountID.cpp プロジェクト: E-LLP/rippled
boost::optional<AccountID>
deprecatedParseBitcoinAccountID (std::string const& s)
{
    auto const result =
        decodeBase58TokenBitcoin(
            s, TOKEN_ACCOUNT_ID);
    if (result.empty())
        return boost::none;
    AccountID id;
    if (result.size() != id.size())
        return boost::none;
    std::memcpy(id.data(),
        result.data(), result.size());
    return id;
}