Diff
Not logged in

Differences From Artifact [1965244c3e]:

To Artifact [91d8639a2e]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
52
53
54
55
56
57
58
59
60


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
297
298
299
300
301
302
...
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
...
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383

384
385
386
387
388
389
390
...
394
395
396
397
398
399
400
401
402
403
404
405
406

407
408
409
410
411
412
413
...
415
416
417
418
419
420
421
422
423
424
425
426
427

428
429
430
431
432
433
434
...
450
451
452
453
454
455
456
457
458
459
460
461
462

463
464
465
466
467
468

469
470
471
472
473
474
475
476
477

478
479
480
481
// Copyright 2015 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement, version 1.1.  This, along with the
// Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.


use error::RoutingError;
use maidsafe_utilities::serialisation::{deserialise, serialise, serialised_size};
use rust_sodium::crypto::{box_, sealedbox};
use rust_sodium::crypto::sign::{self, PublicKey, SecretKey, Signature};
use rustc_serialize::{Decodable, Decoder};

use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{self, Debug, Formatter};
use super::{AppendWrapper, AppendedData, DataIdentifier, Filter, NO_OWNER_PUB_KEY};
use xor_name::XorName;

/// Maximum allowed size for a private appendable data to grow to
pub const MAX_PRIV_APPENDABLE_DATA_SIZE_IN_BYTES: u64 = 102400;

/// Maximum size of a serialised `PrivAppendedData` item, in bytes.
pub const MAX_PRIV_APPENDED_DATA_BYTES: usize = 220;

/// A private appended data item: an encrypted `AppendedData`.
#[derive(Hash, Eq, PartialEq, PartialOrd, Ord, Clone, RustcEncodable, Debug)]
pub struct PrivAppendedData(pub Vec<u8>);

impl PrivAppendedData {
    /// Creates a new `PrivAppendedData` encrypted with `encrypting_key`.
    pub fn new(appended_data: &AppendedData,
               encrypt_pub_key: &box_::PublicKey)
               -> Result<PrivAppendedData, RoutingError> {
................................................................................
                -> Result<AppendedData, RoutingError> {
        let decipher_result = sealedbox::open(&self.0, pub_key, secret_key)
            .map_err(|()| RoutingError::AsymmetricDecryptionFailure)?;
        Ok(deserialise(&decipher_result)?)
    }
}

impl Decodable for PrivAppendedData {
    fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {


        let data: Vec<u8> = Decodable::decode(d)?;
        if data.len() > MAX_PRIV_APPENDED_DATA_BYTES {
            return Err(d.error("wrong private appended data size"));
        }
        Ok(PrivAppendedData(data))
    }
}

/// Private appendable data.
///
/// These types may be stored unsigned with previous and current owner keys
/// set to the same keys. Updates require a signature to validate.
///
/// Data can be appended by any key that is not excluded by the filter.
#[derive(Hash, Eq, PartialEq, PartialOrd, Ord, Clone, RustcDecodable, RustcEncodable)]
pub struct PrivAppendableData {
    /// The name of this data chunk.
    pub name: XorName,
    /// The version, i.e. the number of times this has been updated by a `Post` request.
    pub version: u64,
    /// The filter defining who is allowed to append items.
    pub filter: Filter,
................................................................................
               encrypt_key: box_::PublicKey)
               -> Result<PrivAppendableData, RoutingError> {
        if owners.len() > 1 {
            return Err(RoutingError::InvalidOwners);
        }

        Ok(PrivAppendableData {
            name: name,
            version: version,
            filter: filter,
            encrypt_key: encrypt_key,
            deleted_data: deleted_data,
            owners: owners,
            signatures: BTreeMap::new(),
            data: BTreeSet::new(),
        })
    }

    /// Updates this data item with the given updated version if the update is valid, otherwise
    /// returns an error.
    ///
    /// This allows types to be created and `previous_owner_signatures` added one by one.
    /// To transfer ownership, the current owner signs over the data; the previous owners field
................................................................................
        super::verify_signatures(&self.owners, &data, &other.signatures)
    }

    /// Inserts the given data item, or returns `false` if it cannot be added because it has
    /// recently been deleted.
    pub fn append(&mut self, priv_appended_data: PrivAppendedData, sign_key: &PublicKey) -> bool {
        if match self.filter {
            Filter::WhiteList(ref white_list) => !white_list.contains(sign_key),
            Filter::BlackList(ref black_list) => black_list.contains(sign_key),
        } || self.deleted_data.contains(&priv_appended_data) {
            return false;
        }
        self.data
            .insert(priv_appended_data)
    }

    /// Inserts the given wrapper item, or returns `false` if cannot
    pub fn apply_wrapper(&mut self, wrapper: AppendWrapper) -> bool {
        if !wrapper.verify_signature() || &self.version != wrapper.version() {
            return false;
        }
................................................................................
               self.version,
               self.owners,
               self.signatures)
        // TODO(afck): Print `data` and `deleted_data`.
    }
}

#[derive(RustcEncodable)]
struct SerialisablePrivAppendableData<'a> {
    name: XorName,
    version: Vec<u8>,
    filter: &'a Filter,
    encrypt_key: &'a box_::PublicKey,
    owners: &'a BTreeSet<PublicKey>,
    deleted_data: &'a BTreeSet<PrivAppendedData>,
}

#[cfg(test)]
mod tests {

    use data::{self, AppendWrapper, AppendedData, DataIdentifier, Filter};
    use maidsafe_utilities::serialisation::serialise;
    use rand;
    use rust_sodium::crypto::{box_, sign};
    use std::collections::BTreeSet;
    use super::*;
    use xor_name::XorName;

    #[test]
    fn serialised_priv_appended_data_size() {
        let keys = sign::gen_keypair();
        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
................................................................................
                let data = match priv_appendable_data.data_to_sign() {
                    Ok(data) => data,
                    Err(error) => panic!("Error: {:?}", error),
                };
                assert!(data::verify_signatures(&owner_keys,
                                                &data,
                                                priv_appendable_data.get_signatures())
                    .is_err());
                assert!(priv_appendable_data.add_signature(&keys).is_ok());
                assert!(data::verify_signatures(&owner_keys,
                                                &data,
                                                priv_appendable_data.get_signatures())
                    .is_ok());
            }
            Err(error) => panic!("Error: {:?}", error),
        }
    }

    #[test]
    fn single_owner_other_signature() {
................................................................................
                let data = match priv_appendable_data.data_to_sign() {
                    Ok(data) => data,
                    Err(error) => panic!("Error: {:?}", error),
                };
                assert!(data::verify_signatures(&owner_keys,
                                                &data,
                                                priv_appendable_data.get_signatures())
                    .is_err());
            }
            Err(error) => panic!("Error: {:?}", error),
        }
    }

    #[test]
    fn appending_with_white_list() {
        let keys = sign::gen_keypair();
        let encrypt_keys = box_::gen_keypair();

        let white_key = sign::gen_keypair();
        let black_key = sign::gen_keypair();

        let mut priv_appendable_data = unwrap!(PrivAppendableData::new(rand::random(),
                                            0,
                                            BTreeSet::new(),
                                            BTreeSet::new(),
                                            Filter::white_list(vec![white_key.0]),
                                            encrypt_keys.0));


        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
        let priv_appended_data = unwrap!(PrivAppendedData::new(&appended_data, &encrypt_keys.0));

        assert!(!priv_appendable_data.append(priv_appended_data.clone(), &black_key.0));
        assert!(priv_appendable_data.append(priv_appended_data, &white_key.0));
................................................................................
    fn appending_with_black_list() {
        let keys = sign::gen_keypair();
        let encrypt_keys = box_::gen_keypair();

        let white_key = sign::gen_keypair();
        let black_key = sign::gen_keypair();

        let mut priv_appendable_data = unwrap!(PrivAppendableData::new(rand::random(),
                                            0,
                                            BTreeSet::new(),
                                            BTreeSet::new(),
                                            Filter::black_list(vec![black_key.0]),
                                            encrypt_keys.0));


        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
        let priv_appended_data = unwrap!(PrivAppendedData::new(&appended_data, &encrypt_keys.0));

        assert!(!priv_appendable_data.append(priv_appended_data.clone(), &black_key.0));
        assert!(priv_appendable_data.append(priv_appended_data, &white_key.0));
................................................................................

    #[test]
    fn apply_wrapper() {
        let keys = sign::gen_keypair();
        let encrypt_keys = box_::gen_keypair();
        let name: XorName = rand::random();

        let mut priv_appendable_data = unwrap!(PrivAppendableData::new(name,
                                                                       0,
                                                                       BTreeSet::new(),
                                                                       BTreeSet::new(),
                                                                       Filter::black_list(None),
                                                                       encrypt_keys.0));


        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
        let priv_appended_data = unwrap!(PrivAppendedData::new(&appended_data, &encrypt_keys.0));

        // apply correct wrapper
        let append_wrapper = unwrap!(AppendWrapper::new_priv(name,
................................................................................
        let mut owner = BTreeSet::new();
        owner.insert(keys.0);
        let mut new_owner = BTreeSet::new();
        new_owner.insert(other_keys.0);
        let name: XorName = rand::random();
        let encrypt_keys = box_::gen_keypair();

        let mut ad = unwrap!(PrivAppendableData::new(name,
                                                     0,
                                                     owner,
                                                     BTreeSet::new(),
                                                     Filter::black_list(None),
                                                     encrypt_keys.0));

        let mut ad_new = unwrap!(PrivAppendableData::new(name,
                                                         1,
                                                         new_owner.clone(),
                                                         BTreeSet::new(),
                                                         Filter::black_list(None),
                                                         encrypt_keys.0));

        assert!(ad_new.add_signature(&keys).is_ok());
        assert!(ad.update_with_other(ad_new).is_ok());

        let mut ad_fail = unwrap!(PrivAppendableData::new(name,
                                                          2,
                                                          new_owner.clone(),
                                                          BTreeSet::new(),
                                                          Filter::black_list(None),
                                                          encrypt_keys.0));

        assert!(ad_fail.add_signature(&keys).is_ok());
        assert!(ad.update_with_other(ad_fail).is_err());
    }
}







|
|








>




|
>


<






|


|







 







|
|
>
>
|

|











|







 







|
|
|
|
|
|
|
|
|







 







|
|
|


<
|







 







|











>





<







 







|




|







 







|













|
|
|
|
|
|
>







 







|
|
|
|
|
|
>







 







|
|
|
|
|
|
>







 







|
|
|
|
|
|
>
|
|
|
|
|
|
>



|
|
|
|
|
|
>




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
171
172
173
174
175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297

298
299
300
301
302
303
304
...
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
...
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
...
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
// Copyright 2015 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement.  This, along with the Licenses can be
// found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.

use super::{AppendWrapper, AppendedData, DataIdentifier, Filter, NO_OWNER_PUB_KEY};
use error::RoutingError;
use maidsafe_utilities::serialisation::{deserialise, serialise, serialised_size};
use rust_sodium::crypto::{box_, sealedbox};
use rust_sodium::crypto::sign::{self, PublicKey, SecretKey, Signature};
use serde::{Deserialize, Deserializer};
use serde::de::Error;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{self, Debug, Formatter};

use xor_name::XorName;

/// Maximum allowed size for a private appendable data to grow to
pub const MAX_PRIV_APPENDABLE_DATA_SIZE_IN_BYTES: u64 = 102400;

/// Maximum size of a serialised `PrivAppendedData` item, in bytes.
pub const MAX_PRIV_APPENDED_DATA_BYTES: usize = 212;

/// A private appended data item: an encrypted `AppendedData`.
#[derive(Hash, Eq, PartialEq, PartialOrd, Ord, Clone, Serialize, Debug)]
pub struct PrivAppendedData(pub Vec<u8>);

impl PrivAppendedData {
    /// Creates a new `PrivAppendedData` encrypted with `encrypting_key`.
    pub fn new(appended_data: &AppendedData,
               encrypt_pub_key: &box_::PublicKey)
               -> Result<PrivAppendedData, RoutingError> {
................................................................................
                -> Result<AppendedData, RoutingError> {
        let decipher_result = sealedbox::open(&self.0, pub_key, secret_key)
            .map_err(|()| RoutingError::AsymmetricDecryptionFailure)?;
        Ok(deserialise(&decipher_result)?)
    }
}

impl Deserialize for PrivAppendedData {
    fn deserialize<D>(d: D) -> Result<Self, D::Error>
        where D: Deserializer
    {
        let data: Vec<u8> = Deserialize::deserialize(d)?;
        if data.len() > MAX_PRIV_APPENDED_DATA_BYTES {
            return Err(D::Error::custom("wrong private appended data size"));
        }
        Ok(PrivAppendedData(data))
    }
}

/// Private appendable data.
///
/// These types may be stored unsigned with previous and current owner keys
/// set to the same keys. Updates require a signature to validate.
///
/// Data can be appended by any key that is not excluded by the filter.
#[derive(Hash, Eq, PartialEq, PartialOrd, Ord, Clone, Deserialize, Serialize)]
pub struct PrivAppendableData {
    /// The name of this data chunk.
    pub name: XorName,
    /// The version, i.e. the number of times this has been updated by a `Post` request.
    pub version: u64,
    /// The filter defining who is allowed to append items.
    pub filter: Filter,
................................................................................
               encrypt_key: box_::PublicKey)
               -> Result<PrivAppendableData, RoutingError> {
        if owners.len() > 1 {
            return Err(RoutingError::InvalidOwners);
        }

        Ok(PrivAppendableData {
               name: name,
               version: version,
               filter: filter,
               encrypt_key: encrypt_key,
               deleted_data: deleted_data,
               owners: owners,
               signatures: BTreeMap::new(),
               data: BTreeSet::new(),
           })
    }

    /// Updates this data item with the given updated version if the update is valid, otherwise
    /// returns an error.
    ///
    /// This allows types to be created and `previous_owner_signatures` added one by one.
    /// To transfer ownership, the current owner signs over the data; the previous owners field
................................................................................
        super::verify_signatures(&self.owners, &data, &other.signatures)
    }

    /// Inserts the given data item, or returns `false` if it cannot be added because it has
    /// recently been deleted.
    pub fn append(&mut self, priv_appended_data: PrivAppendedData, sign_key: &PublicKey) -> bool {
        if match self.filter {
               Filter::WhiteList(ref white_list) => !white_list.contains(sign_key),
               Filter::BlackList(ref black_list) => black_list.contains(sign_key),
           } || self.deleted_data.contains(&priv_appended_data) {
            return false;
        }

        self.data.insert(priv_appended_data)
    }

    /// Inserts the given wrapper item, or returns `false` if cannot
    pub fn apply_wrapper(&mut self, wrapper: AppendWrapper) -> bool {
        if !wrapper.verify_signature() || &self.version != wrapper.version() {
            return false;
        }
................................................................................
               self.version,
               self.owners,
               self.signatures)
        // TODO(afck): Print `data` and `deleted_data`.
    }
}

#[derive(Serialize)]
struct SerialisablePrivAppendableData<'a> {
    name: XorName,
    version: Vec<u8>,
    filter: &'a Filter,
    encrypt_key: &'a box_::PublicKey,
    owners: &'a BTreeSet<PublicKey>,
    deleted_data: &'a BTreeSet<PrivAppendedData>,
}

#[cfg(test)]
mod tests {
    use super::*;
    use data::{self, AppendWrapper, AppendedData, DataIdentifier, Filter};
    use maidsafe_utilities::serialisation::serialise;
    use rand;
    use rust_sodium::crypto::{box_, sign};
    use std::collections::BTreeSet;

    use xor_name::XorName;

    #[test]
    fn serialised_priv_appended_data_size() {
        let keys = sign::gen_keypair();
        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
................................................................................
                let data = match priv_appendable_data.data_to_sign() {
                    Ok(data) => data,
                    Err(error) => panic!("Error: {:?}", error),
                };
                assert!(data::verify_signatures(&owner_keys,
                                                &data,
                                                priv_appendable_data.get_signatures())
                                .is_err());
                assert!(priv_appendable_data.add_signature(&keys).is_ok());
                assert!(data::verify_signatures(&owner_keys,
                                                &data,
                                                priv_appendable_data.get_signatures())
                                .is_ok());
            }
            Err(error) => panic!("Error: {:?}", error),
        }
    }

    #[test]
    fn single_owner_other_signature() {
................................................................................
                let data = match priv_appendable_data.data_to_sign() {
                    Ok(data) => data,
                    Err(error) => panic!("Error: {:?}", error),
                };
                assert!(data::verify_signatures(&owner_keys,
                                                &data,
                                                priv_appendable_data.get_signatures())
                                .is_err());
            }
            Err(error) => panic!("Error: {:?}", error),
        }
    }

    #[test]
    fn appending_with_white_list() {
        let keys = sign::gen_keypair();
        let encrypt_keys = box_::gen_keypair();

        let white_key = sign::gen_keypair();
        let black_key = sign::gen_keypair();

        let data = PrivAppendableData::new(rand::random(),
                                           0,
                                           BTreeSet::new(),
                                           BTreeSet::new(),
                                           Filter::white_list(vec![white_key.0]),
                                           encrypt_keys.0);
        let mut priv_appendable_data = unwrap!(data);

        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
        let priv_appended_data = unwrap!(PrivAppendedData::new(&appended_data, &encrypt_keys.0));

        assert!(!priv_appendable_data.append(priv_appended_data.clone(), &black_key.0));
        assert!(priv_appendable_data.append(priv_appended_data, &white_key.0));
................................................................................
    fn appending_with_black_list() {
        let keys = sign::gen_keypair();
        let encrypt_keys = box_::gen_keypair();

        let white_key = sign::gen_keypair();
        let black_key = sign::gen_keypair();

        let data = PrivAppendableData::new(rand::random(),
                                           0,
                                           BTreeSet::new(),
                                           BTreeSet::new(),
                                           Filter::black_list(vec![black_key.0]),
                                           encrypt_keys.0);
        let mut priv_appendable_data = unwrap!(data);

        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
        let priv_appended_data = unwrap!(PrivAppendedData::new(&appended_data, &encrypt_keys.0));

        assert!(!priv_appendable_data.append(priv_appended_data.clone(), &black_key.0));
        assert!(priv_appendable_data.append(priv_appended_data, &white_key.0));
................................................................................

    #[test]
    fn apply_wrapper() {
        let keys = sign::gen_keypair();
        let encrypt_keys = box_::gen_keypair();
        let name: XorName = rand::random();

        let data = PrivAppendableData::new(name,
                                           0,
                                           BTreeSet::new(),
                                           BTreeSet::new(),
                                           Filter::black_list(None),
                                           encrypt_keys.0);
        let mut priv_appendable_data = unwrap!(data);

        let pointer = DataIdentifier::Structured(rand::random(), 10000);
        let appended_data = unwrap!(AppendedData::new(pointer, keys.0, &keys.1));
        let priv_appended_data = unwrap!(PrivAppendedData::new(&appended_data, &encrypt_keys.0));

        // apply correct wrapper
        let append_wrapper = unwrap!(AppendWrapper::new_priv(name,
................................................................................
        let mut owner = BTreeSet::new();
        owner.insert(keys.0);
        let mut new_owner = BTreeSet::new();
        new_owner.insert(other_keys.0);
        let name: XorName = rand::random();
        let encrypt_keys = box_::gen_keypair();

        let mut data = PrivAppendableData::new(name,
                                               0,
                                               owner,
                                               BTreeSet::new(),
                                               Filter::black_list(None),
                                               encrypt_keys.0);
        let mut ad = unwrap!(data);
        data = PrivAppendableData::new(name,
                                       1,
                                       new_owner.clone(),
                                       BTreeSet::new(),
                                       Filter::black_list(None),
                                       encrypt_keys.0);
        let mut ad_new = unwrap!(data);
        assert!(ad_new.add_signature(&keys).is_ok());
        assert!(ad.update_with_other(ad_new).is_ok());

        data = PrivAppendableData::new(name,
                                       2,
                                       new_owner.clone(),
                                       BTreeSet::new(),
                                       Filter::black_list(None),
                                       encrypt_keys.0);
        let mut ad_fail = unwrap!(data);
        assert!(ad_fail.add_signature(&keys).is_ok());
        assert!(ad.update_with_other(ad_fail).is_err());
    }
}