• Aucun résultat trouvé

1 Features / Use Cases

N/A
N/A
Protected

Academic year: 2021

Partager "1 Features / Use Cases"

Copied!
16
0
0

Texte intégral

(1)

Code Challenge Website - Report (v1.0)

Marius Hansen and Daniel Quanz

{hansen_m,quanz}@rbg.informatik.tu-darmstadt.de

1 Features / Use Cases

First we create a list with our features. Using these features we create use cases.

1.1 Features

The features below are listed in descending order of importance:

Creation of random challenges / binary r × n matrices

H

r×n

=

a

1,1

a

1,2

· · · a

1,n

a

2,1

a

2,2

· · · a

2,n

.. . .. . . . . .. . a

r,1

a

r,2

· · · a

r,n

, a

i,j

= P RN G(seed) ∈ {0, 1}

r - number of rows n - number of columns

seed - a random value to initialize the pseudorandom number generator (PRNG)

Verification of a solution We want to verify

H

r×n

e

|

= 0 ⇔ t ≤ 1.1 · GV (n, k, q) q := 2, k := n − r, n ≥ k H - a given binary r × n matrix

e - a solution vector ∈ F

n2

t - number of errors - weight(e)

1.1 · GV (n, k, q) - Gilbert-Varshamov bound + 10% tolerance

Definition: (q-ary Gilbert-Varshamov bound). Let C be an (n, k, t) code over F

q

, and let r := n − k. The q-ary GV bound is the smallest integer t

0

such that

t0

X

i=0

n i

(q − 1)

i

≥ q

r

(2)

For large values of n, the last term dominates the sum, so the condition is often approximated by

n t

0

(q − 1)

t0

≥ q

r

If the number of errors that have to be corrected is smaller than the GV bound, then there is at most one solution. Otherwise, there can be several solutions. [2]

Algorithm 1 Calculate H · e

|

= 0 (column-wise multiplication ([3, p. 6]) Require: H

r×n

∈ {a

i,j

| 1 ≤ i ≤ r, 1 ≤ j ≤ n, a

i,j

∈ {0, 1}}

Require: e ∈ F

n2

result ← (0, . . . , 0)

|r

for j = 1 → n do

if e

j

= 1 then for i = 1 → r do

result

i

← result

i

⊕ a

i,j

end for end if end for return result

Submission of a solution The actor should use a form to submit his solution.

He has to input his name, his email-address, his solution and a description how he has solved this challenge. Each challenge has its own submission form.

Listing of solutions in a Hall of Fame If the actor has submited a solution, he will listed in the Hall of Fame list. It is not possible to submit a duplicate solution.

Notification system This feature is needed to inform the website administra- tor. The admin will be notified if the Hall of Fame is changed. It is possible to notify several people.

1.2 Use Cases

Figure 1 shows a short overview of all actions of the code challenge website.

2 Implementation

In this lab we decided to use Ruby on Rails (RoR), an open source web appli-

cation framework for the Ruby programming language. In [1] you find a nice

step-by-step tutorial to create RoR projects.

(3)

Fig. 1. Code Challenge Website Use Cases

2.1 Basics

Each RoR - project is structured as follows:

app includes the RoR application

app/controllers includes the application controllers (MVC) app/helpers includes application helpers

app/mailers includes application mailers

app/models includes application models (MVC) app/views includes application views (MVC) config includes the RoR application config files

db includes the application databases and migration files doc includes the application documentation

log includes application logs for each environment

public includes the application public files (CSS, Javascript, images) test includes tests of the RoR application

2.2 Database

The user input is stored in a sqlite3 database. For this application we need two

different tables. Figure 2 shows the relation of these two tables.

(4)

Fig. 2. DB relationship

Challenge

r number of rows of a binary matrix H n number of columns of a binary matrix H

seed input for a PRNG to create a random binary matrix H bound value of the GV bound of H

created at Creation date

updated at date of the last update Solution

e solution vector

t weight of solution vector

name name of solver

mail email address of solver

description Description, how to solve the solution challenge id foreign key to challenge

created at Creation date

updated at date of the last update

2.3 Creation of random challenges / matrices

To create a new challenge we need a random binary r × n matrix H . The user has to input to positve integeres r and n, such that r ≤ n. These values will be saved in the “Challenge”-SQLite3-table. In addition the Gilbert-Varshamov (GV) bound will be computed and the seed will be defined. (Lines: 5-6 in Listing 1.1). In line 62ff you find the implementaion of th GV-bound computing.

The binary matrix is not created yet. It will be generated, if the user wants

to download it. The file that stores the matrix is created temporarily to save

memory.

(5)

2.4 Download a challenge

The challenge downlod is implemented in listing 1.2 (14-36). First we read the needed attributes (r, n, seed) from the database. Then we create a temporary file. In this file we write the generated binary matrix.

2.5 Verification of a solution

The feature ”Verification of a solution” is implemented in Listing 1.3. First we validate the user input. The user has to input his name (line 6), his email address (line 7) and a valid solution vector. A solution vector must be unique for a challenge (line 8), must be a binary string (line 9), the weight of the solution vector must be lower or equal the GV bound of the challenge matrix (line 10) and finally the multiplication H

r×n

e

|

must be zero. (line 11)

2.6 Pages and links of the website

Home This one is the ”welcome” page. There you find the rules and how you can participate. You can also find the TOP 5 of the Hall-of-Fame List.

<url-to-website>/home

Hall of Fame You can find the whole high score list.

<url-to-website>/halloffame

Create a Challenge On this page the user is able to create a new challenge.

<url-to-website>/generate

Available Challenges You can find a list of available challenges to download them.

<url-to-website>/challenges

Download challenge < CID > You can find a list of available challenges to download them.

<url-to-website>/challenges/<CID>

Submit a solution for challenge < CID > You can find a list of available challenges to download them.

<url-to-website>/challenges/<CID>/solutions/new

Show solution < SID > for challenge < CID > You can find a list of avail- able challenges to download them.

<url-to-website>/challenges/<CID>/solutions/<SID>

2.7 Configuration

You find the configuration file of the webpage in conf ig/conf ig.yml The table below lists the config attributes. Each attribute is stored in the APP CONFIG[]

- array.

(6)

attribute Description

challenge gvbound tolerance GV bound tolerance in percent (here 10)

challenge max columns the number of the max n

challenge download name prefix a prefix name for the challenge file challenges per page number of challenges to be listed per

page

home highscore number number of hall of fame entries on the welcome page

highscore per page number of solutions per page in the hall of fame

notifier mail from notification from: mail-address notifier mail to notify to: mail-address

notifier mail subject notifier mail subject

References

1. M. Hartl. Ruby on Rails 3 Tutorial Livelessons Bundle: Learn Rails by Example.

LiveLessons Series. ADDISON WESLEY (PEAR, 2011.

2. Robert Niebuhr, Pierre-Louis Cayrel, Stanislav Bulygin, and Johannes Buch- mann. On lower bounds for Information Set Decoding over Fq. http://www.cdc.

informatik.tu-darmstadt.de/~rniebuhr/publications/ISD-Fq.pdf .

3. Falko Strenzke. How to implement the public key operations in code-based cryptog- raphy on how to implement the public key operations in code-based cryptography on memory-constrained devices. eprint.iacr.org/2010/465.pdf, 2010.

A Implementation listings

1 #/∗∗

2 # ∗ Model f o r c h a l l e n g e

3 # ∗

4 # ∗ @author Marius Hansen , D a n i e l Quanz

5 # ∗/

6

7 c l a s s C h a l l e n g e < A c t i v e R e c o r d : : Base 8

9 has many : s o l u t i o n s 10

11 v a l i d a t e s n u m e r i c a l i t y o f : r , : a l l o w n i l = > f a l s e , :

g r e a t e r t h a n o r e q u a l t o = > 1 , : l e s s t h a n o r e q u a l t o = >

: n , : o n l y i n t e g e r = > true

12 v a l i d a t e s n u m e r i c a l i t y o f : n , : a l l o w n i l = > f a l s e , :

g r e a t e r t h a n o r e q u a l t o = > 1 , : l e s s t h a n o r e q u a l t o = >

APP CONFIG [ ’ c h a l l e n g e m a x c o l u m n s ’ ] , : o n l y i n t e g e r = >

true

(7)

13

14 b e f o r e s a v e ( : on = > : c r e a t e ) do 15 s e l f . s e e d = Time . now

16 s e l f . bound = getGVt ( s e l f . n , s e l f . n−s e l f . r )

17 end

18

19 def s e e d

20 return r e a d a t t r i b u t e ( : s e e d )

21 end

22

23 def r

24 return r e a d a t t r i b u t e ( : r )

25 end

26

27 def n

28 return r e a d a t t r i b u t e ( : n )

29 end

30

31 def bound

32 return r e a d a t t r i b u t e ( : bound )

33 end

34

35 p r i v a t e 36

37 #/∗∗

38 # ∗ s i m p l e compution o f f a c t o r i a l

39 # ∗/

40 def f a c t ( n )

41 return n==0 ? 1 : ( 1 . . n ) . i n j e c t ( : ∗ )

42 end

43

44 #/∗∗

45 # ∗ compution o f b i n o m i a l c o e f f i c i e n t

46 # ∗/

47 def binom ( n , k )

48 return ( n==k | | k==0) ? 1 : f a c t ( n ) / ( f a c t ( n−k ) ∗ f a c t ( k ) )

49 end

50

51 #/∗∗

52 # ∗ q−a r y G i l b e r t −Varshamov bound // u p d a t e d t o 2−a r y

53 # ∗

54 # ∗

55 # ∗ @see

56 # ∗ Paper : On l o w e r b o u n d s f o r I n f o r m a t i o n S e t D e c o di n g o v e r Fq

57 # ∗ by : R o b e r t N i e b u h r ( 1 ) , P i e r r e −L o u i s C a y r e l ( 2 ) , S t a n i s l a v B u l y g i n ( 2 ) , and Johannes Buchmann ( 1 , 2 )

58 # ∗ ( 1 ) TU Darmstadt − F a c h b e r e i c h I n f o r m a t i k −

K r y p t o g r a p h i e und C o m p u t e r a l g e b r a

(8)

59 # ∗ ( 2 ) CASED − C e n t e r f o r Advanced S e c u r i t y R e s e a r c h Darmstadt

60 # ∗

61 # ∗/

62 def getGVt ( n , k )

63 i f ( k==1)

64 return n /2

65 end

66 q r = 2 << ( n− k −1)

67 s t e p = 2 << ( ( n / 2 ) . t o s ( 2 ) . l e n g t h − 1 )

68 l a s t = 1

69 while s t e p != 1 do

70 tempd = l a s t

71 while getGVtLargeN ( n , tempd ) < q r && tempd<n do

72 l a s t = tempd

73 i f tempd+s t e p <= n

74 tempd+=s t e p

75 e l s e

76 tempd=n

77 end

78 end

79 s t e p >>=1

80 end

81

82 while getGVtSmallN ( n , tempd ) >= q r do

83 tempd−=1

84 end

85 return tempd+1

86 end

87

88 def getGVtLargeN ( n , tempd ) 89 return binom ( n , tempd )

90 end

91

92 def getGVtSmallN ( n , tempd )

93 return ( 0 . . tempd ) . map{ | i | binom ( n , i ) } . i n j e c t ( : + )

94 end

95 end

Listing 1.1. Challenge model

1 r e q u i r e ’ t e m p f i l e ’ 2

3 c l a s s C h a l l e n g e s C o n t r o l l e r < A p p l i c a t i o n C o n t r o l l e r 4 # GET / c h a l l e n g e s

5 # GET / c h a l l e n g e s . xml 6 def i n d e x

7 @ c h a l l e n g e s = C h a l l e n g e . p a g i n a t e ( : page = > params [ : page ] , : p e r p a g e = > APP CONFIG [ ’ c h a l l e n g e s p e r p a g e ’ ] , : o r d e r

= > ” c r e a t e d a t DESC” )

(9)

8

9 r e s p o n d t o do | f o r m a t |

10 f o r m a t . html # i n d e x . h t m l . e r b

11 end

12 end

13

14 def show

15 @ c h a l l e n g e = C h a l l e n g e . f i n d ( params [ : i d ] ) 16 prng = Random . new ( @ c h a l l e n g e . s e e d ) 17

18 f i l e = T e m p f i l e . new ( ’ c h a l l e n g e ’ ) 19

20 d a t a = ”#{@ c h a l l e n g e . r . t o s }\n#{@ c h a l l e n g e . n . t o s }\n\n”

21 f i l e . w r i t e ( d a t a )

22 f o r i in 1 . . @ c h a l l e n g e . r

23 d a t a = @ c h a l l e n g e . n . t i m e s . map{ prng . rand ( 0 . . 1 ) } 24 f i l e . w r i t e ( ”#{d a t a . j o i n }\n” )

25 end

26 27

28 s e n d f i l e f i l e , : f i l e n a m e = > ”# {APP CONFIG [ ’

c h a l l e n g e d o w n l o a d n a m e p r e f i x ’ ] } ID#{params [ : i d ] } # {

@ c h a l l e n g e . r} #{@ c h a l l e n g e . n } . t x t ” 29

30

31 f i l e . c l o s e 32 f i l e . u n l i n k

33 r e s p o n d t o do | f o r m a t |

34 f o r m a t . html { r e d i r e c t t o ( c h a l l e n g e s p a t h ) }

35 return

36 end

37 end

38

39 # GET / c h a l l e n g e s /new 40 # GET / c h a l l e n g e s /new . xml

41 def new

42 @ c h a l l e n g e = C h a l l e n g e . new 43

44 r e s p o n d t o do | f o r m a t | 45 f o r m a t . html # new . h t m l . e r b

46 end

47 end

48

49 # POST / c h a l l e n g e s 50 # POST / c h a l l e n g e s . xml 51 def c r e a t e

52 @ c h a l l e n g e = C h a l l e n g e . new ( params [ : c h a l l e n g e ] ) 53

54 r e s p o n d t o do | f o r m a t |

55 i f @ c h a l l e n g e . s a v e

(10)

56

57 f o r m a t . html { r e d i r e c t t o ( c h a l l e n g e s p a t h , : n o t i c e = >

”You c r e a t e d a new b i n a r y #{@ c h a l l e n g e . r } x #{

@ c h a l l e n g e . n} m a t r i x ( ID : #{@ c h a l l e n g e . i d }) . Download i t #{v i e w c o n t e x t . l i n k t o ( ’ h e r e ’ ,

@ c h a l l e n g e ) }. ” . h t m l s a f e ) }

58 e l s e

59 f o r m a t . html { r e n d e r : a c t i o n = > ”new” }

60 end

61 end

62 end

63

64 # DELETE / c h a l l e n g e s /1 65 # DELETE / c h a l l e n g e s / 1 . xml 66 def d e s t r o y

67 @ c h a l l e n g e = C h a l l e n g e . f i n d ( params [ : i d ] ) 68 @ c h a l l e n g e . d e s t r o y

69

70 r e s p o n d t o do | f o r m a t |

71 f o r m a t . html { r e d i r e c t t o ( c h a l l e n g e s u r l ) }

72 end

73 end

74 end

Listing 1.2. Challenge Controller

1 c l a s s S o l u t i o n < A c t i v e R e c o r d : : Base 2

3 b e l o n g s t o : c h a l l e n g e 4

5 ## no d u p l i c a t e s o l u t i o n v e c t o r 6 v a l i d a t e s : name , : p r e s e n c e = > true

7 v a l i d a t e s : mail , : p r e s e n c e = > true , : f o r m a t = > { : w i t h = >

/ ˆ ( [ ˆ@\ s ] + )@( ( ? : [ − a−z0 −9 ] +\ . ) +[a−z ] { 2 , } ) $ / i } , : l e n g t h

= > { : w i t h i n = > 5 . . 2 5 5 }

8 v a l i d a t e s : e , : p r e s e n c e = > true , : u n i q u e n e s s = > { : s c o p e = > : c h a l l e n g e i d }

9 v a l i d a t e : h a s V a l i d C o n t e n t 10 v a l i d a t e : gvBoundAndESize 11 v a l i d a t e : m u l t i p l y I s Z e r o 12

13 b e f o r e s a v e ( : on = > : c r e a t e ) do 14 s e l f . t = c o u n t E r r o r s ( )

15 end

16

17 def gvBoundAndESize

18 bound = c h a l l e n g e . bound

19 b = bound + bound / APP CONFIG [ ’

c h a l l e n g e g v b o u n d t o l e r a n c e ’ ]

20 p u t s b

(11)

21 p u t s c o u n t E r r o r s ( )

22 i f e . l e n g t h != c h a l l e n g e . n

23 e r r o r s . add ( : e , ” h a s n o t t h e c o r r e c t l e n g t h ! The l e n g t h o f e i s #{e . l e n g t h } , but i t must be #{c h a l l e n g e . n}” ) 24 return f a l s e

25 end

26

27 i f ! ( 1 . . b ) . i n c l u d e ? ( c o u n t E r r o r s ( ) )

28 e r r o r s . add ( : e , ” i s n o t a non−z e r o v e c t o r o r w e i g h t ( e ) >

1 . 1∗ GVbound . 1 . 1 ∗ GVbound = #{b }. w e i g h t ( e ) = #{

c o u n t E r r o r s }” ) 29 return f a l s e

30 end

31 end

32

33 def m u l t i p l y I s Z e r o 34

35 prng = Random . new ( c h a l l e n g e . s e e d ) 36 r = Array . new ( c h a l l e n g e . n , 0 ) 37

38 d a t a = ( c h a l l e n g e . r ) . t i m e s . map{( c h a l l e n g e . n ) . t i m e s . map{

prng . rand ( 0 . . 1 ) }}

39 m a t r i x = d a t a . t r a n s p o s e

40 v e c = c o n v e r t S t r i n g 2 D i g i t A r r a y ( e ) 41 0 . upto ( ( c h a l l e n g e . n ) −1) do | i |

42 i f v e c [ i ] == 1

43 r = m a t r i x [ i ] . z i p ( r ) . c o l l e c t { | t , k | t . t o i ˆ k . t o i }

44 end

45 end

46

47 i f r . i n j e c t ( : + ) != 0

48 e r r o r s . add ( : e , ” i s n o t a s o l u t i o n −− > He != 0 ” ) 49 return f a l s e

50 end

51

52 return true

53 end

54

55 def h a s V a l i d C o n t e n t

56 # c h e c k e a c h e l e m e n t i s w i t h i n r a n g e ( 0 . . 1 ) 57 v e c = c o n v e r t S t r i n g 2 D i g i t A r r a y ( e )

58 # i f v e c . n i l ? | | v e c . l e n g t h < = 0 59 # e r r o r s . add ( : e , ” i s b l a n k ” ) 60 #r e t u r n f a l s e

61 #end

62 b o o l = v e c . map{ | e l | ( 0 . . 1 ) . i n c l u d e ? ( e l ) } . i n j e c t ( : & ) 63 i f ! b o o l

64 e r r o r s . add ( : e , ” i s n o t a b i n a r y s t r i n g ” )

65 end

66 return b o o l

(12)

67 end 68

69 def c o u n t E r r o r s 70 # c o u n t a l l 1

71 @eVector = c o n v e r t S t r i n g 2 D i g i t A r r a y ( e ) 72 return @eVector . i n j e c t ( : + )

73 end

74

75 def c o n v e r t S t r i n g 2 D i g i t A r r a y ( e ) 76 i f ( e . n i l ? )

77 return n i l

78 end

79 # c o n v e r t d i g i t −s t r i n g t o t o a d i g i t −a r r a y 80 return e . s p l i t ( ” ” ) . map( & : t o i )

81 end

82

83 end

Listing 1.3. Solution model

B Screenshots

(13)

Fig. 3. Welcome page

(14)

Fig. 4. List of challenges

Fig. 5. New challenge created

(15)

Fig. 6. Hall of Fame

(16)

Fig. 7. Invalid solution

Fig. 8. Valid solution

Références

Documents relatifs

A signal event may cause a response, such as a state machine transition as specified in the classifier behavior of the classifier that specified the receiver object, if the

Addis Ababa, 19 May 2011 (ECA) - As part of the effort by the 7th Session of the Committee on Women and Development (CWD) to assess where Africa stands on women’s

I think physicians who truly take the time to talk to their patients in depth about weight, using a nonthreat- ening, question-and-answer approach, will be shocked by

Moreover, our result is also sharp in the sense that all viscosity solutions to the exterior Dirichlet problem is asymptotic to a quadratic polynomial by the result of Caffarelli and

(Recall that an upper triangular matrix A has arbitrary values on and above the main diagonal, but it is all zero below the diagonal. Any lower triangular matrix A must satisfy the

In this paper we have argued that appro- priate language design can bring determinism in a much more flexible way to shared memory parallel computing, even in rich,

A leaf routing domain that is willing to accept prefixes derived from its direct provider gets a prefix from the provider’s address space subdivision associated

Kigali, 15 March 2016 - The Economic Commission for Africa (ECA)‘s Executive Secretary of Carlos Lopes said that although Africa has experienced unprecedented growth over the