Skip to content

Commit

Permalink
Merge with official b2e2 github repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsgde committed Apr 2, 2024
2 parents 4d2e1e2 + 80aedd2 commit b467bf9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The latest version of the sequence and entity relationship diagrams from the whi
Make sure that your node JS version is 16.17.1 because some of the dependencies do not work with newer versions.

## Cloning the repository
git clone --recursive <<todo: official github repo URL>>
git clone --recursive https://github.com/B2E2/b2e2_contracts.git

## Installing Dependencies
sudo npm global add truffle ganache ganache-cli
Expand Down
12 changes: 8 additions & 4 deletions contracts/ClaimVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "./ClaimCommons.sol";
library ClaimVerifier {
// Constants ERC-735
uint256 constant public ECDSA_SCHEME = 1;
uint256 constant public PREFIXED_ECDSA_SCHEME = 2;

// JSON parsing constants.
uint256 constant MAX_NUMBER_OF_JSON_FIELDS = 20;
Expand Down Expand Up @@ -325,10 +326,10 @@ library ClaimVerifier {

function verifySignature(address _subject, uint256 _topic, uint256 _scheme, address _issuer, bytes memory _signature, bytes memory _data) public view returns (bool __valid) {
// Check for currently unsupported signature.
if(_scheme != ECDSA_SCHEME)
if(_scheme != ECDSA_SCHEME && _scheme != PREFIXED_ECDSA_SCHEME)
return false;

address signer = getSignerAddress(claimAttributes2SigningFormat(_subject, _topic, _data), _signature);
address signer = getSignerAddress(claimAttributes2SigningFormat(_scheme, _subject, _topic, _data), _signature);

if(isContract(_issuer)) {
return signer == IdentityContract(_issuer).owner();
Expand Down Expand Up @@ -400,8 +401,11 @@ library ClaimVerifier {
return getInt256Field(_fieldName, _data) <= JsmnSolLib.parseInt(_fieldContent);
}

function claimAttributes2SigningFormat(address _subject, uint256 _topic, bytes memory _data) internal pure returns (bytes32 __claimInSigningFormat) {
return keccak256(abi.encodePacked(_subject, _topic, _data));
function claimAttributes2SigningFormat(uint256 _scheme, address _subject, uint256 _topic, bytes memory _data) internal pure returns (bytes32 __claimInSigningFormat) {
if(_scheme == ECDSA_SCHEME)
return keccak256(abi.encodePacked(_subject, _topic, _data));
else
return ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked(_subject, _topic, _data)));
}

function getSignerAddress(bytes32 _claimInSigningFormat, bytes memory _signature) internal pure returns (address __signer) {
Expand Down

0 comments on commit b467bf9

Please sign in to comment.