Documentation ¶
Index ¶
- func GenBLSKeyWithPassPhrase(passphrase string) (*ffi_bls.SecretKey, string, error)
- func LoadAwsCMKEncryptedBLSKey(fileName string, kmsClient *kms.KMS) (*ffi_bls.SecretKey, error)
- func LoadBLSKeyWithPassPhrase(fileName, passphrase string) (*ffi_bls.SecretKey, error)
- func LoadKeys(cfg Config) (multibls.PrivateKeys, error)
- func WriteToFile(filename string, data string) error
- type AwsCfgSrcType
- type AwsConfig
- type Config
- type PassSrcType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenBLSKeyWithPassPhrase ¶
GenBLSKeyWithPassPhrase generates bls key with passphrase and write into disk.
func LoadAwsCMKEncryptedBLSKey ¶
LoadAwsCMKEncryptedBLSKey loads aws encrypted bls key.
func LoadBLSKeyWithPassPhrase ¶
LoadBLSKeyWithPassPhrase loads bls key with passphrase.
func LoadKeys ¶
func LoadKeys(cfg Config) (multibls.PrivateKeys, error)
LoadKeys load all BLS keys with the given config. If loading keys from files, the file extension will decide which decryption algorithm to use.
Example ¶
dir, err := prepareDataForExample() if err != nil { fmt.Println(err) return } config := Config{ BlsDir: &dir, PassSrcType: PassSrcFile, // not assign PassFile to dynamically use .pass path AwsCfgSrcType: AwsCfgSrcNil, // disable loading file with kms } keys, err := LoadKeys(config) if err != nil { fmt.Println(err) return } fmt.Printf("loaded %v keys\n", len(keys)) for i, key := range keys { fmt.Printf(" key %v: %x\n", i, key.Pub.Bytes) }
Output: loaded 2 keys key 0: 0e969f8b302cf7648bc39652ca7a279a8562b72933a3f7cddac2252583280c7c3495c9ae854f00f6dd19c32fc5a17500 key 1: 152beed46d7a0002ef0f960946008887eedd4775bdf2ed238809aa74e20d31fdca267443615cc6f4ede49d58911ee083
func WriteToFile ¶
WriteToFile will print any string of text to a file safely by checking for errors and syncing at the end.
Types ¶
type AwsCfgSrcType ¶
type AwsCfgSrcType uint8
AwsCfgSrcType is the type of src to load aws config. Four options available:
AwsCfgSrcNil - Disable kms decryption AwsCfgSrcFile - Provide the aws config through a file (json). AwsCfgSrcPrompt - Provide the aws config though prompt. AwsCfgSrcShared - Use the shard aws config (env -> default .aws directory)
const ( // AwsCfgSrcNil is the nil place holder for AwsCfgSrcType. AwsCfgSrcNil AwsCfgSrcType = iota // AwsCfgSrcFile instruct reading aws config through a json file. AwsCfgSrcFile // AwsCfgSrcPrompt use a user interactive prompt to ge aws config. AwsCfgSrcPrompt AwsCfgSrcShared )
type AwsConfig ¶
type AwsConfig struct { AccessKey string `json:"aws-access-key-id"` SecretKey string `json:"aws-secret-access-key"` Region string `json:"aws-region"` Token string `json:"aws-token,omitempty"` }
AwsConfig is the config data structure for credentials and region. Used for AWS KMS decryption.
type Config ¶
type Config struct { // source for bls key loading. At least one of the MultiBlsKeys and BlsDir // need to be provided. // // MultiBlsKeys defines a slice of key files to load from. MultiBlsKeys []string // BlsDir defines a file directory to load keys from. BlsDir *string // Passphrase related settings. Used for passphrase encrypted key files. // // PassSrcType defines the source to get passphrase. Three source types are available // PassSrcNil - do not use passphrase decryption // PassSrcFile - get passphrase from a .pass file // PassSrcPrompt - get passphrase from prompt // PassSrcAuto - try to unlock with .pass file. If not success, ask user with prompt PassSrcType PassSrcType // PassFile specifies the .pass file to be used when loading passphrase from file. // If not set, default to the .pass file in the same directory as the key file. PassFile *string // PersistPassphrase set whether to persist the passphrase to a .pass file when // prompt the user for passphrase. Persisted pass file is a file with .pass extension // under the same directory as the key file. PersistPassphrase bool // KMS related settings, including AWS credentials and region info. // Used for KMS encrypted passphrase files. // // AwsCfgSrcType defines the source to get aws config. Three types available: // AwsCfgSrcNil - do not use Aws KMS decryption service. // AwsCfgSrcFile - get AWS config through a json file. See AwsConfig for content fields. // AwsCfgSrcPrompt - get AWS config through prompt. // AwsCfgSrcShared - Use the default AWS config settings (from env and $HOME/.aws/config) AwsCfgSrcType AwsCfgSrcType // AwsConfigFile set the json file to load aws config. AwsConfigFile *string }
Config is the config structure for LoadKeys.
type PassSrcType ¶
type PassSrcType uint8
PassSrcType is the type of passphrase provider source. Four options available:
PassSrcNil - Do not use passphrase decryption PassSrcFile - Read the passphrase from files PassSrcPrompt - Read the passphrase from prompt PassSrcAuto - First try to unlock with passphrase from file, then read passphrase from prompt
const ( // PassSrcNil is place holder for nil src PassSrcNil PassSrcType = iota // PassSrcFile provide the passphrase through pass files PassSrcFile // PassSrcPrompt provide the passphrase through prompt PassSrcPrompt // PassSrcAuto first try to unlock with pass from file, then look for prompt PassSrcAuto )