github.com/igggame/nebulas-go@v2.1.0+incompatible/crypto/keystore/key.go (about) 1 // Copyright (C) 2017 go-nebulas authors 2 // 3 // This file is part of the go-nebulas library. 4 // 5 // the go-nebulas library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // the go-nebulas library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with the go-nebulas library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 19 package keystore 20 21 // Algorithm type alias 22 type Algorithm uint8 23 24 const ( 25 // SECP256K1 a type of signer 26 SECP256K1 Algorithm = 1 27 28 // SCRYPT a type of encrypt 29 SCRYPT Algorithm = 1 << 4 30 ) 31 32 // Key interface 33 type Key interface { 34 35 // Algorithm returns the standard algorithm for this key. For 36 // example, "ECDSA" would indicate that this key is a ECDSA key. 37 Algorithm() Algorithm 38 39 // Encoded returns the key in its primary encoding format, or null 40 // if this key does not support encoding. 41 Encoded() ([]byte, error) 42 43 // Decode decode data to key 44 Decode(data []byte) error 45 46 // Clear clear key content 47 Clear() 48 } 49 50 // PrivateKey privatekey interface 51 type PrivateKey interface { 52 53 // Algorithm returns the standard algorithm for this key. For 54 // example, "ECDSA" would indicate that this key is a ECDSA key. 55 Algorithm() Algorithm 56 57 // Encoded returns the key in its primary encoding format, or null 58 // if this key does not support encoding. 59 Encoded() ([]byte, error) 60 61 // Decode decode data to key 62 Decode(data []byte) error 63 64 // Clear clear key content 65 Clear() 66 67 // PublicKey returns publickey 68 PublicKey() PublicKey 69 } 70 71 // PublicKey publickey interface 72 type PublicKey interface { 73 74 // Algorithm returns the standard algorithm for this key. For 75 // example, "ECDSA" would indicate that this key is a ECDSA key. 76 Algorithm() Algorithm 77 78 // Encoded returns the key in its primary encoding format, or null 79 // if this key does not support encoding. 80 Encoded() ([]byte, error) 81 82 // Decode decode data to key 83 Decode(data []byte) error 84 85 // Clear clear key content 86 Clear() 87 }