github.com/elastos/Elastos.ELA.SideChain.ETH@v0.2.2/chainbridge-core/crypto/keypair.go (about)

     1  // Copyright 2020 ChainSafe Systems
     2  // SPDX-License-Identifier: LGPL-3.0-only
     3  
     4  /*
     5  The crypto package is used to provide functionality to several keypair types.
     6  The current supported types are secp256k1 and sr25519.
     7  
     8  Keypairs
     9  
    10  The keypair interface is used to bridge the different types of crypto formats.
    11  Every Keypair has both a Encode and Decode function that allows writing and reading from keystore files.
    12  There is also the Address and PublicKey functions that allow access to public facing fields.
    13  
    14  Types
    15  
    16  A general overview on the secp256k1 can be found here: https://en.bitcoin.it/wiki/Secp256k1
    17  A general overview on the sr25519 type can be found here: https://wiki.polkadot.network/docs/en/learn-cryptography
    18  */
    19  package crypto
    20  
    21  type KeyType = string
    22  
    23  const Sr25519Type KeyType = "sr25519"
    24  const Secp256k1Type KeyType = "secp256k1"
    25  
    26  type Keypair interface {
    27  	// Encode is used to write the key to a file
    28  	Encode() []byte
    29  	// Decode is used to retrieve a key from a file
    30  	Decode([]byte) error
    31  	// Address provides the address for the keypair
    32  	Address() string
    33  	// PublicKey returns the keypair's public key an encoded a string
    34  	PublicKey() string
    35  	PublicKeyBytes() []byte
    36  }