Information Security-4: knapsack Algorithm for public key cryptography [original]

Source: Internet
Author: User

Forwarding Annotated Source: http://www.cnblogs.com/0zcl/p/6111686.html

Objective

Originally I want to learn RSA algorithm, but found too difficult, not I can understand, so I first look at the backpack algorithm in front of the textbook. Not surprisingly, the next blog will introduce the RSA algorithm!

Backpack Problem Description:

Given some objects, each object has a different weight, is it possible to put these objects into a backpack, so that the weight of the backpack is equal to a given value.

    • The knapsack algorithm is the first public key encryption algorithm to be generalized.
    • Although this algorithm was later found to be unsafe, it is still worth studying because it shows how to use NP-complete problems with public key algorithms (well, I don't know what that means ~).

Example:

The weight of these objects is 1,5,6,11,14,20, then the heavy 5,6,11 object can be placed into a heavy 22 backpack. But it doesn't fit into a backpack that weighs 24.

    • Knapsack problem: equals a given value.
    • Solution for the case of the choice goods loading, loaded with 1, not loaded with 0. The solution for the given value 22 is {0,1,1,1,0,0} in the example
    • The time required for this problem increases exponentially with the number of objects.

Basic principle

This algorithm I do not program, the test month, time is tense, and so I have time to come back to do ~

First, the knapsack algorithm is used for information security (cryptography), we have to figure out what is clear text, ciphertext, key bar?!

Example:

PlainText: 1 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 0

Key: 1 5 6 11 14 20 1 5 6 11 14 20 1 5 6 11 14 20

Ciphertext: 1+5+6+20=32 5+11+14=30 5+6=11

From the above can be summed up:

    • Clear text for the loading of the article, is a sequence of 1/0, and the length of the plaintext is equal to the number of objects, indicating that the object is loaded into the backpack
    • The ciphertext is the quality of the selected object and
    • Key is the item weight sequence in knapsack problem

The algorithm security is embodied as:

If the attacker obtains ciphertext and keys, it is not possible to seek clear text in linear time (item loading)

The key to the algorithm

The key to the algorithm is that there are two different pack weight sequences, which are the same for a given value of two weight sequences (the same as the loading of an item)

The weight list of the former items is incremented, while the latter is unordered

The former can be decrypted, see below ~ ~

1. Build an ascending sequence backpack

Easy-to-solve knapsack problem: If the item's weight list is a super-increment sequence, then the knapsack problem is easy to solve.

For example, increment sequence: 1 3 6 13 27 52

Example:

    • Non-incremental backpack is a difficult problem
    • The knapsack algorithm first finds the weight sequence of an ascending backpack as the private key, and then constructs a sequence (a sequence of common knapsack problems with the same solution) as the public key (important!).

How to construct a public key?

2. Construct the public key from the private key

After the above calculation, the sequence is: {62 93 81 88 102 37} as the public key

3. Encryption

4. Decryption

Decryption here I have a problem: how to find n-1, that is, how to find n on the inverse of modulo m?? (Note: Here must understand, otherwise the next blog RSA algorithm will certainly not understand!)

I found a lot of Baidu, but also looked at the blog, such as http://blog.sina.com.cn/s/blog_65a5cf5e0100nyqo.html, but I do not understand AH!! Finally, I found a way that I could read. Inverse element method for solving the >! of inversion < The inverse element of the method of solving the Euclidean modulus (has been programmed to achieve), the next blog will be issued ~ ~

In order to facilitate my finishing, I put the process of the inverse meta-related, we can also click the link to see ~ ending~

......

Information Security-4: knapsack Algorithm for public key cryptography [original]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.