Encoding Watermark Numbers as Reducible Permutation Graphs using Self-inverting Permutations

Encoding Watermark Numbers as Reducible Permutation Graphs using Self-inverting Permutations

Maria Chroni   Stavros D. Nikolopoulos   Leonidas Palios
Abstract

Several graph theoretic watermark methods have been proposed to encode numbers as graph structures in software watermarking environments. In this paper we propose an efficient and easily implementable codec system for encoding watermark numbers as reducible permutation flow-graphs and, thus, we extend the class of graphs used in such a watermarking environment. More precisely, we present an algorithm for encoding a watermark number  as a self-inverting permutation , an algorithm for encoding the self-inverting permutation  into a reducible permutation graph  whose structure resembles the structure of real program graphs, as well as decoding algorithms which extract the permutation  from the reducible permutation graph  and the number  from . Both the encoding and the decoding process takes time and space linear in the length of the binary representation of . The two main components of our proposed codec system, i.e., the self-inverting permutation and the reducible permutation graph , incorporate the binary representation of the watermark  in their structure and possess important structural properties, which make our system resilient to attacks; to this end, we experimentally evaluated our system under edge modification attacks on the graph  and the results show that we can detect such attacks with high probability.

Keywords:  Watermarking, self-inverting permutations, reducible permutation graphs, polynomial codec algorithms, structural properties, evaluation.

Department of Computer Science & Engineering

University of Ioannina

GR-45110  Ioannina, Greece

{mchroni,stavros,palios}@cs.uoi.gr


1 Introduction

Software watermarking is a technique that is currently being studied to prevent or discourage software piracy and copyright infringement. The idea is similar to digital (or media) watermarking where a unique identifier is embedded in image, audio, or video data through the introduction of errors not detectable by human perception [14]. The software watermarking problem can be described as the problem of embedding a structure into a program producing a program  such that can be reliably located and extracted from even after has been subjected to code transformations such as translation, optimization, and obfuscation [24]. More precisely, given a program , a watermark , and a key , the software watermarking problem can be formally described by the following two functions: embed and extract .

Although digital watermarking has made considerable progress and become a popular technique for copyright protection of multimedia information [14, 27, 29], research on software watermarking has only recently received considerable attention. The patent by Davidson and Myhrvold [15] presented the first published software watermarking algorithm. The preliminary concepts of software watermarking also appeared in the patents [21, 28]. Collberg et al. [10] presented detailed definitions for software watermarking. Zhang et al. [31] and Zhu et al. [32] have given brief surveys of software watermarking research (see also Collberg and Nagra [7] for an exposition of the main results).

Graph-based Software Watermarking. Recently, several graph-based software watermarking techniques have been proposed that encode identification data as graph structures and embed them into software ensuring functionality, usability and reversibility. We refer to the identification data as the identifier and to the graph structure as the watermark graph; we may regard identifiers as numbers (integers in this paper) and refer to them as watermark numbers or, simply, watermarks.

A typical graph-based software watermarking system is mainly comprised of the following four functions:

  • encoder: it makes use of an encoding function encode which converts a watermark  into a graph , i.e., ;

  • embedder: it mainly uses a function which takes as input the program (either binary or source code), the intended watermark graph , and possible a secret key , and returns the modified program containing the graph , i.e., ;

  • extractor: it undertakes to retrieve the watermark graph from the watermarked program using an appropriate function, i.e., ;

  • decoder: it consists of a decoding function decode which converts the watermark graph into the watermark , i.e., .

In this domain, we usually call the pair codec system and refer to both functions encode and decode as codec algorithms[8]. In a similar manner, we may use the terms embex system and embex algorithms for the pair and the corresponding embed and extract functions, respectively.

  • Codec systems. While designing a codec system that is appropriate for use in a real software watermarking environment, we are mainly looking for a class of graphs , along with the corresponding functions encode and decode, having the following desirable properties and characteristics:

    • appropriate graph types: graphs in should be directed having appropriate properties (e.g., nodes with small outdegree) so that their structure resembles that of real program graphs;

    • high resilience: the function should be insensitive to small changes of (e.g., insertions or deletions of a constant number of nodes or edges), that is, if and then with ;

    • small size: the size of the embedded watermark graph should be small;

    • efficient codecs: both encode and decode functions should be polynomially computable.

    In this paper, we focus on the codec part of a software watermark system and propose the codec which incorporates several of the above properties and characteristics making it appropriate for practical use.

  • Embex systems. On the other hand, for the design of an efficient embex system , we are usually looking for techniques which associate a program to a directed graph representing the structure of as sequences of instructions and methods which handle the graph and the watermark graph in an appropriate way; that is the reason we require the structure of produced by a codec system resembling that of real program graphs. Such a graph may be the control flow-graph (CFG) of which can be obtained by means of a static analysis [26]. In a straight-forward approach, the embedder inserts appropriate code into , thus producing the watermarked program , so that the watermark graph shows up as an induced subgraph of . In turn, the extractor retrieves that subgraph of and passes it to the codec system, where its decoder converts the watermark graph into . Note that, the embedding process must preserve program semantics, that is, and must have the same behavior.

We should mention that a software watermarking system usually contains of another function namely recognizer: it takes the program , the watermark and the key as input and returns how confident we are that the contains , i.e., recognize [7].

Techniques and Previous Results. The major software watermarking algorithms currently available are based on a number of techniques, such as the register allocation, spread-spectrum, opaque predicate, abstract interpretation, and dynamic path techniques (see [1, 6, 12, 13, 22, 25]).

In general, according to Collberg and Thomborson’s informal taxonomy [10], the software watermarking techniques can be broadly divided into two main categories, namely, static and dynamic: in a static technique the watermark is stored inside the program in a certain format, either as data or code, and its extraction from the watermarked program requires no execution of , whereas in a dynamic one is stored in during the execution stage, perhaps only after a particular sequence of input has been used, and it might be retrieved by analyzing the data structures built when is running; see also [7, 15, 21, 30]. We should also point out that a different software watermarking technique, namely, abstract watermarking, has also been proposed: in an abstract framework the watermark is built in memory, in an abstract data structure, only when is executed on a particular abstract domain and its extraction requires static analysis on using some abstract interpretation of the semantics of [12, 16, 17].

We next report some of the pioneering results in the area of graph-based software watermarking. Indeed, in 1996 Davidson and Myhrvold [15] proposed the first static algorithm which embeds the watermark by reordering the basic blocks of a control flow-graph. Based on this idea, Venkatesan, Vazirani, and Sinha [30] proposed the first graph-based software watermarking algorithm which embeds the watermark by extending a method’s control flow-graph through the insertion of a directed subgraph; it is a static algorithm and is called VVS or GTW. Collberg et al. [9] proposed the first publicly available implementation (GTW) of algorithm GTW; in GTW the watermark is encoded as a reducible permutation graph (RPG) [8], which is a reducible control flow-graph with maximum out-degree of two, mimicking real code. The first dynamic watermarking algorithm (CT) was proposed by Collberg and Thomborson [10]; it embeds the watermark through a graph structure which is built on a heap at runtime. Recently, authors of this paper have contributed in this area by proposing several codec and embex systems [3, 4, 5, 23].

Attacks. A successful attack against the watermarked program  prevents the recognizer from extracting the watermark while not seriously harming the performance or correctness of . It is generally assumed that the attacker has access to the algorithm used by the embedder and recognizer. There are four main ways to attack a watermark stored in :

  • additive attacks: encode a new watermark and embed the corresponding watermark graph into software , so that an ambiguity is caused and thus the original copyright owners of the software cannot prove their ownership;

  • subtractive attacks: remove the watermark of the watermarked software without affecting the functionality of the watermarked software;

  • distortive attacks: modify the watermark graph to prevent it from being extracted by the copyright owners and still keep the usability of the software (in this case the decoder fails to return any output);

  • recognition attacks: modify the watermark so that the recognizer gives a misleading result, that is, the extractor retrieves the graph and the decoder returns .

Typical attacks against the watermark graph can mainly occur in the following three ways: edge-flip attacks, edge-addition/deletion attacks, and node-addition/deletion attacks.

Our Contribution. In this paper, we present an efficient and easily implementable codec system for encoding integer numbers as reducible permutation graphs, whose structure resembles that of real program graphs, through the use of self-inverting permutations (or SiP, for short).

More precisely, we first present an efficient algorithm which encodes an integer watermark number as a self-inverting permutation . Our algorithm, which we call Encode_W.to.SiP, takes as input an integer , computes its binary representation, constructs a bitonic permutation on numbers, and finally produces a self-inverting permutation  of length in time and space. We also present the corresponding decoding algorithm Decode_SiP.to.W, which converts the permutation into the integer  within the same time and space complexity.

Having designed an efficient method for encoding integers as self-inverting permutations, we next describe an algorithm for encoding a self-inverting permutation  of length as a reducible permutation graph or, equivalently, watermark flow-graph . In particular, we propose the algorithm Encode_SiP.to.RPG which exploits domination relations on the elements of and properties of a DAG representation of , and produces a reducible permutation flow-graph on nodes; the whole encoding process takes time and requires space. The corresponding decoding algorithm Decode_RPG.to.SiP extracts the self-inverting permutation  from the graph  by first converting it into a directed tree  and then applying DFS-search on . The decoding process takes time and space linear in the size of the flow-graph , that is, the decoding algorithm takes time and space; recall that the length of the permutation  and the size of the flow-graph  are both , where .

Our codec algorithms are very simple, use elementary operations on sequences and linked structures, and have very low time and space complexity. Moreover, both the permutation  and the flow-graph  incorporate the binary representation of the watermark  in their structure and thus possess important structural properties; experimental evaluation results substantiate that edge modifications attackes on the graph can be detected with high probability.

Road Map. The paper is organized as follows: In Section 2 we establish the notation and related terminology and present background results. In Section 3 we describe the main components of our codec system and present the encoding and decoding algorithms for the two main phases of our system, namely W-SiP and SiP-RPG. In Sections 4 and 5 we provide structural properties and characterizations of the self-inverting permutation  and the reducible permutation graph , while in Section 6 we experimentally show that these properties help prevent edge and/or node modifications attacks. Finally, in Section 7 we conclude the paper and discuss possible future extensions.

2 Theoretical Framework

In this section, we present background results and the main components, namely, the self-inverting permutations (SiP) and the reducible permutation graphs (RPG), which are used in the design of our codec system.

2.1 Preliminaries

We consider finite graphs with no multiple edges. For a graph , we denote by and the vertex set and edge set of , respectively. The neighborhood  of a vertex  of the graph  is the set of all the vertices of which are adjacent to . The degree of a vertex  in the graph , denoted , is the number of edges incident on ; thus, . For a node  of a directed graph , the number of directed edges coming in is called the indegree of and the number of directed edges leaving is its outdegree.

Next, we introduce some definitions that are key to our algorithms for encoding numbers as graphs. Let be a permutation over the set . We think of permutation as a sequence , so, for example, the permutation has , , etc. By we denote the position in the sequence of number ; in our example, , , , etc [18]. The length of a permutation is the number of elements in . The reverse of , denoted , is the permutation . The inverse of is the permutation with . For example, the inverse of the permutation is the permutation . Clearly, every permutation has a unique inverse, and the inverse of the inverse is the original permutation.

A subsequence of a permutation is a sequence such that . If, in addition, , then we say that is an increasing subsequence of , while if we say that is a decreasing subsequence of ; the length of a subsequence is the number of elements in .

The concatenation of subsequences of a permutation is a sequence of length such that for and , the th element of is equal to the th element of where, by convention, . Additionally, we denote by the subsequence which results from after having ignored the elements of the subsequence ; more generally, we denote by the subsequence which results from after having ignored the elements of the subsequences , , …, .

A cycle of a permutation is an index sequence with , , , . For example, the permutation has three cycles , , and of lengths 4, 2, and 1, respectively. In general, a permutation  contains cycles, where ; for example, the identity permutation over the set contains cycles of length 1. Throughout the paper, a cycle of length  is referred to as a -cycle.

A left-to-right maximum (left-to-right minimum, resp.) of is an element , , such that (, resp.) for all . The increasing (decreasing, resp.) subsequence is a left-to-right maxima (minima, resp.) subsequence if it consists of all the left-to-right maxima (minima, resp.) of ; clearly, . For example, the left-to-right maxima subsequence of the permutation is , while the left-to-right minima subsequence of is .

The st increasing (decreasing, resp.) subsequence of a permutation is defined to be the left-to-right maxima (minima, resp.) subsequence of . The th increasing (decreasing, resp.) subsequence of is defined to be the left-to-right maxima (minima, resp.) subsequence of , where results from after having ignored the elements of the st, nd, …, st increasing (decreasing, resp.) subsequences of , i.e., . For example, the increasing subsequences of the permutation are , since , , and , while its decreasing subsequences are , , , and .

We say that an element  of a permutation  over the set  dominates the element if and . An element  directly dominates (or d-dominates, for short) the element  if dominates and there exists no element  in such that dominates and dominates ; for example, in the permutation , the element  dominates the elements and directly dominates the elements . Let - be the set of all the elements of a permutation  which d-dominate the element  and be the element of the set - with maximum value; for example, in , - and , and - and . By definition, the element  of a permutation such that is the rightmost element on the left of in that d-dominates .

2.2 Self-inverting Permutations (SiP)

We next define the main component of our codec system, namely, the self-inverting permutation (SiP), and prove key properties for encoding numbers as reducible permutation graphs.

Definition 2.1

Let be a permutation over the set . A self-inverting permutation (or involution) is a permutation that is its own inverse: .

The definition of the inverse of a permutation implies that a permutation is a self-inverting permutation iff all its cycles are of length 1 or 2; hereafter, we shall denote a 2-cycle by with and a 1-cycle by or, equivalently, .

Definition 2.2

A sequence of all the 2- and 1-cycles of a self-inverting permutation  is a decreasing cycle representation of if where (with and ) if , . The cycle  containing the smallest element among the elements of the cycles is the minimum element of the sequence .

2.3 Reducible Permutation Graphs (RPG)

A directed graph  is strongly connected if for every ordered pair of vertices of there is a directed path in from to . A node  is an entry for a subgraph  of the graph  if there is an edge in such that and .

Definition 2.3

A flow-graph is a directed graph with a source node from which all other nodes are reachable. A flow-graph is reducible if it does not have a strongly connected subgraph with two (or more) entries.

We can equivalently define a reducible flow-graph as a directed graph with a source node such that every node of is reached from and every directed path from to a directed cycle reaches at the same node.

There are at least two other equivalent definitions, as Theorem 2.1 shows. These definitions use a few more graph-theoretic concepts. For some node , the edge is a cycle-edge. A depth first search (DFS) traversal of a graph partitions its edges into tree, forward, back, and cross edges. The tree, forward, and cross edges of form a dag known as a DFS dag.

Theorem 2.1

[19, 20] Let be a flow-graph. The following three statements about are equivalent:

  • the graph  is reducible;

  • the graph  has a unique DFS dag;

  • the graph  can be transformed into a single node by repeated application of the transformations and , where removes a cycle-edge, and picks a non-initial node  that has only one incoming edge  and glues nodes and .

It is well-known that a reducible flow-graph has at most one Hamiltonian path [8].

3 Our Codec System

For encoding a watermark number , our codec system uses two main components: (i) the self-inverting permutation  and (ii) the reducible permutation graph ; see Figure 1. The same figure also depicts the two main phases of our codec system process:

  • Phase W–SiP: it uses two algorithms, one for encoding the watermark number  into a self-inverting permutation  and the other for extracting from ;

  • Phase SiP–RPG: this phase uses two algorithms as well, one for encoding the self-inverting permutation  into a reducible permutation graph  and the other for extracting from .

Our codec system encodes an integer  as a self-inverting permutation  using a construction technique which captures into important structural properties (see Section 4). As we shall see in Section 6, these properties enable an attack-detection system to identify edge and/or node modifications made by an attacker to . Moreover, the encoding approach adopted in our system enables it to encode any integer  as a self-inverting permutation  of length , where .

The reducible permutation graph  produced by our system’s algorithms consists of nodes, say, , which include:

  1. A header node: it is a root node with outdegree 1 from which all other nodes of the graph  are reachable; note that every control flow-graph has such a node. In the header node is denoted by ;

  2. A footer node: it is a node with outdegree 0 that is reachable from all other nodes of the graph . Every control flow-graph has such a node representing the exit of the method. In the footer node is denoted by ;

  3. The body: it consists of nodes each with outdegree 2. In particular, each node has exactly two outgoing pointers: one points to node and the other points to a node  with ; recall that and .

By construction, the reducible permutation graph  is of order (i.e., number of nodes) and size (i.e., number of edges) . Thus, since , both the order and size of graph  are of , where .

Recall that our contribution in this paper has to do with both the W–SiP and the SiP–RPG phase. We design and analyze algorithms for encoding a watermark number  as a SiP  and algorithms for encoding a SiP  as a reducible permutation flow-graph  along with the corresponding decoding algorithms; we also show properties of our codec system that prevent edge and/or node modification attacks.

   

Figure 1: The main data components used by the codec system W-RPG for encoding a watermark number : (i) the self-inverting permutation  and (ii) the reducible permutation graph .

3.1 Codec Algorithms for Phase W-SiP

In this section, we first introduce the notion of a Bitonic Permutation and then we present two algorithms, namely Encode_W.to.SiP and Decode_SiP.to.W, for encoding an integer  into a self-inverting permutation  and for extracting it from , respectively. Both algorithms run in time, where is the length of the binary representation of the integer  [3].

Bitonic Permutations: A permutation over the set is called bitonic if it either monotonically increases and then monotonically decreases, or monotonically decreases and then monotonically increases. For example, the permutations and are both bitonic. Trivially, an increasing or decreasing permutation is considered bitonic.

Let be a bitonic permutation over the set that first monotonically increases and then monotonically decreases and let be the leftmost element of such that ; note that is the maximum element of . Then, we call the sequence the increasing subsequence of and the sequence the decreasing subsequence of . Note that although is increasing, the increasing subsequence of is defined up to the element .

Notations: If and are two binary numbers, then the number is the binary number . The binary sequence of the number is the sequence of length .

   

Figure 2: The main data components used by Algorithms Encode_W.to.SiP and Decode_SiP.to.W.

3.1.1 Algorithm Encode_W.to.SiP

We next present an algorithm for encoding an integer as a self-inverting permutation without having to consult a list of all self-inverting permutations. Our algorithm takes as input an integer , computes its binary representation, and then produces a self-inverting permutation  in time linear in the length of the binary representation of . The proposed algorithm is the following:

Algorithm Encode_W.to.SiP

  1. Compute the binary representation of and let be the length of ;

  2. Construct the binary number of length , and then the binary sequence of ;

  3. Construct the sequence of the s’ positions and the sequence of the s’ positions in from left to right, where ;

  4. Construct the bitonic permutation over the set ;

  5. for do
    xxxconstruct a 2-cycle with the -th element of from left and the -th element from right
    xxx
    construct the 2-cycle ;
    construct the 1-cycle ;

  6. Initialize the permutation  to the identity permutation ;
    for each 2-cycle computed at Step 5, set and ;

  7. Return the self-inverting permutation ;

Example 3.1 Let be the input watermark integer in the algorithm Encode_W.to.SiP. We first compute the binary representation of the number ; then we construct the binary number and the binary sequence of ; we compute the sequences and , and then construct the bitonic permutation on numbers; since is odd, we form four 2-cycles , , , and one 1-cycle , and then construct the self-inverting permutation .

Time and Space Complexity. The encoding algorithm Encode_W.to.SiP performs basic operations on sequences of length, where is the number of bits in the binary representation of (see Figure 2). Thus, the whole encoding process requires time and space, and the following theorem holds:

Theorem 3.1

Let be an integer and let be the binary representation of . The algorithm Encode_W.to.SiP encodes the number  in a self-inverting permutation  of length in time and space.


3.1.2 Algorithm Decode_SiP.to.W

Next, we present an algorithm for decoding a self-inverting permutation. More precisely, our algorithm, which we call Decode_SiP.to.W, takes as input a self-inverting permutation  produced by Algorithm Encode_W.to.SiP and returns its corresponding integer . Its time complexity is linear in the length of the permutation . We next describe the proposed algorithm:

Algorithm Decode_SiP.to.W

  1. Compute the decreasing cycle representation of the self-inverting permutation , where ;

  2. Construct the bitonic permutation of length as follows:
    let , where with , , and ;
    xxx  compute ;
    xxx  delete from the element which forms the 1-cycle of and thus ;
    xxx  set ;

  3. Construct the increasing subsequence of and then the decreasing subsequence , where is the top element of ;

  4. Construct the binary sequence by setting 1 in positions and 0 in positions ;

  5. Compute from ;

  6. Return the decimal value  of the binary number ;

The decoding algorithm Decode_SiP.to.W is essentially the reverse of the corresponding encoding algorithm Encode_W.to.SiP.

Example 3.2 Let be a self-inverting permutation produced by Algorithm Encode_W.to.SiP. The decreasing cycle representation of is the sequence ; we take the cycles in from right to left and construct the permutation ; then, we compute the increasing subsequence and the decreasing subsequence of ; we next construct the binary sequence of length and finally the the sequence of the elements of ; the decimal value of the binary number 1100 is the integer .

Time and Space Complexity. It is easy to see that the decoding algorithm Decode_SiP.to.W performs the same basic operations on sequences of length as the encoding algorithm (see Figure 2). Thus, we obtain the following result:

Theorem 3.2

Let be an integer (whose binary representation has length ) and let be the self-inverting permutation of length produced by Algorithm Encode_W.to.SiP to encode . Algorithm Decode_SiP.to.W correctly extracts from in time and space.

3.2 Codec Algorithms for Phase SiP-RPG

In this section, we concentrate on the system’s phase SiP–RPG and present an efficient algorithm for encoding a self-inverting permutation  into a reducible permutation graph , along with the corresponding decoding algorithm.

The proposed encoding algorithm, which we call Encode_SiP.to.RPG, takes as input the self-inverting permutation  produced by the algorithm Encode_W.to.SiP and constructs a reducible permutation flow-graph  by using a DAG representation  of the permutation ; in fact, it uses a parent-relation of a tree obtained from the graph  defined below. The whole encoding process takes time and requires space, where is the length of the input self-inverting permutation .

   

Figure 3: The DAG of the self-inverting permutation and the corresponding Dmax-tree .

Next, we first describe the main ideas and the structures behind our encoding algorithm. In particular, given a self-inverting permutation  we construct a directed acyclic graph and a directed tree by taking advantage of the values of the elements of (recall that with respect to the permutation , where , is equal to the maximum value element among the elements in that d-dominate ; see Subsection 2.1).

DAG Representation : We construct the directed acyclic graph by exploiting the d-domination relation of the elements of as follows: (i) for every element of , we create a corresponding vertex  and we add it into the vertex set  of ; (ii) for every pair of vertices where , we add the directed edge  in if the element  d-dominates the element  in ; (iii) we create two dummy vertices and and we add them both in ; then, we add in the directed edge  for every with indegree equal to , and the edge for every with outdegree equal to .

Figure 3 depicts the graph  of the permutation . Note that, by construction, for every directed edge  of since the element  d-dominates the element  in .

Dmax-tree : We next construct the directed tree , which we call Dmax-tree, by exploiting the values of the elements on the nodes of . The Dmax-tree is simply constructed as follows:

  • construct the DAG ;

  • delete the directed edge  from if .

The Dmax-tree of the permutation is shown in Figure 3. We point out that the construction of the Dmax-tree can also be done directly from permutation  by computing the element for each element , ; note that dominates all the elements of .


3.2.1 Algorithm Encode_SiP.to.RPG

Given a self-inverting permutation  of length , our proposed encoding algorithm Encode_W.to.SiP works as follows: first, it computes the value of each of the elements of the self-inverting permutation (Step 1), which it then uses to construct a directed graph  on nodes (Steps 2 and 3). Next, we present the encoding algorithm in detail.

Algorithm Encode_SiP.to.RPG

  1. for each element , , do
    xxx  Compute ;

  2. Construct a directed graph on vertices as follows:
    xxx  ;
    xxx  add the forward edges in , for ;

  3. for each vertex , , do
    xxx  add the backward edge in , where ;

  4. Return the graph ;

Time and Space Complexity. The most time-consuming step of the algorithm is the computation of the value for each element  of (Step 1). On the other hand, the construction of the reducible permutation flow-graph on nodes requires only the forward edges (Step 2) which can be trivially computed, and the backward edges (Step 3) which can be computed using the values of .

Returning to Step 1, since is the rightmost element on the left of the element  in the permutation  that is greater than , the values  can be computed using the input permutation as follows:

  1. insert the element  with value  into an initially empty stack ;

  2. for each element , , do the following:
    xxxwhile the element at the top of is less than
    xxxxxxpop it from the stack ;
    xxx element at the top of ;
    xxxpush into the stack ;

For the correctness of this procedure, note that the contents of the stack  are in decreasing order from bottom to top; in fact, at the completion of the processing of element , contains (from top to bottom) the left-to-right maxima of the reverse subpermutation . Additionally, it is important to observe that the value at the bottom of the stack  is never removed.

The time to process element  in step (ii) is where is the number of elements popped from the stack  while processing . Since the number of pops from does not exceed the number of pushes in and since each element of the input permutation is inserted exactly once in , the whole computation of the function  takes time and space, where is the length of the permutation . Thus, we obtain the following result.

Theorem 3.3

The algorithm Encode_SiP.to.RPG for encoding a self-inverting permutation of length as a reducible permutation flow-graph requires time and space.

   

Figure 4: The main structures used or constructed by the algorithms Encode_SiP.to.RPG and Decode_RPG.to.SiP, that is, the self-inverting permutation , the function , the reducible graph , and the Dmax-tree .

3.2.2 Algorithm Decode_RPG.to.SiP

Having presented the encoding algorithm Encode_SiP.to.RPG, we are interested in designing an efficient and easily implementable algorithm for decoding the permutation  from the graph . Thus, we next present such a decoding algorithm, we call it Decode_RPG.to.SiP, which is easily implementable: indeed, the only operations used by the algorithm are edge modifications on and DFS-search on trees.

The algorithm takes as input a reducible permutation flow-graph  on nodes constructed by Algorithm Encode_SiP.to.RPG, and produces a permutation  of length ; it works as follows:

Algorithm Decode_RPG.to.SiP

  1. Delete the forward edges from the set , , and the node from ;

  2. Flip all the remaining edges (backward edges) of the graph  yielding the Dmax-tree with nodes ;

  3. Perform DFS-search on the tree starting at node  by always proceeding to the minimum-labeled child node and compute the DFS discovery time of each node  of ;

  4. Order the nodes of the tree  by their DFS discovery time and let be the resulting order;

  5. Return ;

Time and Space Complexity. The size of the reducible permutation graph  constructed by the algorithm Encode_SiP.to.RPG is , where is the length of the permutation , and thus the size of the resulting tree  is also . It is well known that the DFS-search on the tree  takes time linear in the size of . Thus, the decoding algorithm is executed in time using space. Thus, the following theorem holds:

Theorem 3.4

Let be a reducible permutation flow-graph of size produced by the algorithm Encode_SiP.to.RPG. The algorithm Decode_RPG.to.SiP decodes the flow-graph  in time and space.

4 Structure and Properties of the SiP 

In this section, we analyze the structure of a self-inverting permutation  produced by the algorithms Encode_W.to.SiP and present properties which are important in their own right, at least from a graph-theoretic point of view, and prove useful in shielding our watermark graph  against attacks.

4.1 The Subsequences and

Consider a self-inverting permutation  encoding an integer in the range , where is the length of the binary representation of ; we distinguish the following two cases:

All-One case: Suppose that , that is, all the bits in ’s binary representation are . Then, according to Algorithm Encode_W.to.SiP, , , and , that is, is the concatenation of the (increasing) subsequences and where

(1)

Zero-and-One case: Suppose that . Then, the concatenation of the binary representation of with a trailing  consists of s, followed by s, followed by s, followed by s, and so on, followed by s, followed by s where ,