Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kem/hybrid: Remove restriction on seed sizes #342

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions kem/hybrid/hybrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
// deterministically, we expand a single seed to both using SHAKE256,
// so that a non-uniform seed (such as a shared secret generated by a hybrid
// KEM where one of the KEMs is weak) doesn't impact just one of the KEMs.
//
// Of our XOF (SHAKE256), we desire two security properties:
//
// 1. The internal state of the XOF should be big enough so that we
// do not loose entropy.
// 2. From one of the new seeds, we shouldn't be able to derive
// the other or the original seed.
//
// SHAKE256, and all siblings in the SHA3 family, have a 200B internal
// state, so (1) is fine if our seeds are less than 200B.
// If SHAKE256 is computationally indistinguishable from a random
// sponge, then it affords us 256b security against (2) by the
// flat sponge claim [https://keccak.team/files/SpongeFunctions.pdf].
// None of the implemented schemes claim more than 256b security
// and so SHAKE256 will do fine.
package hybrid

import (
Expand Down Expand Up @@ -92,9 +107,6 @@ func (sch *scheme) SeedSize() int {
if first > second {
ret = first
}
if ret > 32 {
panic("SeedSize too big for SHAKE256")
}
return ret
}

Expand All @@ -113,9 +125,6 @@ func (sch *scheme) EncapsulationSeedSize() int {
if first > second {
ret = first
}
if ret > 32 {
panic("EncapsulationSeedSize too big for SHAKE256")
}
return ret
}

Expand Down
3 changes: 3 additions & 0 deletions kem/schemes/schemes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func TestApi(t *testing.T) {
t.Fatal()
}

_ = scheme.SeedSize()
_ = scheme.EncapsulationSeedSize()

pk, sk, err := scheme.GenerateKeyPair()
if err != nil {
t.Fatal()
Expand Down