From d097942631b48e4291f8af5bd0102a72e82c59d8 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 26 Jun 2024 16:23:23 -0700 Subject: [PATCH 1/2] Remove recursive prompt The python config script `interactive_prompt_input` functions recursed on error, requiring a balanced number of `0` entries to exit cleanly. This is unnecessary, since the prompt body itself already loops and can just fall through to the next iteration to reprompt after an error. Remove the recursive call so entering zero to finish scheme selection exits promptly. --- arduino/config.py | 1 - c/config16.py | 1 - c/config32.py | 1 - c/config64.py | 1 - cpp/config16.py | 1 - cpp/config32.py | 1 - cpp/config64.py | 1 - go/config32.py | 1 - go/config64.py | 1 - java/config32.py | 1 - java/config64.py | 1 - rust/config32.py | 2 +- rust/config64.py | 2 +- swift/config32.py | 2 +- swift/config64.py | 2 +- wasm/config32.py | 2 +- wasm/config64.py | 2 +- 17 files changed, 6 insertions(+), 17 deletions(-) diff --git a/arduino/config.py b/arduino/config.py index b389b6c..26d14fa 100755 --- a/arduino/config.py +++ b/arduino/config.py @@ -836,7 +836,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() diff --git a/c/config16.py b/c/config16.py index 11d06dc..c37b298 100755 --- a/c/config16.py +++ b/c/config16.py @@ -636,7 +636,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() while keep_querying and not testing: diff --git a/c/config32.py b/c/config32.py index 2a5150f..a8c6f52 100755 --- a/c/config32.py +++ b/c/config32.py @@ -871,7 +871,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() while keep_querying and not testing: diff --git a/c/config64.py b/c/config64.py index 2fc157c..b8f8eab 100755 --- a/c/config64.py +++ b/c/config64.py @@ -908,7 +908,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() def usage(): print("Usage: ./config64.py [OPTIONS] [ARGUMENTS]\n") diff --git a/cpp/config16.py b/cpp/config16.py index 94f2564..4c5def1 100755 --- a/cpp/config16.py +++ b/cpp/config16.py @@ -636,7 +636,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() while keep_querying and not testing: diff --git a/cpp/config32.py b/cpp/config32.py index 38e83a1..eebd9bb 100755 --- a/cpp/config32.py +++ b/cpp/config32.py @@ -872,7 +872,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() while keep_querying and not testing: diff --git a/cpp/config64.py b/cpp/config64.py index b25021b..ec3dfbb 100755 --- a/cpp/config64.py +++ b/cpp/config64.py @@ -909,7 +909,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() def usage(): print("Usage: ./config64.py [OPTIONS] [ARGUMENTS]\n") diff --git a/go/config32.py b/go/config32.py index aac72c1..b0f4f66 100755 --- a/go/config32.py +++ b/go/config32.py @@ -408,7 +408,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() diff --git a/go/config64.py b/go/config64.py index 4fd41e1..e0240f7 100755 --- a/go/config64.py +++ b/go/config64.py @@ -407,7 +407,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() diff --git a/java/config32.py b/java/config32.py index 36dbe94..2bd0abb 100755 --- a/java/config32.py +++ b/java/config32.py @@ -449,7 +449,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() diff --git a/java/config64.py b/java/config64.py index aef0e00..438b38e 100755 --- a/java/config64.py +++ b/java/config64.py @@ -446,7 +446,6 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() interactive_prompt_print() diff --git a/rust/config32.py b/rust/config32.py index 58f1410..1c35b37 100755 --- a/rust/config32.py +++ b/rust/config32.py @@ -384,7 +384,7 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() + if __name__ == '__main__': copytext="cp " diff --git a/rust/config64.py b/rust/config64.py index 58e46a1..66ece89 100755 --- a/rust/config64.py +++ b/rust/config64.py @@ -388,7 +388,7 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() + if __name__ == '__main__': copytext="cp " diff --git a/swift/config32.py b/swift/config32.py index 9048445..0081b20 100755 --- a/swift/config32.py +++ b/swift/config32.py @@ -377,7 +377,7 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() + interactive_prompt_print() while keep_querying and not testing: diff --git a/swift/config64.py b/swift/config64.py index 2bf0ccc..6cc70c3 100755 --- a/swift/config64.py +++ b/swift/config64.py @@ -375,7 +375,7 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() + interactive_prompt_print() while keep_querying and not testing: diff --git a/wasm/config32.py b/wasm/config32.py index 27cc433..7101b89 100755 --- a/wasm/config32.py +++ b/wasm/config32.py @@ -879,7 +879,7 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() + interactive_prompt_print() while keep_querying : diff --git a/wasm/config64.py b/wasm/config64.py index 1510641..5cb00a7 100755 --- a/wasm/config64.py +++ b/wasm/config64.py @@ -885,7 +885,7 @@ def interactive_prompt_input(): if (userInput == ''): return 0 print("Non-integer input, select values between 1 and " + str(miracl_crypto.total_entries)) - interactive_prompt_input() + interactive_prompt_print() while keep_querying : From 1a4dcda67b7b2b57b2c034f050c899e866ce07d9 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Thu, 27 Jun 2024 13:06:01 -0700 Subject: [PATCH 2/2] Remove trailing whitespace from python code Some code editors flag this, or automatically correct it. Addressing this in a single commit reduces confusion for readers and noise in making other changes. --- arduino/config.py | 4 ++-- c/config32.py | 2 +- c/config64.py | 18 +++++++++--------- cpp/config32.py | 2 +- go/config32.py | 6 +++--- go/config64.py | 4 ++-- java/config32.py | 4 ++-- java/config64.py | 6 +++--- python/big.py | 4 ++-- python/bls12381.py | 4 ++-- python/bls12443.py | 4 ++-- python/constants.py | 6 +++--- python/ecp2.py | 4 ++-- python/fp.py | 4 ++-- python/fp12.py | 6 +++--- python/fp2.py | 10 +++++----- python/fp4.py | 4 ++-- python/pair.py | 26 +++++++++++++------------- rust/config32.py | 4 ++-- rust/config64.py | 6 +++--- swift/config32.py | 4 ++-- swift/config64.py | 4 ++-- wasm/config32.py | 2 +- wasm/config64.py | 18 +++++++++--------- 24 files changed, 78 insertions(+), 78 deletions(-) diff --git a/arduino/config.py b/arduino/config.py index 26d14fa..b1fce2d 100755 --- a/arduino/config.py +++ b/arduino/config.py @@ -473,7 +473,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fnameh,"ZZZ",tc) replace(fnameh,"YYY",tf) replace(fnameh,"XXX",bd) - + fnamec="pair_"+tc+".cpp" fnameh="pair_"+tc+".h" @@ -650,7 +650,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_file("pair8.cpp", fnamec) copy_file("pair8.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) diff --git a/c/config32.py b/c/config32.py index a8c6f52..bf7ade6 100755 --- a/c/config32.py +++ b/c/config32.py @@ -712,7 +712,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("pair8.c", fnamec) copy_keep_file("pair8.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) diff --git a/c/config64.py b/c/config64.py index b8f8eab..bdc0c2d 100755 --- a/c/config64.py +++ b/c/config64.py @@ -515,7 +515,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp12.c", fnamec) copy_keep_file("fp12.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -557,7 +557,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("mpin.c", fnamec) copy_keep_file("mpin.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) @@ -586,7 +586,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp8.c", fnamec) copy_keep_file("fp8.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -657,7 +657,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("bls192.c", fnamec) copy_keep_file("bls192.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) @@ -673,7 +673,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp8.c", fnamec) copy_keep_file("fp8.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -703,7 +703,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp16.c", fnamec) copy_keep_file("fp16.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -718,7 +718,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp48.c", fnamec) copy_keep_file("fp48.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -733,7 +733,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("pair8.c", fnamec) copy_keep_file("pair8.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) @@ -761,7 +761,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("bls256.c", fnamec) copy_keep_file("bls256.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) diff --git a/cpp/config32.py b/cpp/config32.py index eebd9bb..24e1899 100755 --- a/cpp/config32.py +++ b/cpp/config32.py @@ -713,7 +713,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("pair8.cpp", fnamec) copy_keep_file("pair8.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) diff --git a/go/config32.py b/go/config32.py index b0f4f66..b2c5f5b 100755 --- a/go/config32.py +++ b/go/config32.py @@ -200,8 +200,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fpath+"CONFIG_CURVE.go","@AB@",ab) replace(fpath+"CONFIG_CURVE.go","@G2@",g2) - replace(fpath+"CONFIG_CURVE.go","@HC@",hc) - replace(fpath+"CONFIG_CURVE.go","@HC2@",hc2) + replace(fpath+"CONFIG_CURVE.go","@HC@",hc) + replace(fpath+"CONFIG_CURVE.go","@HC2@",hc2) if cs == "128" : replace(fpath+"CONFIG_CURVE.go","@HT@","32") @@ -327,7 +327,7 @@ class miracl_crypto: ("TWEEDLEDUM","29","255","33","1","NOT_SPECIAL","5","WEIERSTRASS","0","NOT","NOT","NOT","NOT","NOT","128"), ("TWEEDLEDEE","29","255","34","1","NOT_SPECIAL","5","WEIERSTRASS","0","NOT","NOT","NOT","NOT","NOT","128") ) - + pf_curves = ( ("BN254","28","254","1",["-1","-1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","D_TYPE","NEGATIVEX","71","66","128"), diff --git a/go/config64.py b/go/config64.py index e0240f7..d7fd5fe 100755 --- a/go/config64.py +++ b/go/config64.py @@ -201,8 +201,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fpath+"CONFIG_CURVE.go","@AB@",ab) replace(fpath+"CONFIG_CURVE.go","@G2@",g2) - replace(fpath+"CONFIG_CURVE.go","@HC@",hc) - replace(fpath+"CONFIG_CURVE.go","@HC2@",hc2) + replace(fpath+"CONFIG_CURVE.go","@HC@",hc) + replace(fpath+"CONFIG_CURVE.go","@HC2@",hc2) if cs == "128" : replace(fpath+"CONFIG_CURVE.go","@HT@","32") diff --git a/java/config32.py b/java/config32.py index 2bd0abb..af617e8 100755 --- a/java/config32.py +++ b/java/config32.py @@ -227,8 +227,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fpath+"CONFIG_CURVE.java","@AB@",ab) replace(fpath+"CONFIG_CURVE.java","@G2@",g2) - replace(fpath+"CONFIG_CURVE.java","@HC@",hc) - replace(fpath+"CONFIG_CURVE.java","@HC2@",hc2) + replace(fpath+"CONFIG_CURVE.java","@HC@",hc) + replace(fpath+"CONFIG_CURVE.java","@HC2@",hc2) if cs == "128" : replace(fpath+"CONFIG_CURVE.java","@HT@","32") diff --git a/java/config64.py b/java/config64.py index 438b38e..fc3213f 100755 --- a/java/config64.py +++ b/java/config64.py @@ -227,8 +227,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fpath+"CONFIG_CURVE.java","@AB@",ab) replace(fpath+"CONFIG_CURVE.java","@G2@",g2) - replace(fpath+"CONFIG_CURVE.java","@HC@",hc) - replace(fpath+"CONFIG_CURVE.java","@HC2@",hc2) + replace(fpath+"CONFIG_CURVE.java","@HC@",hc) + replace(fpath+"CONFIG_CURVE.java","@HC2@",hc2) if cs == "128" : replace(fpath+"CONFIG_CURVE.java","@HT@","32") @@ -372,7 +372,7 @@ class miracl_crypto: ("BN254","56","254","1",["-1","-1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","D_TYPE","NEGATIVEX","71","66","128"), ("BN254CX","56","254","1",["-1","-1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","D_TYPE","NEGATIVEX","76","66","128"), ("BLS12383","58","383","1",["1","1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BLS12","M_TYPE","POSITIVEX","68","65","128"), - ("BLS12381","58","381","1",["11","-2","-1","11","3"],"NOT_SPECIAL","0","WEIERSTRASS","0","BLS12","M_TYPE","NEGATIVEX","69","65","128"), + ("BLS12381","58","381","1",["11","-2","-1","11","3"],"NOT_SPECIAL","0","WEIERSTRASS","0","BLS12","M_TYPE","NEGATIVEX","69","65","128"), ("FP256BN","56","256","1",["1","1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","M_TYPE","NEGATIVEX","83","66","128"), ("FP512BN","60","512","1",["1","1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","M_TYPE","POSITIVEX","172","130","128"), ("BLS12443","60","443","1",["-7","1","1","11","3"],"NOT_SPECIAL","0","WEIERSTRASS","0","BLS12","M_TYPE","POSITIVEX","78","75","128"), diff --git a/python/big.py b/python/big.py index d228598..5dcc7ef 100755 --- a/python/big.py +++ b/python/big.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # Number Theoretic functions diff --git a/python/bls12381.py b/python/bls12381.py index 760cbd1..51c0aa2 100755 --- a/python/bls12381.py +++ b/python/bls12381.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # BLS12381 curve constants diff --git a/python/bls12443.py b/python/bls12443.py index 94780c6..c34663e 100755 --- a/python/bls12443.py +++ b/python/bls12443.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # BLS12443 curve constants diff --git a/python/constants.py b/python/constants.py index 8b3f243..05e5cc4 100755 --- a/python/constants.py +++ b/python/constants.py @@ -41,15 +41,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # fixed constants -__all__ = ['WEIERSTRASS', 'EDWARDS', 'MONTGOMERY','D_TYPE','M_TYPE','NEGATIVEX','POSITIVEX','BN','BLS','ECDH_INVALID_PUBLIC_KEY','ECDH_ERROR'] +__all__ = ['WEIERSTRASS', 'EDWARDS', 'MONTGOMERY','D_TYPE','M_TYPE','NEGATIVEX','POSITIVEX','BN','BLS','ECDH_INVALID_PUBLIC_KEY','ECDH_ERROR'] WEIERSTRASS = 0 EDWARDS = 1 diff --git a/python/ecp2.py b/python/ecp2.py index d7d162f..2ea1c16 100755 --- a/python/ecp2.py +++ b/python/ecp2.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # Elliptic Curve Points over Fp^2 diff --git a/python/fp.py b/python/fp.py index c1943b5..8928edc 100755 --- a/python/fp.py +++ b/python/fp.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # bigs modulo n diff --git a/python/fp12.py b/python/fp12.py index 53ab952..7c3973f 100755 --- a/python/fp12.py +++ b/python/fp12.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # Fp^12 CLass - towered over Fp^4 @@ -250,7 +250,7 @@ def smul(self,other) : tb=other.a.a+other.a.b tc=ta*tb tc-=(w1+w2) - + ta=self.a.a+self.c.b tb=other.a.a+other.c.b td=ta*tb diff --git a/python/fp2.py b/python/fp2.py index 3a1cdc9..41fb6bf 100755 --- a/python/fp2.py +++ b/python/fp2.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # Fp^2 CLass @@ -207,13 +207,13 @@ def pow(self, other): while True : bt=z&1 z >>= 1 - if bt == 1: + if bt == 1: r *= w if z == 0 : break w.sqr() return r.copy() - + def qr(self): w=self.conj() w *= self @@ -237,7 +237,7 @@ def sqrt(self): self.a = w2.copy() w2 += w2 w2 = w2.inverse() - self.b *= w2 + self.b *= w2 diff --git a/python/fp4.py b/python/fp4.py index b0c8ec3..6c168b5 100755 --- a/python/fp4.py +++ b/python/fp4.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # Fp^4 CLass - towered over Fp^2 diff --git a/python/pair.py b/python/pair.py index d4db3b0..f778b48 100755 --- a/python/pair.py +++ b/python/pair.py @@ -41,11 +41,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# You can be released from the requirements of the license by purchasing +# You can be released from the requirements of the license by purchasing # a commercial license. Buying such a license is mandatory as soon as you # develop commercial activities involving the MIRACL Core Crypto SDK # without disclosing the source code of your own applications, or shipping -# the MIRACL Core Crypto SDK with a closed source product. +# the MIRACL Core Crypto SDK with a closed source product. # # Optimal Ate Pairing @@ -77,7 +77,7 @@ def dbl(A) : if curve.SexticTwist == D_TYPE: YY = YY.mulQNR() CC = CC.mulQNR() - if curve.SexticTwist == M_TYPE: + if curve.SexticTwist == M_TYPE: BB = BB.mulQNR() BB=BB-YY A.dbl() @@ -148,7 +148,7 @@ def miller(r) : res.conj() res *= r[0] return res - + def pack(AA,BB,CC) : i=CC.inverse() return Fp4(AA*i,BB*i) @@ -157,7 +157,7 @@ def unpack(T,Qx,Qy) : aa,bb=T.get() aa=aa.muls(Qy) a=Fp4(aa,bb) - + t=Fp2(Qx) if curve.SexticTwist == D_TYPE: b=Fp4(t) @@ -182,7 +182,7 @@ def precomp(GV) : if big.bit(n3, i) == 0 and big.bit(n, i) == 1: AA,BB,CC=add(A,MP) T.append(pack(AA,BB,CC)) - + if curve.PairingFriendly == BN: KA = P.copy() KA.frobenius() @@ -196,14 +196,14 @@ def precomp(GV) : T.append(pack(AA,BB,CC)) return T -# Accumulate another set of line functions for n-pairing, assuming precomputation on G2 +# Accumulate another set of line functions for n-pairing, assuming precomputation on G2 def another_pc(r,T,QV) : if QV.isinf() : return nb,n3,n=lbits() Q=QV.copy() Q.affine() - Qx, Qy = Q.getxy() + Qx, Qy = Q.getxy() j=0 for i in range(nb - 2, 0, -1): lv=unpack(T[j],Qx,Qy) @@ -212,7 +212,7 @@ def another_pc(r,T,QV) : lv2=unpack(T[j],Qx,Qy) j+=1 lv.smul(lv2) - if big.bit(n3, i) == 0 and big.bit(n, i) == 1: + if big.bit(n3, i) == 0 and big.bit(n, i) == 1: lv2=unpack(T[j],Qx,Qy) j+=1 lv.smul(lv2) @@ -225,7 +225,7 @@ def another_pc(r,T,QV) : lv.smul(lv2) r[0] *= lv -# Accumulate another set of line functions for n-pairing +# Accumulate another set of line functions for n-pairing def another(r,P1,Q1) : if Q1.isinf() : return @@ -236,7 +236,7 @@ def another(r,P1,Q1) : P.affine() Q.affine() A = P.copy() - Qx, Qy = Q.getxy() + Qx, Qy = Q.getxy() for i in range(nb - 2, 0, -1): lv=g(A, A, Qx, Qy) @@ -247,7 +247,7 @@ def another(r,P1,Q1) : lv2 = g(A, -P, Qx, Qy) lv.smul(lv2) r[i] *= lv - + if curve.PairingFriendly == BN: KA = P.copy() KA.frobenius() @@ -271,7 +271,7 @@ def ate(P1, Q1): if Q1.isinf() : return one(); nb,n3,n=lbits() - + P = P1.copy() Q = Q1.copy() diff --git a/rust/config32.py b/rust/config32.py index 1c35b37..c35fb7a 100755 --- a/rust/config32.py +++ b/rust/config32.py @@ -178,8 +178,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fpath+"ecp.rs","@AB@",ab) replace(fpath+"ecp.rs","@G2@",g2) - replace(fpath+"ecp.rs","@HC@",hc) - replace(fpath+"ecp.rs","@HC2@",hc2) + replace(fpath+"ecp.rs","@HC@",hc) + replace(fpath+"ecp.rs","@HC2@",hc2) if cs == "128" : replace(fpath+"ecp.rs","@HT@","32") diff --git a/rust/config64.py b/rust/config64.py index 66ece89..d30d3ba 100755 --- a/rust/config64.py +++ b/rust/config64.py @@ -181,8 +181,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : replace(fpath+"ecp.rs","@AB@",ab) replace(fpath+"ecp.rs","@G2@",g2) - replace(fpath+"ecp.rs","@HC@",hc) - replace(fpath+"ecp.rs","@HC2@",hc2) + replace(fpath+"ecp.rs","@HC@",hc) + replace(fpath+"ecp.rs","@HC2@",hc2) if cs == "128" : replace(fpath+"ecp.rs","@HT@","32") @@ -323,7 +323,7 @@ class miracl_crypto: ("bls48556","58","556","1",["-1","2","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BLS48","M_TYPE","POSITIVEX","35","32","256"), ("bls48581","60","581","1",["2","2","0"],"NOT_SPECIAL","10","WEIERSTRASS","0","BLS48","D_TYPE","NEGATIVEX","36","33","256"), ("bls48286","60","286","1",["1","1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BLS48","M_TYPE","POSITIVEX","20","17","128"), - ("bn158","56","158","1",["1","1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","M_TYPE","NEGATIVEX","49","42","128") + ("bn158","56","158","1",["1","1","0"],"NOT_SPECIAL","0","WEIERSTRASS","0","BN","M_TYPE","NEGATIVEX","49","42","128") ) rsa_params = ( diff --git a/swift/config32.py b/swift/config32.py index 0081b20..5b1f555 100755 --- a/swift/config32.py +++ b/swift/config32.py @@ -179,8 +179,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,ab,cs) : replace(fpath+"config_curve.swift","@SX@",sx) replace(fpath+"config_curve.swift","@AB@",ab) - replace(fpath+"config_curve.swift","@HC@",hc) - replace(fpath+"config_curve.swift","@HC2@",hc2) + replace(fpath+"config_curve.swift","@HC@",hc) + replace(fpath+"config_curve.swift","@HC2@",hc2) if cs == "128" : replace(fpath+"config_curve.swift","@HT@","32") diff --git a/swift/config64.py b/swift/config64.py index 6cc70c3..7ffd026 100755 --- a/swift/config64.py +++ b/swift/config64.py @@ -179,8 +179,8 @@ def curveset(tc,base,nbt,m8,rz,mt,qi,ct,ca,pf,stw,sx,ab,cs) : replace(fpath+"config_curve.swift","@SX@",sx) replace(fpath+"config_curve.swift","@AB@",ab) - replace(fpath+"config_curve.swift","@HC@",hc) - replace(fpath+"config_curve.swift","@HC2@",hc2) + replace(fpath+"config_curve.swift","@HC@",hc) + replace(fpath+"config_curve.swift","@HC2@",hc2) if cs == "128" : replace(fpath+"config_curve.swift","@HT@","32") diff --git a/wasm/config32.py b/wasm/config32.py index 7101b89..f04fffa 100755 --- a/wasm/config32.py +++ b/wasm/config32.py @@ -718,7 +718,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("pair8.c", fnamec) copy_keep_file("pair8.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) diff --git a/wasm/config64.py b/wasm/config64.py index 5cb00a7..95c9d1a 100755 --- a/wasm/config64.py +++ b/wasm/config64.py @@ -491,7 +491,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp12.c", fnamec) copy_keep_file("fp12.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -536,7 +536,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("mpin.c", fnamec) copy_keep_file("mpin.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) @@ -567,7 +567,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp8.c", fnamec) copy_keep_file("fp8.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -642,7 +642,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("bls192.c", fnamec) copy_keep_file("bls192.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) @@ -659,7 +659,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp8.c", fnamec) copy_keep_file("fp8.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -691,7 +691,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp16.c", fnamec) copy_keep_file("fp16.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -706,7 +706,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("fp48.c", fnamec) copy_keep_file("fp48.h", fnameh) - + replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) replace(fnamec,"ZZZ",tc) @@ -721,7 +721,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("pair8.c", fnamec) copy_keep_file("pair8.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd) @@ -751,7 +751,7 @@ def curveset(nbt,tf,tc,base,m8,rz,mt,qi,ct,ca,pf,stw,sx,g2,ab,cs) : copy_temp_file("bls256.c", fnamec) copy_keep_file("bls256.h", fnameh) - + replace(fnamec,"ZZZ",tc) replace(fnamec,"YYY",tf) replace(fnamec,"XXX",bd)