Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
4d89fa1b
Commit
4d89fa1b
authored
Jan 05, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-ngrams-groups
parents
6af9b3d6
b5738963
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
3 deletions
+86
-3
package.yaml
package.yaml
+1
-1
Types.hs
src/Gargantext/Core/Types.hs
+3
-1
Prelude.hs
src/Gargantext/Prelude.hs
+1
-1
Share.hs
src/Gargantext/Prelude/Crypto/Share.hs
+81
-0
No files found.
package.yaml
View file @
4d89fa1b
name
:
gargantext
version
:
'
0.0.2.
3
'
version
:
'
0.0.2.
4
'
synopsis
:
Search, map, share
description
:
Please see README.md
category
:
Data
...
...
src/Gargantext/Core/Types.hs
View file @
4d89fa1b
...
...
@@ -30,6 +30,7 @@ import Control.Lens (Prism', (#))
import
Control.Monad.Except
(
MonadError
(
throwError
))
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Maybe
import
Data.Monoid
import
Data.Semigroup
import
Data.Set
(
Set
,
empty
)
...
...
@@ -39,7 +40,6 @@ import Data.Text (Text, unpack)
import
Data.Validity
import
GHC.Generics
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
wellNamedSchema
)
...
...
@@ -47,6 +47,8 @@ import Gargantext.Prelude
------------------------------------------------------------------------
data
Ordering
=
Down
|
Up
deriving
(
Enum
,
Show
,
Eq
,
Bounded
)
------------------------------------------------------------------------
type
Name
=
Text
type
Term
=
Text
...
...
src/Gargantext/Prelude.hs
View file @
4d89fa1b
...
...
@@ -52,7 +52,7 @@ import Protolude ( Bool(True, False), Int, Int64, Double, Integer
,
takeWhile
,
sqrt
,
identity
,
abs
,
min
,
max
,
maximum
,
minimum
,
return
,
snd
,
truncate
,
(
+
),
(
*
),
(
/
),
(
-
),
(
.
),
(
$
),
(
&
),
(
**
),
(
^
),
(
<
),
(
>
),
log
,
Eq
,
(
==
),
(
>=
),
(
<=
),
(
<>
),
(
/=
)
,
Eq
,
(
==
),
(
>=
),
(
<=
),
(
<>
),
(
/=
)
,
xor
,
(
&&
),
(
||
),
not
,
any
,
all
,
concatMap
,
fst
,
snd
,
toS
...
...
src/Gargantext/Prelude/Crypto/Share.hs
0 → 100644
View file @
4d89fa1b
{-|
Module : Gargantext.Prelude.Crypto.Share
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
# Random work/research (WIP)
Goal: share secretly a sequence of random actions (either [Bool] or
[Ordering] for instances here) but without sharing secrets.
Motivation: useful to share clustering algorithm reproduction using BAC
(Ballades Aléatoires Courtes).
Question: how to certify the author of such (random) actions ? Solution
later ;)
-}
------------------------------------------------------------------------
{-# OPTIONS_GHC -fno-warn-orphans #-}
------------------------------------------------------------------------
module
Gargantext.Prelude.Crypto.Share
where
import
Data.Maybe
import
System.Random
import
Prelude
(
fromEnum
,
toEnum
)
import
Gargantext.Core.Types
(
Ordering
)
import
Gargantext.Prelude
------------------------------------------------------------------------
-- | Main Types
newtype
Seed
=
Seed
Int
type
Private
=
Seed
type
Public
=
Seed
------------------------------------------------------------------------
instance
Random
Ordering
where
randomR
(
a
,
b
)
g
=
case
randomR
(
fromEnum
a
,
fromEnum
b
)
g
of
(
x
,
g'
)
->
(
toEnum
x
,
g'
)
random
g
=
randomR
(
minBound
,
maxBound
)
g
randomOrdering
::
Maybe
Seed
->
Int
->
IO
[
Ordering
]
randomOrdering
=
randomWith
randomBool
::
Maybe
Seed
->
Int
->
IO
[
Bool
]
randomBool
=
randomWith
------------------------------------------------------------------
randomWith
::
Random
a
=>
Maybe
Seed
->
Int
->
IO
[
a
]
randomWith
seed
n
=
do
g
<-
case
seed
of
Nothing
->
newStdGen
Just
(
Seed
s
)
->
pure
$
mkStdGen
s
pure
$
take
n
$
(
randoms
g
)
genWith
::
Private
->
Public
->
Int
->
IO
[
Bool
]
genWith
privateSeed
publicSeed
n
=
do
xs
<-
randomBool
(
Just
privateSeed
)
n
ys
<-
randomBool
(
Just
publicSeed
)
n
pure
$
zipWith
xor
xs
ys
{-
- TODO WIP
searchSeeds :: Int -> IO [Int]
searchSeeds xs = mapM (\n -> randomWith (Just n) l) [1..]
where
l = length xs
shareSeed = undefined
certifySeed = undefined
-}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment