mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 03:35:51 +00:00
Key derivation: consistent terminology
This commit is contained in:
@@ -61,9 +61,9 @@ class Seed:
|
||||
"""
|
||||
self.correct_rfc1751 = correct_rfc1751
|
||||
# Keys are lazy-derived later
|
||||
self._secp256k1_pri = None
|
||||
self._secp256k1_sec = None
|
||||
self._secp256k1_pub = None
|
||||
self._ed25519_pri = None
|
||||
self._ed25519_sec = None
|
||||
self._ed25519_pub = None
|
||||
|
||||
if in_string is None:
|
||||
@@ -143,14 +143,14 @@ class Seed:
|
||||
return RFC1751.key_to_english(buf)
|
||||
|
||||
@property
|
||||
def ed25519_private_key(self):
|
||||
def ed25519_secret_key(self):
|
||||
"""
|
||||
Returns a 32-byte Ed25519 private key (bytes).
|
||||
Returns a 32-byte Ed25519 secret key (bytes).
|
||||
Saves the calculation for later calls.
|
||||
"""
|
||||
if self._ed25519_pri is None:
|
||||
self._ed25519_pri = sha512half(self.bytes)
|
||||
return self._ed25519_pri
|
||||
if self._ed25519_sec is None:
|
||||
self._ed25519_sec = sha512half(self.bytes)
|
||||
return self._ed25519_sec
|
||||
|
||||
@property
|
||||
def ed25519_public_key(self):
|
||||
@@ -160,17 +160,17 @@ class Seed:
|
||||
"""
|
||||
if self._ed25519_pub is None:
|
||||
self._ed25519_pub = (ED_PREFIX +
|
||||
ed25519.publickey(self.ed25519_private_key))
|
||||
ed25519.publickey(self.ed25519_secret_key))
|
||||
return self._ed25519_pub
|
||||
|
||||
@property
|
||||
def secp256k1_private_key(self):
|
||||
def secp256k1_secret_key(self):
|
||||
"""
|
||||
32-byte secp256k1 private key (bytes)
|
||||
32-byte secp256k1 secret key (bytes)
|
||||
"""
|
||||
if self._secp256k1_pri is None:
|
||||
if self._secp256k1_sec is None:
|
||||
self.derive_secp256k1_master_keys()
|
||||
return self._secp256k1_pri
|
||||
return self._secp256k1_sec
|
||||
|
||||
@property
|
||||
def secp256k1_public_key(self):
|
||||
@@ -198,19 +198,19 @@ class Seed:
|
||||
Saves the values to the object for later reference.
|
||||
"""
|
||||
|
||||
root_pri_i = secp256k1_private_key_from(self.bytes)
|
||||
root_pub_point = keys.get_public_key(root_pri_i, curve.secp256k1)
|
||||
root_sec_i = secp256k1_secret_key_from(self.bytes)
|
||||
root_pub_point = keys.get_public_key(root_sec_i, curve.secp256k1)
|
||||
root_pub_b = compress_secp256k1_public(root_pub_point)
|
||||
fam_b = bytes(4) # Account families are unused; just 4 bytes of zeroes
|
||||
inter_pk_i = secp256k1_private_key_from(root_pub_b+fam_b)
|
||||
inter_pk_i = secp256k1_secret_key_from(root_pub_b+fam_b)
|
||||
inter_pub_point = keys.get_public_key(inter_pk_i, curve.secp256k1)
|
||||
|
||||
# Private keys are ints, so just add them mod the secp256k1 modulus
|
||||
master_pri_i = (root_pri_i + inter_pk_i) % SECP_MODULUS
|
||||
# Secret keys are ints, so just add them mod the secp256k1 group order
|
||||
master_sec_i = (root_sec_i + inter_pk_i) % SECP_MODULUS
|
||||
# Public keys are points, so the fastecdsa lib handles adding them
|
||||
master_pub_point = root_pub_point + inter_pub_point
|
||||
|
||||
self._secp256k1_pri = master_pri_i.to_bytes(32, byteorder="big", signed=False)
|
||||
self._secp256k1_sec = master_sec_i.to_bytes(32, byteorder="big", signed=False)
|
||||
self._secp256k1_pub = compress_secp256k1_public(master_pub_point)
|
||||
self._secp256k1_root_pub = root_pub_b
|
||||
|
||||
@@ -243,13 +243,13 @@ class Seed:
|
||||
return base58.b58encode_check(prefix +
|
||||
self.ed25519_public_key).decode()
|
||||
|
||||
def secp256k1_private_key_from(seed):
|
||||
def secp256k1_secret_key_from(seed):
|
||||
"""
|
||||
Calculate a valid secp256k1 private key by hashing a seed value;
|
||||
Calculate a valid secp256k1 secret key by hashing a seed value;
|
||||
if the result isn't a valid key, increment a seq value and try
|
||||
again.
|
||||
|
||||
Returns a private key as a 32-byte integer.
|
||||
Returns a secret key as a 32-byte integer.
|
||||
"""
|
||||
seq = 0
|
||||
while True:
|
||||
@@ -304,10 +304,10 @@ if __name__ == "__main__":
|
||||
Seed (hex): {hex}
|
||||
Seed (true RFC-1751): {rfc1751_true}
|
||||
Seed (rippled RFC-1751): {rfc1751_rippled}
|
||||
Ed25519 Private Key (hex): {ed25519_secret}
|
||||
Ed25519 Secret Key (hex): {ed25519_secret}
|
||||
Ed25519 Public Key (hex): {ed25519_public}
|
||||
Ed25519 Public Key (base58 - Account): {ed25519_pub_base58}
|
||||
secp256k1 Private Key (hex): {secp256k1_secret}
|
||||
secp256k1 Secret Key (hex): {secp256k1_secret}
|
||||
secp256k1 Public Key (hex): {secp256k1_public}
|
||||
secp256k1 Public Key (base58 - Account): {secp256k1_pub_base58}
|
||||
secp256k1 Public Key (base58 - Validator): {secp256k1_pub_base58_val}
|
||||
@@ -316,9 +316,9 @@ if __name__ == "__main__":
|
||||
hex=seed.encode_hex(),
|
||||
rfc1751_true=seed.encode_rfc1751(correct_rfc1751=True),
|
||||
rfc1751_rippled=seed.encode_rfc1751(correct_rfc1751=False),
|
||||
ed25519_secret=seed.ed25519_private_key.hex().upper(),
|
||||
ed25519_secret=seed.ed25519_secret_key.hex().upper(),
|
||||
ed25519_public=seed.ed25519_public_key.hex().upper(),
|
||||
secp256k1_secret=seed.secp256k1_private_key.hex().upper(),
|
||||
secp256k1_secret=seed.secp256k1_secret_key.hex().upper(),
|
||||
secp256k1_public=seed.secp256k1_public_key.hex().upper(),
|
||||
secp256k1_pub_base58=seed.encode_secp256k1_public_base58(),
|
||||
secp256k1_pub_base58_val=seed.encode_secp256k1_public_base58(
|
||||
|
||||
@@ -372,8 +372,8 @@ compressed)</panel_attributes>
|
||||
<w>160</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Add, Mod
|
||||
Curve Modulus
|
||||
<panel_attributes>Add, Modulo
|
||||
Group Order
|
||||
type=sender</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
|
||||
@@ -33,11 +33,11 @@ To be "canonical", signatures created with the ECDSA algorithm and secp256k1 cur
|
||||
|
||||
- The signature must be properly [DER-encoded data](https://en.wikipedia.org/wiki/X.690#DER_encoding).
|
||||
- The signature must not have any padding bytes outside the DER-encoded data.
|
||||
- The signature's component integers must not be negative, and they must not be larger than the secp256k1 modulus.
|
||||
- The signature's component integers must not be negative, and they must not be larger than the secp256k1 group order.
|
||||
|
||||
Generally speaking, any standard ECDSA implementation handles these requirements automatically. However, with secp256k1, those requirements are insufficient to prevent malleability. Thus, the XRP Ledger has a concept of "fully canonical" signatures which do not have the same problem.
|
||||
|
||||
An ECDSA signature consists of two integers, called R and S. The secp256k1 modulus, called N, is a constant value for all secp256k1 signatures. Specifically, N is the value `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141`. For any given signature `(R,S)`, the signature `(R, N-S)` (that is, using N minus S in place of S) is also valid.
|
||||
An ECDSA signature consists of two integers, called R and S. The secp256k1 _group order_, called N, is a constant value for all secp256k1 signatures. Specifically, N is the value `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141`. For any given signature `(R,S)`, the signature `(R, N-S)` (that is, using N minus S in place of S) is also valid.
|
||||
|
||||
Thus, to have _fully_ canonical signatures, one must choose which of the two possibilities is preferred and declare the other to be invalid. The creators of the XRP Ledger decided arbitrarily to prefer the _smaller_ of the two possible values, `S` or `N-S`. A transaction is considered _fully canonical_ if it uses the preferred (smaller) value of `S`, and follows all the normal rules for being canonical.
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Cryptographic Keys
|
||||
|
||||
In the XRP Ledger, a digital signature proves that a transaction is authorized to do a specific set of actions. Only signed transactions can be submitted to the network and included in a validated ledger. <!-- STYLE_OVERRIDE: is authorized to -->
|
||||
In the XRP Ledger, a digital signature proves that a [transaction](transaction-basics.html) is authorized to do a specific set of actions. Only signed transactions can be submitted to the network and included in a validated ledger. <!-- STYLE_OVERRIDE: is authorized to -->
|
||||
|
||||
Every digital signature is based on a cryptographic key pair associated with the transaction's sending account. A key pair may be generated using any of the XRP Ledger's supported [cryptographic signing algorithms](#signing-algorithms). A key pair can be used as [master key pair](#master-key-pair), [regular key pair](#regular-key-pair) or a member of a [signer list](multi-signing.html), regardless of what algorithm was used to generate it.
|
||||
|
||||
**Warning:** It is important to maintain proper security over your private keys. Digital signatures are the only way of verifying to the XRP Ledger that you are authorized to send a transaction, and there is no privileged administrator who can undo or reverse any transaction that has been applied to the ledger. If someone else knows the private key of your XRP Ledger account, that person can create digital signatures to authorize any transaction the same as you could.
|
||||
**Warning:** It is important to maintain proper security over your secret keys. Digital signatures are the only way of verifying to the XRP Ledger that you are authorized to send a transaction, and there is no privileged administrator who can undo or reverse any transaction that has been applied to the ledger. If someone else knows the secret key of your XRP Ledger account, that person can create digital signatures to authorize any transaction the same as you could.
|
||||
|
||||
## Generating Keys
|
||||
|
||||
@@ -26,15 +26,21 @@ You generate a key pair using the [`wallet_propose`](wallet_propose.html) method
|
||||
}
|
||||
```
|
||||
|
||||
The response contains a key pair (a private key and a public key, in various formats) as well as an `account_id`.
|
||||
The response contains a key pair (a seed and a public key, in various formats) as well as an `account_id`.
|
||||
|
||||
**Private Key**
|
||||
**Seed**
|
||||
|
||||
The `master_key`, `master_seed`, and `master_seed_hex` are the private key in various formats, all of which can be used to sign transactions. Despite being prefixed with `master_`, these keys are not necessarily the master keys for an account. In this context, the `master_` prefix refers more to the keys' role as private keys. The `master_seed` is the master seed from which all other information about this account is derived.
|
||||
A _seed_ value is a compact value that is used to [derive](#key-derivation) the actual secret key (and public key) for an account. The `master_key`, `master_seed`, and `master_seed_hex` all represent the same seed value, in various formats. Any of these formats can be used to [sign transactions](transaction-basics.html#signing-and-submitting-transactions) in the [`rippled` APIs](rippled-api.html) and some [other XRPL software](software-ecosystem.html). Despite being prefixed with `master_`, the keys this seed represents are not necessarily the master keys for an account; you can use a key pair as a regular key or a member of a multi-signing list as well.
|
||||
|
||||
Because the seed value is the basis for all the other information of an account, you must protect it very carefully. Anyone who has knows an address's seed value effectively has full control over that address.
|
||||
|
||||
**Secret Key**
|
||||
|
||||
The `wallet_propose` response does not explicitly list the secret key value, also called a _private key_. Software that can sign transactions is expected to [derive the secret key](#key-derivation) from the seed value.
|
||||
|
||||
**Public Key**
|
||||
|
||||
The `public_key` and `public_key_hex` are the public key in various formats, with the `public_key_hex` being the public key corresponding to the private key that signed the transaction. Both the `public_key` and `public_key_hex` are directly derived from the `master_seed`.
|
||||
The `public_key` and `public_key_hex` both represent the same public key value. The public key is derived from the secret key as part of key derivation. The public key makes it possible to verify the authenticity of a transaction signature, but not to create more signatures.
|
||||
|
||||
**account_id**
|
||||
|
||||
@@ -55,7 +61,7 @@ The field `key_type` indicates what [cryptographic signing algorithm](#signing-a
|
||||
|
||||
## Master Key Pair
|
||||
|
||||
The master key pair is composed of a private key and a public key. In addition to being able to sign all transactions that a regular key pair can, the master key pair's private key is the only key that can be used to perform the following actions:
|
||||
The master key pair is composed of a secret key and a public key. In addition to being able to sign all transactions that a regular key pair can, the master key pair's secret key is the only key that can be used to perform the following actions:
|
||||
|
||||
* [Disable the master public key](accountset.html).
|
||||
|
||||
@@ -63,20 +69,20 @@ The master key pair is composed of a private key and a public key. In addition t
|
||||
|
||||
* Send a cost-0 [key reset transaction](transaction-cost.html#key-reset-transaction).
|
||||
|
||||
The master key pair for an account is generated in the same [`wallet_propose`](wallet_propose.html) response as the `account_id` of the account the master key pair is authorized to sign transactions for. Because the master key pair is generated in the same response, it is [intrinsically related](accounts.html#address-encoding) to the `account_id`, which is derived from the `public_key_hex`.
|
||||
The master key pair for an account is generated in the same [`wallet_propose`](wallet_propose.html) response as the `account_id` of the account the master key pair is authorized to sign transactions for. Because the master key pair is generated in the same response, it is [intrinsically related](accounts.html#address-encoding) to the address, which is derived from the public key.
|
||||
|
||||
This is as opposed to a regular key pair, which is also generated using the `wallet_propose` method, but which must be explicitly assigned as a regular key pair to an account. Because a regular key pair is explicitly assigned, it is not intrinsically related to the `account_id` of the account it is authorized to sign transactions for. For more information, see [Regular Key Pair](#regular-key-pair).
|
||||
This is as opposed to a regular key pair, which is also generated using the `wallet_propose` method, but which must be explicitly assigned as a regular key pair to an account. Because a regular key pair is explicitly assigned, it is not intrinsically related to the address of the account it is authorized to sign transactions for. For more information, see [Regular Key Pair](#regular-key-pair).
|
||||
|
||||
**Caution:** A master key pair cannot be changed, but it can be disabled. This means that if your master private key is compromised, rather than change it, you must [disable it](accountset.html).
|
||||
**Caution:** A master key pair cannot be changed, but it can be disabled. This means that if your master seed or secret key is compromised, rather than change it, you must [disable it](accountset.html).
|
||||
|
||||
Because a master key pair cannot be changed and can only disabled in the event of a compromise, this is a compelling reason to keep your master key pair offline and set up a regular key pair to sign transactions from your account instead.
|
||||
|
||||
Keeping your master key pair offline means not putting your master private key somewhere malicious actors can get access to it. For example, this can mean keeping it on an air-gapped machine that never connects to the internet, on a piece of paper stored in a safe, or in general, not within reach of a computer program that interacts with the internet at large. Ideally, a master key pair is used only on the most trusted of devices and for emergencies only, such as to change a regular key pair in the event of a possible or actual compromise.
|
||||
Keeping your master key pair offline means not putting your master secret key anywhere that malicious actors can get access to it. For example, this can mean keeping it on an air-gapped machine that never connects to the internet, on a piece of paper stored in a safe, or in general, not within reach of a computer program that interacts with the internet at large. Ideally, a master key pair is used only on the most trusted of devices and for emergencies only, such as to change a regular key pair in the event of a possible or actual compromise.
|
||||
|
||||
|
||||
## Regular Key Pair
|
||||
|
||||
The XRP Ledger allows an account to authorize a secondary key pair, called a _regular key pair_, to sign future transactions, while keeping your master key pair offline. If the private key of a regular key pair is compromised, you can remove or replace it without changing the rest of your account and re-establishing its relationships to other accounts. You can also rotate a regular key pair proactively. (Neither of those things is possible for the master key pair of an account, which is intrinsically linked to the account's address.)
|
||||
The XRP Ledger allows an account to authorize a secondary key pair, called a _regular key pair_, to sign future transactions, while keeping your master key pair offline. If the seed or secret key of a regular key pair is compromised, you can remove or replace the key pair without changing the rest of your account. This saves the trouble of re-establishing the account's settings and relationships to other accounts. You can also rotate a regular key pair proactively. (Neither of those things is possible for the master key pair of an account, which is intrinsically linked to the account's address.)
|
||||
|
||||
You generate a key pair to use as a regular key pair using the [`wallet_propose`](wallet_propose.html) method. However, unlike with a [master key pair](#master-key-pair), which is generated alongside and intrinsically related to the `account_id` of an account it supports, you must explicitly create the relationship between a regular key pair and the account you want it to sign transactions for. You use the [`SetRegularKey`](setregularkey.html) method to assign a regular key pair to an account.
|
||||
|
||||
@@ -84,19 +90,19 @@ For a tutorial on assigning a regular key pair, see [Assign a Regular Key Pair](
|
||||
|
||||
After you assign a regular key pair to an account, the account has two key pairs associated with it:
|
||||
|
||||
* A master key pair that is intrinsically related to the account's `account_id` and which you keep offline.
|
||||
* A master key pair that is intrinsically related to the account's `account_id` and which you should keep offline.
|
||||
* A regular key pair that you've explicitly assigned to the account and which you use to sign transactions for the account.
|
||||
|
||||
You can assign one regular key pair to an account and use it to sign all transactions, except for the ones reserved for the [master key pair](#master-key-pair).
|
||||
|
||||
You can remove or change a regular key pair at any time. This means that if a regular private key is compromised (but the master private key is not), you can regain control of your account by simply removing or changing the regular key pair.
|
||||
You can remove or change a regular key pair at any time. This means that if a regular secret key is compromised (but the master secret key is not), you can regain control of your account by simply removing or changing the regular key pair.
|
||||
|
||||
For a tutorial on changing or removing a regular key pair, see [Assign a Regular Key Pair](assign-a-regular-key-pair.html).
|
||||
|
||||
|
||||
## Signing Algorithms
|
||||
|
||||
Cryptographic key pairs are always tied to a specific signing algorithm, which defines the mathematical relationships between the private key and the public key. Cryptographic signing algorithms have the property that, given the current state of cryptographic techniques, it is "easy" to use a private key to calculate a matching public key, but it is effectively impossible to compute a matching private key by starting from a public key.
|
||||
Cryptographic key pairs are always tied to a specific signing algorithm, which defines the mathematical relationships between the secret key and the public key. Cryptographic signing algorithms have the property that, given the current state of cryptographic techniques, it is "easy" to use a secret key to calculate a matching public key, but it is effectively impossible to compute a matching secret key by starting from a public key.
|
||||
|
||||
The XRP Ledger supports the following cryptographic signing algorithms:
|
||||
|
||||
@@ -134,11 +140,11 @@ The key derivation processes described here are implemented in multiple places a
|
||||
### Ed25519 Key Derivation
|
||||
[[Source]](https://github.com/ripple/rippled/blob/fc7ecd672a3b9748bfea52ce65996e324553c05f/src/ripple/protocol/impl/SecretKey.cpp#L203 "Source")
|
||||
|
||||
[](img/key-derivation-ed25519.png)
|
||||
[](img/key-derivation-ed25519.png)
|
||||
|
||||
1. Calculate the [SHA-512Half][] of the seed value. The result is the 32-byte private key.
|
||||
1. Calculate the [SHA-512Half][] of the seed value. The result is the 32-byte secret key.
|
||||
|
||||
**Tip:** All 32-byte numbers are valid Ed25519 private keys. However, only numbers that are chosen randomly enough are secure enough to be used as private keys.
|
||||
**Tip:** All 32-byte numbers are valid Ed25519 secret keys. However, only numbers that are chosen randomly enough are secure enough to be used as secret keys.
|
||||
|
||||
2. To calculate an Ed25519 public key, use the standard public key derivation for [Ed25519](https://ed25519.cr.yp.to/software.html) to derive the 32-byte public key.
|
||||
|
||||
@@ -159,7 +165,7 @@ The key derivation processes described here are implemented in multiple places a
|
||||
|
||||
Key derivation for secp256k1 XRP Ledger account keys involves more steps than Ed25519 key derivation for a couple reasons:
|
||||
|
||||
- Not all 32-byte numbers are valid secp256k1 private keys.
|
||||
- Not all 32-byte numbers are valid secp256k1 secret keys.
|
||||
- The XRP Ledger's reference implementation has an unused, incomplete framework for deriving a family of key pairs from a single seed value.
|
||||
|
||||
The steps to derive the XRP Ledger's secp256k1 account key pair from a seed value are as follows:
|
||||
@@ -172,11 +178,11 @@ The steps to derive the XRP Ledger's secp256k1 account key pair from a seed valu
|
||||
|
||||
2. Calculate the [SHA-512Half][] of the concatenated (seed+root sequence) value.
|
||||
|
||||
3. If the result is not a valid secp265k1 private key, increment the root sequence by 1 and start over. [[Source]](https://github.com/ripple/rippled/blob/fc7ecd672a3b9748bfea52ce65996e324553c05f/src/ripple/crypto/impl/GenerateDeterministicKey.cpp#L103 "Source")
|
||||
3. If the result is not a valid secp265k1 secret key, increment the root sequence by 1 and start over. [[Source]](https://github.com/ripple/rippled/blob/fc7ecd672a3b9748bfea52ce65996e324553c05f/src/ripple/crypto/impl/GenerateDeterministicKey.cpp#L103 "Source")
|
||||
|
||||
A valid secp256k1 key must not be zero, and it must be numerically less than the _secp256k1 modulus_ (also called the "group order"). The secp256k1 modulus is the constant value `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141`.
|
||||
A valid secp256k1 key must not be zero, and it must be numerically less than the _secp256k1 group order_. The secp256k1 group order is the constant value `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141`.
|
||||
|
||||
4. With a valid secp256k1 private key, use the standard ECDSA public key derivation with the secp256k1 curve to derive the root public key. (As always with cryptographic algorithms, use a standard, well-known, publicly-audited implementation whenever possible. For example, [OpenSSL](https://www.openssl.org/) has implementations of core Ed25519 and secp256k1 functions.)
|
||||
4. With a valid secp256k1 secret key, use the standard ECDSA public key derivation with the secp256k1 curve to derive the root public key. (As always with cryptographic algorithms, use a standard, well-known, publicly-audited implementation whenever possible. For example, [OpenSSL](https://www.openssl.org/) has implementations of core Ed25519 and secp256k1 functions.)
|
||||
|
||||
**Tip:** Validators use this root key pair. If you are calculating a validator's key pair, you can stop here. To distinguish between these two different types of public keys, the [base58][] serialization for validator public keys uses the prefix `0x1c`.
|
||||
|
||||
@@ -197,18 +203,16 @@ The steps to derive the XRP Ledger's secp256k1 account key pair from a seed valu
|
||||
|
||||
2. Calculate the [SHA-512Half][] of the concatenated value.
|
||||
|
||||
3. If the result is not a valid secp265k1 private key, increment the key sequence by 1 and restart deriving the account's intermediate key pair.
|
||||
3. If the result is not a valid secp265k1 secret key, increment the key sequence by 1 and restart deriving the account's intermediate key pair.
|
||||
|
||||
4. With a valid secp256k1 private key, use the standard ECDSA public key derivation with the secp256k1 curve to derive the intermediate public key. (As always with cryptographic algorithms, use a standard, well-known, publicly-audited implementation whenever possible. For example, [OpenSSL](https://www.openssl.org/) has implementations of core Ed25519 and secp256k1 functions.)
|
||||
4. With a valid secp256k1 secret key, use the standard ECDSA public key derivation with the secp256k1 curve to derive the intermediate public key. (As always with cryptographic algorithms, use a standard, well-known, publicly-audited implementation whenever possible. For example, [OpenSSL](https://www.openssl.org/) has implementations of core Ed25519 and secp256k1 functions.)
|
||||
|
||||
4. Derive the master public key pair by adding the intermediate public key to the root public key. Similarly, derive the private key by adding the intermediate private key to the root private key.
|
||||
4. Derive the master public key pair by adding the intermediate public key to the root public key. Similarly, derive the secret key by adding the intermediate secret key to the root secret key.
|
||||
|
||||
- An ECDSA private key is just a very large integer, so you can calculate the sum of two private keys by summing them modulo the secp256k1 modulus.
|
||||
- An ECDSA secret key is just a very large integer, so you can calculate the sum of two secret keys by summing them modulo the secp256k1 group order.
|
||||
|
||||
- An ECDSA public key is a point on the elliptic curve, so you should use elliptic curve math to sum the points.
|
||||
|
||||
**Tip:** You don't need any private keys to derive the master public key. You can do so using only the root public key.
|
||||
|
||||
5. Convert the master public key to its 33-byte compressed form, as before.
|
||||
|
||||
6. When serializing an account's public key to its [base58][] format, use the account public key prefix, `0x23`.
|
||||
|
||||
@@ -72,14 +72,14 @@ The request can contain the following parameters:
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:-------------|:-------|:-----------------------------------------------------|
|
||||
| `key_type` | String | Which elliptic curve to use for this key pair. Valid values are `ed25519` and `secp256k1` (all lower case). Defaults to `secp256k1`. |
|
||||
| `key_type` | String |Which [signing algorithm](cryptographic-keys.html#signing-algorithms) to use to derive this key pair. Valid values are `ed25519` and `secp256k1` (all lower case). The default is `secp256k1`. |
|
||||
| `passphrase` | String | _(Optional)_ Generate a key pair and address from this seed value. This value can be formatted in [hexadecimal][], the XRP Ledger's [base58][] format, [RFC-1751][], or as an arbitrary string. Cannot be used with `seed` or `seed_hex`. |
|
||||
| `seed` | String | _(Optional)_ Generate the key pair and address from this seed value in the XRP Ledger's [base58][]-encoded format. Cannot be used with `passphrase` or `seed_hex`. |
|
||||
| `seed_hex` | String | _(Optional)_ Generate the key pair and address from this seed value in [hexadecimal][] format. Cannot be used with `passphrase` or `seed`. |
|
||||
|
||||
You must provide **at most one** of the following fields: `passphrase`, `seed`, or `seed_hex`. If you omit all three, `rippled` uses a random seed.
|
||||
|
||||
**Note:** [Ed25519](https://ed25519.cr.yp.to/) support is experimental. The commandline version of this command cannot generate Ed25519 keys.
|
||||
**Note:** The commandline version of this command cannot generate [Ed25519](https://ed25519.cr.yp.to/) keys.
|
||||
|
||||
#### Specifying a Seed
|
||||
|
||||
@@ -167,9 +167,10 @@ The response follows the [standard format][], with a successful result containin
|
||||
|
||||
| `Field` | Type | Description |
|
||||
|:------------------|:-------|:------------------------------------------------|
|
||||
| `key_type` | String | Which [signing algorithm](cryptographic-keys.html#signing-algorithms) was used to derive this key pair. Valid values are `ed25519` and `secp256k1` (all lower case). |
|
||||
| `master_seed` | String | This is the private key of the key pair. The master seed from which all other information about this account is derived, in the XRP Ledger's [base58][] encoded string format. Typically, you use the key in this format to sign transactions. |
|
||||
| `master_seed_hex` | String | The master seed, in hex format. A simple, widely-supported way to represent the private key. Can be used to sign transactions. |
|
||||
| `master_key` | String | The master seed, in [RFC 1751](http://tools.ietf.org/html/rfc1751) format. An easier to remember, easier-to-write-down version of the private key. Can be used to sign transactions. |
|
||||
| `master_key` | String | The master seed, in [RFC-1751][] format. An easier to remember, easier-to-write-down version of the private key. Can be used to sign transactions. **Note:** The `rippled` implementation reverses the byte order of the key after decoding from RFC-1751 and before encoding it to RFC-1751; if you read or write keys for use with the XRP Ledger using a different RFC-1751 implementation, you must do the same to be compatible with `rippled`'s RFC-1751 encoding. |
|
||||
| `account_id` | String | The [Address][] of the account in the XRP Ledger's [base58][] format. This is not the public key, but a hash-of-a-hash of it. It also has a checksum so a typo almost certainly results in an invalid address rather than a valid, but different address. This is the primary identifier of an account in the XRP Ledger. You tell people this to get paid, and use it in transactions to indicate who you are and who you're paying, trusting, and so forth. [Multi-signing lists](multi-signing.html) also use these to identify other signers. |
|
||||
| `public_key` | String | The public key of the key pair, in the XRP Ledger's [base58][] encoded string format. Derived from the `master_seed`. |
|
||||
| `public_key_hex` | String | This is the public key of the key pair, in hexadecimal. Derived from the `master_seed`. To validate the signature on a transaction, `rippled` needs this public key. That's why the format for a signed transaction includes the public key in the `SigningPubKey` field. |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Serialization Format
|
||||
[[Source]<br>](https://github.com/ripple/rippled/blob/develop/src/ripple/protocol/impl/STObject.cpp#L696-L718 "Source")
|
||||
|
||||
This page describes the XRP Ledger's canonical binary format for transactions and other data. This binary format is necessary to create and verify digital signatures of those transactions' contents, and is also used in other places. The [rippled APIs](rippled-api.html) typically use JSON to communicate with client applications. However, JSON is unsuitable as a format for serializing transactions for being digitally signed, because JSON can represent the same data in many different but equivalent ways.
|
||||
This page describes the XRP Ledger's canonical binary format for transactions and other data. This binary format is necessary to create and verify digital signatures of those transactions' contents, and is also used in other places including in the [peer-to-peer communications between servers](peer-protocol.html). The [`rippled` APIs](rippled-api.html) typically use JSON to communicate with client applications. However, JSON is unsuitable as a format for serializing transactions for being digitally signed, because JSON can represent the same data in many different but equivalent ways.
|
||||
|
||||
The process of serializing a transaction from JSON or any other representation into their canonical binary format can be summarized with these steps:
|
||||
|
||||
@@ -9,7 +9,7 @@ The process of serializing a transaction from JSON or any other representation i
|
||||
|
||||
The [Transaction Formats Reference](transaction-formats.html) defines the required and optional fields for XRP Ledger transactions.
|
||||
|
||||
**Note:** The `SigningPubKey` must also be provided at this step. When signing, you can derive this key from the secret key that is provided for signing.
|
||||
**Note:** The `SigningPubKey` must also be provided at this step. When signing, you can [derive this key](cryptographic-keys.html#key-derivation) from the secret key that is provided for signing.
|
||||
|
||||
2. Convert each field's data into its ["internal" binary format](#internal-format).
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
Reference in New Issue
Block a user