From 9f4bc590cfe4767e9681284070c289107118c645 Mon Sep 17 00:00:00 2001 From: qd-qd Date: Wed, 18 Oct 2023 09:58:16 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=B7=20fix=20forge=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/webauthn-forge.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/webauthn-forge.yml b/.github/workflows/webauthn-forge.yml index 12b44cd4..fe882505 100644 --- a/.github/workflows/webauthn-forge.yml +++ b/.github/workflows/webauthn-forge.yml @@ -11,7 +11,7 @@ on: - master # This action will only run on pull requests that include changes to the following files paths: - - "tests/WebAuthn_forge/**/*" + - "solidity/**/*" - "sage/FCL_ecdsa_precompute/FCL_ecdsa_precompute.sage" env: @@ -64,16 +64,14 @@ jobs: version: nightly - name: Run Forge build - working-directory: tests/WebAuthn_forge run: | forge --version - forge build --sizes + forge build --root solidity/tests/WebAuthn_forge --sizes id: build - name: Run Forge tests - working-directory: tests/WebAuthn_forge run: | - forge test -vvvv --ffi + forge test --root solidity/tests/WebAuthn_forge -vvvv --ffi id: test lint: @@ -93,14 +91,12 @@ jobs: version: nightly - name: Run Forge build - working-directory: tests/WebAuthn_forge run: | forge --version - forge build --sizes + forge build --root solidity/tests/WebAuthn_forge --sizes id: build - name: Run Forge fmt - working-directory: tests/WebAuthn_forge run: | - forge fmt --check + forge fmt --check --root solidity/tests/WebAuthn_forge id: lint From 38eeece844ef439e82375bc05a705887518b96da Mon Sep 17 00:00:00 2001 From: qd-qd Date: Wed, 18 Oct 2023 10:16:54 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20fix=20linter=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/WebAuthn_forge/test/FCL_ecdsa.t.sol | 3 --- .../tests/WebAuthn_forge/test/FCL_elliptic.t.sol | 16 +++++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/solidity/tests/WebAuthn_forge/test/FCL_ecdsa.t.sol b/solidity/tests/WebAuthn_forge/test/FCL_ecdsa.t.sol index 8bd07af9..89f5deb8 100644 --- a/solidity/tests/WebAuthn_forge/test/FCL_ecdsa.t.sol +++ b/solidity/tests/WebAuthn_forge/test/FCL_ecdsa.t.sol @@ -30,9 +30,6 @@ import "@external/ECops.sol"; //echo "itsakindofmagic" | sha256sum, used as a label to find precomputations inside bytecode uint256 constant _MAGIC_ENCODING = 0x9a8295d6f225e4f07313e2e1440ab76e26d4c6ed2d1eb4cbaa84827c8b7caa8d; - - - // library elliptic solidity from orbs network contract wrap_ecdsa_orbs { uint256 constant gx = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296; diff --git a/solidity/tests/WebAuthn_forge/test/FCL_elliptic.t.sol b/solidity/tests/WebAuthn_forge/test/FCL_elliptic.t.sol index e89001c6..bdbfda88 100644 --- a/solidity/tests/WebAuthn_forge/test/FCL_elliptic.t.sol +++ b/solidity/tests/WebAuthn_forge/test/FCL_elliptic.t.sol @@ -168,28 +168,26 @@ contract ArithmeticTest is Test { assertEq(radd, raddN); } - function test_Fuzz_SigVerif(uint256 k, uint256 kpriv, uint256 message) public - { + function test_Fuzz_SigVerif(uint256 k, uint256 kpriv, uint256 message) public { vm.assume(k < FCL_Elliptic_ZZ.n); vm.assume(k > 1); vm.assume(kpriv < FCL_Elliptic_ZZ.n); vm.assume(kpriv > 1); - + vm.assume(message < FCL_Elliptic_ZZ.n); vm.assume(message > 1); - uint256 xpub=FCL_Elliptic_ZZ.ecZZ_mulmuladd_S_asm(0,0, kpriv, 0); //deriv public key + uint256 xpub = FCL_Elliptic_ZZ.ecZZ_mulmuladd_S_asm(0, 0, kpriv, 0); //deriv public key uint256 ypub = FCL_Elliptic_ZZ.ec_Decompress(xpub, 0); uint256 r; uint256 s; assertEq(FCL_Elliptic_ZZ.ecAff_isOnCurve(xpub, ypub), true); - (r,s)= FCL_Elliptic_ZZ.ecdsa_sign(bytes32(message), k, kpriv); - + (r, s) = FCL_Elliptic_ZZ.ecdsa_sign(bytes32(message), k, kpriv); - bool res1=FCL_Elliptic_ZZ.ecdsa_verify(bytes32(message), r,s, xpub, ypub); - bool res2=FCL_Elliptic_ZZ.ecdsa_verify(bytes32(message), r,s, xpub, p-ypub); - bool res=res1||res2; + bool res1 = FCL_Elliptic_ZZ.ecdsa_verify(bytes32(message), r, s, xpub, ypub); + bool res2 = FCL_Elliptic_ZZ.ecdsa_verify(bytes32(message), r, s, xpub, p - ypub); + bool res = res1 || res2; assertEq(res, true); }