コード例 #1
0
from experimental_testing.robustness_eval import tsm_utils

# Define file names
input_file = '../../res/testing/original_test_files/SQAM/58.wav'
output_dir = '../../res/demo'
filename = input_file.split('/')[-1].split('.')[0]
suffix = '_24_bits_xs'

# Load sound file
samples, fs = sf.read(input_file, dtype=np.int16)

# Construct the watermarking system
wm_sys_xs = XsWMSystem(num_bins=224, la=2.5, threshold=50, delta=0.05, step=5)

# Form the watermark w, each list element is embedded in one channel
w = watermarking_utils.construct_watermark(['HdM', 'Stg'])

# Mark the samples
marked_samples, key = wm_sys_xs.embed_watermark(samples, w, key=[1234, 5678])

# Write result to disk
out_file = path.join(output_dir, filename + suffix + '.wav')
sf.write(out_file, marked_samples, fs)

# Write the IV to disk for later detection
params = wm_sys_xs.get_params()
watermarking_utils.dump_params(output_dir,
                               filename + suffix,
                               iv=params,
                               mark=w,
                               key=key)
コード例 #2
0
samples, samplerate = sf.read(input_file, dtype=np.int16)
# Key material
a = 1
b = 2
n = 5

samples, padding_length = catmap_encryption.encrypt(samples[:, 0], a, b, n)
output_file = path.join(out_dir,
                        input_file[0:len(input_file) - 4] + '_encrypted.wav')
sf.write(output_file, samples, samplerate)

# Reads encrypted audio file and marks it
samples, samplerate = sf.read(output_file, dtype=np.int16)

# Form mark and syn code
w = watermarking_utils.construct_watermark('CWE')
syn = w[:4]

# Construct watermarking system
wm_system = XsWMSystem()  # init with default values

# Mark the samples
marked_samples, bin_pairs = wm_system.embed_watermark(samples, w, key=1234)
output_file = output_file[0:len(input_file) - 4] + '_marked.wav'
sf.write(output_file, marked_samples, samplerate)

# Read marked and encrypted audio file and decrypt it
samples, samplerate = sf.read(output_file, dtype=np.int16)
samples = catmap_encryption.decrypt(samples, padding_length, a, b, n)
output_file = path.join(
    out_dir, input_file[0:len(input_file) - 4] + '_decrypted' + '_marked.wav')
コード例 #3
0
Demonstrates the minimum knowledge verification protocol procedure presented
in the associated thesis. Bob can verify the presence of Alice watermark,
which was embedded via the acquired histogram-based watermarking scheme for
audio data.

Note, this demo is meant to be simple and straightforward. For the
sake of brewity and clarity a short watermark and a very short
signal was chosen. Normally the watermark should have a length of at least
approximately 1000 bits, so that the GI-problem becomes hard to solve.
Refer to the iPython notebook 'minimum_knowledge_verification_demo'
('../notebooks/minimum_knowledge_verification_demo.ipynb') for a more
sophisticated example.
"""

# Create the watermark
wmk = watermarking_utils.construct_watermark('HdM')

# Prepare media object...
samples, samplerate = sf.read(
    '../../res/testing/original_test_files/misc/440_sine.wav', dtype=np.int16)
samples = samples[:, 0]

# ...and watermarking parameters
num_bins = len(wmk) * 10
la = 2.5
threshold = 5
seed = 63

# Create the prover
tau = LogMapKey(3.57567, 0.8, 102)
p = Prover(tau, len(wmk))
コード例 #4
0
__author__ = 'gru'
from core.audio_cwe import watermarking_utils
import soundfile as sf
import numpy as np

b1 = watermarking_utils.construct_watermark(['T', 'E'])
b2 = watermarking_utils.construct_watermark(['T', 'e'])

#print(watermarking_utils.calc_bit_error_rate(b1,b2))
watermarking_utils.compare_watermarks(b1, b2)

b1 = watermarking_utils.construct_watermark('T')
b2 = watermarking_utils.construct_watermark('t')
#print(watermarking_utils.calc_bit_error_rate(b1,b2))
watermarking_utils.compare_watermarks(b1, b2)