github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/libkb/secwords_test.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package libkb 5 6 import ( 7 "testing" 8 ) 9 10 func TestSecWordList(t *testing.T) { 11 words, err := SecWordList(65) 12 if err != nil { 13 t.Fatal(err) 14 } 15 t.Logf("words: %v", words) 16 if len(words) != 6 { 17 t.Errorf("# words = %d, expected 6", len(words)) 18 } 19 } 20 21 func TestSecWordList128(t *testing.T) { 22 words, err := SecWordList(128) 23 if err != nil { 24 t.Fatal(err) 25 } 26 t.Logf("words: %v", words) 27 if len(words) != 12 { 28 t.Errorf("# words = %d, expected 12", len(words)) 29 } 30 } 31 32 func TestSecWordList144(t *testing.T) { 33 words, err := SecWordList(144) 34 if err != nil { 35 t.Fatal(err) 36 } 37 t.Logf("words: %v", words) 38 if len(words) != 14 { 39 t.Errorf("# words = %d, expected 14", len(words)) 40 } 41 } 42 43 func TestSecWordListConstants(t *testing.T) { 44 words, err := SecWordList(PaperKeySecretEntropy + PaperKeyIDBits + PaperKeyVersionBits) 45 if err != nil { 46 t.Fatal(err) 47 } 48 if len(words) != PaperKeyWordCountMin { 49 t.Errorf("paper key words for constants: %d, expected %d", len(words), PaperKeyWordCountMin) 50 } 51 }