Révision 91 pobysoPythonSage/src/sageSLZ/sageSLZ.sage
| sageSLZ.sage (revision 91) | ||
|---|---|---|
| 356 | 356 |
|
| 357 | 357 |
:returns: a 4 elements tuple: |
| 358 | 358 |
- the polynomial; |
| 359 |
- the module (N); |
|
| 359 |
- the modulus (N); |
|
| 360 |
- the t bound; |
|
| 360 | 361 |
- the lcm used to compute the integral coefficients and the |
| 361 | 362 |
module. |
| 362 | 363 |
""" |
| ... | ... | |
| 364 | 365 |
IP = PolynomialRing(ZZ, name=str(variable1) + "," + str(variable2)) |
| 365 | 366 |
# Coefficients are issued in the increasing power order. |
| 366 | 367 |
ratPolyCoefficients = ratPolyOfInt.coefficients() |
| 368 |
# Print the reversed list for debugging. |
|
| 369 |
print ratPolyCoefficients[::-1] |
|
| 367 | 370 |
# Build the list of number we compute the lcmm of. |
| 368 | 371 |
coefficientDenominators = sro_denominators(ratPolyCoefficients) |
| 369 | 372 |
coefficientDenominators.append(2^precision) |
| ... | ... | |
| 371 | 374 |
leastCommonMultiple = lcm(coefficientDenominators) |
| 372 | 375 |
# Compute the expression corresponding to the new polynomial |
| 373 | 376 |
coefficientNumerators = sro_numerators(ratPolyCoefficients) |
| 374 |
print coefficientNumerators |
|
| 377 |
#print coefficientNumerators
|
|
| 375 | 378 |
polynomialExpression = 0 |
| 376 | 379 |
power = 0 |
| 377 | 380 |
# Iterate over two lists at the same time, stop when the shorter is |
| ... | ... | |
| 385 | 388 |
polynomialExpression += - variable2 |
| 386 | 389 |
return (IP(polynomialExpression), |
| 387 | 390 |
leastCommonMultiple / 2^precision, # 2^K or N. |
| 388 |
leastCommonMultiple / 2 ^(targetHardnessToRound + 1), # tBound
|
|
| 389 |
leastCommonMultiple) |
|
| 391 |
leastCommonMultiple / 2^(targetHardnessToRound + 1), # tBound |
|
| 392 |
leastCommonMultiple) # If we want to make test computations.
|
|
| 390 | 393 |
|
| 391 | 394 |
# End slz_ratPoly_of_int_to_poly_for_coppersmith |
| 392 | 395 |
|
| ... | ... | |
| 401 | 404 |
respectively, the "right" power. |
| 402 | 405 |
""" |
| 403 | 406 |
polynomialField = ratPolyOfRat.parent() |
| 404 |
polynomialVariable = rationalPolynomial.variables()[0]
|
|
| 405 |
print "The polynomial field is:", polynomialField |
|
| 407 |
polynomialVariable = ratPolyOfRat.variables()[0]
|
|
| 408 |
#print "The polynomial field is:", polynomialField
|
|
| 406 | 409 |
return \ |
| 407 |
polynomialField(rationalPolynomial.subs({polynomialVariable : \
|
|
| 410 |
polynomialField(ratPolyOfRat.subs({polynomialVariable : \
|
|
| 408 | 411 |
polynomialVariable/2^(precision-1)})) |
| 409 | 412 |
|
| 410 | 413 |
# Return a tuple: |
Formats disponibles : Unified diff