github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/crypto/keys/utils.go (about) 1 package keys 2 3 import ( 4 "fmt" 5 "path/filepath" 6 ) 7 8 const ( 9 defaultKeyDBName = "keys" 10 defaultKeyDBDir = "data" 11 ) 12 13 // NewKeyBaseFromDir initializes a keybase at a particular dir. 14 func NewKeyBaseFromDir(rootDir string) (Keybase, error) { 15 return NewLazyDBKeybase(defaultKeyDBName, filepath.Join(rootDir, defaultKeyDBDir)), nil 16 } 17 18 func ValidateMultisigThreshold(k, nKeys int) error { 19 if k <= 0 { 20 return fmt.Errorf("threshold must be a positive integer") 21 } 22 if nKeys < k { 23 return fmt.Errorf( 24 "threshold k of n multisignature: %d < %d", nKeys, k) 25 } 26 return nil 27 }