mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
b9caf70f97
commit
1597707afe
|
@ -123,6 +123,25 @@ groupKeyEntries = do
|
|||
_ -> throwIO $ BadFormException @C nil
|
||||
|
||||
|
||||
entry $ bindMatch "hbs2:groupkey:dump" $ nil_ $ \syn -> do
|
||||
case syn of
|
||||
|
||||
[StringLike "--file", StringLike fn] -> do
|
||||
notice "READ-FROM-FILE"
|
||||
|
||||
[HashLike gkh] -> do
|
||||
sto <- getStorage
|
||||
|
||||
lbs <- runExceptT (readFromMerkle sto (SimpleKey (fromHashRef gkh)))
|
||||
>>= orThrowUser "can't read merkle tree"
|
||||
|
||||
gk <- deserialiseOrFail @(GroupKey 'Symm HBS2Basic) lbs & orThrowUser "invalid group key"
|
||||
|
||||
liftIO $ print $ pretty gk
|
||||
|
||||
_ -> do
|
||||
notice "READ-FROM-STDIN"
|
||||
|
||||
entry $ bindMatch "hbs2:groupkey:list-public-keys" $ \syn -> do
|
||||
case syn of
|
||||
[LitStrVal s] -> do
|
||||
|
|
|
@ -97,6 +97,10 @@ newtype GroupKeyId = GroupKeyId N.ByteString
|
|||
instance Pretty GroupKeyId where
|
||||
pretty what = pretty (AsBase58 (coerce @_ @N.ByteString what))
|
||||
|
||||
instance Pretty GroupKeyIdScheme where
|
||||
pretty = \case
|
||||
GroupKeyIdJustHash -> "just-hash"
|
||||
|
||||
-- NOTE: not-a-monoid
|
||||
-- это моноид, но опасный, потому, что секретные ключи у двух разных
|
||||
-- групповых ключей могут быть разными, и если
|
||||
|
@ -203,9 +207,14 @@ instance (ForGroupKeySymm s) => Serialise (GroupKey 'Symm s) where
|
|||
|
||||
|
||||
instance (Pretty (AsBase58 (PubKey 'Encrypt s)) ) => Pretty (GroupKey 'Symm s) where
|
||||
pretty g = vcat (fmap prettyEntry (HashMap.toList (recipients @s g)))
|
||||
pretty g = gkType <> line <> vcat (fmap prettyEntry (HashMap.toList (recipients @s g)))
|
||||
where
|
||||
prettyEntry (pk, _) = "member" <+> dquotes (pretty (AsBase58 pk))
|
||||
gkType = case g of
|
||||
GroupKeySymmPlain{} -> ";" <+> "plain group key" <> line
|
||||
GroupKeySymmFancy{} -> ";" <+> "fancy group key" <> line
|
||||
<> "group-key-id" <+> pretty (getGroupKeyId g) <> line
|
||||
<> "group-key-id-scheme" <+> pretty (getGroupKeyIdScheme g) <> line
|
||||
|
||||
|
||||
instance ForGroupKeySymm s => FromStringMaybe (GroupKey 'Symm s) where
|
||||
|
|
Loading…
Reference in New Issue