Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple SPDX removal for flattening bug+ harmonization of solc versions #31

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ The implemented content is:


### Directory solidity:
* FCL_elliptic.sol: an EVM optimized implementation of sec256r1(P256), using language hacks and specificities, as described in paper https://eprint.iacr.org/2023/939.pdf.

* FCL_ecdsa.sol: an EVM optimized implementation of ecdsa over sec256r1(P256), using language hacks and specificities, as described in paper https://eprint.iacr.org/2023/939.pdf.
* FCL_eddsa.sol : an EVM optimized implementation of ed25519, using same paper tricks.
* FCL_sha512.sol : implementation of the SHA512 primitive (single bloc implementation)
* FLC_Webauthn.sol: implementation of the WebAuthn2/FIDO2 authentication over ECDSA with P256
<!--- FCL_ecdaa.sol: an EVM version of the ECDAA anonymous attestation for anonymous airdrops -->

### Directory cairo0.9:

* FCL_ec_mulmuladd.cairo: an implementation of the operation aP+bQ (addition of the results of two distincts point multiplication by scalar a and b). It uses the Shamir's trick with the windowing method.
signature_opt.cairo : optimisation of ECDSA verification using ec_mulmuladd_W function

Expand Down
2 changes: 1 addition & 1 deletion solidity/external/ECCMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

/**
* @title ECCMath
Expand Down
2 changes: 1 addition & 1 deletion solidity/external/ECops.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

// Orbs implementation
library ECops {
Expand Down
2 changes: 1 addition & 1 deletion solidity/external/Numerology.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

/// @title Numerology: A Solidity library for fast ECC arithmetics using curve secp256k1
/// @author David Nuñez ([email protected])
Expand Down
2 changes: 1 addition & 1 deletion solidity/external/Secp256k1.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "./ECCMath.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/external/Secp256r1.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;
//
// Heavily inspired from
// https://github.com/maxrobot/elliptic-solidity/blob/master/contracts/Secp256r1.sol
Expand Down
2 changes: 1 addition & 1 deletion solidity/external/Secp256r1_maxrobot.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

library Secp256r1_maxrobot {
uint256 constant gx = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296;
Expand Down
4 changes: 2 additions & 2 deletions solidity/src/FCL_Webauthn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//* WARNING: this code SHALL not be used for non prime order curves for security reasons.
// Code is optimized for a=-3 only curves with prime order, constant like -1, -2 shall be replaced
// if ever used for other curve than sec256R1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

import {Base64Url} from "./utils/Base64Url.sol";
import {FCL_Elliptic_ZZ} from "./FCL_elliptic.sol";
Expand Down
6 changes: 3 additions & 3 deletions solidity/src/FCL_ecdsa.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
//* WARNING: this code SHALL not be used for non prime order curves for security reasons.
// Code is optimized for a=-3 only curves with prime order, constant like -1, -2 shall be replaced
// if ever used for other curve than sec256R1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;


import {FCL_Elliptic_ZZ} from "./FCL_elliptic.sol";
Expand Down Expand Up @@ -122,4 +122,4 @@ library FCL_ecdsa {

}

}
}
2 changes: 1 addition & 1 deletion solidity/src/FCL_ed25519.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///* optimization
///*
//**************************************************************************************/
// SPDX-License-Identifier: MIT
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

// prime field modulus of the ed25519 curve
Expand Down
2 changes: 1 addition & 1 deletion solidity/src/FCL_eddsa.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
///* DESCRIPTION: Implementation of RFC8032 using FCL Shamir's trick
///*
//**************************************************************************************/
// SPDX-License-Identifier: MIT
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

//import "./FCL_ed25519.sol" as Curve;
Expand Down
2 changes: 1 addition & 1 deletion solidity/src/FCL_edwards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
///* DESCRIPTION: Implementation of RFC8032 using FCL Shamir's trick
///*
//**************************************************************************************/
// SPDX-License-Identifier: MIT
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

import "./FCL_ed25519.sol" as Curve;
Expand Down
4 changes: 2 additions & 2 deletions solidity/src/FCL_elliptic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
//* WARNING: this code SHALL not be used for non prime order curves for security reasons.
// Code is optimized for a=-3 only curves with prime order, constant like -1, -2 shall be replaced
// if ever used for other curve than sec256R1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

library FCL_Elliptic_ZZ {
// Set parameters for curve sec256r1.
Expand Down
4 changes: 2 additions & 2 deletions solidity/src/FCL_sha512.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//**************************************************************************************/
//Initialize hash values:
//(first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):

pragma solidity ^0.8.20;
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

library sha512 {
uint256 constant SHA512_BLOCK_LENGTH8 = 128;
Expand Down
1 change: 1 addition & 0 deletions solidity/src/fcl_ecdsa_precbytecode.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pragma solidity >=0.8.19 <0.9.0;
// Public key
//x:fdf8bce27f54e06f3aee3b6a542db1ab1f2418d7370a78b150d06965f942b14a y:470cdee69ab50e610c39b840681bf816b030f4a0a5d5af02ce27dcce6bede89f
bytes constant x =
Expand Down
2 changes: 2 additions & 0 deletions solidity/tests/WebAuthn_forge/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
src = "src"
out = "out"
libs = ["lib"]
solc = "0.8.19"

optimizer = true
optimizer_runs = 1000000
allow_paths = ["../../../solidity"]
Expand Down
20 changes: 20 additions & 0 deletions solidity/tests/WebAuthn_forge/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,23 @@ lint-write: forge-lint
clean: forge-clean

install: git-submodule-update

# ℹ️ RUN THIS SCRIPT USING A LEDGER:
# forge script DeployElliptic.s.sol:MyScript --rpc-url <RPC_URL> --ledger --sender <ACCOUNT_ADDRESS> \
# [--broadcast]

# ℹ️ RUN THIS SCRIPT WITH AN ARBITRARY PRIVATE KEY (NOT RECOMMENDED):
# PRIVATE_KEY=<PRIVATE_KEY> forge script DeployElliptic.s.sol:MyScript --rpc-url <RPC_URL> [--broadcast]
https://ethereum-holesky.publicnode.com

#deploy: forge script DeployElliptic.s.sol:MyScript --rpc-url https://ethereum-sepolia.blockpi.network/v1/rpc/public --private-key b3619b5eb554ae89e6c53ca7d4d1c4dee671a96d16c0a20e597e194609cc2cc2
deploy:
forge script script/DeployElliptic.s.sol:MyScript --rpc-url https://ethereum-sepolia.blockpi.network/v1/rpc/public --private-key b3619b5eb554ae89e6c53ca7d4d1c4dee671a96d16c0a20e597e194609cc2cc2 --etherscan-api-key HURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5X --verify

#verify: forge verify-contract --rpc-url https://ethereum-holesky.publicnode.com --etherscan-api-key HURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5XHURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5X 0x1695C55D8bFd9C9035a9197191448381e38d1bF9 DeployElliptic.s.sol:LibraryWrapper


#forge verify-contract --etherscan-api-key HURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5XHURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5X --chain holesky --force 0x1695C55D8bFd9C9035a9197191448381e38d1bF9 DeployElliptic.s.sol:LibraryWrapper
forge verify-contract --etherscan-api-key HURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5XHURV4UYJZCCUTXEYM73M6J6CIJE1KN1W5X --chain sepolia --flatten --force 0x3c548295a71383976318819599937fC3daC75289 script/DeployElliptic.s.sol:LibraryWrapper --watch


2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/script/BaseScript.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// License:MIT, SPDX Identifier is removed because it breaks with the flatten command.
pragma solidity >=0.8.19 <0.9.0;

import {Script} from "../lib/forge-std/src/Script.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/FCL_Webauthn.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";
//FreshCryptoLib implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma solidity >=0.8.19 <0.9.0;

import {Test, console2} from "forge-std/Test.sol";
import {FCL_WebAuthn} from "@solidity/FCL_Webauthn.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/FCL_ecdsa.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///*
//**************************************************************************************/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";
import "@solidity/FCL_elliptic.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/FCL_eddsa.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///*
//**************************************************************************************/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/FCL_edwards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///*
//**************************************************************************************/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/FCL_elliptic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
///* DESCRIPTION: test file for elliptic primitives
///*
//**************************************************************************************/
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";
import "@solidity/FCL_elliptic.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/FCL_sha512.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///*
//**************************************************************************************/

pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";
import "@solidity/FCL_sha512.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/bench_androlo.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/tests/WebAuthn_forge/test/bench_numerology.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.20;
pragma solidity >=0.8.19 <0.9.0;

import "forge-std/Test.sol";
import "@external/Numerology.sol";
Expand Down
Loading