|
| 1 | +-- This file is part of the Wire Server implementation. |
| 2 | +-- |
| 3 | +-- Copyright (C) 2022 Wire Swiss GmbH <[email protected]> |
| 4 | +-- |
| 5 | +-- This program is free software: you can redistribute it and/or modify it under |
| 6 | +-- the terms of the GNU Affero General Public License as published by the Free |
| 7 | +-- Software Foundation, either version 3 of the License, or (at your option) any |
| 8 | +-- later version. |
| 9 | +-- |
| 10 | +-- This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | +-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 | +-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
| 13 | +-- details. |
| 14 | +-- |
| 15 | +-- You should have received a copy of the GNU Affero General Public License along |
| 16 | +-- with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +module Wire.API.MLS.GroupInfoBundle where |
| 19 | + |
| 20 | +import Imports |
| 21 | +import Test.QuickCheck |
| 22 | +import Wire.API.MLS.PublicGroupState |
| 23 | +import Wire.API.MLS.Serialisation |
| 24 | +import Wire.Arbitrary |
| 25 | + |
| 26 | +data GroupInfoEncryption = UnencryptedGroupInfo | JweEncryptedGroupInfo |
| 27 | + deriving stock (Eq, Show, Generic, Bounded, Enum) |
| 28 | + deriving (Arbitrary) via (GenericUniform GroupInfoEncryption) |
| 29 | + |
| 30 | +data GroupInfoTreeType = TreeFull | TreeDelta | TreeByRef |
| 31 | + deriving stock (Eq, Show, Generic, Bounded, Enum) |
| 32 | + deriving (Arbitrary) via (GenericUniform GroupInfoTreeType) |
| 33 | + |
| 34 | +data GroupInfoBundle = GroupInfoBundle |
| 35 | + { gipEncryptionType :: GroupInfoEncryption, |
| 36 | + gipTreeType :: GroupInfoTreeType, |
| 37 | + gipGroupState :: PublicGroupState |
| 38 | + } |
| 39 | + deriving stock (Eq, Show, Generic) |
| 40 | + deriving (Arbitrary) via GenericUniform GroupInfoBundle |
| 41 | + |
| 42 | +instance ParseMLS GroupInfoBundle where |
| 43 | + parseMLS = |
| 44 | + GroupInfoBundle |
| 45 | + <$> parseMLSEnum @Word8 "GroupInfoEncryptionEnum" |
| 46 | + <*> parseMLSEnum @Word8 "RatchetTreeEnum" |
| 47 | + <*> parseMLS |
| 48 | + |
| 49 | +instance SerialiseMLS GroupInfoBundle where |
| 50 | + serialiseMLS (GroupInfoBundle e t pgs) = do |
| 51 | + serialiseMLSEnum @Word8 e |
| 52 | + serialiseMLSEnum @Word8 t |
| 53 | + serialiseMLS pgs |
0 commit comments