Skip to content

Commit 1f6ff3d

Browse files
KyrylRArvolear
andauthored
Fix PRSASHAAuthenticator auth (#40)
* Verifiers (v0.1.8) * Added Z_PER_PASSPORT_1_256_3_4_600_248_1_1496_3_256 import * Add more verifiers * Fix verifiers * Added rarimo-l2-testnet network * Added more verifiers * Fixed PRSASHAAuthenticator auth * Prettified assembly * Updated deployment scripts * removed duplication * fixed naming --------- Co-authored-by: Artem Chystiakov <artem.ch31@gmail.com>
1 parent 654766f commit 1f6ff3d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

contracts/passport/authenticators/PRSASHAAuthenticator.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ contract PRSASHAAuthenticator is Initializable {
2424
* @notice Checks active authentication of a passport. The RSA algorithm is as follows:
2525
*
2626
* 1. Decrypt the signature
27-
* 2. Remove the 1 byte (hash function indicator) suffix
27+
* 2. Remove the 1 byte or 2 bytes (hash function indicator) suffix
2828
* 3. The last 20 bytes of the decrypted signature is the SHA1 hash of random + challenge or the last 32 bytes in case SHA2 hash
2929
*/
3030
function authenticate(
@@ -41,7 +41,8 @@ contract PRSASHAAuthenticator is Initializable {
4141
bytes memory decipher_ = s_.decrypt(e_, n_);
4242

4343
assembly {
44-
mstore(decipher_, sub(mload(decipher_), 1))
44+
let suffixLen_ := add(1, iszero(sload(isSha1.slot)))
45+
mstore(decipher_, sub(mload(decipher_), suffixLen_))
4546
}
4647

4748
bytes memory prepared_ = new bytes(decipher_.length - hashLen - 1);

hardhat.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,15 @@ const config: HardhatUserConfig = {
101101
chainId: 7368,
102102
urls: {
103103
apiURL: "https://evmscan.l2.rarimo.com/api",
104-
browserURL: "https://newscan.l2.rarimo.com/",
104+
browserURL: "https://scan.rarimo.com/",
105+
},
106+
},
107+
{
108+
network: "rarimo-l2-testnet",
109+
chainId: 7369,
110+
urls: {
111+
apiURL: "https://scan.testnet.rarimo.com/api",
112+
browserURL: "https://scan.testnet.rarimo.com",
105113
},
106114
},
107115
{

0 commit comments

Comments
 (0)