1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-27 02:18:25 +00:00

Made changes to appdx-sx.asciidoc

This commit is contained in:
drusselloctal@gmail.com 2014-10-31 08:50:00 -07:00
parent 5c02ed6914
commit b2c4f790f5

View File

@ -123,7 +123,7 @@ UTILITY
encode-addr Encode an address from internal RIPEMD representation to encode-addr Encode an address from internal RIPEMD representation to
base58check form. base58check form.
FORMAT (WIF) FORMAT (WIF)
secret-to-wif Convert a secret exponent value to Wallet Import Format secret-to-wif Convert a secret exponent value to Wallet Import Format.
wif-to-secret Convert a Wallet Import Format to secret exponent value. wif-to-secret Convert a Wallet Import Format to secret exponent value.
HASHES HASHES
ripemd-hash RIPEMD hash data from STDIN. ripemd-hash RIPEMD hash data from STDIN.
@ -138,9 +138,9 @@ See 'sx help COMMAND' for more information on a specific command.
---- ----
Below, we look at some examples of using sx tools to experiment with keys and addresses. Next, we look at some examples of using sx tools to experiment with keys and addresses.
Generate a new private key with the operating system's random number generator by using the +newkey+ command. We save the standard output into the file +private_key+: Generate a new private key with the operating system's random number generator by using the +newkey+ command. We save the standard output into the file _private_key_:
---- ----
$ sx newkey > private_key $ sx newkey > private_key
@ -148,7 +148,7 @@ $ cat private_key
5Jgx3UAaXw8AcCQCi1j7uaTaqpz2fqNR9K3r4apxdYn6rTzR1PL 5Jgx3UAaXw8AcCQCi1j7uaTaqpz2fqNR9K3r4apxdYn6rTzR1PL
---- ----
Now, generate the public key from that private key using the +pubkey+ command. Pass the +private_key+ file into the standard input and save the standard output of the command into a new file +public_key+: Now, generate the public key from that private key using the +pubkey+ command. Pass the _private_key_ file into the standard input and save the standard output of the command into a new file _public_key_:
---- ----
$ sx pubkey < private_key > public_key $ sx pubkey < private_key > public_key
@ -156,14 +156,14 @@ $ cat public_key
02fca46a6006a62dfdd2dbb2149359d0d97a04f430f12a7626dd409256c12be500 02fca46a6006a62dfdd2dbb2149359d0d97a04f430f12a7626dd409256c12be500
---- ----
We can re-format the public_key as an address using the +addr+ command. We pass the +public_key+ into standard input: We can reformat the +public_key+ as an address using the +addr+ command. We pass the +public_key+ into standard input:
---- ----
$ sx addr < public_key $ sx addr < public_key
17re1S4Q8ZHyCP8Kw7xQad1Lr6XUzWUnkG 17re1S4Q8ZHyCP8Kw7xQad1Lr6XUzWUnkG
---- ----
The keys generated above are so called type-0 non-deterministic keys. That means that each one is generated from a random number generator. The sx tools also support type-2 deterministic keys, where a "master" key is created and then extended to produce a chain or tree of subkeys. The keys generated are so called type-0 nondeterministic keys. That means that each one is generated from a random number generator. The sx tools also support type-2 deterministic keys, where a "master" key is created and then extended to produce a chain or tree of subkeys.
First, we generate a "seed" that will be used as the basis to derive a chain of keys, compatible with the Electrum wallet and other similar implementations. We use the +newseed+ command to produce a seed value: First, we generate a "seed" that will be used as the basis to derive a chain of keys, compatible with the Electrum wallet and other similar implementations. We use the +newseed+ command to produce a seed value:
@ -189,7 +189,7 @@ $ sx mnemonic < words
eb68ee9f3df6bd4441a9feadec179ff1 eb68ee9f3df6bd4441a9feadec179ff1
---- ----
With the seed, we can now generate a sequence of private and public keys, a key chain. We use the +genpriv+ command to generate a sequence of private keys from a seed and the +addr+ command to generate the corresponding public key. With the seed, we can now generate a sequence of private and public keys, a key chain. We use the +genpriv+ command to generate a sequence of private keys from a seed and the +addr+ command to generate the corresponding public key:
[source,bash] [source,bash]
---- ----
@ -204,4 +204,4 @@ $ sx genpriv 1 < seed | sx addr
1G1oTeXitk76c2fvQWny4pryTdH1RTqSPW 1G1oTeXitk76c2fvQWny4pryTdH1RTqSPW
---- ----
With deterministic keys we can generate and re-generate thousands of keys, all derived from a single seed in a deterministic chain. This technique is used in many wallet applications to generate keys that can be backed up and restored with a simple multi-word mnemonic. This is easier than having to back up the wallet with all its randomly generated keys every time a new key is created. With deterministic keys we can generate and regenerate thousands of keys, all derived from a single seed in a deterministic chain. This technique is used in many wallet applications to generate keys that can be backed up and restored with a simple multi-word mnemonic. This is easier than having to back up the wallet with all its randomly generated keys every time a new key is created.