You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.0 KiB

  1. /*
  2. go-crypto is a customized/convenience cryptography package
  3. for supporting Tendermint.
  4. It wraps select functionality of equivalent functions in the
  5. Go standard library, for easy usage with our libraries.
  6. Keys:
  7. All key generation functions return an instance of the PrivKey interface
  8. which implements methods
  9. AssertIsPrivKeyInner()
  10. Bytes() []byte
  11. Sign(msg []byte) Signature
  12. PubKey() PubKey
  13. Equals(PrivKey) bool
  14. Wrap() PrivKey
  15. From the above method we can:
  16. a) Retrieve the public key if needed
  17. pubKey := key.PubKey()
  18. For example:
  19. privKey, err := crypto.GenPrivKeyEd25519()
  20. if err != nil {
  21. ...
  22. }
  23. pubKey := privKey.PubKey()
  24. ...
  25. // And then you can use the private and public key
  26. doSomething(privKey, pubKey)
  27. We also provide hashing wrappers around algorithms:
  28. Sha256
  29. sum := crypto.Sha256([]byte("This is Tendermint"))
  30. fmt.Printf("%x\n", sum)
  31. Ripemd160
  32. sum := crypto.Ripemd160([]byte("This is consensus"))
  33. fmt.Printf("%x\n", sum)
  34. */
  35. package crypto
  36. // TODO: Add more docs in here