mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Support Ed25519 keys and signatures:
Recognize a new JSON parameter `key_type` in handlers for wallet_propose
and sign/submit. In addition to letting the caller to specify either of
secp256k1 or ed25519, its presence prohibits the (now-deprecated) use of
heuristically polymorphic parameters for secret data -- the `passphrase`
parameter to wallet_propose will be not be considered as an encoded seed
value (for which `seed` and `seed_hex` should be used), and the `secret`
parameter to sign and submit will be obsoleted entirely by the same trio
above.
* Use constants instead of literals for JSON parameter names.
* Move KeyType to its own unit and add string conversions.
* RippleAddress
* Pass the entire message, rather than a hash, to accountPrivateSign()
and accountPublicVerify().
* Recognize a 33-byte value beginning with 0xED as an Ed25519 key when
signing and verifying (for accounts only).
* Add keyFromSeed() to generate an Ed25519 secret key from a seed.
* Add getSeedFromRPC() to extract the seed from JSON parameters for an
RPC call.
* Add generateKeysFromSeed() to produce a key pair of either type from
a seed.
* Extend Ledger tests to cover both key types.
This commit is contained in:
@@ -152,6 +152,14 @@ STTx::getMentionedAccounts () const
|
||||
return accounts;
|
||||
}
|
||||
|
||||
static Blob getSigningData (STTx const& that)
|
||||
{
|
||||
Serializer s;
|
||||
s.add32 (HashPrefix::txSign);
|
||||
that.add (s, false);
|
||||
return s.getData();
|
||||
}
|
||||
|
||||
uint256
|
||||
STTx::getSigningHash () const
|
||||
{
|
||||
@@ -178,8 +186,7 @@ Blob STTx::getSignature () const
|
||||
|
||||
void STTx::sign (RippleAddress const& private_key)
|
||||
{
|
||||
Blob signature;
|
||||
private_key.accountPrivateSign (getSigningHash (), signature);
|
||||
Blob const signature = private_key.accountPrivateSign (getSigningData (*this));
|
||||
setFieldVL (sfTxnSignature, signature);
|
||||
}
|
||||
|
||||
@@ -196,7 +203,7 @@ bool STTx::checkSign () const
|
||||
RippleAddress n;
|
||||
n.setAccountPublic (getFieldVL (sfSigningPubKey));
|
||||
|
||||
sig_state_ = n.accountPublicVerify (getSigningHash (),
|
||||
sig_state_ = n.accountPublicVerify (getSigningData (*this),
|
||||
getFieldVL (sfTxnSignature), fullyCanonical);
|
||||
}
|
||||
catch (...)
|
||||
|
||||
Reference in New Issue
Block a user