crypto: Rename last traces of go-crypto (#1786)

Follow-up to #1782
This commit is contained in:
Alexander Simmerl 2018-06-22 06:24:36 +02:00 committed by Anton Kaliaev
parent 7e3de2027e
commit 3e1baf68f8
6 changed files with 40 additions and 43 deletions

View File

@ -1,6 +1,6 @@
# go-crypto # crypto
go-crypto is the cryptographic package adapted for Tendermint's uses crypto is the cryptographic package adapted for Tendermint's uses
## Importing it ## Importing it
`import "github.com/tendermint/tendermint/crypto"` `import "github.com/tendermint/tendermint/crypto"`
@ -11,7 +11,7 @@ For Binary encoding, please refer to the [Tendermint encoding spec](https://gith
## JSON Encoding ## JSON Encoding
go-crypto `.Bytes()` uses Amino:binary encoding, but Amino:JSON is also supported. crypto `.Bytes()` uses Amino:binary encoding, but Amino:JSON is also supported.
```go ```go
Example Amino:JSON encodings: Example Amino:JSON encodings:

View File

@ -15,7 +15,7 @@ func init() {
RegisterAmino(cdc) RegisterAmino(cdc)
} }
// RegisterAmino registers all go-crypto related types in the given (amino) codec. // RegisterAmino registers all crypto related types in the given (amino) codec.
func RegisterAmino(cdc *amino.Codec) { func RegisterAmino(cdc *amino.Codec) {
cdc.RegisterInterface((*PubKey)(nil), nil) cdc.RegisterInterface((*PubKey)(nil), nil)
cdc.RegisterConcrete(PubKeyEd25519{}, cdc.RegisterConcrete(PubKeyEd25519{},

View File

@ -1,48 +1,45 @@
/* // crypto is a customized/convenience cryptography package for supporting
go-crypto is a customized/convenience cryptography package // Tendermint.
for supporting Tendermint.
It wraps select functionality of equivalent functions in the // It wraps select functionality of equivalent functions in the
Go standard library, for easy usage with our libraries. // Go standard library, for easy usage with our libraries.
Keys: // Keys:
All key generation functions return an instance of the PrivKey interface // All key generation functions return an instance of the PrivKey interface
which implements methods // which implements methods
AssertIsPrivKeyInner() // AssertIsPrivKeyInner()
Bytes() []byte // Bytes() []byte
Sign(msg []byte) Signature // Sign(msg []byte) Signature
PubKey() PubKey // PubKey() PubKey
Equals(PrivKey) bool // Equals(PrivKey) bool
Wrap() PrivKey // Wrap() PrivKey
From the above method we can: // From the above method we can:
a) Retrieve the public key if needed // a) Retrieve the public key if needed
pubKey := key.PubKey() // pubKey := key.PubKey()
For example: // For example:
privKey, err := crypto.GenPrivKeyEd25519() // privKey, err := crypto.GenPrivKeyEd25519()
if err != nil { // if err != nil {
... // ...
} // }
pubKey := privKey.PubKey() // pubKey := privKey.PubKey()
... // ...
// And then you can use the private and public key // // And then you can use the private and public key
doSomething(privKey, pubKey) // doSomething(privKey, pubKey)
// We also provide hashing wrappers around algorithms:
We also provide hashing wrappers around algorithms: // Sha256
// sum := crypto.Sha256([]byte("This is Tendermint"))
// fmt.Printf("%x\n", sum)
Sha256 // Ripemd160
sum := crypto.Sha256([]byte("This is Tendermint")) // sum := crypto.Ripemd160([]byte("This is consensus"))
fmt.Printf("%x\n", sum) // fmt.Printf("%x\n", sum)
Ripemd160
sum := crypto.Ripemd160([]byte("This is consensus"))
fmt.Printf("%x\n", sum)
*/
package crypto package crypto
// TODO: Add more docs in here // TODO: Add more docs in here

View File

@ -28,7 +28,7 @@ func TestReadPrivKey(t *testing.T) {
// garbage in, garbage out // garbage in, garbage out
garbage := []byte("hjgewugfbiewgofwgewr") garbage := []byte("hjgewugfbiewgofwgewr")
XXX This test wants to register BadKey globally to go-crypto, XXX This test wants to register BadKey globally to crypto,
but we don't want to support that. but we don't want to support that.
_, err := PrivKeyFromBytes(garbage) _, err := PrivKeyFromBytes(garbage)
require.Error(err) require.Error(err)

View File

@ -7,7 +7,7 @@ For details on peer discovery, see the [peer exchange (PEX) reactor doc](https:/
## Peer Identity ## Peer Identity
Tendermint peers are expected to maintain long-term persistent identities in the form of a public key. Tendermint peers are expected to maintain long-term persistent identities in the form of a public key.
Each peer has an ID defined as `peer.ID == peer.PubKey.Address()`, where `Address` uses the scheme defined in go-crypto. Each peer has an ID defined as `peer.ID == peer.PubKey.Address()`, where `Address` uses the scheme defined in `crypto` package.
A single peer ID can have multiple IP addresses associated with it, but a node A single peer ID can have multiple IP addresses associated with it, but a node
will only ever connect to one at a time. will only ever connect to one at a time.

View File

@ -58,7 +58,7 @@ func (tm2pb) Validator(val *Validator) abci.Validator {
} }
// XXX: panics on nil or unknown pubkey type // XXX: panics on nil or unknown pubkey type
// TODO: add cases when new pubkey types are added to go-crypto // TODO: add cases when new pubkey types are added to crypto
func (tm2pb) PubKey(pubKey crypto.PubKey) abci.PubKey { func (tm2pb) PubKey(pubKey crypto.PubKey) abci.PubKey {
switch pk := pubKey.(type) { switch pk := pubKey.(type) {
case crypto.PubKeyEd25519: case crypto.PubKeyEd25519:
@ -153,7 +153,7 @@ var PB2TM = pb2tm{}
type pb2tm struct{} type pb2tm struct{}
func (pb2tm) PubKey(pubKey abci.PubKey) (crypto.PubKey, error) { func (pb2tm) PubKey(pubKey abci.PubKey) (crypto.PubKey, error) {
// TODO: define these in go-crypto and use them // TODO: define these in crypto and use them
sizeEd := 32 sizeEd := 32
sizeSecp := 33 sizeSecp := 33
switch pubKey.Type { switch pubKey.Type {