Hi Sage Support,

I tested the Sbox function S.interpolation_polynomial() on the AES S-box, 
and got a polynomial that I wasn't expecting. I was expecting the AES S-box 
polynomial: 0x5*(x^254) + 0x9*(x^253) + 0xf9*(x^251) + 0x25*(x^247) + 
0xf4*(x^239) + (x^223) + 0xb5*(x^191) + 0x8f*(x^127) + 0x63, which only has 
9 terms. But I got an almost fully termed polynomial from S.
interpolation_polynomial().

I am not sure if I misinterpret the function of S.interpolation_polynomial() 
or anything...

I also tried the function R.lagrange_polynomial(*) on the data points and 
got the same polynomial as S.interpolation_polynomial(). But this 
polynomial is not what I expect it to be...

Please help, or enlighten me if I had misconception about these 2 functions.

Thank you!!

*My code for S.interpolation_polynomial():*

S = mq.SBox([
  0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 
0xfe, 0xd7, 0xab, 0x76,
  0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 
0x9c, 0xa4, 0x72, 0xc0,
  0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 
0x71, 0xd8, 0x31, 0x15,
  0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 
0xeb, 0x27, 0xb2, 0x75,
  0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 
0x29, 0xe3, 0x2f, 0x84,
  0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 
0x4a, 0x4c, 0x58, 0xcf,
  0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 
0x50, 0x3c, 0x9f, 0xa8,
  0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 
0x10, 0xff, 0xf3, 0xd2,
  0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 
0x64, 0x5d, 0x19, 0x73,
  0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 
0xde, 0x5e, 0x0b, 0xdb,
  0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 
0x91, 0x95, 0xe4, 0x79,
  0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 
0x65, 0x7a, 0xae, 0x08,
  0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 
0x4b, 0xbd, 0x8b, 0x8a,
  0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 
0x86, 0xc1, 0x1d, 0x9e,
  0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 
0xce, 0x55, 0x28, 0xdf,
  0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 
0xb0, 0x54, 0xbb, 0x16])

Sintp = S.interpolation_polynomial()
print "S.intp = ", Sintp


*Result:*

S.intp =  (a + 1)*x^254 + (a^6 + a^5 + a^2)*x^253 + (a^7 + a^6 + a^5 + a)*x^252 
+ (a^7 + a^5 + a^3 + a + 1)*x^251 + (a^7 + a^6 + a^5 + a^3 + a)*x^250 + (a^7 + 
a^2 + 1)*x^249 + (a^4 + a^3 + a^2 + 1)*x^248 + (a^7 + a^6 + a^5 + a)*x^247 + 
(a^4 + 1)*x^246 + (a^7 + a^6 + a^5 + a^4 + a^3)*x^245 + (a^5 + 1)*x^244 + (a^7 
+ a^6 + a^5 + a^4 + a + 1)*x^243 + (a^7 + a^5 + a^3 + a^2 + a + 1)*x^242 + (a^7 
+ a^6 + a^4)*x^241 + (a^6 + a^5 + a^4 + a^3 + a^2 + a)*x^240 + (a^6 + a^4 + a^3 
+ 1)*x^239 + (a^7 + a^6 + a^4 + a^3 + a^2 + a)*x^238 + (a^7 + a^6 + a^3 + 
a)*x^237 + (a^7 + a^6 + a^4 + a + 1)*x^236 + (a^4 + a^3 + a + 1)*x^235 + (a^7 + 
a^4 + a^2 + a)*x^234 + (a^7 + a^6 + a^5 + a^4)*x^233 + (a^7 + a^6)*x^232 + (a^7 
+ a^6 + a^4 + a^3 + a)*x^231 + (a^7 + a^6 + a^5 + a^3 + a^2 + 1)*x^230 + (a^7 + 
a^6 + a^5 + a^4 + a^2 + a)*x^229 + (a^6 + a^5 + a)*x^228 + (a^7 + a^6 + a^5 + 
a^3)*x^227 + (a^7 + a^6 + a)*x^226 + (a^5 + a^3 + a^2)*x^225 + (a^7 + a^6 + a^5 
+ a^3 + a^2 + 1)*x^224 + (a^7 + a^5 + a^3 + a)*x^223 + (a^5 + a^3)*x^222 + (a^7 
+ a^6 + a^3 + a + 1)*x^221 + (a^5 + a^4 + a + 1)*x^220 + (a^5 + a^4 + 
a^2)*x^219 + (a^6 + a^3 + a^2)*x^218 + (a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^217 
+ (a^7 + a^5 + a^2 + 1)*x^216 + (a^7 + a^6 + a^4 + a^3 + 1)*x^215 + (a^6 + a^4 
+ a^3)*x^214 + (a^7 + a^6 + a^5 + a^4 + a^2)*x^213 + (a^6 + a^4 + a + 1)*x^212 
+ (a^5 + a)*x^211 + (a^5 + a^4)*x^210 + (a^7 + a^6 + a^5 + a^2 + a + 1)*x^209 + 
(a^7 + a^6 + a^5 + a^3)*x^208 + (a^5 + a^4 + a^3 + a^2 + a + 1)*x^207 + (a^5 + 
a^4 + a^3 + a^2 + a)*x^206 + (a^6 + a^5 + a^4 + a^3 + 1)*x^205 + (a^7 + a^4 + 
a^3 + 1)*x^204 + (a^5 + a^3 + a)*x^203 + (a^7 + a^4 + a^3 + a)*x^202 + (a^6 + 
a^5 + a^3)*x^201 + (a^7 + a^3 + a^2 + a + 1)*x^200 + (a^5 + a + 1)*x^199 + (a^7 
+ a^6 + a^5)*x^198 + (a^7 + a^4 + a^3 + a^2 + a + 1)*x^197 + (a^7 + a^6 + a^5 + 
a^4 + a^3 + a^2 + a)*x^196 + (a^5 + a^3)*x^195 + (a^6 + a^5 + a^4 + a^3 + 
a)*x^194 + (a^6 + a^2 + a)*x^193 + (a^6 + a^3 + a + 1)*x^192 + (a^4 + 1)*x^191 
+ (a^4 + a + 1)*x^190 + (a^7 + a^3 + a^2 + a)*x^189 + (a^6 + a^5 + a^4 + a^3 + 
a^2 + a + 1)*x^188 + (a^7 + a^6 + a^5 + a^2 + a)*x^187 + (a^6 + a^5 + a^3 + 
a)*x^186 + (a^5 + a^4 + a^2 + 1)*x^185 + a^7*x^184 + (a^6 + a^5 + a^4 + a^3 + 
a^2 + 1)*x^183 + (a^7 + a^6 + a^5 + a^3)*x^182 + (a^7 + a^6 + a^4 + a^2)*x^181 
+ (a^7 + a^3 + a^2 + a + 1)*x^180 + (a^7 + a^2 + a)*x^179 + a^7*x^178 + (a^7 + 
a^6 + a^4 + a^3 + a + 1)*x^177 + (a^6 + a^5 + a^3 + a^2 + a + 1)*x^176 + (a^7 + 
a^6 + a^5 + a^3 + a^2 + a + 1)*x^175 + (a^3 + 1)*x^174 + (a^7 + a^6 + a^3 + a^2 
+ 1)*x^173 + a^6*x^172 + (a^7 + a^4 + 1)*x^171 + a^2*x^169 + (a^7 + 1)*x^168 + 
(a^7 + a^4 + a^2 + a)*x^167 + a*x^166 + (a^7 + a^4 + a)*x^165 + (a^5 + a^3 + 
a)*x^164 + (a^6 + a^4 + a + 1)*x^163 + (a^7 + a^5 + 1)*x^162 + (a^7 + a^6 + a^4 
+ 1)*x^161 + (a^6 + a^5 + a^2 + a + 1)*x^160 + (a^6 + a^5 + a^3 + a)*x^159 + 
(a^6 + a^4 + a^2)*x^158 + (a^7 + a^4)*x^157 + (a^5 + 1)*x^156 + (a^7 + a^5 + 
a^3 + a^2 + a + 1)*x^155 + (a^7 + a^5 + a^3)*x^154 + (a^7 + a^5 + a^4 + 
a^3)*x^153 + (a^7 + a^6 + a^5 + a)*x^152 + (a^4 + a^3 + a)*x^151 + (a^6 + a^4 + 
a^2 + 1)*x^150 + (a^3 + a)*x^149 + (a^5 + a^4 + a^3 + a)*x^148 + (a^7 + a^6 + 
a^5 + a^4 + a^3 + a^2 + a)*x^147 + (a^7 + a^5 + a^3 + a)*x^146 + x^145 + (a^6 + 
a^5 + a^4 + a^3 + a^2)*x^144 + a*x^143 + (a^7 + a^6 + a^3 + a^2 + 1)*x^142 + 
(a^7 + a^6 + a^4 + a^2 + a + 1)*x^141 + (a^7 + a^5 + a^4 + a^3 + a + 1)*x^140 + 
(a^6 + a^5 + a^3)*x^139 + (a^6 + a^5 + a^4 + a^2 + a + 1)*x^138 + (a^5 + a^4 + 
a^3 + a)*x^137 + (a^7 + a^6 + a^2 + 1)*x^136 + (a^5 + a^4 + a^3 + 1)*x^135 + 
(a^7 + a^4 + a^2)*x^134 + (a^7 + a^6 + a^4 + a^3 + a^2 + a)*x^133 + (a^6 + 
a)*x^132 + (a^5 + a^4 + a^3 + a^2 + 1)*x^131 + (a^5 + a^2 + a)*x^130 + (a^7 + 
a^6 + a^5 + a^4 + a^2 + a + 1)*x^129 + (a^6 + a^5 + a^4 + a^3)*x^128 + (a^7 + 
a^6 + a^4 + a^3 + a + 1)*x^127 + (a^4 + a^2 + a + 1)*x^126 + (a^7 + a^2 + 
1)*x^125 + (a^6 + 1)*x^124 + (a^7 + a^5 + a^3 + 1)*x^123 + (a^7 + a^6 + 
a)*x^122 + (a^7 + a^5 + a^3 + a^2 + 1)*x^121 + (a^7 + a^5 + a^4 + a^3 + a^2 + 
a)*x^120 + (a^7 + a^6 + a^4)*x^119 + (a^5 + a^4 + a^3 + a)*x^118 + (a^6 + a^5 + 
a^3 + a^2 + 1)*x^117 + (a^5 + a^4 + a^2 + 1)*x^116 + (a^7 + a^5 + a^3 + 
a^2)*x^115 + (a^6 + a^5 + a^4 + a^2 + a)*x^114 + (a^6 + a^5 + a^4 + a^2 + a + 
1)*x^113 + (a^7 + a^6 + a^3 + a^2 + a + 1)*x^112 + (a^5 + a^4 + a^2 + a + 
1)*x^111 + (a^7 + a^6 + a^4 + a^3 + a)*x^110 + (a^6 + a^5 + a^4 + 1)*x^109 + 
(a^5 + a^4 + a^3 + a^2 + a + 1)*x^108 + (a^7 + a^6 + a^5 + a^4 + a + 1)*x^107 + 
(a^6 + a^5 + a^2 + a)*x^106 + (a^7 + a^6 + a^4)*x^105 + (a^7 + a^5 + a^3)*x^104 
+ (a^7 + a^3 + 1)*x^103 + (a^4 + a)*x^102 + (a^7 + a^6 + a^5 + a^3 + 1)*x^101 + 
(a^5 + a^4 + a^3)*x^100 + (a^7 + a^6 + a^5 + a^4 + a + 1)*x^99 + (a^7 + a^5 + 
a^3 + a^2 + a)*x^98 + (a^6 + a^5 + a^3 + a^2 + 1)*x^97 + (a^4 + a^3 + a + 
1)*x^96 + (a^4 + a^3 + a + 1)*x^95 + (a^7 + a^6 + a^5 + a^4 + a^3 + a)*x^94 + 
(a^6 + a^5 + a^2 + a)*x^93 + (a^6 + a^5 + a^4 + a + 1)*x^92 + (a^7 + a^6 + a^5 
+ a)*x^91 + (a^6 + a^4 + a^3 + 1)*x^90 + (a^7 + a^6 + 1)*x^89 + (a^7 + a^6 + 
a^5 + a^4 + a^2 + a)*x^88 + (a^7 + a)*x^87 + (a^6 + a^5 + a^4 + a^3 + a^2 + 
a)*x^86 + (a^7 + a^5 + a^3 + a^2 + 1)*x^85 + (a^7 + a^2 + a + 1)*x^84 + (a^7 + 
a^5 + a^4 + a)*x^83 + (a^6 + 1)*x^82 + x^81 + (a^7 + a^3 + a^2 + 1)*x^80 + (a^7 
+ a^6 + a^4 + a^2 + 1)*x^79 + (a^7 + a^5 + a^2)*x^78 + (a^5 + a^3 + a^2)*x^77 + 
(a^7 + a^6 + a^5 + a^4 + a^3 + 1)*x^76 + (a^7 + a^6 + a^4 + a^3 + 1)*x^75 + 
(a^7 + a^6 + a^2 + 1)*x^74 + (a^6 + a^2 + 1)*x^73 + (a^7 + a^4 + a^2)*x^72 + 
(a^6 + a^3 + a^2 + a)*x^71 + (a^7 + a^6 + a^3 + a)*x^70 + (a^7 + a^5 + a^4 + 
a^3 + a)*x^69 + (a^5 + a^3 + a + 1)*x^68 + (a^5 + a + 1)*x^67 + (a^2 + a)*x^66 
+ (a^6 + a^5 + a^3 + 1)*x^65 + (a^7 + a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^64 + 
(a^6 + a^4 + a + 1)*x^63 + (a^5 + a^2 + 1)*x^62 + (a^6 + a^5 + a^4 + a^2)*x^61 
+ (a^4 + a^3)*x^60 + (a^6 + a^3 + a^2 + a + 1)*x^59 + (a^7 + a^4 + a^3 + a^2 + 
a + 1)*x^58 + (a^7 + a^6 + a^5 + a^2 + a + 1)*x^57 + (a^5 + a^4 + a^3 + 
a^2)*x^56 + (a^3 + 1)*x^55 + (a^7 + a^6 + a^5 + a^4 + a^3)*x^54 + (a^7 + a^4 + 
a + 1)*x^53 + (a^7 + a^6 + a^5 + a^2 + a + 1)*x^52 + (a^6 + a^4 + a + 1)*x^51 + 
(a^7 + a^6 + a^5 + a^4 + a^3 + a)*x^50 + (a^7 + a^6 + a^5 + a^3 + a^2 + a + 
1)*x^49 + (a^7 + a^6 + a^4 + a^2)*x^48 + (a^7 + a^6 + a^5 + a^4 + a^3 + 1)*x^47 
+ (a^5 + a^3 + a^2 + 1)*x^46 + (a^5 + a^3 + a)*x^45 + (a^7 + a^3)*x^44 + (a^6 + 
a^5 + a^4 + a^3 + a + 1)*x^43 + (a^7 + a^6 + a^5 + a^4 + a^2)*x^41 + (a^6 + a^5 
+ a^3 + 1)*x^40 + (a^6 + a^5 + a^3 + a^2 + 1)*x^39 + (a^7 + a^5 + a^3 + a^2 + 
1)*x^38 + (a^4 + a^3 + a^2 + a)*x^37 + (a^7 + a^6 + a^3 + a + 1)*x^36 + (a^7 + 
a^6 + a^5 + a)*x^35 + (a^7 + a^5 + a^3)*x^34 + (a^7 + a^6 + a^4 + a^3 + a)*x^33 
+ (a^7 + a^6 + a^5 + a^4 + a^3 + a^2)*x^32 + (a^6 + a^3 + a^2 + a)*x^31 + (a^7 
+ a^6 + a^4 + a^3 + a^2 + 1)*x^30 + (a^6 + a^5 + a^2 + a)*x^29 + (a^6 + a^5 + 
a^4 + a^3 + a^2 + a)*x^28 + (a^5 + a^3 + a^2)*x^27 + (a^5 + a^4 + a^3 + a + 
1)*x^26 + (a^7 + a^3)*x^25 + (a^7 + a^4 + a^2 + 1)*x^24 + (a^3 + a^2 + 1)*x^23 
+ (a^7 + a^6 + a)*x^22 + (a^6 + a^2 + 1)*x^21 + (a^7 + a^3 + 1)*x^20 + (a^4 + 
1)*x^19 + (a^7 + a^4 + a^3 + 1)*x^18 + (a^7 + a^6 + a^5 + a^2 + a + 1)*x^17 + 
(a^5 + a^3 + 1)*x^16 + (a^5 + a^4 + a + 1)*x^15 + (a^7 + a^5 + a^4 + a^3 + a^2 
+ 1)*x^14 + (a^5 + a^3 + a^2 + a)*x^13 + (a^5 + a^3 + a^2)*x^12 + (a^7 + a^5 + 
a^3 + a)*x^11 + (a^5 + a^4 + a^3 + a)*x^10 + (a^4 + a^3 + a^2 + a + 1)*x^9 + 
(a^6 + a^5 + a^4)*x^8 + (a^7 + a^5 + a^4 + a^2 + a)*x^7 + (a^5 + a^4 + a^3 + 
a^2 + 1)*x^6 + (a^7 + a^4 + 1)*x^5 + (a^6 + a^5 + a^3 + a^2)*x^4 + (a^6 + a^4 + 
a^3 + a^2)*x^3 + (a^6 + a^5)*x^2 + (a^4 + a^3)*x + a^6 + a^5 + a + 1



-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to