Documentation
¶
Overview ¶
Package keyphrase provides shared cryptographic randomness and entropy contracts for password, passphrase, and BIP-39 mnemonic generation.
It does not hash passwords, manage wallets, derive wallet keys, store secrets, or distribute secret material.
Example (Passphrase) ¶
package main
import (
"context"
"fmt"
"github.com/faustbrian/go-keyphrase/passphrase"
"github.com/faustbrian/go-keyphrase/wordlist/eff"
)
func main() {
list, err := eff.Large()
if err != nil {
panic(err)
}
secret, err := passphrase.DefaultGenerator().Generate(context.Background(), passphrase.Policy{
WordList: list,
Words: 6,
Separator: " ",
})
if err != nil {
panic(err)
}
defer clear(secret)
fmt.Println(len(secret) > 0)
}
Output: true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error is a typed, secret-safe generation error.
Error deliberately omits the wrapped error text. Callers that need the underlying cause may inspect it with errors.Is or errors.As, but should not log arbitrary source errors without reviewing their disclosure behavior.
func (*Error) MarshalText ¶
MarshalText omits wrapped source diagnostics from encoded output.
type ErrorCode ¶
type ErrorCode string
ErrorCode identifies a generation failure without exposing secret material.
const ( // CodeInvalidBound reports a nonpositive selection bound. CodeInvalidBound ErrorCode = "invalid_bound" // CodeInvalidSource reports a nil randomness source. CodeInvalidSource ErrorCode = "invalid_source" // CodeInvalidOption reports an invalid selector option. CodeInvalidOption ErrorCode = "invalid_option" // CodeOversized reports a request above a resource limit. CodeOversized ErrorCode = "oversized" // CodeSource reports a randomness-source failure. CodeSource ErrorCode = "source_failure" // CodeShortRead reports a source that made invalid progress. CodeShortRead ErrorCode = "short_read" // CodeAttemptsExceeded reports too many rejected samples. CodeAttemptsExceeded ErrorCode = "attempts_exceeded" // CodeCanceled reports context cancellation. CodeCanceled ErrorCode = "canceled" )
type Option ¶
Option configures a Selector.
func WithMaxAttempts ¶
WithMaxAttempts bounds rejected samples from a faulty or hostile source.
type Secret ¶
type Secret []byte
Secret is a caller-owned byte slice whose fmt representation is always redacted. Convert it explicitly to []byte or string only at a reviewed integration boundary.
func (Secret) Clear ¶
func (s Secret) Clear()
Clear overwrites the current backing array as a best-effort measure. Go and the operating system may retain compiler, runtime, string, or page copies.
func (Secret) MarshalText ¶
MarshalText prevents disclosure through standard text and JSON encoders.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector performs bounded rejection sampling from a Source.
func DefaultSelector ¶
func DefaultSelector() *Selector
DefaultSelector returns a selector backed by crypto/rand.
func NewSelector ¶
NewSelector constructs a selector using source.
func (*Selector) BigInt ¶
BigInt returns a uniformly distributed arbitrary-precision value in [0, upper). The returned integer never aliases upper.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bip39 implements BIP-39 mnemonic encoding, validation, language detection, and seed derivation.
|
Package bip39 implements BIP-39 mnemonic encoding, validation, language detection, and seed derivation. |
|
Package keyphrasetest provides deterministic sources and statistical test helpers.
|
Package keyphrasetest provides deterministic sources and statistical test helpers. |
|
Package passphrase generates and validates uniformly selected word-list passphrases with optional independently generated password affixes.
|
Package passphrase generates and validates uniformly selected word-list passphrases with optional independently generated password affixes. |
|
Package password generates uniformly distributed passwords under explicit character and required-class policies.
|
Package password generates uniformly distributed passwords under explicit character and required-class policies. |
|
Package wordlist validates and exposes immutable cryptographic word lists.
|
Package wordlist validates and exposes immutable cryptographic word lists. |
|
eff
Package eff embeds the Electronic Frontier Foundation diceware word lists with pinned source and integrity metadata.
|
Package eff embeds the Electronic Frontier Foundation diceware word lists with pinned source and integrity metadata. |