-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: auth validity verification when impersoanting, pub keys where used
everytime
- Loading branch information
Showing
5 changed files
with
207 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import "../libs/sismo-connect/SismoConnectLib.sol"; | ||
|
||
contract CheatSheet is SismoConnect { | ||
// reference your appId | ||
bytes16 public constant APP_ID = 0x32403ced4b65f2079eda77c84e7d2be6; | ||
// allow impersonation | ||
bool public constant IS_IMPERSONATION_MODE = true; | ||
|
||
constructor() | ||
// use buildConfig helper to easily build a Sismo Connect config in Solidity | ||
SismoConnect(buildConfig({appId: APP_ID, isImpersonationMode: IS_IMPERSONATION_MODE})) | ||
{} | ||
|
||
function verifySismoConnectResponse(bytes memory response) public { | ||
// Recreate the request made in the fontend to verify the proof | ||
AuthRequest[] memory auths = new AuthRequest[](6); | ||
auths[0] = _authRequestBuilder.build({authType: AuthType.VAULT}); | ||
auths[1] = _authRequestBuilder.build({authType: AuthType.EVM_ACCOUNT}); | ||
auths[2] = _authRequestBuilder.build({ | ||
authType: AuthType.EVM_ACCOUNT, | ||
userId: uint160(0xA4C94A6091545e40fc9c3E0982AEc8942E282F38) | ||
}); | ||
auths[3] = _authRequestBuilder.build({authType: AuthType.GITHUB}); | ||
auths[4] = _authRequestBuilder.build({ | ||
authType: AuthType.TWITTER, | ||
userId: 295218901, | ||
isOptional: true, | ||
isSelectableByUser: false | ||
}); | ||
auths[5] = _authRequestBuilder.build({ | ||
authType: AuthType.TELEGRAM, | ||
userId: 875608110, | ||
isOptional: true, | ||
isSelectableByUser: false | ||
}); | ||
|
||
ClaimRequest[] memory claims = new ClaimRequest[](6); | ||
claims[0] = _claimRequestBuilder.build({groupId: 0xfae674b6cba3ff2f8ce2114defb200b1}); | ||
claims[1] = _claimRequestBuilder.build({ | ||
groupId: 0x1cde61966decb8600dfd0749bd371f12, | ||
claimType: ClaimType.GTE, | ||
value: 15 | ||
}); | ||
claims[2] = _claimRequestBuilder.build({ | ||
groupId: 0xfae674b6cba3ff2f8ce2114defb200b1, | ||
claimType: ClaimType.EQ, | ||
value: 10 | ||
}); | ||
claims[3] = _claimRequestBuilder.build({ | ||
groupId: 0x1cde61966decb8600dfd0749bd371f12, | ||
claimType: ClaimType.EQ, | ||
value: 15, | ||
isSelectableByUser: true, | ||
isOptional: true | ||
}); | ||
claims[4] = _claimRequestBuilder.build({ | ||
groupId: 0xfae674b6cba3ff2f8ce2114defb200b1, | ||
claimType: ClaimType.GTE, | ||
isSelectableByUser: true, | ||
isOptional: true | ||
}); | ||
claims[5] = _claimRequestBuilder.build({ | ||
groupId: 0x1cde61966decb8600dfd0749bd371f12, | ||
claimType: ClaimType.GTE, | ||
value: 25, | ||
isSelectableByUser: true, | ||
isOptional: false | ||
}); | ||
|
||
SismoConnectVerifiedResult memory result = verify({ | ||
responseBytes: response, | ||
auths: auths, | ||
claims: claims, | ||
signature: _signatureBuilder.build({message: abi.encode("I love Sismo!")}) | ||
}); | ||
|
||
// implement some logic if the proof is successful | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.