Browse Source

update some docs

pull/1606/head
Ethan Buchman 6 years ago
parent
commit
d47b4ef12d
5 changed files with 22 additions and 144 deletions
  1. +1
    -1
      CHANGELOG.md
  2. +5
    -8
      README.md
  3. +9
    -11
      docs/spec/blockchain/encoding.md
  4. +6
    -123
      docs/spec/scripts/crypto.go
  5. +1
    -1
      networks/local/README.md

+ 1
- 1
CHANGELOG.md View File

@ -12,7 +12,7 @@ BREAKING CHANGES:
* Integers are encoded as strings * Integers are encoded as strings
- [crypto] Update go-crypto to v0.10.0 and merge into `crypto` - [crypto] Update go-crypto to v0.10.0 and merge into `crypto`
* privKey.Sign returns error. * privKey.Sign returns error.
* ed25519 address is the first 20-bytes of the SHA256 of the pubkey
* ed25519 address changed to the first 20-bytes of the SHA256 of the raw pubkey bytes
* `tmlibs/merkle` -> `crypto/merkle`. Uses SHA256 instead of RIPEMD160 * `tmlibs/merkle` -> `crypto/merkle`. Uses SHA256 instead of RIPEMD160
- [rpc] `syncing` is now called `catching_up`. - [rpc] `syncing` is now called `catching_up`.


+ 5
- 8
README.md View File

@ -50,11 +50,11 @@ Go version | Go1.9 or higher
## Install ## Install
See the [install instructions](/docs/install.rst)
See the [install instructions](/docs/install.md)
## Quick Start ## Quick Start
- [Single node](/docs/using-tendermint.rst)
- [Single node](/docs/using-tendermint.md)
- [Local cluster using docker-compose](/networks/local) - [Local cluster using docker-compose](/networks/local)
- [Remote cluster using terraform and ansible](/docs/terraform-and-ansible.md) - [Remote cluster using terraform and ansible](/docs/terraform-and-ansible.md)
- [Join the public testnet](https://cosmos.network/testnet) - [Join the public testnet](https://cosmos.network/testnet)
@ -72,10 +72,7 @@ Additional information about some - and eventually all - of the sub-projects bel
### Sub-projects ### Sub-projects
* [ABCI](http://github.com/tendermint/abci), the Application Blockchain Interface
* [Go-Wire](http://github.com/tendermint/go-wire), a deterministic serialization library
* [Go-Crypto](http://github.com/tendermint/tendermint/crypto), an elliptic curve cryptography library
* [TmLibs](http://github.com/tendermint/tmlibs), an assortment of Go libraries used internally
* [Amino](http://github.com/tendermint/go-amino), a reflection-based improvement on proto3
* [IAVL](http://github.com/tendermint/iavl), Merkleized IAVL+ Tree implementation * [IAVL](http://github.com/tendermint/iavl), Merkleized IAVL+ Tree implementation
### Tools ### Tools
@ -119,8 +116,8 @@ CHANGELOG even if they don't lead to MINOR version bumps:
- node - node
Exported objects in these packages that are not covered by the versioning scheme Exported objects in these packages that are not covered by the versioning scheme
are explicitly marked by `// UNSTABLE` in their go doc comment and may change at any time.
Functions, types, and values in any other package may also change at any time.
are explicitly marked by `// UNSTABLE` in their go doc comment and may change at any
time without notice. Functions, types, and values in any other package may also change at any time.
### Upgrades ### Upgrades


+ 9
- 11
docs/spec/blockchain/encoding.md View File

@ -54,17 +54,15 @@ familiar with amino encoding.
You can simply use below table and concatenate Prefix || Length (of raw bytes) || raw bytes You can simply use below table and concatenate Prefix || Length (of raw bytes) || raw bytes
( while || stands for byte concatenation here). ( while || stands for byte concatenation here).
| Type | Name | Prefix | Length |
| ---- | ---- | ------ | ----- |
| PubKeyEd25519 | tendermint/PubKeyEd25519 | 0x1624DE62 | 0x20 |
| PubKeyLedgerEd25519 | tendermint/PubKeyLedgerEd25519 | 0x5C3453B2 | 0x20 |
| PubKeySecp256k1 | tendermint/PubKeySecp256k1 | 0xEB5AE982 | 0x21 |
| PrivKeyEd25519 | tendermint/PrivKeyEd25519 | 0xA3288912 | 0x40 |
| PrivKeySecp256k1 | tendermint/PrivKeySecp256k1 | 0xE1B0F79A | 0x20 |
| PrivKeyLedgerSecp256k1 | tendermint/PrivKeyLedgerSecp256k1 | 0x10CAB393 | variable |
| PrivKeyLedgerEd25519 | tendermint/PrivKeyLedgerEd25519 | 0x0CFEEF9B | variable |
| SignatureEd25519 | tendermint/SignatureKeyEd25519 | 0x3DA1DB2A | 0x40 |
| SignatureSecp256k1 | tendermint/SignatureKeySecp256k1 | 0x16E1FEEA | variable |
| Type | Name | Prefix | Length | Notes |
| ---- | ---- | ------ | ----- | ------ |
| PubKeyEd25519 | tendermint/PubKeyEd25519 | 0x1624DE64 | 0x20 | |
| PubKeySecp256k1 | tendermint/PubKeySecp256k1 | 0xEB5AE987 | 0x21 | |
| PrivKeyEd25519 | tendermint/PrivKeyEd25519 | 0xA3288910 | 0x40 | |
| PrivKeySecp256k1 | tendermint/PrivKeySecp256k1 | 0xE1B0F79B | 0x20 | |
| SignatureEd25519 | tendermint/SignatureEd25519 | 0x2031EA53 | 0x40 | |
| SignatureSecp256k1 | tendermint/SignatureSecp256k1 | 0x7FC4A495 | variable |
|
### Examples ### Examples


+ 6
- 123
docs/spec/scripts/crypto.go View File

@ -2,132 +2,15 @@ package main
import ( import (
"fmt" "fmt"
"os"
"github.com/tendermint/tendermint/crypto"
amino "github.com/tendermint/go-amino"
crypto "github.com/tendermint/tendermint/crypto"
) )
// SECRET
var SECRET = []byte("some secret")
func printEd() {
priv := crypto.GenPrivKeyEd25519FromSecret(SECRET)
pub := priv.PubKey().(crypto.PubKeyEd25519)
sigV, err := priv.Sign([]byte("hello"))
if err != nil {
fmt.Println("Unexpected error:", err)
}
sig := sigV.(crypto.SignatureEd25519)
name := "tendermint/PubKeyEd25519"
length := len(pub[:])
fmt.Println("### PubKeyEd25519")
fmt.Println("")
fmt.Println("```")
fmt.Printf("// Name: %s\n", name)
fmt.Printf("// PrefixBytes: 0x%X \n", pub.Bytes()[:4])
fmt.Printf("// Length: 0x%X \n", length)
fmt.Println("// Notes: raw 32-byte Ed25519 pubkey")
fmt.Println("type PubKeyEd25519 [32]byte")
fmt.Println("")
fmt.Println(`func (pubkey PubKeyEd25519) Address() []byte {
// NOTE: hash of the Amino encoded bytes!
return RIPEMD160(AminoEncode(pubkey))
}`)
fmt.Println("```")
fmt.Println("")
fmt.Printf("For example, the 32-byte Ed25519 pubkey `%X` would be encoded as `%X`.\n\n", pub[:], pub.Bytes())
fmt.Printf("The address would then be `RIPEMD160(0x%X)` or `%X`\n", pub.Bytes(), pub.Address())
fmt.Println("")
name = "tendermint/SignatureKeyEd25519"
length = len(sig[:])
fmt.Println("### SignatureEd25519")
fmt.Println("")
fmt.Println("```")
fmt.Printf("// Name: %s\n", name)
fmt.Printf("// PrefixBytes: 0x%X \n", sig.Bytes()[:4])
fmt.Printf("// Length: 0x%X \n", length)
fmt.Println("// Notes: raw 64-byte Ed25519 signature")
fmt.Println("type SignatureEd25519 [64]byte")
fmt.Println("```")
fmt.Println("")
fmt.Printf("For example, the 64-byte Ed25519 signature `%X` would be encoded as `%X`\n", sig[:], sig.Bytes())
fmt.Println("")
name = "tendermint/PrivKeyEd25519"
fmt.Println("### PrivKeyEd25519")
fmt.Println("")
fmt.Println("```")
fmt.Println("// Name:", name)
fmt.Println("// Notes: raw 32-byte priv key concatenated to raw 32-byte pub key")
fmt.Println("type PrivKeyEd25519 [64]byte")
fmt.Println("```")
}
func printSecp() {
priv := crypto.GenPrivKeySecp256k1FromSecret(SECRET)
pub := priv.PubKey().(crypto.PubKeySecp256k1)
sigV, err := priv.Sign([]byte("hello"))
if err != nil {
fmt.Println("Unexpected error:", err)
}
sig := sigV.(crypto.SignatureSecp256k1)
name := "tendermint/PubKeySecp256k1"
length := len(pub[:])
fmt.Println("### PubKeySecp256k1")
fmt.Println("")
fmt.Println("```")
fmt.Printf("// Name: %s\n", name)
fmt.Printf("// PrefixBytes: 0x%X \n", pub.Bytes()[:4])
fmt.Printf("// Length: 0x%X \n", length)
fmt.Println("// Notes: OpenSSL compressed pubkey prefixed with 0x02 or 0x03")
fmt.Println("type PubKeySecp256k1 [33]byte")
fmt.Println("")
fmt.Println(`func (pubkey PubKeySecp256k1) Address() []byte {
// NOTE: hash of the raw pubkey bytes (not Amino encoded!).
// Compatible with Bitcoin addresses.
return RIPEMD160(SHA256(pubkey[:]))
}`)
fmt.Println("```")
fmt.Println("")
fmt.Printf("For example, the 33-byte Secp256k1 pubkey `%X` would be encoded as `%X`\n\n", pub[:], pub.Bytes())
fmt.Printf("The address would then be `RIPEMD160(SHA256(0x%X))` or `%X`\n", pub[:], pub.Address())
fmt.Println("")
name = "tendermint/SignatureKeySecp256k1"
fmt.Println("### SignatureSecp256k1")
fmt.Println("")
fmt.Println("```")
fmt.Printf("// Name: %s\n", name)
fmt.Printf("// PrefixBytes: 0x%X \n", sig.Bytes()[:4])
fmt.Printf("// Length: Variable\n")
fmt.Printf("// Encoding prefix: Variable\n")
fmt.Println("// Notes: raw bytes of the Secp256k1 signature")
fmt.Println("type SignatureSecp256k1 []byte")
fmt.Println("```")
fmt.Println("")
fmt.Printf("For example, the Secp256k1 signature `%X` would be encoded as `%X`\n", []byte(sig[:]), sig.Bytes())
fmt.Println("")
name = "tendermint/PrivKeySecp256k1"
fmt.Println("### PrivKeySecp256k1")
fmt.Println("")
fmt.Println("```")
fmt.Println("// Name:", name)
fmt.Println("// Notes: raw 32-byte priv key")
fmt.Println("type PrivKeySecp256k1 [32]byte")
fmt.Println("```")
}
func main() { func main() {
printEd()
cdc := amino.NewCodec()
crypto.RegisterAmino(cdc)
cdc.PrintTypes(os.Stdout)
fmt.Println("") fmt.Println("")
printSecp()
} }

+ 1
- 1
networks/local/README.md View File

@ -2,7 +2,7 @@
## Requirements ## Requirements
- [Install tendermint](/docs/install.rst)
- [Install tendermint](/docs/install.md)
- [Install docker](https://docs.docker.com/engine/installation/) - [Install docker](https://docs.docker.com/engine/installation/)
- [Install docker-compose](https://docs.docker.com/compose/install/) - [Install docker-compose](https://docs.docker.com/compose/install/)


Loading…
Cancel
Save