Commit 656d164c authored by nagayama15's avatar nagayama15

Update watermarker driver

parent f649775a
......@@ -4,16 +4,18 @@
#include "kyut/BitStreamWriter.hpp"
#include "kyut/watermarker/FunctionOrderingWatermarker.hpp"
#include "kyut/watermarker/OperandSwappingWatermarker.hpp"
int main(int argc, char *argv[]) {
// Parse command line options
if (argc != 2) {
fmt::print(std::cerr, "{} <input file>\n", argv[0]);
if (argc != 3) {
fmt::print(std::cerr, "{} <input file> <method>\n", argv[0]);
return 1;
}
const std::string inputFile = argv[1];
const std::string method = argv[2];
try {
// Read the input module
......@@ -22,7 +24,15 @@ int main(int argc, char *argv[]) {
// Embed watermarks
kyut::BitStreamWriter stream;
kyut::watermarker::extractFunctionOrdering(module, stream, 10);
std::size_t numBits;
if (method == "opswap") {
numBits = kyut::watermarker::extractOperandSwapping(module, stream);
} else if (method == "funcord") {
numBits = kyut::watermarker::extractFunctionOrdering(module, stream, 10);
} else {
throw std::runtime_error{fmt::format("unknown embedding method: {}", method)};
}
// Output watermarks extracted
std::cout << stream.dataAsString();
......
......@@ -4,17 +4,19 @@
#include "kyut/CircularBitStreamReader.hpp"
#include "kyut/watermarker/FunctionOrderingWatermarker.hpp"
#include "kyut/watermarker/OperandSwappingWatermarker.hpp"
int main(int argc, char *argv[]) {
// Parse command line options
if (argc != 3) {
fmt::print(std::cerr, "{} <input file> <watermark>\n", argv[0]);
if (argc != 4) {
fmt::print(std::cerr, "{} <input file> <method> <watermark>\n", argv[0]);
return 1;
}
const std::string inputFile = argv[1];
const std::string watermark = argv[2];
const std::string method = argv[2];
const std::string watermark = argv[3];
try {
// Read the input module
......@@ -24,7 +26,13 @@ int main(int argc, char *argv[]) {
// Embed watermarks
const auto stream = kyut::CircularBitStreamReader::fromString(watermark);
kyut::watermarker::embedFunctionOrdering(module, *stream, 10);
if (method == "opswap") {
kyut::watermarker::embedOperandSwapping(module, *stream);
} else if (method == "funcord") {
kyut::watermarker::embedFunctionOrdering(module, *stream, 10);
} else {
throw std::runtime_error{fmt::format("unknown embedding method: {}", method)};
}
// Output the result
wasm::ModuleWriter{}.writeText(module, "");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment