From 3e1baf68f83dc1da2afa1cb8b7458e39369a563c Mon Sep 17 00:00:00 2001 From: Alexander Simmerl Date: Fri, 22 Jun 2018 06:24:36 +0200 Subject: [PATCH] crypto: Rename last traces of go-crypto (#1786) Follow-up to #1782 --- crypto/README.md | 6 ++-- crypto/amino.go | 2 +- crypto/doc.go | 67 ++++++++++++++++++++--------------------- crypto/priv_key_test.go | 2 +- docs/spec/p2p/peer.md | 2 +- types/protobuf.go | 4 +-- 6 files changed, 40 insertions(+), 43 deletions(-) diff --git a/crypto/README.md b/crypto/README.md index b160f715c..32afde699 100644 --- a/crypto/README.md +++ b/crypto/README.md @@ -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 `import "github.com/tendermint/tendermint/crypto"` @@ -11,7 +11,7 @@ For Binary encoding, please refer to the [Tendermint encoding spec](https://gith ## 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 Example Amino:JSON encodings: diff --git a/crypto/amino.go b/crypto/amino.go index 2a57afdee..6a8703fc9 100644 --- a/crypto/amino.go +++ b/crypto/amino.go @@ -15,7 +15,7 @@ func init() { 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) { cdc.RegisterInterface((*PubKey)(nil), nil) cdc.RegisterConcrete(PubKeyEd25519{}, diff --git a/crypto/doc.go b/crypto/doc.go index c6701bc58..544e0df36 100644 --- a/crypto/doc.go +++ b/crypto/doc.go @@ -1,48 +1,45 @@ -/* -go-crypto is a customized/convenience cryptography package -for supporting Tendermint. +// crypto is a customized/convenience cryptography package for supporting +// Tendermint. -It wraps select functionality of equivalent functions in the -Go standard library, for easy usage with our libraries. +// It wraps select functionality of equivalent functions in the +// Go standard library, for easy usage with our libraries. -Keys: +// Keys: -All key generation functions return an instance of the PrivKey interface -which implements methods +// All key generation functions return an instance of the PrivKey interface +// which implements methods - AssertIsPrivKeyInner() - Bytes() []byte - Sign(msg []byte) Signature - PubKey() PubKey - Equals(PrivKey) bool - Wrap() PrivKey +// AssertIsPrivKeyInner() +// Bytes() []byte +// Sign(msg []byte) Signature +// PubKey() PubKey +// Equals(PrivKey) bool +// Wrap() PrivKey -From the above method we can: -a) Retrieve the public key if needed +// From the above method we can: +// a) Retrieve the public key if needed - pubKey := key.PubKey() +// pubKey := key.PubKey() -For example: - privKey, err := crypto.GenPrivKeyEd25519() - if err != nil { - ... - } - pubKey := privKey.PubKey() - ... - // And then you can use the private and public key - doSomething(privKey, pubKey) +// For example: +// privKey, err := crypto.GenPrivKeyEd25519() +// if err != nil { +// ... +// } +// pubKey := privKey.PubKey() +// ... +// // And then you can use the private and public key +// 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 - sum := crypto.Sha256([]byte("This is Tendermint")) - fmt.Printf("%x\n", sum) - -Ripemd160 - sum := crypto.Ripemd160([]byte("This is consensus")) - fmt.Printf("%x\n", sum) -*/ +// Ripemd160 +// sum := crypto.Ripemd160([]byte("This is consensus")) +// fmt.Printf("%x\n", sum) package crypto // TODO: Add more docs in here diff --git a/crypto/priv_key_test.go b/crypto/priv_key_test.go index ab56ebad2..c1ae33ed1 100644 --- a/crypto/priv_key_test.go +++ b/crypto/priv_key_test.go @@ -28,7 +28,7 @@ func TestReadPrivKey(t *testing.T) { // garbage in, garbage out 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. _, err := PrivKeyFromBytes(garbage) require.Error(err) diff --git a/docs/spec/p2p/peer.md b/docs/spec/p2p/peer.md index 3cda0c8a4..69c5bbacf 100644 --- a/docs/spec/p2p/peer.md +++ b/docs/spec/p2p/peer.md @@ -7,7 +7,7 @@ For details on peer discovery, see the [peer exchange (PEX) reactor doc](https:/ ## Peer Identity 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 will only ever connect to one at a time. diff --git a/types/protobuf.go b/types/protobuf.go index 5155b4b81..b3f5c86f6 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -58,7 +58,7 @@ func (tm2pb) Validator(val *Validator) abci.Validator { } // 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 { switch pk := pubKey.(type) { case crypto.PubKeyEd25519: @@ -153,7 +153,7 @@ var PB2TM = pb2tm{} type pb2tm struct{} 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 sizeSecp := 33 switch pubKey.Type {