Skip to content
Open
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
420 changes: 0 additions & 420 deletions contracts/EllipticCurve.sol

This file was deleted.

1,617 changes: 1,617 additions & 0 deletions contracts/Elliptic_ZZ.sol

Large diffs are not rendered by default.

558 changes: 558 additions & 0 deletions contracts/FCL_elliptic.sol

Large diffs are not rendered by default.

35 changes: 29 additions & 6 deletions contracts/Webauthn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@
pragma solidity ^0.8.0;

import {Base64URL} from "./Base64URL.sol";
import {EllipticCurve} from "./EllipticCurve.sol";
import {FCL_Elliptic_ZZ} from "./FCL_elliptic.sol";
import "hardhat/console.sol";



error InvalidAuthenticatorData();
error InvalidClientData();
error InvalidSignature();

contract Webauthn {
uint256 public counter;


function ecdsa_verif( bytes32 hash, uint[2] memory rs,
uint[2] memory Q) public returns (bool)
{
// bytes32 message = sha256(verifyData);
console.log("hash=", uint(hash));
console.log("rs0=", rs[0]);

bool result=FCL_Elliptic_ZZ.ecdsa_verify(bytes32(hash), rs, Q);
console.log("result= %s", result);

}

function checkSignature(
bytes memory authenticatorData,
bytes1 authenticatorDataFlagMask,
Expand All @@ -20,7 +35,7 @@ contract Webauthn {
uint clientChallengeDataOffset,
uint[2] memory rs,
uint[2] memory Q
) public view returns (bool) {
) public returns (bool) {
// Let the caller check if User Presence (0x01) or User Verification (0x04) are set
if (
(authenticatorData[32] & authenticatorDataFlagMask) !=
Expand Down Expand Up @@ -64,10 +79,21 @@ contract Webauthn {
verifyData,
authenticatorData.length
);

/*
uint8 tmp=verifyData[0];
console.log("verifyData:", tmp);
*/
bytes32 message = sha256(verifyData);
return EllipticCurve.validateSignature(message, rs, Q);
//bool result=Ec_ZZ.validateSignature(message, rs, Q);
bool result=FCL_Elliptic_ZZ.ecdsa_verify(message, rs, Q);
console.log("result= %s", result);

return result;
}



function validate(
bytes memory authenticatorData,
bytes1 authenticatorDataFlagMask,
Expand All @@ -93,9 +119,6 @@ contract Webauthn {
counter++;
}

/*
The following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license
*/
function copyBytes(
bytes memory _from,
uint _fromOffset,
Expand Down
Loading