Closed KendallWeihe closed 4 months ago
@KendallWeihe thoughts on doing the following for the argument passed to GenerateEntropy
and also allowing it to be passed to GenerateNonce
?
type EntropySize int
const (
// Directly set the sizes according to NIST recommendations for entropy
// defined here: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
Entropy112Bits EntropySize = 112 / 8 // 14 bytes
Entropy128Bits = 128 / 8 // 16 bytes
Entropy192Bits = 192 / 8 // 24 bytes
Entropy256Bits = 256 / 8 // 32 bytes
)
this way we can call either function like so:
crypto.GenerateEntropy(Entropy128Bits)
crypto.GenerateNonce(Entropy128Bits)
This provides consumers with easy access to recommended values. wish we could use iota
for this but recommended sizes does not increment by a consistent amount that would easily map to iota
's default behavior
could also leave off Bits
e.g.
const (
// Directly set the sizes according to NIST recommendations for entropy
// defined here: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
Entropy112 EntropySize = 112 / 8 // 14 bytes
Entropy128 = 128 / 8 // 16 bytes
Entropy192 = 192 / 8 // 24 bytes
Entropy256 = 256 / 8 // 32 bytes
)
@mistermoe awesome idea! Done ✅ And also added additional test coverage for custom size, and nonce error case, as well as a doc comment for GenerateEntropy()
Closes https://github.com/TBD54566975/web5-go/issues/51