This is an automated email from the ASF dual-hosted git repository. kmccusker pushed a commit to branch issue10 in repository https://gitbox.apache.org/repos/asf/incubator-milagro-crypto-js.git
commit 2e3e83687861d9db4325935540d2b3c5a868d2fa Author: Kealan McCusker <[email protected]> AuthorDate: Thu Jun 27 16:08:44 2019 +0100 add Apache headers and crypto notice --- LICENSE | 2 +- NOTICE | 5 + README.md | 55 ++- doc/AMCL.pdf | Bin 423451 -> 0 bytes examples/browser/example_BLS.html | 19 + examples/browser/example_all.html | 19 + examples/node/example_AES_ENCRYPTION.js | 34 +- examples/node/example_BLS_BLS381.js | 19 + examples/node/example_DVS_BLS381.js | 32 +- examples/node/example_ECC_BLS381_NIST521.js | 33 +- examples/node/example_ECC_NIST256.js | 33 +- examples/node/example_HASH.js | 32 +- examples/node/example_MPIN_BLS381.js | 32 +- examples/node/example_MPIN_FULL_BLS381.js | 32 +- examples/node/example_MPIN_ONE_PASS_BLS381.js | 32 +- examples/node/example_RSA2048_ECDSA_NIST256.js | 32 +- examples/node/example_RSA2048_GENKEY.js | 32 +- index.js | 19 + test/test_AES.js | 35 +- test/test_BIG.js | 33 +- test/test_BLS.js | 32 +- test/test_DVS.js | 32 +- test/test_ECC.js | 263 +++++++------ test/test_ECP.js | 315 ++++++++------- test/test_ECP2.js | 299 +++++++------- test/test_ECP4.js | 35 +- test/test_ECP8.js | 35 +- test/test_FP12_js | 33 +- test/test_FP16_js | 33 +- test/test_FP24_js | 33 +- test/test_FP2_js | 325 ++++++++-------- test/test_FP48_js | 32 +- test/test_FP4_js | 513 ++++++++++++------------- test/test_FP8_js | 33 +- test/test_FP_js | 289 +++++++------- test/test_GCM.js | 35 +- test/test_HASH.js | 255 ++++++------ test/test_MPIN.js | 32 +- test/test_PAIR.js | 32 +- test/test_RSA2048.js | 32 +- test/test_RSA3072.js | 32 +- test/test_RSA4096.js | 32 +- 42 files changed, 1692 insertions(+), 1590 deletions(-) diff --git a/LICENSE b/LICENSE index 9b5e401..e873a35 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2018 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..77370a4 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache Milagro Release +Copyright 2019 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/README.md b/README.md index 381aa3e..43d4f4d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + # MCJS - *Milagro Crypto JavaScript* [](https://github.com/apache/incubator-milagro-crypto-js/tree/master) @@ -103,7 +122,10 @@ The following is the list of all the RSA security level supported by *MCJS* #### Other functions -MCJS supports SHA256, SHA384, SHA512, AES-GCM encryption and Marsaglia & Zaman random number generator. Those functions are contained in every context initialized with RSA or with an elliptic curve. If you want to create a context supporting only those general functions then initialize it with no parameter as follows: +MCJS supports SHA256, SHA384, SHA512, AES-GCM encryption and Marsaglia & Zaman +random number generator. Those functions are contained in every context initialized +with RSA or with an elliptic curve. If you want to create a context supporting only +those general functions then initialize it with no parameter as follows: ``` var CTX = require("milagro-crypto-js"); @@ -122,7 +144,7 @@ node ./examples/node/example_ECC_NIST256.js ## Browsers -The library source code is browser compatible. The browser examples are locates +The library source code is browser compatible. The browser examples are located in `./examples/browser`. ## Docker @@ -133,6 +155,23 @@ The tests can be run using Docker: docker build -t mcjs:builder . docker run --rm mcjs:builder ``` +## Crypto Notice + +This distribution includes cryptographic software. The country in which you +currently reside may have restrictions on the import, possession, use, and/or +re-export to another country, of encryption software. BEFORE using any +encryption software, please check your country's laws, regulations and +policies concerning the import, possession, or use, and re-export of encryption +software, to see if this is permitted. See <http://www.wassenaar.org/> for +more information. + +The Apache Software Foundation has classified this software as Export Commodity +Control Number (ECCN) 5D002, which includes information security software using +or performing cryptographic functions with asymmetric algorithms. The form and +manner of this Apache Software Foundation distribution makes it eligible for +export under the "publicly available" Section 742.15(b) exemption (see the BIS +Export Administration Regulations, Section 742.15(b)) for both object code and +source code. ## Contributors @@ -147,11 +186,11 @@ Please add yourself here if you make or have made a contribution. ## Making a Contribution -1. [Check for open issues](https://github.com/apache/incubator-milagro-crypto-js/issues) or start a discussion around a feature idea or a bug by sending a -mail to [email protected] -2. Fork the repository to start making your changes. Please use the -"development" branch as a basis. -3. Write a test which shows that the bug was fixed or that the feature works -as expected. +1. [Check for open issues](https://github.com/apache/incubator-milagro-crypto-js/issues) + or start a discussion around a feature idea or a bug by sending a mail to + [email protected] +2. Fork the repository to start making your changes. Please use the "development" branch + as a basis. +3. Write a test which shows that the bug was fixed or that the feature works as expected. 4. Make a pull request with a reference to the issue diff --git a/doc/AMCL.pdf b/doc/AMCL.pdf deleted file mode 100644 index e4fa685..0000000 Binary files a/doc/AMCL.pdf and /dev/null differ diff --git a/examples/browser/example_BLS.html b/examples/browser/example_BLS.html index ab8cbf4..7fed187 100644 --- a/examples/browser/example_BLS.html +++ b/examples/browser/example_BLS.html @@ -1,3 +1,22 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + <!DOCTYPE HTML> <html> <head> diff --git a/examples/browser/example_all.html b/examples/browser/example_all.html index 24fb9ab..5dc7a1a 100644 --- a/examples/browser/example_all.html +++ b/examples/browser/example_all.html @@ -1,3 +1,22 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + <!DOCTYPE HTML> <html> <head> diff --git a/examples/node/example_AES_ENCRYPTION.js b/examples/node/example_AES_ENCRYPTION.js index c0d2525..16fb8af 100644 --- a/examples/node/example_AES_ENCRYPTION.js +++ b/examples/node/example_AES_ENCRYPTION.js @@ -1,23 +1,23 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ -/* Test HASH function - test driver and function exerciser for SHA256, SHA384, SHA512 API Functions */ +// Test AES var CTX = require("../../index"); diff --git a/examples/node/example_BLS_BLS381.js b/examples/node/example_BLS_BLS381.js index fc28aa2..f7f2c77 100644 --- a/examples/node/example_BLS_BLS381.js +++ b/examples/node/example_BLS_BLS381.js @@ -1,3 +1,22 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + /* Test BLS - test driver and function exerciser for BLS API Functions */ var CTX = require("../../index"); diff --git a/examples/node/example_DVS_BLS381.js b/examples/node/example_DVS_BLS381.js index 416892c..b01a1fe 100644 --- a/examples/node/example_DVS_BLS381.js +++ b/examples/node/example_DVS_BLS381.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test DVS - test driver and function exerciser for Designated Verifier Signature API Functions */ diff --git a/examples/node/example_ECC_BLS381_NIST521.js b/examples/node/example_ECC_BLS381_NIST521.js index 9849b78..e1aa886 100644 --- a/examples/node/example_ECC_BLS381_NIST521.js +++ b/examples/node/example_ECC_BLS381_NIST521.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test ECC - test driver and function exerciser for ECDH/ECIES/ECDSA API Functions */ var CTX = require("../../index"); diff --git a/examples/node/example_ECC_NIST256.js b/examples/node/example_ECC_NIST256.js index f661be6..27bd5e3 100644 --- a/examples/node/example_ECC_NIST256.js +++ b/examples/node/example_ECC_NIST256.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test ECC - test driver and function exerciser for ECDH/ECIES/ECDSA API Functions */ var CTX = require("../../index"); diff --git a/examples/node/example_HASH.js b/examples/node/example_HASH.js index 6ff0d0d..18b23fa 100644 --- a/examples/node/example_HASH.js +++ b/examples/node/example_HASH.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Example Hash functions */ diff --git a/examples/node/example_MPIN_BLS381.js b/examples/node/example_MPIN_BLS381.js index 11e2b78..a8e5c24 100644 --- a/examples/node/example_MPIN_BLS381.js +++ b/examples/node/example_MPIN_BLS381.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test MPIN - test driver and function exerciser for MPIN API Functions */ diff --git a/examples/node/example_MPIN_FULL_BLS381.js b/examples/node/example_MPIN_FULL_BLS381.js index 0e9f9a3..a9e7ba1 100644 --- a/examples/node/example_MPIN_FULL_BLS381.js +++ b/examples/node/example_MPIN_FULL_BLS381.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test MPIN - test driver and function exerciser for MPIN API Functions */ diff --git a/examples/node/example_MPIN_ONE_PASS_BLS381.js b/examples/node/example_MPIN_ONE_PASS_BLS381.js index 9de9ba6..4d3b829 100644 --- a/examples/node/example_MPIN_ONE_PASS_BLS381.js +++ b/examples/node/example_MPIN_ONE_PASS_BLS381.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test MPIN - test driver and function exerciser for MPIN API Functions */ diff --git a/examples/node/example_RSA2048_ECDSA_NIST256.js b/examples/node/example_RSA2048_ECDSA_NIST256.js index 7b6aa86..78dab3f 100644 --- a/examples/node/example_RSA2048_ECDSA_NIST256.js +++ b/examples/node/example_RSA2048_ECDSA_NIST256.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -'License'); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test RSA - test driver and function exerciser for RSA_2048 and ECDSA with NIST256 */ diff --git a/examples/node/example_RSA2048_GENKEY.js b/examples/node/example_RSA2048_GENKEY.js index d462571..f849ffc 100644 --- a/examples/node/example_RSA2048_GENKEY.js +++ b/examples/node/example_RSA2048_GENKEY.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -'License'); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test RSA - test driver and function exerciser for RSA_2048 API Functions */ diff --git a/index.js b/index.js index 8a4b508..f4b405e 100644 --- a/index.js +++ b/index.js @@ -1 +1,20 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + module.exports = require("./src/ctx"); diff --git a/test/test_AES.js b/test/test_AES.js index b0b7074..3c65c5e 100644 --- a/test/test_AES.js +++ b/test/test_AES.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test AES function - test driver and function exerciser for AES API Functions */ var CTX = require("../index"); @@ -240,4 +239,4 @@ describe('TEST AES', function() { done(); }); -}); \ No newline at end of file +}); diff --git a/test/test_BIG.js b/test/test_BIG.js index 0ba368e..c047407 100644 --- a/test/test_BIG.js +++ b/test/test_BIG.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test BIG consistency - test driver and function exerciser for BIG API Functions */ var chai = require('chai'); diff --git a/test/test_BLS.js b/test/test_BLS.js index 9b8d2bb..90df161 100644 --- a/test/test_BLS.js +++ b/test/test_BLS.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ // Test BLS diff --git a/test/test_DVS.js b/test/test_DVS.js index 3f9eeea..8418f3b 100644 --- a/test/test_DVS.js +++ b/test/test_DVS.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either exprtns or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test DVS - test driver and function exerciser for Designated Veifier Signature API Functions */ diff --git a/test/test_ECC.js b/test/test_ECC.js index b267ced..e292ac7 100644 --- a/test/test_ECC.js +++ b/test/test_ECC.js @@ -1,132 +1,131 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either exprtns or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test ECC - test driver and function exerciser for ECDH/ECIES/ECDSA API Functions */ - -var chai = require('chai'); - -var CTX = require("../index"); - -var expect = chai.expect; - -var all_curves = ['ED25519', 'GOLDILOCKS', 'NIST256', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'C25519', 'SECP256K1', 'NIST384', 'C41417', 'NIST521', 'NUMS256W', - 'NUMS256E', 'NUMS384W', 'NUMS384E', 'NUMS512W', 'NUMS512E', 'BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48' -]; - -all_curves.forEach(function(curve) { - - var ctx = new CTX(curve); - - describe('TEST ECC ' + curve, function() { - - var pp = "M0ng00se", - sha = ctx.ECP.HASH_TYPE, - S1 = [], - W0 = [], - W1 = [], - Z0 = [], - Z1 = [], - RAW = [], - SALT = [], - P1 = [], - P2 = [], - V = [], - M1 = [], - CS = [], - DS = [], - rng = new ctx.RAND(), - T = new Array(12), // must specify required length - PW, KEY1, KEY2, C, M2, S0, rtn; - - before(function(done) { - this.timeout(0); - rng.clean(); - for (i = 0; i < 100; i++) RAW[i] = i; - rng.seed(100, RAW); - for (i = 0; i < 8; i++) SALT[i] = (i + 1); // set Salt - PW = ctx.ECDH.stringtobytes(pp); - // private key S0 of size EGS bytes derived from Password and Salt - S0 = ctx.ECDH.PBKDF2(sha, PW, SALT, 1000, ctx.ECDH.EGS); - done(); - }); - - - it('test ECDH', function(done) { - this.timeout(0); - - // Generate Key pair S/W - ctx.ECDH.KEY_PAIR_GENERATE(null, S0, W0); - - rtn = ctx.ECDH.PUBLIC_KEY_VALIDATE(W0); - expect(rtn).to.be.equal(0); - // Random private key for other party - ctx.ECDH.KEY_PAIR_GENERATE(rng, S1, W1); - - rtn = ctx.ECDH.PUBLIC_KEY_VALIDATE(W1); - expect(rtn).to.be.equal(0); - - // Calculate common key using DH - IEEE 1363 method - - ctx.ECDH.ECPSVDP_DH(S0, W1, Z0); - ctx.ECDH.ECPSVDP_DH(S1, W0, Z1); - - var same = true; - for (i = 0; i < ctx.ECDH.EFS; i++) - if (Z0[i] != Z1[i]) same = false; - - - KEY1 = ctx.ECDH.KDF2(sha, Z0, null, ctx.ECP.AESKEY); - KEY2 = ctx.ECDH.KDF2(sha, Z1, null, ctx.ECP.AESKEY); - - expect(KEY1.toString()).to.be.equal(KEY2.toString()); - done(); - }); - - if (ctx.ECP.CURVETYPE != ctx.ECP.MONTGOMERY) { - it('test ECIES', function(done) { - this.timeout(0); - P1[0] = 0x0; - P1[1] = 0x1; - P1[2] = 0x2; - P2[0] = 0x0; - P2[1] = 0x1; - P2[2] = 0x2; - P2[3] = 0x3; - - for (i = 0; i <= 16; i++) M1[i] = i; - - C = ctx.ECDH.ECIES_ENCRYPT(sha, P1, P2, rng, W1, M1, V, T); - - M2 = ctx.ECDH.ECIES_DECRYPT(sha, P1, P2, V, C, T, S1); - - expect(M1.toString()).to.equal(M2.toString()); - - done(); - }); - - it('test ECDSA', function(done) { - this.timeout(0); - expect(ctx.ECDH.ECPSP_DSA(sha, rng, S0, M1, CS, DS)).to.be.equal(0); - expect(ctx.ECDH.ECPVP_DSA(sha, W0, M1, CS, DS)).to.be.equal(0); - done(); - }); - } - }); -}); +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test ECC - test driver and function exerciser for ECDH/ECIES/ECDSA API Functions */ + +var chai = require('chai'); + +var CTX = require("../index"); + +var expect = chai.expect; + +var all_curves = ['ED25519', 'GOLDILOCKS', 'NIST256', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'C25519', 'SECP256K1', 'NIST384', 'C41417', 'NIST521', 'NUMS256W', + 'NUMS256E', 'NUMS384W', 'NUMS384E', 'NUMS512W', 'NUMS512E', 'BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48' +]; + +all_curves.forEach(function(curve) { + + var ctx = new CTX(curve); + + describe('TEST ECC ' + curve, function() { + + var pp = "M0ng00se", + sha = ctx.ECP.HASH_TYPE, + S1 = [], + W0 = [], + W1 = [], + Z0 = [], + Z1 = [], + RAW = [], + SALT = [], + P1 = [], + P2 = [], + V = [], + M1 = [], + CS = [], + DS = [], + rng = new ctx.RAND(), + T = new Array(12), // must specify required length + PW, KEY1, KEY2, C, M2, S0, rtn; + + before(function(done) { + this.timeout(0); + rng.clean(); + for (i = 0; i < 100; i++) RAW[i] = i; + rng.seed(100, RAW); + for (i = 0; i < 8; i++) SALT[i] = (i + 1); // set Salt + PW = ctx.ECDH.stringtobytes(pp); + // private key S0 of size EGS bytes derived from Password and Salt + S0 = ctx.ECDH.PBKDF2(sha, PW, SALT, 1000, ctx.ECDH.EGS); + done(); + }); + + + it('test ECDH', function(done) { + this.timeout(0); + + // Generate Key pair S/W + ctx.ECDH.KEY_PAIR_GENERATE(null, S0, W0); + + rtn = ctx.ECDH.PUBLIC_KEY_VALIDATE(W0); + expect(rtn).to.be.equal(0); + // Random private key for other party + ctx.ECDH.KEY_PAIR_GENERATE(rng, S1, W1); + + rtn = ctx.ECDH.PUBLIC_KEY_VALIDATE(W1); + expect(rtn).to.be.equal(0); + + // Calculate common key using DH - IEEE 1363 method + + ctx.ECDH.ECPSVDP_DH(S0, W1, Z0); + ctx.ECDH.ECPSVDP_DH(S1, W0, Z1); + + var same = true; + for (i = 0; i < ctx.ECDH.EFS; i++) + if (Z0[i] != Z1[i]) same = false; + + + KEY1 = ctx.ECDH.KDF2(sha, Z0, null, ctx.ECP.AESKEY); + KEY2 = ctx.ECDH.KDF2(sha, Z1, null, ctx.ECP.AESKEY); + + expect(KEY1.toString()).to.be.equal(KEY2.toString()); + done(); + }); + + if (ctx.ECP.CURVETYPE != ctx.ECP.MONTGOMERY) { + it('test ECIES', function(done) { + this.timeout(0); + P1[0] = 0x0; + P1[1] = 0x1; + P1[2] = 0x2; + P2[0] = 0x0; + P2[1] = 0x1; + P2[2] = 0x2; + P2[3] = 0x3; + + for (i = 0; i <= 16; i++) M1[i] = i; + + C = ctx.ECDH.ECIES_ENCRYPT(sha, P1, P2, rng, W1, M1, V, T); + + M2 = ctx.ECDH.ECIES_DECRYPT(sha, P1, P2, V, C, T, S1); + + expect(M1.toString()).to.equal(M2.toString()); + + done(); + }); + + it('test ECDSA', function(done) { + this.timeout(0); + expect(ctx.ECDH.ECPSP_DSA(sha, rng, S0, M1, CS, DS)).to.be.equal(0); + expect(ctx.ECDH.ECPVP_DSA(sha, W0, M1, CS, DS)).to.be.equal(0); + done(); + }); + } + }); +}); diff --git a/test/test_ECP.js b/test/test_ECP.js index 83b626e..7c4c97a 100644 --- a/test/test_ECP.js +++ b/test/test_ECP.js @@ -1,158 +1,157 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test ECP ARITHMETICS - test driver and function exerciser for ECP API Functions */ - -var chai = require('chai'); - -var CTX = require("../index"); - -var expect = chai.expect; - -var ecp_curves = ['ED25519', 'GOLDILOCKS', 'NIST256', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'C25519', 'SECP256K1', 'NIST384', 'C41417', - 'NIST521', 'NUMS256W', 'NUMS384W', 'NUMS512W', 'BN254', 'BN254CX', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48' -]; - -var readBIG = function(string, ctx) { - while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} - return ctx.BIG.fromBytes(Buffer.from(string, "hex")); -} - -var readPoint = function(string, ctx) { - var P = new ctx.ECP(), - X,Y; - - string = string.split(":"); - - X = readBIG(string[0],ctx); - Y = readBIG(string[1],ctx); - P.setxy(X,Y); - - return P; -} - -describe('TEST ECP ARITHMETIC', function() { - - ecp_curves.forEach(function(curve) { - - it('test '+ curve, function(done) { - this.timeout(0); - - var ctx = new CTX(curve); - var vectors = require('../testVectors/ecp/'+curve+'.json'); - - vectors.forEach(function(vector) { - var P1 = readPoint(vector.ECP1,ctx); - var Paux1 = new ctx.ECP(0); - - // test copy and equals - Paux1.copy(P1); - expect(Paux1.equals(P1)).to.equal(true); - - if (ctx.ECP.CURVETYPE != ctx.ECP.MONTGOMERY) { - // test that y^2 = RHS - var x = Paux1.getx(); - var y = Paux1.gety(); - y.sqr(); - x = ctx.ECP.RHS(x); - - expect(x.toString()).to.equal(y.toString()); - - // test commutativity of the sum - var P2 = readPoint(vector.ECP2,ctx); - var Psum = readPoint(vector.ECPsum,ctx); - var Paux2 = new ctx.ECP(0); - Paux1.copy(P1); - Paux2.copy(P2); - Paux1.add(P2); - Paux2.add(P1); - expect(Paux1.toString()).to.equal(Psum.toString()); - expect(Paux2.toString()).to.equal(Psum.toString()); - - // test associativity of the sum - Paux2.copy(P2); - Paux2.add(Psum); - Paux2.add(P1); - Paux1.add(Psum) - expect(Paux1.toString()).to.equal(Paux2.toString()); - - // Test sum with infinity - Paux1.copy(P1); - Paux2.inf(); - Paux1.add(Paux2); - expect(Paux1.toString()).to.equal(P1.toString()); - Paux2.add(Paux1); - expect(Paux2.toString()).to.equal(P1.toString()); - - // test negative of a point - var Pneg = readPoint(vector.ECPneg,ctx); - Paux1.copy(P1); - Paux1.neg(); - expect(Paux1.toString()).to.equal(Pneg.toString()); - - // test subtraction between points - var Psub = readPoint(vector.ECPsub,ctx); - Paux1.copy(P1); - Paux1.sub(P2); - expect(Paux1.toString()).to.equal(Psub.toString()); - } - - // test doubling - var Pdbl = readPoint(vector.ECPdbl,ctx); - Paux1.copy(P1); - Paux1.dbl(); - expect(Paux1.toString()).to.equal(Pdbl.toString()); - - // test scalar multiplication - var Pmul = readPoint(vector.ECPmul,ctx); - var Scalar1 = readBIG(vector.BIGscalar1, ctx); - Paux1.copy(P1); - Paux1 = Paux1.mul(Scalar1); - expect(Paux1.toString()).to.equal(Pmul.toString()); - - if (ctx.ECP.CURVETYPE != ctx.ECP.MONTGOMERY) { - // test multiplication by small integer - var Ppinmul = readPoint(vector.ECPpinmul,ctx); - Paux1.copy(P1); - Paux1 = Paux1.pinmul(1234,14); - expect(Paux1.toString()).to.equal(Ppinmul.toString()); - - // test mul2 - var Pmul2 = readPoint(vector.ECPmul2,ctx); - var Scalar1 = readBIG(vector.BIGscalar1, ctx); - var Scalar2 = readBIG(vector.BIGscalar2, ctx); - Paux1.copy(P1); - Paux2.copy(P2); - Paux1 = Paux1.mul2(Scalar1,Paux2,Scalar2); - expect(Paux1.toString()).to.equal(Pmul2.toString()); - } - - // test wrong coordinates and infinity point - var Pwrong = readPoint(vector.ECPwrong,ctx); - var Pinf = readPoint(vector.ECPinf,ctx); - // test copy and equals - expect(Pwrong.is_infinity()).to.equal(true); - expect(Pinf.is_infinity()).to.equal(true); - expect(Pwrong.equals(Pinf)).to.equal(true); - }); - done(); - }); - }); -}); \ No newline at end of file +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test ECP ARITHMETICS - test driver and function exerciser for ECP API Functions */ + +var chai = require('chai'); + +var CTX = require("../index"); + +var expect = chai.expect; + +var ecp_curves = ['ED25519', 'GOLDILOCKS', 'NIST256', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'C25519', 'SECP256K1', 'NIST384', 'C41417', + 'NIST521', 'NUMS256W', 'NUMS384W', 'NUMS512W', 'BN254', 'BN254CX', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48' +]; + +var readBIG = function(string, ctx) { + while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} + return ctx.BIG.fromBytes(Buffer.from(string, "hex")); +} + +var readPoint = function(string, ctx) { + var P = new ctx.ECP(), + X,Y; + + string = string.split(":"); + + X = readBIG(string[0],ctx); + Y = readBIG(string[1],ctx); + P.setxy(X,Y); + + return P; +} + +describe('TEST ECP ARITHMETIC', function() { + + ecp_curves.forEach(function(curve) { + + it('test '+ curve, function(done) { + this.timeout(0); + + var ctx = new CTX(curve); + var vectors = require('../testVectors/ecp/'+curve+'.json'); + + vectors.forEach(function(vector) { + var P1 = readPoint(vector.ECP1,ctx); + var Paux1 = new ctx.ECP(0); + + // test copy and equals + Paux1.copy(P1); + expect(Paux1.equals(P1)).to.equal(true); + + if (ctx.ECP.CURVETYPE != ctx.ECP.MONTGOMERY) { + // test that y^2 = RHS + var x = Paux1.getx(); + var y = Paux1.gety(); + y.sqr(); + x = ctx.ECP.RHS(x); + + expect(x.toString()).to.equal(y.toString()); + + // test commutativity of the sum + var P2 = readPoint(vector.ECP2,ctx); + var Psum = readPoint(vector.ECPsum,ctx); + var Paux2 = new ctx.ECP(0); + Paux1.copy(P1); + Paux2.copy(P2); + Paux1.add(P2); + Paux2.add(P1); + expect(Paux1.toString()).to.equal(Psum.toString()); + expect(Paux2.toString()).to.equal(Psum.toString()); + + // test associativity of the sum + Paux2.copy(P2); + Paux2.add(Psum); + Paux2.add(P1); + Paux1.add(Psum) + expect(Paux1.toString()).to.equal(Paux2.toString()); + + // Test sum with infinity + Paux1.copy(P1); + Paux2.inf(); + Paux1.add(Paux2); + expect(Paux1.toString()).to.equal(P1.toString()); + Paux2.add(Paux1); + expect(Paux2.toString()).to.equal(P1.toString()); + + // test negative of a point + var Pneg = readPoint(vector.ECPneg,ctx); + Paux1.copy(P1); + Paux1.neg(); + expect(Paux1.toString()).to.equal(Pneg.toString()); + + // test subtraction between points + var Psub = readPoint(vector.ECPsub,ctx); + Paux1.copy(P1); + Paux1.sub(P2); + expect(Paux1.toString()).to.equal(Psub.toString()); + } + + // test doubling + var Pdbl = readPoint(vector.ECPdbl,ctx); + Paux1.copy(P1); + Paux1.dbl(); + expect(Paux1.toString()).to.equal(Pdbl.toString()); + + // test scalar multiplication + var Pmul = readPoint(vector.ECPmul,ctx); + var Scalar1 = readBIG(vector.BIGscalar1, ctx); + Paux1.copy(P1); + Paux1 = Paux1.mul(Scalar1); + expect(Paux1.toString()).to.equal(Pmul.toString()); + + if (ctx.ECP.CURVETYPE != ctx.ECP.MONTGOMERY) { + // test multiplication by small integer + var Ppinmul = readPoint(vector.ECPpinmul,ctx); + Paux1.copy(P1); + Paux1 = Paux1.pinmul(1234,14); + expect(Paux1.toString()).to.equal(Ppinmul.toString()); + + // test mul2 + var Pmul2 = readPoint(vector.ECPmul2,ctx); + var Scalar1 = readBIG(vector.BIGscalar1, ctx); + var Scalar2 = readBIG(vector.BIGscalar2, ctx); + Paux1.copy(P1); + Paux2.copy(P2); + Paux1 = Paux1.mul2(Scalar1,Paux2,Scalar2); + expect(Paux1.toString()).to.equal(Pmul2.toString()); + } + + // test wrong coordinates and infinity point + var Pwrong = readPoint(vector.ECPwrong,ctx); + var Pinf = readPoint(vector.ECPinf,ctx); + // test copy and equals + expect(Pwrong.is_infinity()).to.equal(true); + expect(Pinf.is_infinity()).to.equal(true); + expect(Pwrong.equals(Pinf)).to.equal(true); + }); + done(); + }); + }); +}); diff --git a/test/test_ECP2.js b/test/test_ECP2.js index ab405cc..c19d9b7 100644 --- a/test/test_ECP2.js +++ b/test/test_ECP2.js @@ -1,150 +1,149 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test ECP2 ARITHMETICS - test driver and function exerciser for ECP2 API Functions */ - -var chai = require('chai'); - -var CTX = require("../index"); - -var expect = chai.expect; - -var pf_curves = ['BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN']; - -var readBIG = function(string, ctx) { - while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} - return ctx.BIG.fromBytes(Buffer.from(string, "hex")); -} - -var readPoint2 = function(string, ctx) { - var P = new ctx.ECP2(), - X, Y; - - var coxy = string.split("&"); - var cox = coxy[0].split(":"); - var coy = coxy[1].split(":"); - - var x1 = readBIG(cox[0],ctx); - var x2 = readBIG(cox[1],ctx); - var y1 = readBIG(coy[0],ctx); - var y2 = readBIG(coy[1],ctx); - - X = new ctx.FP2(x1,x2); - Y = new ctx.FP2(y1,y2); - P.setxy(X,Y); - - return P; -} - -describe('TEST ECP2 ARITHMETIC', function() { - - pf_curves.forEach(function(curve) { - - it('test '+curve, function(done) { - this.timeout(0); - - var ctx = new CTX(curve); - var vectors = require('../testVectors/ecp2/'+curve+'.json'); - - var i = 0; - vectors.forEach(function(vector) { - var P1 = readPoint2(vector.ECP21,ctx); - var Paux1 = new ctx.ECP2(0); - - // test copy and equals - Paux1.copy(P1); - expect(Paux1.equals(P1)).to.equal(true); - - // test that y^2 = RHS - var x = Paux1.getx(); - var y = Paux1.gety(); - y.sqr(); - var res = ctx.ECP2.RHS(x); - - expect(res.toString()).to.equal(y.toString()); - - // test commutativity of the sum - var P2 = readPoint2(vector.ECP22,ctx); - var Psum = readPoint2(vector.ECP2sum,ctx); - var Paux2 = new ctx.ECP2(0); - Paux1.copy(P1); - Paux2.copy(P2); - Paux1.add(P2); - Paux2.add(P1); - expect(Paux1.toString()).to.equal(Psum.toString()); - expect(Paux2.toString()).to.equal(Psum.toString()); - - // test associativity of the sum - Paux2.copy(P1); - Paux2.add(P2); - Paux2.add(Psum); - Paux1.add(Psum) - expect(Paux1.toString()).to.equal(Paux2.toString()); - - // test negative of a point - var Pneg = readPoint2(vector.ECP2neg,ctx); - Paux1.copy(P1); - Paux1.neg(); - expect(Paux1.toString()).to.equal(Pneg.toString()); - - // test subtraction between points - var Psub = readPoint2(vector.ECP2sub,ctx); - Paux1.copy(P1); - Paux1.sub(P2); - expect(Paux1.toString()).to.equal(Psub.toString()); - - // test doubling - var Pdbl = readPoint2(vector.ECP2dbl,ctx); - Paux1.copy(P1); - Paux1.dbl(); - expect(Paux1.toString()).to.equal(Pdbl.toString()); - - // test scalar multiplication - var Pmul = readPoint2(vector.ECP2mul,ctx); - var Scalar1 = readBIG(vector.BIGscalar1, ctx); - Paux1.copy(P1); - Paux1 = Paux1.mul(Scalar1); - expect(Paux1.toString()).to.equal(Pmul.toString()); - - // test linear mul4, linear combination of 4 points - // Only executed once for timing reasons - if (i===0){ - i++; - var P3 = readPoint2(vector.ECP23,ctx); - var P4 = readPoint2(vector.ECP24,ctx); - var Scalar2 = readBIG(vector.BIGscalar2, ctx); - var Scalar3 = readBIG(vector.BIGscalar3, ctx); - var Scalar4 = readBIG(vector.BIGscalar4, ctx); - var Pmul4 = readPoint2(vector.ECP2mul4,ctx); - Paux1 = ctx.ECP2.mul4([P1,P2,P3,P4],[Scalar1,Scalar2,Scalar3,Scalar4]); - expect(Paux1.toString()).to.equal(Pmul4.toString()); - } - - // test wrong coordinates and infinity point - var Pwrong = readPoint2(vector.ECP2wrong,ctx); - var Pinf = readPoint2(vector.ECP2inf,ctx); - expect(Pwrong.is_infinity()).to.equal(true); - expect(Pinf.is_infinity()).to.equal(true); - expect(Pwrong.equals(Pinf)).to.equal(true); - }); - done(); - }); - }); -}); \ No newline at end of file +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test ECP2 ARITHMETICS - test driver and function exerciser for ECP2 API Functions */ + +var chai = require('chai'); + +var CTX = require("../index"); + +var expect = chai.expect; + +var pf_curves = ['BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN']; + +var readBIG = function(string, ctx) { + while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} + return ctx.BIG.fromBytes(Buffer.from(string, "hex")); +} + +var readPoint2 = function(string, ctx) { + var P = new ctx.ECP2(), + X, Y; + + var coxy = string.split("&"); + var cox = coxy[0].split(":"); + var coy = coxy[1].split(":"); + + var x1 = readBIG(cox[0],ctx); + var x2 = readBIG(cox[1],ctx); + var y1 = readBIG(coy[0],ctx); + var y2 = readBIG(coy[1],ctx); + + X = new ctx.FP2(x1,x2); + Y = new ctx.FP2(y1,y2); + P.setxy(X,Y); + + return P; +} + +describe('TEST ECP2 ARITHMETIC', function() { + + pf_curves.forEach(function(curve) { + + it('test '+curve, function(done) { + this.timeout(0); + + var ctx = new CTX(curve); + var vectors = require('../testVectors/ecp2/'+curve+'.json'); + + var i = 0; + vectors.forEach(function(vector) { + var P1 = readPoint2(vector.ECP21,ctx); + var Paux1 = new ctx.ECP2(0); + + // test copy and equals + Paux1.copy(P1); + expect(Paux1.equals(P1)).to.equal(true); + + // test that y^2 = RHS + var x = Paux1.getx(); + var y = Paux1.gety(); + y.sqr(); + var res = ctx.ECP2.RHS(x); + + expect(res.toString()).to.equal(y.toString()); + + // test commutativity of the sum + var P2 = readPoint2(vector.ECP22,ctx); + var Psum = readPoint2(vector.ECP2sum,ctx); + var Paux2 = new ctx.ECP2(0); + Paux1.copy(P1); + Paux2.copy(P2); + Paux1.add(P2); + Paux2.add(P1); + expect(Paux1.toString()).to.equal(Psum.toString()); + expect(Paux2.toString()).to.equal(Psum.toString()); + + // test associativity of the sum + Paux2.copy(P1); + Paux2.add(P2); + Paux2.add(Psum); + Paux1.add(Psum) + expect(Paux1.toString()).to.equal(Paux2.toString()); + + // test negative of a point + var Pneg = readPoint2(vector.ECP2neg,ctx); + Paux1.copy(P1); + Paux1.neg(); + expect(Paux1.toString()).to.equal(Pneg.toString()); + + // test subtraction between points + var Psub = readPoint2(vector.ECP2sub,ctx); + Paux1.copy(P1); + Paux1.sub(P2); + expect(Paux1.toString()).to.equal(Psub.toString()); + + // test doubling + var Pdbl = readPoint2(vector.ECP2dbl,ctx); + Paux1.copy(P1); + Paux1.dbl(); + expect(Paux1.toString()).to.equal(Pdbl.toString()); + + // test scalar multiplication + var Pmul = readPoint2(vector.ECP2mul,ctx); + var Scalar1 = readBIG(vector.BIGscalar1, ctx); + Paux1.copy(P1); + Paux1 = Paux1.mul(Scalar1); + expect(Paux1.toString()).to.equal(Pmul.toString()); + + // test linear mul4, linear combination of 4 points + // Only executed once for timing reasons + if (i===0){ + i++; + var P3 = readPoint2(vector.ECP23,ctx); + var P4 = readPoint2(vector.ECP24,ctx); + var Scalar2 = readBIG(vector.BIGscalar2, ctx); + var Scalar3 = readBIG(vector.BIGscalar3, ctx); + var Scalar4 = readBIG(vector.BIGscalar4, ctx); + var Pmul4 = readPoint2(vector.ECP2mul4,ctx); + Paux1 = ctx.ECP2.mul4([P1,P2,P3,P4],[Scalar1,Scalar2,Scalar3,Scalar4]); + expect(Paux1.toString()).to.equal(Pmul4.toString()); + } + + // test wrong coordinates and infinity point + var Pwrong = readPoint2(vector.ECP2wrong,ctx); + var Pinf = readPoint2(vector.ECP2inf,ctx); + expect(Pwrong.is_infinity()).to.equal(true); + expect(Pinf.is_infinity()).to.equal(true); + expect(Pwrong.equals(Pinf)).to.equal(true); + }); + done(); + }); + }); +}); diff --git a/test/test_ECP4.js b/test/test_ECP4.js index bdcde8f..e148566 100644 --- a/test/test_ECP4.js +++ b/test/test_ECP4.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test ECP4 ARITHMETICS - test driver and function exerciser for ECP4 API Functions */ var chai = require('chai'); @@ -157,4 +156,4 @@ describe('TEST ECP4 ARITHMETIC', function() { done(); }); }); -}); \ No newline at end of file +}); diff --git a/test/test_ECP8.js b/test/test_ECP8.js index aec4fe4..b696060 100644 --- a/test/test_ECP8.js +++ b/test/test_ECP8.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test ECP8 ARITHMETICS - test driver and function exerciser for ECP8 API Functions */ var chai = require('chai'); @@ -157,4 +156,4 @@ describe('TEST ECP8 ARITHMETIC', function() { done(); }); }); -}); \ No newline at end of file +}); diff --git a/test/test_FP12_js b/test/test_FP12_js index 49ea61c..0a07ac3 100644 --- a/test/test_FP12_js +++ b/test/test_FP12_js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test FP12 ARITHMETICS - test driver and function exerciser for FP4 API Functions */ var chai = require('chai'); diff --git a/test/test_FP16_js b/test/test_FP16_js index 7ff7511..efba770 100644 --- a/test/test_FP16_js +++ b/test/test_FP16_js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test FP16 ARITHMETICS - test driver and function exerciser for FP16 API Functions */ var chai = require('chai'); diff --git a/test/test_FP24_js b/test/test_FP24_js index da76b0f..5c85e2d 100644 --- a/test/test_FP24_js +++ b/test/test_FP24_js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test FP24 ARITHMETICS - test driver and function exerciser for FP4 API Functions */ var chai = require('chai'); diff --git a/test/test_FP2_js b/test/test_FP2_js index 06a31e0..abedc07 100644 --- a/test/test_FP2_js +++ b/test/test_FP2_js @@ -1,164 +1,163 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test FP2 ARITHMETICS - test driver and function exerciser for FP2 API Functions */ - -var chai = require('chai'); - -var CTX = require("../index"); - -var expect = chai.expect; - -var pf_curves = ['BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48']; - -var readBIG = function(string, ctx) { - while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} - return ctx.BIG.fromBytes(Buffer.from(string, "hex")); -} - -var readFP2 = function(string, ctx) { - - string = string.split(","); - var cox = string[0].slice(1); - var coy = string[1].slice(0,-1); - - var x = readBIG(cox,ctx); - var y = readBIG(coy,ctx); - - return new ctx.FP2(x,y); -} - -describe('TEST FP2 ARITHMETIC', function() { - - pf_curves.forEach(function(curve){ - - it('test '+ curve, function(done) { - this.timeout(0); - - var ctx = new CTX(curve); - var vectors = require('../testVectors/fp2/'+curve+'.json'); - var i=0; - - vectors.forEach(function(vector){ - - // test commutativity of addition - var fp21 = readFP2(vector.FP21,ctx); - var fp22 = readFP2(vector.FP22,ctx); - var fp2add = readFP2(vector.FP2add,ctx); - var a1 = new ctx.FP2(0); - var a2 = new ctx.FP2(0); - a1.copy(fp21); - a1.add(fp22); - expect(a1.toString()).to.equal(fp2add.toString()); - a2.copy(fp22); - a2.add(fp21); - expect(a2.toString()).to.equal(fp2add.toString()); - - // test associativity of addition - a2.add(fp2add); - a1.copy(fp21); - a1.add(fp2add); - a1.add(fp22); - expect(a1.toString()).to.equal(a2.toString()); - - // test subtraction - var fp2sub = readFP2(vector.FP2sub, ctx); - a1.copy(fp21); - a1.sub(fp22); - expect(a1.toString()).to.equal(fp2sub.toString()); - - // test negative of a FP2 - var fp2neg = readFP2(vector.FP2neg, ctx); - a1.copy(fp21); - a1.neg(); - expect(a1.toString()).to.equal(fp2neg.toString()); - - // test conjugate of a FP2 - var fp2conj = readFP2(vector.FP2conj, ctx); - a1.copy(fp21); - a1.conj(); - expect(a1.toString()).to.equal(fp2conj.toString()); - - // test scalar multiplication - var fp2pmul = readFP2(vector.FP2pmul, ctx); - var scalar = readBIG(vector.BIGsc, ctx); - var fpsc = new ctx.FP(0); - fpsc.bcopy(scalar); - a1.copy(fp21); - a1.pmul(fpsc); - expect(a1.toString()).to.equal(fp2pmul.toString()); - - // test small scalar multiplication - var fp2imul = readFP2(vector.FP2imul, ctx); - a1.copy(fp21); - a1.imul(i); - expect(a1.toString()).to.equal(fp2imul.toString()); - i++; - - // test square and square root - var fp2sqr = readFP2(vector.FP2sqr, ctx); - a1.copy(fp21); - a1.sqr(); - expect(a1.toString()).to.equal(fp2sqr.toString()); - a1.sqrt(); - a1.sqr(); - expect(a1.toString()).to.equal(fp2sqr.toString()); - - // test multiplication - var fp2mul = readFP2(vector.FP2mul, ctx); - a1.copy(fp21); - a2.copy(fp22); - a1.mul(a2); - expect(a1.toString()).to.equal(fp2mul.toString()); - - // test power - var fp2pow = readFP2(vector.FP2pow, ctx); - a1 = fp21.pow(scalar); - expect(a1.toString()).to.equal(fp2pow.toString()); - - // test inverse - var fp2inv = readFP2(vector.FP2inv, ctx); - a1.copy(fp21); - a1.inverse(); - expect(a1.toString()).to.equal(fp2inv.toString()); - - // test division by 2 - var fp2div2 = readFP2(vector.FP2div2, ctx); - a1.copy(fp21); - a1.div2(); - expect(a1.toString()).to.equal(fp2div2.toString()); - - // test multiplication by (1+sqrt(-1)) - var fp2mulip = readFP2(vector.FP2mulip, ctx); - a1.copy(fp21); - a1.mul_ip(); - expect(a1.toString()).to.equal(fp2mulip.toString()); - - // test division by (1+sqrt(-1)) - var fp2divip = readFP2(vector.FP2divip, ctx); - a1.copy(fp21); - a1.div_ip(); - expect(a1.toString()).to.equal(fp2divip.toString()); - - }); - done(); - }); - }); +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test FP2 ARITHMETICS - test driver and function exerciser for FP2 API Functions */ + +var chai = require('chai'); + +var CTX = require("../index"); + +var expect = chai.expect; + +var pf_curves = ['BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48']; + +var readBIG = function(string, ctx) { + while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} + return ctx.BIG.fromBytes(Buffer.from(string, "hex")); +} + +var readFP2 = function(string, ctx) { + + string = string.split(","); + var cox = string[0].slice(1); + var coy = string[1].slice(0,-1); + + var x = readBIG(cox,ctx); + var y = readBIG(coy,ctx); + + return new ctx.FP2(x,y); +} + +describe('TEST FP2 ARITHMETIC', function() { + + pf_curves.forEach(function(curve){ + + it('test '+ curve, function(done) { + this.timeout(0); + + var ctx = new CTX(curve); + var vectors = require('../testVectors/fp2/'+curve+'.json'); + var i=0; + + vectors.forEach(function(vector){ + + // test commutativity of addition + var fp21 = readFP2(vector.FP21,ctx); + var fp22 = readFP2(vector.FP22,ctx); + var fp2add = readFP2(vector.FP2add,ctx); + var a1 = new ctx.FP2(0); + var a2 = new ctx.FP2(0); + a1.copy(fp21); + a1.add(fp22); + expect(a1.toString()).to.equal(fp2add.toString()); + a2.copy(fp22); + a2.add(fp21); + expect(a2.toString()).to.equal(fp2add.toString()); + + // test associativity of addition + a2.add(fp2add); + a1.copy(fp21); + a1.add(fp2add); + a1.add(fp22); + expect(a1.toString()).to.equal(a2.toString()); + + // test subtraction + var fp2sub = readFP2(vector.FP2sub, ctx); + a1.copy(fp21); + a1.sub(fp22); + expect(a1.toString()).to.equal(fp2sub.toString()); + + // test negative of a FP2 + var fp2neg = readFP2(vector.FP2neg, ctx); + a1.copy(fp21); + a1.neg(); + expect(a1.toString()).to.equal(fp2neg.toString()); + + // test conjugate of a FP2 + var fp2conj = readFP2(vector.FP2conj, ctx); + a1.copy(fp21); + a1.conj(); + expect(a1.toString()).to.equal(fp2conj.toString()); + + // test scalar multiplication + var fp2pmul = readFP2(vector.FP2pmul, ctx); + var scalar = readBIG(vector.BIGsc, ctx); + var fpsc = new ctx.FP(0); + fpsc.bcopy(scalar); + a1.copy(fp21); + a1.pmul(fpsc); + expect(a1.toString()).to.equal(fp2pmul.toString()); + + // test small scalar multiplication + var fp2imul = readFP2(vector.FP2imul, ctx); + a1.copy(fp21); + a1.imul(i); + expect(a1.toString()).to.equal(fp2imul.toString()); + i++; + + // test square and square root + var fp2sqr = readFP2(vector.FP2sqr, ctx); + a1.copy(fp21); + a1.sqr(); + expect(a1.toString()).to.equal(fp2sqr.toString()); + a1.sqrt(); + a1.sqr(); + expect(a1.toString()).to.equal(fp2sqr.toString()); + + // test multiplication + var fp2mul = readFP2(vector.FP2mul, ctx); + a1.copy(fp21); + a2.copy(fp22); + a1.mul(a2); + expect(a1.toString()).to.equal(fp2mul.toString()); + + // test power + var fp2pow = readFP2(vector.FP2pow, ctx); + a1 = fp21.pow(scalar); + expect(a1.toString()).to.equal(fp2pow.toString()); + + // test inverse + var fp2inv = readFP2(vector.FP2inv, ctx); + a1.copy(fp21); + a1.inverse(); + expect(a1.toString()).to.equal(fp2inv.toString()); + + // test division by 2 + var fp2div2 = readFP2(vector.FP2div2, ctx); + a1.copy(fp21); + a1.div2(); + expect(a1.toString()).to.equal(fp2div2.toString()); + + // test multiplication by (1+sqrt(-1)) + var fp2mulip = readFP2(vector.FP2mulip, ctx); + a1.copy(fp21); + a1.mul_ip(); + expect(a1.toString()).to.equal(fp2mulip.toString()); + + // test division by (1+sqrt(-1)) + var fp2divip = readFP2(vector.FP2divip, ctx); + a1.copy(fp21); + a1.div_ip(); + expect(a1.toString()).to.equal(fp2divip.toString()); + + }); + done(); + }); + }); }); \ No newline at end of file diff --git a/test/test_FP48_js b/test/test_FP48_js index 5312e44..eecfcd6 100644 --- a/test/test_FP48_js +++ b/test/test_FP48_js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test FP48 ARITHMETICS - test driver and function exerciser for FP4 API Functions */ diff --git a/test/test_FP4_js b/test/test_FP4_js index 2057a6c..cefec53 100644 --- a/test/test_FP4_js +++ b/test/test_FP4_js @@ -1,257 +1,256 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test FP4 ARITHMETICS - test driver and function exerciser for FP4 API Functions */ - -var chai = require('chai'); - -var CTX = require("../index"); - -var expect = chai.expect; - -var pf_curves = ['BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48']; - -var readBIG = function(string, ctx) { - while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} - return ctx.BIG.fromBytes(Buffer.from(string, "hex")); -} - -var readFP2 = function(string, ctx) { - string = string.split(","); - var cox = string[0].slice(1); - var coy = string[1].slice(0,-1); - - var x = readBIG(cox,ctx); - var y = readBIG(coy,ctx); - - return new ctx.FP2(x,y);; -} - -var readFP4 = function(string, ctx) { - var X, Y; - - string = string.split("],["); - var cox = string[0].slice(1) + "]"; - var coy = "[" + string[1].slice(0,-1); - - X = readFP2(cox,ctx); - Y = readFP2(coy,ctx); - - return new ctx.FP4(X,Y); -} - -describe('TEST FP4 ARITHMETIC', function() { - - pf_curves.forEach(function(curve){ - - it('test '+ curve, function(done) { - this.timeout(0); - - var ctx = new CTX(curve); - var vectors = require('../testVectors/fp4/'+curve+'.json'); - var i=0; - - var a1 = new ctx.FP4(1), - a2 = new ctx.FP4(0), - one = new ctx.FP4(1), - zero = new ctx.FP4(0), - fp2one = new ctx.FP2(1), - fp2zero = new ctx.FP2(0); - - // Test iszilch and isunity - expect(zero.iszilch()).to.be.true; - expect(one.iszilch()).to.be.false; - expect(zero.isunity()).to.be.false; - expect(one.isunity()).to.be.true; - - // Test real/isreal - expect(one.isreal()).to.be.true; - expect(one.real().toString()).to.be.equal(fp2one.toString()); - one.times_i(); - expect(one.isreal()).to.be.false; - expect(one.real().toString()).to.be.equal(fp2zero.toString()); - - // Test set using FP2 - one.set(fp2one,fp2zero); - expect(one.isunity()).to.be.true; - one.seta(fp2one); - expect(one.isunity()).to.be.true; - - // Test handling sqrt 0,1 - a1.zero(); - expect(a1.sqrt()).to.be.true; - expect(a1.toString()).to.equal(zero.toString()); - a1.one(); - expect(a1.sqrt()).to.be.true; - expect(a1.toString()).to.equal(one.toString()); - - vectors.forEach(function(vector){ - - // test commutativity of addition - var fp41 = readFP4(vector.FP41,ctx); - var fp42 = readFP4(vector.FP42,ctx); - var fp4add = readFP4(vector.FP4add,ctx); - - a1.copy(fp41); - a1.add(fp42); - expect(a1.toString()).to.equal(fp4add.toString()); - a2.copy(fp42); - a2.add(fp41); - expect(a2.toString()).to.equal(fp4add.toString()); - - // test associativity of addition - a2.add(fp4add); - a1.copy(fp41); - a1.add(fp4add); - a1.add(fp42); - expect(a1.toString()).to.equal(a2.toString()); - - // test subtraction - var fp4sub = readFP4(vector.FP4sub, ctx); - a1.copy(fp41); - a1.sub(fp42); - expect(a1.toString()).to.equal(fp4sub.toString()); - - // test negative of a FP4 - var fp4neg = readFP4(vector.FP4neg, ctx); - a1.copy(fp41); - a1.neg(); - expect(a1.toString()).to.equal(fp4neg.toString()); - - // test conjugate of a FP4 - var fp4conj = readFP4(vector.FP4conj, ctx); - a1.copy(fp41); - a1.conj(); - expect(a1.toString()).to.equal(fp4conj.toString()); - - // test negative conjugate of a FP4 - var fp4nconj = readFP4(vector.FP4nconj, ctx); - a1.copy(fp41); - a1.nconj(); - expect(a1.toString()).to.equal(fp4nconj.toString()); - - // test multiplication by FP2 - var fp4pmul = readFP4(vector.FP4pmul, ctx); - var fp2sc = readFP2(vector.FP2sc, ctx); - a1.copy(fp41); - a1.pmul(fp2sc); - expect(a1.toString()).to.equal(fp4pmul.toString()); - - // test small scalar multiplication - var fp4imul = readFP4(vector.FP4imul, ctx); - a1.copy(fp41); - a1.imul(i); - expect(a1.toString()).to.equal(fp4imul.toString()); - i++; - - // test square - var fp4sqr = readFP4(vector.FP4sqr, ctx); - a1.copy(fp41); - a1.sqr(); - expect(a1.toString()).to.equal(fp4sqr.toString()); - - // test multiplication - var fp4mul = readFP4(vector.FP4mul, ctx); - a1.copy(fp41); - a1.mul(fp42); - expect(a1.toString()).to.equal(fp4mul.toString()); - - // test power - var fp4pow = readFP4(vector.FP4pow, ctx); - var BIGsc1 = readBIG(vector.BIGsc1, ctx); - a1 = fp41.pow(BIGsc1); - expect(a1.toString()).to.equal(fp4pow.toString()); - - // test inverse - var fp4inv = readFP4(vector.FP4inv, ctx); - a1.copy(fp41); - a1.inverse(); - expect(a1.toString()).to.equal(fp4inv.toString()); - - // test multiplication by sqrt(1+sqrt(-1)) - var fp4mulj = readFP4(vector.FP4mulj, ctx); - a1.copy(fp41); - a1.times_i(); - expect(a1.toString()).to.equal(fp4mulj.toString()); - - // // test the XTR addition function r=w*x-conj(x)*y+z - var fp4xtrA = readFP4(vector.FP4xtrA, ctx); - a1.copy(fp42); - a1.xtr_A(fp41,fp4add,fp4sub); - expect(a1.toString()).to.equal(fp4xtrA.toString()); - - // test the XTR addition function r=w*x-conj(x)*y+z - var fp4xtrD = readFP4(vector.FP4xtrD, ctx); - a1.copy(fp41); - a1.xtr_D(); - expect(a1.toString()).to.equal(fp4xtrD.toString()); - - // test the XTR single power r=Tr(x^e) - var fp4xtrpow = readFP4(vector.FP4xtrpow, ctx); - var fp121 = readFP4(vector.FP121, ctx); - a1 = fp121.xtr_pow(BIGsc1); - expect(a1.toString()).to.equal(fp4xtrpow.toString()); - - // test the XTR double power r=Tr(x^e) - var fp4xtrpow2 = readFP4(vector.FP4xtrpow2, ctx); - var fp122 = readFP4(vector.FP122, ctx); - var fp123 = readFP4(vector.FP123, ctx); - var fp124 = readFP4(vector.FP124, ctx); - var BIGsc2 = readBIG(vector.BIGsc2, ctx); - a1 = fp121.xtr_pow2(fp122,fp123,fp124,BIGsc2,BIGsc1); - expect(a1.toString()).to.equal(fp4xtrpow2.toString()); - - if (ctx.ECP.AESKEY > 16) { - // Test division by 2 - var fp4div2 = readFP4(vector.FP4div2, ctx); - a1.copy(fp41); - a1.div2(); - expect(a1.toString()).to.equal(fp4div2.toString()); - - // Test division by i - var fp4divi = readFP4(vector.FP4divi, ctx); - a1.copy(fp41); - a1.div_i(); - expect(a1.toString()).to.equal(fp4divi.toString()) - - // Test division by 2i - var fp4div2i = readFP4(vector.FP4div2i, ctx); - a1.copy(fp41); - a1.div_2i(); - expect(a1.toString()).to.equal(fp4div2i.toString()) - - // Test square root - var fp4sqrt = readFP4(vector.FP4sqrt, ctx); - a1.copy(fp41); - expect(a1.sqrt()).to.equal(true); - expect(a1).to.satisfy(function(p) { - if(fp4sqrt.toString() === p.toString()) { - return true; - } else { - fp4sqrt.neg(); - } - return fp4sqrt.toString() === p.toString(); - }); - } - }); - done(); - }); - }); -}); +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test FP4 ARITHMETICS - test driver and function exerciser for FP4 API Functions */ + +var chai = require('chai'); + +var CTX = require("../index"); + +var expect = chai.expect; + +var pf_curves = ['BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48']; + +var readBIG = function(string, ctx) { + while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} + return ctx.BIG.fromBytes(Buffer.from(string, "hex")); +} + +var readFP2 = function(string, ctx) { + string = string.split(","); + var cox = string[0].slice(1); + var coy = string[1].slice(0,-1); + + var x = readBIG(cox,ctx); + var y = readBIG(coy,ctx); + + return new ctx.FP2(x,y);; +} + +var readFP4 = function(string, ctx) { + var X, Y; + + string = string.split("],["); + var cox = string[0].slice(1) + "]"; + var coy = "[" + string[1].slice(0,-1); + + X = readFP2(cox,ctx); + Y = readFP2(coy,ctx); + + return new ctx.FP4(X,Y); +} + +describe('TEST FP4 ARITHMETIC', function() { + + pf_curves.forEach(function(curve){ + + it('test '+ curve, function(done) { + this.timeout(0); + + var ctx = new CTX(curve); + var vectors = require('../testVectors/fp4/'+curve+'.json'); + var i=0; + + var a1 = new ctx.FP4(1), + a2 = new ctx.FP4(0), + one = new ctx.FP4(1), + zero = new ctx.FP4(0), + fp2one = new ctx.FP2(1), + fp2zero = new ctx.FP2(0); + + // Test iszilch and isunity + expect(zero.iszilch()).to.be.true; + expect(one.iszilch()).to.be.false; + expect(zero.isunity()).to.be.false; + expect(one.isunity()).to.be.true; + + // Test real/isreal + expect(one.isreal()).to.be.true; + expect(one.real().toString()).to.be.equal(fp2one.toString()); + one.times_i(); + expect(one.isreal()).to.be.false; + expect(one.real().toString()).to.be.equal(fp2zero.toString()); + + // Test set using FP2 + one.set(fp2one,fp2zero); + expect(one.isunity()).to.be.true; + one.seta(fp2one); + expect(one.isunity()).to.be.true; + + // Test handling sqrt 0,1 + a1.zero(); + expect(a1.sqrt()).to.be.true; + expect(a1.toString()).to.equal(zero.toString()); + a1.one(); + expect(a1.sqrt()).to.be.true; + expect(a1.toString()).to.equal(one.toString()); + + vectors.forEach(function(vector){ + + // test commutativity of addition + var fp41 = readFP4(vector.FP41,ctx); + var fp42 = readFP4(vector.FP42,ctx); + var fp4add = readFP4(vector.FP4add,ctx); + + a1.copy(fp41); + a1.add(fp42); + expect(a1.toString()).to.equal(fp4add.toString()); + a2.copy(fp42); + a2.add(fp41); + expect(a2.toString()).to.equal(fp4add.toString()); + + // test associativity of addition + a2.add(fp4add); + a1.copy(fp41); + a1.add(fp4add); + a1.add(fp42); + expect(a1.toString()).to.equal(a2.toString()); + + // test subtraction + var fp4sub = readFP4(vector.FP4sub, ctx); + a1.copy(fp41); + a1.sub(fp42); + expect(a1.toString()).to.equal(fp4sub.toString()); + + // test negative of a FP4 + var fp4neg = readFP4(vector.FP4neg, ctx); + a1.copy(fp41); + a1.neg(); + expect(a1.toString()).to.equal(fp4neg.toString()); + + // test conjugate of a FP4 + var fp4conj = readFP4(vector.FP4conj, ctx); + a1.copy(fp41); + a1.conj(); + expect(a1.toString()).to.equal(fp4conj.toString()); + + // test negative conjugate of a FP4 + var fp4nconj = readFP4(vector.FP4nconj, ctx); + a1.copy(fp41); + a1.nconj(); + expect(a1.toString()).to.equal(fp4nconj.toString()); + + // test multiplication by FP2 + var fp4pmul = readFP4(vector.FP4pmul, ctx); + var fp2sc = readFP2(vector.FP2sc, ctx); + a1.copy(fp41); + a1.pmul(fp2sc); + expect(a1.toString()).to.equal(fp4pmul.toString()); + + // test small scalar multiplication + var fp4imul = readFP4(vector.FP4imul, ctx); + a1.copy(fp41); + a1.imul(i); + expect(a1.toString()).to.equal(fp4imul.toString()); + i++; + + // test square + var fp4sqr = readFP4(vector.FP4sqr, ctx); + a1.copy(fp41); + a1.sqr(); + expect(a1.toString()).to.equal(fp4sqr.toString()); + + // test multiplication + var fp4mul = readFP4(vector.FP4mul, ctx); + a1.copy(fp41); + a1.mul(fp42); + expect(a1.toString()).to.equal(fp4mul.toString()); + + // test power + var fp4pow = readFP4(vector.FP4pow, ctx); + var BIGsc1 = readBIG(vector.BIGsc1, ctx); + a1 = fp41.pow(BIGsc1); + expect(a1.toString()).to.equal(fp4pow.toString()); + + // test inverse + var fp4inv = readFP4(vector.FP4inv, ctx); + a1.copy(fp41); + a1.inverse(); + expect(a1.toString()).to.equal(fp4inv.toString()); + + // test multiplication by sqrt(1+sqrt(-1)) + var fp4mulj = readFP4(vector.FP4mulj, ctx); + a1.copy(fp41); + a1.times_i(); + expect(a1.toString()).to.equal(fp4mulj.toString()); + + // // test the XTR addition function r=w*x-conj(x)*y+z + var fp4xtrA = readFP4(vector.FP4xtrA, ctx); + a1.copy(fp42); + a1.xtr_A(fp41,fp4add,fp4sub); + expect(a1.toString()).to.equal(fp4xtrA.toString()); + + // test the XTR addition function r=w*x-conj(x)*y+z + var fp4xtrD = readFP4(vector.FP4xtrD, ctx); + a1.copy(fp41); + a1.xtr_D(); + expect(a1.toString()).to.equal(fp4xtrD.toString()); + + // test the XTR single power r=Tr(x^e) + var fp4xtrpow = readFP4(vector.FP4xtrpow, ctx); + var fp121 = readFP4(vector.FP121, ctx); + a1 = fp121.xtr_pow(BIGsc1); + expect(a1.toString()).to.equal(fp4xtrpow.toString()); + + // test the XTR double power r=Tr(x^e) + var fp4xtrpow2 = readFP4(vector.FP4xtrpow2, ctx); + var fp122 = readFP4(vector.FP122, ctx); + var fp123 = readFP4(vector.FP123, ctx); + var fp124 = readFP4(vector.FP124, ctx); + var BIGsc2 = readBIG(vector.BIGsc2, ctx); + a1 = fp121.xtr_pow2(fp122,fp123,fp124,BIGsc2,BIGsc1); + expect(a1.toString()).to.equal(fp4xtrpow2.toString()); + + if (ctx.ECP.AESKEY > 16) { + // Test division by 2 + var fp4div2 = readFP4(vector.FP4div2, ctx); + a1.copy(fp41); + a1.div2(); + expect(a1.toString()).to.equal(fp4div2.toString()); + + // Test division by i + var fp4divi = readFP4(vector.FP4divi, ctx); + a1.copy(fp41); + a1.div_i(); + expect(a1.toString()).to.equal(fp4divi.toString()) + + // Test division by 2i + var fp4div2i = readFP4(vector.FP4div2i, ctx); + a1.copy(fp41); + a1.div_2i(); + expect(a1.toString()).to.equal(fp4div2i.toString()) + + // Test square root + var fp4sqrt = readFP4(vector.FP4sqrt, ctx); + a1.copy(fp41); + expect(a1.sqrt()).to.equal(true); + expect(a1).to.satisfy(function(p) { + if(fp4sqrt.toString() === p.toString()) { + return true; + } else { + fp4sqrt.neg(); + } + return fp4sqrt.toString() === p.toString(); + }); + } + }); + done(); + }); + }); +}); diff --git a/test/test_FP8_js b/test/test_FP8_js index a40f2ca..f21313c 100644 --- a/test/test_FP8_js +++ b/test/test_FP8_js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test FP8 ARITHMETICS - test driver and function exerciser for FP8 API Functions */ var chai = require('chai'); diff --git a/test/test_FP_js b/test/test_FP_js index eb476f2..3ce5b5b 100644 --- a/test/test_FP_js +++ b/test/test_FP_js @@ -1,146 +1,145 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test FP ARITHMETICS - test driver and function exerciser for FP API Functions */ - -// Here we test only some curves, but those tests cover all the fields FP. - -var chai = require('chai'); - -var CTX = require("../index"); - -var expect = chai.expect; - -var fp_curves = ['ED25519', 'GOLDILOCKS', 'NIST256', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'NIST384', 'C41417', 'SECP256K1', 'NIST521', 'NUMS256W', - 'NUMS256E', 'NUMS384W', 'NUMS512W', 'BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48' -]; - -var readBIG = function(string, ctx) { - while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} - return ctx.BIG.fromBytes(Buffer.from(string, "hex")); -} - -var readFP = function(string, ctx) { - return new ctx.FP(readBIG(string, ctx)); -} -describe('TEST FP ARITHMETIC', function() { - - fp_curves.forEach(function(curve){ - - it('test '+ curve, function(done) { - this.timeout(0); - - var ctx = new CTX(curve); - - // Select appropriate field for the curve - var field = ctx.config["FIELD"]; - if (curve == 'NUMS256E') { - field = field+"E"; - } - if (curve == 'NUMS256W') { - field = field+"W"; - } - - var vectors = require('../testVectors/fp/'+field+'.json'); - - vectors.forEach(function(vector) { - - // test commutativity of addition - var fp1 = readFP(vector.FP1,ctx); - var fp2 = readFP(vector.FP2,ctx); - var fpadd = readFP(vector.FPadd,ctx); - var a1 = new ctx.FP(0); - var a2 = new ctx.FP(0); - a1.copy(fp1); - a1.add(fp2); - expect(a1.toString()).to.equal(fpadd.toString()); - a2.copy(fp2); - a2.add(fp1); - expect(a2.toString()).to.equal(fpadd.toString()); - - // test associativity of addition - a2.add(fpadd); - a1.copy(fp1); - a1.add(fpadd); - a1.add(fp2); - expect(a1.toString()).to.equal(a2.toString()); - - // test subtraction - var fpsub = readFP(vector.FPsub, ctx); - a1.copy(fp1); - a1.sub(fp2); - expect(a1.toString()).to.equal(fpsub.toString()); - - // test multiplication - var fpmul = readFP(vector.FPmulmod, ctx); - a1.copy(fp1); - a1.mul(fp2); - expect(a1.toString()).to.equal(fpmul.toString()); - - // test small multiplication - var fpimul = readFP(vector.FPsmallmul, ctx); - a2.imul(0); - expect(a2.iszilch()).to.equal(true); - for (var vi = 1; vi <= 10; vi++) { - a1.copy(fp1); - a2.copy(fp1); - a1.imul(vi); - for (var vj = 1; vj < vi; vj++) { - a2.add(fp1); - } - expect(a1.toString()).to.equal(a2.toString()); - } - expect(a1.toString()).to.equal(fpimul.toString()); - - // test square - var fpsqr = readFP(vector.FPsqr, ctx); - a1.copy(fp1); - a1.sqr(); - expect(a1.toString()).to.equal(fpsqr.toString()); - - // test negative of a FP - var fpneg = readFP(vector.FPneg, ctx); - a1.copy(fp1); - a1.neg(); - expect(a1.toString()).to.equal(fpneg.toString()); - - // test division by 2 - var fpdiv2 = readFP(vector.FPdiv2, ctx); - a1.copy(fp1); - a1.div2(); - expect(a1.toString()).to.equal(fpdiv2.toString()); - - // test inverse - var fpinv = readFP(vector.FPinv, ctx); - a1.copy(fp1); - a1.inverse(); - expect(a1.toString()).to.equal(fpinv.toString()); - - // test power - var fppow = readFP(vector.FPexp, ctx); - a1.copy(fp1); - a2 = readBIG(vector.FP2, ctx); - a1 = a1.pow(a2); - expect(a1.toString()).to.equal(fppow.toString()); - }); - done(); - }); - }); +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test FP ARITHMETICS - test driver and function exerciser for FP API Functions */ + +// Here we test only some curves, but those tests cover all the fields FP. + +var chai = require('chai'); + +var CTX = require("../index"); + +var expect = chai.expect; + +var fp_curves = ['ED25519', 'GOLDILOCKS', 'NIST256', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'NIST384', 'C41417', 'SECP256K1', 'NIST521', 'NUMS256W', + 'NUMS256E', 'NUMS384W', 'NUMS512W', 'BN254', 'BN254CX', 'BLS381', 'BLS383', 'BLS461', 'FP256BN', 'FP512BN', 'BLS24', 'BLS48' +]; + +var readBIG = function(string, ctx) { + while (string.length != ctx.BIG.MODBYTES*2){string = "00"+string;} + return ctx.BIG.fromBytes(Buffer.from(string, "hex")); +} + +var readFP = function(string, ctx) { + return new ctx.FP(readBIG(string, ctx)); +} +describe('TEST FP ARITHMETIC', function() { + + fp_curves.forEach(function(curve){ + + it('test '+ curve, function(done) { + this.timeout(0); + + var ctx = new CTX(curve); + + // Select appropriate field for the curve + var field = ctx.config["FIELD"]; + if (curve == 'NUMS256E') { + field = field+"E"; + } + if (curve == 'NUMS256W') { + field = field+"W"; + } + + var vectors = require('../testVectors/fp/'+field+'.json'); + + vectors.forEach(function(vector) { + + // test commutativity of addition + var fp1 = readFP(vector.FP1,ctx); + var fp2 = readFP(vector.FP2,ctx); + var fpadd = readFP(vector.FPadd,ctx); + var a1 = new ctx.FP(0); + var a2 = new ctx.FP(0); + a1.copy(fp1); + a1.add(fp2); + expect(a1.toString()).to.equal(fpadd.toString()); + a2.copy(fp2); + a2.add(fp1); + expect(a2.toString()).to.equal(fpadd.toString()); + + // test associativity of addition + a2.add(fpadd); + a1.copy(fp1); + a1.add(fpadd); + a1.add(fp2); + expect(a1.toString()).to.equal(a2.toString()); + + // test subtraction + var fpsub = readFP(vector.FPsub, ctx); + a1.copy(fp1); + a1.sub(fp2); + expect(a1.toString()).to.equal(fpsub.toString()); + + // test multiplication + var fpmul = readFP(vector.FPmulmod, ctx); + a1.copy(fp1); + a1.mul(fp2); + expect(a1.toString()).to.equal(fpmul.toString()); + + // test small multiplication + var fpimul = readFP(vector.FPsmallmul, ctx); + a2.imul(0); + expect(a2.iszilch()).to.equal(true); + for (var vi = 1; vi <= 10; vi++) { + a1.copy(fp1); + a2.copy(fp1); + a1.imul(vi); + for (var vj = 1; vj < vi; vj++) { + a2.add(fp1); + } + expect(a1.toString()).to.equal(a2.toString()); + } + expect(a1.toString()).to.equal(fpimul.toString()); + + // test square + var fpsqr = readFP(vector.FPsqr, ctx); + a1.copy(fp1); + a1.sqr(); + expect(a1.toString()).to.equal(fpsqr.toString()); + + // test negative of a FP + var fpneg = readFP(vector.FPneg, ctx); + a1.copy(fp1); + a1.neg(); + expect(a1.toString()).to.equal(fpneg.toString()); + + // test division by 2 + var fpdiv2 = readFP(vector.FPdiv2, ctx); + a1.copy(fp1); + a1.div2(); + expect(a1.toString()).to.equal(fpdiv2.toString()); + + // test inverse + var fpinv = readFP(vector.FPinv, ctx); + a1.copy(fp1); + a1.inverse(); + expect(a1.toString()).to.equal(fpinv.toString()); + + // test power + var fppow = readFP(vector.FPexp, ctx); + a1.copy(fp1); + a2 = readBIG(vector.FP2, ctx); + a1 = a1.pow(a2); + expect(a1.toString()).to.equal(fppow.toString()); + }); + done(); + }); + }); }); \ No newline at end of file diff --git a/test/test_GCM.js b/test/test_GCM.js index 8d00af5..472cac9 100644 --- a/test/test_GCM.js +++ b/test/test_GCM.js @@ -1,23 +1,22 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ - /* Test GCM function - test driver and function exerciser for GCM API Functions */ var CTX = require("../index"); @@ -115,4 +114,4 @@ describe('TEST GCM', function() { done(); }); -}); \ No newline at end of file +}); diff --git a/test/test_HASH.js b/test/test_HASH.js index 8b03389..b9219d7 100644 --- a/test/test_HASH.js +++ b/test/test_HASH.js @@ -1,128 +1,127 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - - -/* Test HASH function - test driver and function exerciser for SHA256, SHA384, SHA512 API Functions */ - -var CTX = require("../index"); - -var chai = require('chai'); - -var expect = chai.expect; - -var ctx = new CTX(); - - -var bytestostring = function(b) { - var s = ""; - var len = b.length; - var ch; - - for (var i = 0; i < len; i++) { - ch = b[i]; - s += ((ch >>> 4) & 15).toString(16); - s += (ch & 15).toString(16); - } - return s; -} - -var stringtobytes = function(s) { - var b = []; - for (var i = 0; i < s.length; i++) - b.push(s.charCodeAt(i)); - return b; -} - -hextobytes = function(value_hex) { - // "use strict"; - var len, byte_value, i; - - len = value_hex.length; - byte_value = []; - - for (i = 0; i < len; i += 2) { - byte_value[(i / 2)] = parseInt(value_hex.substr(i, 2), 16); - } - return byte_value; -}; - -var hashit = function(sha, B) { - var R = []; - - if (sha == ctx.HASH256.len) { - var H = new ctx.HASH256(); - H.process_array(B); - R = H.hash(); - } - else if (sha == ctx.HASH384.len) { - var H = new ctx.HASH384(); - H.process_array(B); - R = H.hash(); - } - else if (sha == ctx.HASH512.len) { - var H = new ctx.HASH512(); - H.process_array(B); - R = H.hash(); - } - if (R.length == 0) return null; - return R; -} - -describe('TEST HASH', function() { - - it('test SHA256', function(done) { - this.timeout(0); - - var vectors = require('../testVectors/sha/SHA256.json'); - var dig; - - for (var vector in vectors) { - dig = hashit(ctx.HASH256.len, hextobytes(vectors[vector].IN)); - expect(bytestostring(dig)).to.be.equal(vectors[vector].OUT); - } - done(); - }); - - it('test SHA384', function(done) { - this.timeout(0); - - var vectors = require('../testVectors/sha/SHA384.json'); - var dig; - - for (var vector in vectors) { - dig = hashit(ctx.HASH384.len, hextobytes(vectors[vector].IN)); - expect(bytestostring(dig)).to.be.equal(vectors[vector].OUT); - } - done(); - }); - - it('test SHA512', function(done) { - this.timeout(0); - - var vectors = require('../testVectors/sha/SHA512.json'); - var dig; - - for (var vector in vectors) { - dig = hashit(ctx.HASH512.len, hextobytes(vectors[vector].IN)); - expect(bytestostring(dig)).to.be.equal(vectors[vector].OUT); - } - done(); - }); - -}); \ No newline at end of file +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* Test HASH function - test driver and function exerciser for SHA256, SHA384, SHA512 API Functions */ + +var CTX = require("../index"); + +var chai = require('chai'); + +var expect = chai.expect; + +var ctx = new CTX(); + + +var bytestostring = function(b) { + var s = ""; + var len = b.length; + var ch; + + for (var i = 0; i < len; i++) { + ch = b[i]; + s += ((ch >>> 4) & 15).toString(16); + s += (ch & 15).toString(16); + } + return s; +} + +var stringtobytes = function(s) { + var b = []; + for (var i = 0; i < s.length; i++) + b.push(s.charCodeAt(i)); + return b; +} + +hextobytes = function(value_hex) { + // "use strict"; + var len, byte_value, i; + + len = value_hex.length; + byte_value = []; + + for (i = 0; i < len; i += 2) { + byte_value[(i / 2)] = parseInt(value_hex.substr(i, 2), 16); + } + return byte_value; +}; + +var hashit = function(sha, B) { + var R = []; + + if (sha == ctx.HASH256.len) { + var H = new ctx.HASH256(); + H.process_array(B); + R = H.hash(); + } + else if (sha == ctx.HASH384.len) { + var H = new ctx.HASH384(); + H.process_array(B); + R = H.hash(); + } + else if (sha == ctx.HASH512.len) { + var H = new ctx.HASH512(); + H.process_array(B); + R = H.hash(); + } + if (R.length == 0) return null; + return R; +} + +describe('TEST HASH', function() { + + it('test SHA256', function(done) { + this.timeout(0); + + var vectors = require('../testVectors/sha/SHA256.json'); + var dig; + + for (var vector in vectors) { + dig = hashit(ctx.HASH256.len, hextobytes(vectors[vector].IN)); + expect(bytestostring(dig)).to.be.equal(vectors[vector].OUT); + } + done(); + }); + + it('test SHA384', function(done) { + this.timeout(0); + + var vectors = require('../testVectors/sha/SHA384.json'); + var dig; + + for (var vector in vectors) { + dig = hashit(ctx.HASH384.len, hextobytes(vectors[vector].IN)); + expect(bytestostring(dig)).to.be.equal(vectors[vector].OUT); + } + done(); + }); + + it('test SHA512', function(done) { + this.timeout(0); + + var vectors = require('../testVectors/sha/SHA512.json'); + var dig; + + for (var vector in vectors) { + dig = hashit(ctx.HASH512.len, hextobytes(vectors[vector].IN)); + expect(bytestostring(dig)).to.be.equal(vectors[vector].OUT); + } + done(); + }); + +}); diff --git a/test/test_MPIN.js b/test/test_MPIN.js index 308474c..164d9dc 100644 --- a/test/test_MPIN.js +++ b/test/test_MPIN.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test MPIN - test driver and function exerciser for MPIN API Functions */ diff --git a/test/test_PAIR.js b/test/test_PAIR.js index b56c187..d194750 100644 --- a/test/test_PAIR.js +++ b/test/test_PAIR.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test MPIN - test driver and function exerciser for MPIN API Functions */ diff --git a/test/test_RSA2048.js b/test/test_RSA2048.js index 27aab32..af1ba9a 100644 --- a/test/test_RSA2048.js +++ b/test/test_RSA2048.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -'License'); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test RSA - test driver and function exerciser for RSA API Functions */ diff --git a/test/test_RSA3072.js b/test/test_RSA3072.js index 5e96e21..b35b0d5 100644 --- a/test/test_RSA3072.js +++ b/test/test_RSA3072.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -'License'); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test RSA - test driver and function exerciser for RSA API Functions */ diff --git a/test/test_RSA4096.js b/test/test_RSA4096.js index add8fd1..4869abf 100644 --- a/test/test_RSA4096.js +++ b/test/test_RSA4096.js @@ -1,20 +1,20 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -'License'); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. */ /* Test RSA - test driver and function exerciser for RSA API Functions */
