Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add backdoor attack #267

Merged
merged 4 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,56 @@ THE SOFTWARE.

--------------------------------------------------------------------------------

Code in federatedscope/contrib/model/resnet.py is adapted from
https://github.com/kuangliu/pytorch-cifar (MIT License)

Copyright (c) 2017 liukuang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------

Code in federatedscope/attack/auxiliary/create_edgeset.py and poisoning_data.py
is adapted from https://github.com/ksreenivasan/OOD_Federated_Learning
(MIT License)

Copyright (c) 2017 liukuang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

--------------------------------------------------------------------------------

The function calculate_time_cost in federatedscope/core/auxiliaries/utils.py
is adopted from https://github.com/SymbioticLab/FedScale

Expand Down
12 changes: 9 additions & 3 deletions federatedscope/attack/auxiliary/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from federatedscope.attack.auxiliary.utils import *
from federatedscope.attack.auxiliary.attack_trainer_builder import \
wrap_attacker_trainer
from federatedscope.attack.auxiliary.attack_trainer_builder \
import wrap_attacker_trainer
from federatedscope.attack.auxiliary.backdoor_utils import *
from federatedscope.attack.auxiliary.poisoning_data import *
from federatedscope.attack.auxiliary.create_edgeset import *

__all__ = [
'get_passive_PIA_auxiliary_dataset', 'iDLG_trick', 'cos_sim',
'get_classifier', 'get_data_info', 'get_data_sav_fn', 'get_info_diff_loss',
'sav_femnist_image', 'get_reconstructor', 'get_generator',
'get_data_property', 'get_passive_PIA_auxiliary_dataset'
'get_data_property', 'get_passive_PIA_auxiliary_dataset',
'load_poisoned_dataset_edgeset', 'load_poisoned_dataset_pixel',
'selectTrigger', 'poisoning', 'create_ardis_poisoned_dataset',
'create_ardis_poisoned_dataset', 'create_ardis_test_dataset'
]
3 changes: 3 additions & 0 deletions federatedscope/attack/auxiliary/attack_trainer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def wrap_attacker_trainer(base_trainer, config):
elif config.attack.attack_method.lower() == 'gradascent':
from federatedscope.attack.trainer import wrap_GradientAscentTrainer
return wrap_GradientAscentTrainer(base_trainer)
elif config.attack.attack_method.lower() == 'backdoor':
from federatedscope.attack.trainer import wrap_backdoorTrainer
return wrap_backdoorTrainer(base_trainer)
else:
raise ValueError('Trainer {} is not provided'.format(
config.attack.attack_method))
Loading