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.

837 lines
23 KiB

  1. # crypto
  2. `import "github.com/tendermint/go-crypto"`
  3. * [Overview](#pkg-overview)
  4. * [Index](#pkg-index)
  5. * [Subdirectories](#pkg-subdirectories)
  6. ## <a name="pkg-overview">Overview</a>
  7. ## <a name="pkg-index">Index</a>
  8. * [Constants](#pkg-constants)
  9. * [func CRandBytes(numBytes int) []byte](#CRandBytes)
  10. * [func CRandHex(numDigits int) string](#CRandHex)
  11. * [func CReader() io.Reader](#CReader)
  12. * [func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error)](#DecodeArmor)
  13. * [func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error)](#DecryptSymmetric)
  14. * [func EncodeArmor(blockType string, headers map[string]string, data []byte) string](#EncodeArmor)
  15. * [func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte)](#EncryptSymmetric)
  16. * [func MixEntropy(seedBytes []byte)](#MixEntropy)
  17. * [func Ripemd160(bytes []byte) []byte](#Ripemd160)
  18. * [func Sha256(bytes []byte) []byte](#Sha256)
  19. * [type PrivKey](#PrivKey)
  20. * [func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error)](#PrivKeyFromBytes)
  21. * [type PrivKeyEd25519](#PrivKeyEd25519)
  22. * [func GenPrivKeyEd25519() PrivKeyEd25519](#GenPrivKeyEd25519)
  23. * [func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519](#GenPrivKeyEd25519FromSecret)
  24. * [func (privKey PrivKeyEd25519) Bytes() []byte](#PrivKeyEd25519.Bytes)
  25. * [func (privKey PrivKeyEd25519) Equals(other PrivKey) bool](#PrivKeyEd25519.Equals)
  26. * [func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519](#PrivKeyEd25519.Generate)
  27. * [func (p PrivKeyEd25519) MarshalJSON() ([]byte, error)](#PrivKeyEd25519.MarshalJSON)
  28. * [func (privKey PrivKeyEd25519) PubKey() PubKey](#PrivKeyEd25519.PubKey)
  29. * [func (privKey PrivKeyEd25519) Sign(msg []byte) Signature](#PrivKeyEd25519.Sign)
  30. * [func (privKey PrivKeyEd25519) String() string](#PrivKeyEd25519.String)
  31. * [func (privKey PrivKeyEd25519) ToCurve25519() *[32]byte](#PrivKeyEd25519.ToCurve25519)
  32. * [func (p *PrivKeyEd25519) UnmarshalJSON(enc []byte) error](#PrivKeyEd25519.UnmarshalJSON)
  33. * [type PrivKeyS](#PrivKeyS)
  34. * [func (p PrivKeyS) Empty() bool](#PrivKeyS.Empty)
  35. * [func (p PrivKeyS) MarshalJSON() ([]byte, error)](#PrivKeyS.MarshalJSON)
  36. * [func (p *PrivKeyS) UnmarshalJSON(data []byte) (err error)](#PrivKeyS.UnmarshalJSON)
  37. * [type PrivKeySecp256k1](#PrivKeySecp256k1)
  38. * [func GenPrivKeySecp256k1() PrivKeySecp256k1](#GenPrivKeySecp256k1)
  39. * [func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1](#GenPrivKeySecp256k1FromSecret)
  40. * [func (privKey PrivKeySecp256k1) Bytes() []byte](#PrivKeySecp256k1.Bytes)
  41. * [func (privKey PrivKeySecp256k1) Equals(other PrivKey) bool](#PrivKeySecp256k1.Equals)
  42. * [func (p PrivKeySecp256k1) MarshalJSON() ([]byte, error)](#PrivKeySecp256k1.MarshalJSON)
  43. * [func (privKey PrivKeySecp256k1) PubKey() PubKey](#PrivKeySecp256k1.PubKey)
  44. * [func (privKey PrivKeySecp256k1) Sign(msg []byte) Signature](#PrivKeySecp256k1.Sign)
  45. * [func (privKey PrivKeySecp256k1) String() string](#PrivKeySecp256k1.String)
  46. * [func (p *PrivKeySecp256k1) UnmarshalJSON(enc []byte) error](#PrivKeySecp256k1.UnmarshalJSON)
  47. * [type PubKey](#PubKey)
  48. * [func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error)](#PubKeyFromBytes)
  49. * [type PubKeyEd25519](#PubKeyEd25519)
  50. * [func (pubKey PubKeyEd25519) Address() []byte](#PubKeyEd25519.Address)
  51. * [func (pubKey PubKeyEd25519) Bytes() []byte](#PubKeyEd25519.Bytes)
  52. * [func (pubKey PubKeyEd25519) Equals(other PubKey) bool](#PubKeyEd25519.Equals)
  53. * [func (pubKey PubKeyEd25519) KeyString() string](#PubKeyEd25519.KeyString)
  54. * [func (p PubKeyEd25519) MarshalJSON() ([]byte, error)](#PubKeyEd25519.MarshalJSON)
  55. * [func (pubKey PubKeyEd25519) String() string](#PubKeyEd25519.String)
  56. * [func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte](#PubKeyEd25519.ToCurve25519)
  57. * [func (p *PubKeyEd25519) UnmarshalJSON(enc []byte) error](#PubKeyEd25519.UnmarshalJSON)
  58. * [func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool](#PubKeyEd25519.VerifyBytes)
  59. * [type PubKeyS](#PubKeyS)
  60. * [func (p PubKeyS) Empty() bool](#PubKeyS.Empty)
  61. * [func (p PubKeyS) MarshalJSON() ([]byte, error)](#PubKeyS.MarshalJSON)
  62. * [func (p *PubKeyS) UnmarshalJSON(data []byte) (err error)](#PubKeyS.UnmarshalJSON)
  63. * [type PubKeySecp256k1](#PubKeySecp256k1)
  64. * [func (pubKey PubKeySecp256k1) Address() []byte](#PubKeySecp256k1.Address)
  65. * [func (pubKey PubKeySecp256k1) Bytes() []byte](#PubKeySecp256k1.Bytes)
  66. * [func (pubKey PubKeySecp256k1) Equals(other PubKey) bool](#PubKeySecp256k1.Equals)
  67. * [func (pubKey PubKeySecp256k1) KeyString() string](#PubKeySecp256k1.KeyString)
  68. * [func (p PubKeySecp256k1) MarshalJSON() ([]byte, error)](#PubKeySecp256k1.MarshalJSON)
  69. * [func (pubKey PubKeySecp256k1) String() string](#PubKeySecp256k1.String)
  70. * [func (p *PubKeySecp256k1) UnmarshalJSON(enc []byte) error](#PubKeySecp256k1.UnmarshalJSON)
  71. * [func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool](#PubKeySecp256k1.VerifyBytes)
  72. * [type Signature](#Signature)
  73. * [func SignatureFromBytes(sigBytes []byte) (sig Signature, err error)](#SignatureFromBytes)
  74. * [type SignatureEd25519](#SignatureEd25519)
  75. * [func (sig SignatureEd25519) Bytes() []byte](#SignatureEd25519.Bytes)
  76. * [func (sig SignatureEd25519) Equals(other Signature) bool](#SignatureEd25519.Equals)
  77. * [func (sig SignatureEd25519) IsZero() bool](#SignatureEd25519.IsZero)
  78. * [func (p SignatureEd25519) MarshalJSON() ([]byte, error)](#SignatureEd25519.MarshalJSON)
  79. * [func (sig SignatureEd25519) String() string](#SignatureEd25519.String)
  80. * [func (p *SignatureEd25519) UnmarshalJSON(enc []byte) error](#SignatureEd25519.UnmarshalJSON)
  81. * [type SignatureS](#SignatureS)
  82. * [func (p SignatureS) Empty() bool](#SignatureS.Empty)
  83. * [func (p SignatureS) MarshalJSON() ([]byte, error)](#SignatureS.MarshalJSON)
  84. * [func (p *SignatureS) UnmarshalJSON(data []byte) (err error)](#SignatureS.UnmarshalJSON)
  85. * [type SignatureSecp256k1](#SignatureSecp256k1)
  86. * [func (sig SignatureSecp256k1) Bytes() []byte](#SignatureSecp256k1.Bytes)
  87. * [func (sig SignatureSecp256k1) Equals(other Signature) bool](#SignatureSecp256k1.Equals)
  88. * [func (sig SignatureSecp256k1) IsZero() bool](#SignatureSecp256k1.IsZero)
  89. * [func (p SignatureSecp256k1) MarshalJSON() ([]byte, error)](#SignatureSecp256k1.MarshalJSON)
  90. * [func (sig SignatureSecp256k1) String() string](#SignatureSecp256k1.String)
  91. * [func (p *SignatureSecp256k1) UnmarshalJSON(enc []byte) error](#SignatureSecp256k1.UnmarshalJSON)
  92. #### <a name="pkg-files">Package files</a>
  93. [armor.go](/src/github.com/tendermint/go-crypto/armor.go) [hash.go](/src/github.com/tendermint/go-crypto/hash.go) [priv_key.go](/src/github.com/tendermint/go-crypto/priv_key.go) [pub_key.go](/src/github.com/tendermint/go-crypto/pub_key.go) [random.go](/src/github.com/tendermint/go-crypto/random.go) [signature.go](/src/github.com/tendermint/go-crypto/signature.go) [symmetric.go](/src/github.com/tendermint/go-crypto/symmetric.go)
  94. ## <a name="pkg-constants">Constants</a>
  95. ``` go
  96. const (
  97. TypeEd25519 = byte(0x01)
  98. TypeSecp256k1 = byte(0x02)
  99. NameEd25519 = "ed25519"
  100. NameSecp256k1 = "secp256k1"
  101. )
  102. ```
  103. Types of implementations
  104. ## <a name="CRandBytes">func</a> [CRandBytes](/src/target/random.go?s=698:734#L28)
  105. ``` go
  106. func CRandBytes(numBytes int) []byte
  107. ```
  108. This uses the OS and the Seed(s).
  109. ## <a name="CRandHex">func</a> [CRandHex](/src/target/random.go?s=924:959#L38)
  110. ``` go
  111. func CRandHex(numDigits int) string
  112. ```
  113. RandHex(24) gives 96 bits of randomness, strong enough for most purposes.
  114. ## <a name="CReader">func</a> [CReader](/src/target/random.go?s=1078:1102#L43)
  115. ``` go
  116. func CReader() io.Reader
  117. ```
  118. Returns a crand.Reader mixed with user-supplied entropy
  119. ## <a name="DecodeArmor">func</a> [DecodeArmor](/src/target/armor.go?s=596:699#L18)
  120. ``` go
  121. func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error)
  122. ```
  123. ## <a name="DecryptSymmetric">func</a> [DecryptSymmetric](/src/target/symmetric.go?s=1048:1133#L23)
  124. ``` go
  125. func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error)
  126. ```
  127. secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
  128. The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
  129. ## <a name="EncodeArmor">func</a> [EncodeArmor](/src/target/armor.go?s=125:206#L1)
  130. ``` go
  131. func EncodeArmor(blockType string, headers map[string]string, data []byte) string
  132. ```
  133. ## <a name="EncryptSymmetric">func</a> [EncryptSymmetric](/src/target/symmetric.go?s=356:430#L6)
  134. ``` go
  135. func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte)
  136. ```
  137. secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
  138. The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
  139. NOTE: call crypto.MixEntropy() first.
  140. ## <a name="MixEntropy">func</a> [MixEntropy](/src/target/random.go?s=407:440#L13)
  141. ``` go
  142. func MixEntropy(seedBytes []byte)
  143. ```
  144. Mix additional bytes of randomness, e.g. from hardware, user-input, etc.
  145. It is OK to call it multiple times. It does not diminish security.
  146. ## <a name="Ripemd160">func</a> [Ripemd160](/src/target/hash.go?s=185:220#L4)
  147. ``` go
  148. func Ripemd160(bytes []byte) []byte
  149. ```
  150. ## <a name="Sha256">func</a> [Sha256](/src/target/hash.go?s=78:110#L1)
  151. ``` go
  152. func Sha256(bytes []byte) []byte
  153. ```
  154. ## <a name="PrivKey">type</a> [PrivKey](/src/target/priv_key.go?s=326:435#L5)
  155. ``` go
  156. type PrivKey interface {
  157. Bytes() []byte
  158. Sign(msg []byte) Signature
  159. PubKey() PubKey
  160. Equals(PrivKey) bool
  161. }
  162. ```
  163. PrivKey is part of PrivAccount and state.PrivValidator.
  164. ### <a name="PrivKeyFromBytes">func</a> [PrivKeyFromBytes](/src/target/priv_key.go?s=1302:1373#L50)
  165. ``` go
  166. func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error)
  167. ```
  168. ## <a name="PrivKeyEd25519">type</a> [PrivKeyEd25519](/src/target/priv_key.go?s=1502:1530#L58)
  169. ``` go
  170. type PrivKeyEd25519 [64]byte
  171. ```
  172. Implements PrivKey
  173. ### <a name="GenPrivKeyEd25519">func</a> [GenPrivKeyEd25519](/src/target/priv_key.go?s=3003:3042#L116)
  174. ``` go
  175. func GenPrivKeyEd25519() PrivKeyEd25519
  176. ```
  177. ### <a name="GenPrivKeyEd25519FromSecret">func</a> [GenPrivKeyEd25519FromSecret](/src/target/priv_key.go?s=3290:3352#L125)
  178. ``` go
  179. func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519
  180. ```
  181. NOTE: secret should be the output of a KDF like bcrypt,
  182. if it's derived from user input.
  183. ### <a name="PrivKeyEd25519.Bytes">func</a> (PrivKeyEd25519) [Bytes](/src/target/priv_key.go?s=1532:1576#L60)
  184. ``` go
  185. func (privKey PrivKeyEd25519) Bytes() []byte
  186. ```
  187. ### <a name="PrivKeyEd25519.Equals">func</a> (PrivKeyEd25519) [Equals](/src/target/priv_key.go?s=1973:2029#L75)
  188. ``` go
  189. func (privKey PrivKeyEd25519) Equals(other PrivKey) bool
  190. ```
  191. ### <a name="PrivKeyEd25519.Generate">func</a> (PrivKeyEd25519) [Generate](/src/target/priv_key.go?s=2761:2825#L106)
  192. ``` go
  193. func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519
  194. ```
  195. Deterministically generates new priv-key bytes from key.
  196. ### <a name="PrivKeyEd25519.MarshalJSON">func</a> (PrivKeyEd25519) [MarshalJSON](/src/target/priv_key.go?s=2156:2209#L83)
  197. ``` go
  198. func (p PrivKeyEd25519) MarshalJSON() ([]byte, error)
  199. ```
  200. ### <a name="PrivKeyEd25519.PubKey">func</a> (PrivKeyEd25519) [PubKey](/src/target/priv_key.go?s=1826:1871#L70)
  201. ``` go
  202. func (privKey PrivKeyEd25519) PubKey() PubKey
  203. ```
  204. ### <a name="PrivKeyEd25519.Sign">func</a> (PrivKeyEd25519) [Sign](/src/target/priv_key.go?s=1635:1691#L64)
  205. ``` go
  206. func (privKey PrivKeyEd25519) Sign(msg []byte) Signature
  207. ```
  208. ### <a name="PrivKeyEd25519.String">func</a> (PrivKeyEd25519) [String](/src/target/priv_key.go?s=2613:2658#L101)
  209. ``` go
  210. func (privKey PrivKeyEd25519) String() string
  211. ```
  212. ### <a name="PrivKeyEd25519.ToCurve25519">func</a> (PrivKeyEd25519) [ToCurve25519](/src/target/priv_key.go?s=2399:2453#L94)
  213. ``` go
  214. func (privKey PrivKeyEd25519) ToCurve25519() *[32]byte
  215. ```
  216. ### <a name="PrivKeyEd25519.UnmarshalJSON">func</a> (\*PrivKeyEd25519) [UnmarshalJSON](/src/target/priv_key.go?s=2250:2306#L87)
  217. ``` go
  218. func (p *PrivKeyEd25519) UnmarshalJSON(enc []byte) error
  219. ```
  220. ## <a name="PrivKeyS">type</a> [PrivKeyS](/src/target/priv_key.go?s=929:962#L30)
  221. ``` go
  222. type PrivKeyS struct {
  223. PrivKey
  224. }
  225. ```
  226. PrivKeyS add json serialization to PrivKey
  227. ### <a name="PrivKeyS.Empty">func</a> (PrivKeyS) [Empty](/src/target/priv_key.go?s=1241:1271#L46)
  228. ``` go
  229. func (p PrivKeyS) Empty() bool
  230. ```
  231. ### <a name="PrivKeyS.MarshalJSON">func</a> (PrivKeyS) [MarshalJSON](/src/target/priv_key.go?s=964:1011#L34)
  232. ``` go
  233. func (p PrivKeyS) MarshalJSON() ([]byte, error)
  234. ```
  235. ### <a name="PrivKeyS.UnmarshalJSON">func</a> (\*PrivKeyS) [UnmarshalJSON](/src/target/priv_key.go?s=1057:1114#L38)
  236. ``` go
  237. func (p *PrivKeyS) UnmarshalJSON(data []byte) (err error)
  238. ```
  239. ## <a name="PrivKeySecp256k1">type</a> [PrivKeySecp256k1](/src/target/priv_key.go?s=3635:3665#L136)
  240. ``` go
  241. type PrivKeySecp256k1 [32]byte
  242. ```
  243. Implements PrivKey
  244. ### <a name="GenPrivKeySecp256k1">func</a> [GenPrivKeySecp256k1](/src/target/priv_key.go?s=5071:5114#L194)
  245. ``` go
  246. func GenPrivKeySecp256k1() PrivKeySecp256k1
  247. ```
  248. ### <a name="GenPrivKeySecp256k1FromSecret">func</a> [GenPrivKeySecp256k1FromSecret](/src/target/priv_key.go?s=5436:5502#L204)
  249. ``` go
  250. func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1
  251. ```
  252. NOTE: secret should be the output of a KDF like bcrypt,
  253. if it's derived from user input.
  254. ### <a name="PrivKeySecp256k1.Bytes">func</a> (PrivKeySecp256k1) [Bytes](/src/target/priv_key.go?s=3667:3713#L138)
  255. ``` go
  256. func (privKey PrivKeySecp256k1) Bytes() []byte
  257. ```
  258. ### <a name="PrivKeySecp256k1.Equals">func</a> (PrivKeySecp256k1) [Equals](/src/target/priv_key.go?s=4235:4293#L158)
  259. ``` go
  260. func (privKey PrivKeySecp256k1) Equals(other PrivKey) bool
  261. ```
  262. ### <a name="PrivKeySecp256k1.MarshalJSON">func</a> (PrivKeySecp256k1) [MarshalJSON](/src/target/priv_key.go?s=4426:4481#L166)
  263. ``` go
  264. func (p PrivKeySecp256k1) MarshalJSON() ([]byte, error)
  265. ```
  266. ### <a name="PrivKeySecp256k1.PubKey">func</a> (PrivKeySecp256k1) [PubKey](/src/target/priv_key.go?s=4032:4079#L151)
  267. ``` go
  268. func (privKey PrivKeySecp256k1) PubKey() PubKey
  269. ```
  270. ### <a name="PrivKeySecp256k1.Sign">func</a> (PrivKeySecp256k1) [Sign](/src/target/priv_key.go?s=3772:3830#L142)
  271. ``` go
  272. func (privKey PrivKeySecp256k1) Sign(msg []byte) Signature
  273. ```
  274. ### <a name="PrivKeySecp256k1.String">func</a> (PrivKeySecp256k1) [String](/src/target/priv_key.go?s=4673:4720#L177)
  275. ``` go
  276. func (privKey PrivKeySecp256k1) String() string
  277. ```
  278. ### <a name="PrivKeySecp256k1.UnmarshalJSON">func</a> (\*PrivKeySecp256k1) [UnmarshalJSON](/src/target/priv_key.go?s=4522:4580#L170)
  279. ``` go
  280. func (p *PrivKeySecp256k1) UnmarshalJSON(enc []byte) error
  281. ```
  282. ## <a name="PubKey">type</a> [PubKey](/src/target/pub_key.go?s=361:506#L7)
  283. ``` go
  284. type PubKey interface {
  285. Address() []byte
  286. Bytes() []byte
  287. KeyString() string
  288. VerifyBytes(msg []byte, sig Signature) bool
  289. Equals(PubKey) bool
  290. }
  291. ```
  292. PubKey is part of Account and Validator.
  293. ### <a name="PubKeyFromBytes">func</a> [PubKeyFromBytes](/src/target/pub_key.go?s=1203:1270#L45)
  294. ``` go
  295. func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error)
  296. ```
  297. ## <a name="PubKeyEd25519">type</a> [PubKeyEd25519](/src/target/pub_key.go?s=1396:1423#L53)
  298. ``` go
  299. type PubKeyEd25519 [32]byte
  300. ```
  301. Implements PubKey
  302. ### <a name="PubKeyEd25519.Address">func</a> (PubKeyEd25519) [Address](/src/target/pub_key.go?s=1425:1469#L55)
  303. ``` go
  304. func (pubKey PubKeyEd25519) Address() []byte
  305. ```
  306. ### <a name="PubKeyEd25519.Bytes">func</a> (PubKeyEd25519) [Bytes](/src/target/pub_key.go?s=1789:1831#L68)
  307. ``` go
  308. func (pubKey PubKeyEd25519) Bytes() []byte
  309. ```
  310. ### <a name="PubKeyEd25519.Equals">func</a> (PubKeyEd25519) [Equals](/src/target/pub_key.go?s=3064:3117#L119)
  311. ``` go
  312. func (pubKey PubKeyEd25519) Equals(other PubKey) bool
  313. ```
  314. ### <a name="PubKeyEd25519.KeyString">func</a> (PubKeyEd25519) [KeyString](/src/target/pub_key.go?s=2983:3029#L115)
  315. ``` go
  316. func (pubKey PubKeyEd25519) KeyString() string
  317. ```
  318. Must return the full bytes in hex.
  319. Used for map keying, etc.
  320. ### <a name="PubKeyEd25519.MarshalJSON">func</a> (PubKeyEd25519) [MarshalJSON](/src/target/pub_key.go?s=2279:2331#L87)
  321. ``` go
  322. func (p PubKeyEd25519) MarshalJSON() ([]byte, error)
  323. ```
  324. ### <a name="PubKeyEd25519.String">func</a> (PubKeyEd25519) [String](/src/target/pub_key.go?s=2823:2866#L109)
  325. ``` go
  326. func (pubKey PubKeyEd25519) String() string
  327. ```
  328. ### <a name="PubKeyEd25519.ToCurve25519">func</a> (PubKeyEd25519) [ToCurve25519](/src/target/pub_key.go?s=2585:2637#L100)
  329. ``` go
  330. func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte
  331. ```
  332. For use with golang/crypto/nacl/box
  333. If error, returns nil.
  334. ### <a name="PubKeyEd25519.UnmarshalJSON">func</a> (\*PubKeyEd25519) [UnmarshalJSON](/src/target/pub_key.go?s=2372:2427#L91)
  335. ``` go
  336. func (p *PubKeyEd25519) UnmarshalJSON(enc []byte) error
  337. ```
  338. ### <a name="PubKeyEd25519.VerifyBytes">func</a> (PubKeyEd25519) [VerifyBytes](/src/target/pub_key.go?s=1888:1960#L72)
  339. ``` go
  340. func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool
  341. ```
  342. ## <a name="PubKeyS">type</a> [PubKeyS](/src/target/pub_key.go?s=841:872#L25)
  343. ``` go
  344. type PubKeyS struct {
  345. PubKey
  346. }
  347. ```
  348. PubKeyS add json serialization to PubKey
  349. ### <a name="PubKeyS.Empty">func</a> (PubKeyS) [Empty](/src/target/pub_key.go?s=1144:1173#L41)
  350. ``` go
  351. func (p PubKeyS) Empty() bool
  352. ```
  353. ### <a name="PubKeyS.MarshalJSON">func</a> (PubKeyS) [MarshalJSON](/src/target/pub_key.go?s=874:920#L29)
  354. ``` go
  355. func (p PubKeyS) MarshalJSON() ([]byte, error)
  356. ```
  357. ### <a name="PubKeyS.UnmarshalJSON">func</a> (\*PubKeyS) [UnmarshalJSON](/src/target/pub_key.go?s=964:1020#L33)
  358. ``` go
  359. func (p *PubKeyS) UnmarshalJSON(data []byte) (err error)
  360. ```
  361. ## <a name="PubKeySecp256k1">type</a> [PubKeySecp256k1](/src/target/pub_key.go?s=3401:3430#L132)
  362. ``` go
  363. type PubKeySecp256k1 [33]byte
  364. ```
  365. Implements PubKey.
  366. Compressed pubkey (just the x-cord),
  367. prefixed with 0x02 or 0x03, depending on the y-cord.
  368. ### <a name="PubKeySecp256k1.Address">func</a> (PubKeySecp256k1) [Address](/src/target/pub_key.go?s=3497:3543#L135)
  369. ``` go
  370. func (pubKey PubKeySecp256k1) Address() []byte
  371. ```
  372. Implements Bitcoin style addresses: RIPEMD160(SHA256(pubkey))
  373. ### <a name="PubKeySecp256k1.Bytes">func</a> (PubKeySecp256k1) [Bytes](/src/target/pub_key.go?s=3774:3818#L145)
  374. ``` go
  375. func (pubKey PubKeySecp256k1) Bytes() []byte
  376. ```
  377. ### <a name="PubKeySecp256k1.Equals">func</a> (PubKeySecp256k1) [Equals](/src/target/pub_key.go?s=4897:4952#L192)
  378. ``` go
  379. func (pubKey PubKeySecp256k1) Equals(other PubKey) bool
  380. ```
  381. ### <a name="PubKeySecp256k1.KeyString">func</a> (PubKeySecp256k1) [KeyString](/src/target/pub_key.go?s=4814:4862#L188)
  382. ``` go
  383. func (pubKey PubKeySecp256k1) KeyString() string
  384. ```
  385. Must return the full bytes in hex.
  386. Used for map keying, etc.
  387. ### <a name="PubKeySecp256k1.MarshalJSON">func</a> (PubKeySecp256k1) [MarshalJSON](/src/target/pub_key.go?s=4405:4459#L171)
  388. ``` go
  389. func (p PubKeySecp256k1) MarshalJSON() ([]byte, error)
  390. ```
  391. ### <a name="PubKeySecp256k1.String">func</a> (PubKeySecp256k1) [String](/src/target/pub_key.go?s=4650:4695#L182)
  392. ``` go
  393. func (pubKey PubKeySecp256k1) String() string
  394. ```
  395. ### <a name="PubKeySecp256k1.UnmarshalJSON">func</a> (\*PubKeySecp256k1) [UnmarshalJSON](/src/target/pub_key.go?s=4500:4557#L175)
  396. ``` go
  397. func (p *PubKeySecp256k1) UnmarshalJSON(enc []byte) error
  398. ```
  399. ### <a name="PubKeySecp256k1.VerifyBytes">func</a> (PubKeySecp256k1) [VerifyBytes](/src/target/pub_key.go?s=3875:3949#L149)
  400. ``` go
  401. func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool
  402. ```
  403. ## <a name="Signature">type</a> [Signature](/src/target/signature.go?s=204:304#L3)
  404. ``` go
  405. type Signature interface {
  406. Bytes() []byte
  407. IsZero() bool
  408. String() string
  409. Equals(Signature) bool
  410. }
  411. ```
  412. Signature is a part of Txs and consensus Votes.
  413. ### <a name="SignatureFromBytes">func</a> [SignatureFromBytes](/src/target/signature.go?s=1031:1098#L40)
  414. ``` go
  415. func SignatureFromBytes(sigBytes []byte) (sig Signature, err error)
  416. ```
  417. ## <a name="SignatureEd25519">type</a> [SignatureEd25519](/src/target/signature.go?s=1221:1251#L48)
  418. ``` go
  419. type SignatureEd25519 [64]byte
  420. ```
  421. Implements Signature
  422. ### <a name="SignatureEd25519.Bytes">func</a> (SignatureEd25519) [Bytes](/src/target/signature.go?s=1253:1295#L50)
  423. ``` go
  424. func (sig SignatureEd25519) Bytes() []byte
  425. ```
  426. ### <a name="SignatureEd25519.Equals">func</a> (SignatureEd25519) [Equals](/src/target/signature.go?s=1520:1576#L58)
  427. ``` go
  428. func (sig SignatureEd25519) Equals(other Signature) bool
  429. ```
  430. ### <a name="SignatureEd25519.IsZero">func</a> (SignatureEd25519) [IsZero](/src/target/signature.go?s=1352:1393#L54)
  431. ``` go
  432. func (sig SignatureEd25519) IsZero() bool
  433. ```
  434. ### <a name="SignatureEd25519.MarshalJSON">func</a> (SignatureEd25519) [MarshalJSON](/src/target/signature.go?s=1701:1756#L66)
  435. ``` go
  436. func (p SignatureEd25519) MarshalJSON() ([]byte, error)
  437. ```
  438. ### <a name="SignatureEd25519.String">func</a> (SignatureEd25519) [String](/src/target/signature.go?s=1420:1463#L56)
  439. ``` go
  440. func (sig SignatureEd25519) String() string
  441. ```
  442. ### <a name="SignatureEd25519.UnmarshalJSON">func</a> (\*SignatureEd25519) [UnmarshalJSON](/src/target/signature.go?s=1797:1855#L70)
  443. ``` go
  444. func (p *SignatureEd25519) UnmarshalJSON(enc []byte) error
  445. ```
  446. ## <a name="SignatureS">type</a> [SignatureS](/src/target/signature.go?s=648:685#L20)
  447. ``` go
  448. type SignatureS struct {
  449. Signature
  450. }
  451. ```
  452. SignatureS add json serialization to Signature
  453. ### <a name="SignatureS.Empty">func</a> (SignatureS) [Empty](/src/target/signature.go?s=966:998#L36)
  454. ``` go
  455. func (p SignatureS) Empty() bool
  456. ```
  457. ### <a name="SignatureS.MarshalJSON">func</a> (SignatureS) [MarshalJSON](/src/target/signature.go?s=687:736#L24)
  458. ``` go
  459. func (p SignatureS) MarshalJSON() ([]byte, error)
  460. ```
  461. ### <a name="SignatureS.UnmarshalJSON">func</a> (\*SignatureS) [UnmarshalJSON](/src/target/signature.go?s=780:839#L28)
  462. ``` go
  463. func (p *SignatureS) UnmarshalJSON(data []byte) (err error)
  464. ```
  465. ## <a name="SignatureSecp256k1">type</a> [SignatureSecp256k1](/src/target/signature.go?s=2013:2043#L80)
  466. ``` go
  467. type SignatureSecp256k1 []byte
  468. ```
  469. Implements Signature
  470. ### <a name="SignatureSecp256k1.Bytes">func</a> (SignatureSecp256k1) [Bytes](/src/target/signature.go?s=2045:2089#L82)
  471. ``` go
  472. func (sig SignatureSecp256k1) Bytes() []byte
  473. ```
  474. ### <a name="SignatureSecp256k1.Equals">func</a> (SignatureSecp256k1) [Equals](/src/target/signature.go?s=2318:2376#L90)
  475. ``` go
  476. func (sig SignatureSecp256k1) Equals(other Signature) bool
  477. ```
  478. ### <a name="SignatureSecp256k1.IsZero">func</a> (SignatureSecp256k1) [IsZero](/src/target/signature.go?s=2146:2189#L86)
  479. ``` go
  480. func (sig SignatureSecp256k1) IsZero() bool
  481. ```
  482. ### <a name="SignatureSecp256k1.MarshalJSON">func</a> (SignatureSecp256k1) [MarshalJSON](/src/target/signature.go?s=2502:2559#L97)
  483. ``` go
  484. func (p SignatureSecp256k1) MarshalJSON() ([]byte, error)
  485. ```
  486. ### <a name="SignatureSecp256k1.String">func</a> (SignatureSecp256k1) [String](/src/target/signature.go?s=2216:2261#L88)
  487. ``` go
  488. func (sig SignatureSecp256k1) String() string
  489. ```
  490. ### <a name="SignatureSecp256k1.UnmarshalJSON">func</a> (\*SignatureSecp256k1) [UnmarshalJSON](/src/target/signature.go?s=2597:2657#L101)
  491. ``` go
  492. func (p *SignatureSecp256k1) UnmarshalJSON(enc []byte) error
  493. ```
  494. - - -
  495. Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)