diff options
author | fabioviecelli <80270098+fabioviecelli@users.noreply.github.com> | 2021-09-08 09:23:56 +0200 |
---|---|---|
committer | fabioviecelli <80270098+fabioviecelli@users.noreply.github.com> | 2021-09-08 09:23:56 +0200 |
commit | 910a4f556d89d75ee07384a2a3fb963334552264 (patch) | |
tree | 53f346e2de59d4bf1365535b709f0a2e8ebffba1 /buch/papers/mceliece/example_code | |
parent | Ergänzungen (diff) | |
parent | editorial edits clifford (diff) | |
download | SeminarMatrizen-910a4f556d89d75ee07384a2a3fb963334552264.tar.gz SeminarMatrizen-910a4f556d89d75ee07384a2a3fb963334552264.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'buch/papers/mceliece/example_code')
-rw-r--r-- | buch/papers/mceliece/example_code/mceliece_simple.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/buch/papers/mceliece/example_code/mceliece_simple.py b/buch/papers/mceliece/example_code/mceliece_simple.py index bac3b42..c8d5e9d 100644 --- a/buch/papers/mceliece/example_code/mceliece_simple.py +++ b/buch/papers/mceliece/example_code/mceliece_simple.py @@ -187,14 +187,10 @@ def decode_linear_code(c, g, syndrome_table): q, r=divmod(Poly(c), g) q=np.r_[q.coef%2, np.zeros(len(c)-len(q)-len(g)+1)] r=np.r_[r.coef%2, np.zeros(len(g)-len(r))] - syndrome_index=np.sum([int(a*2**i) for i, a in enumerate(r)]) - while syndrome_index > 0: - c=c ^ syndrome_table[syndrome_index] - q, r=divmod(Poly(c), g) - q=np.r_[q.coef%2, np.zeros(len(c)-len(q)-len(g)+1)] - r=np.r_[r.coef%2, np.zeros(len(g)-len(r))] - syndrome_index=np.sum([int(a*2**i) for i, a in enumerate(r)]) - return np.array(q, dtype=int) + syndrome_index=np.sum([int(a*2**i) for i, a in enumerate(r)]) #binary to decimal + q_corr, r_corr=divmod(Poly(syndrome_table[syndrome_index]), g) + q_corr=np.r_[q_corr.coef%2, np.zeros(len(c)-len(q_corr)-len(g)+1)] + return q.astype(int) ^ q_corr.astype(int) def encode_linear_code(d, G): ''' @@ -324,4 +320,4 @@ if __name__ == '__main__': print(f'msg_rx: {msg_rx}') -
\ No newline at end of file + |