-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init stack & big int * fix * basic impl * adjustments * fix * refactored & sub * added mul * added moddiv modinv * typos * fix * bigint - optimized * weird stuff * fix mload * 17mil 10 iterations * Quick adjustment * added u384 * Add test * all its * 26.8kk 512 its!!!!! * 44kk 768 its! * 512 its 70kk right answers!!! * added eq fns * 38.1kk * 38kk * 34.8kk shl1 * 32.9kk * ez 26.5kk can be even less if using references * 24kk readable * 23kk * 21.6kk * small * 21.38kk * cleaned up repo * rm stack mock * fixes * fix * fixed test * mv ecdsa to certificates * cleaned up * rm logs * cleaned up cfg * rollback changes * rm bn lib ts * added ecdsa dispatcher * pretty --------- Co-authored-by: dovgopoly <[email protected]> Co-authored-by: joYyHack <[email protected]>
- Loading branch information
1 parent
e129601
commit 4bcfb1e
Showing
18 changed files
with
1,453 additions
and
68 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
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,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.16; | ||
|
||
import {AbstractCDispatcher} from "./abstract/AbstractCDispatcher.sol"; | ||
|
||
import {Bytes2Poseidon} from "../../utils/Bytes2Poseidon.sol"; | ||
|
||
contract CECDSADispatcher is AbstractCDispatcher { | ||
using Bytes2Poseidon for bytes; | ||
|
||
function __CECDSADispatcher_init( | ||
address signer_, | ||
uint256 keyByteLength_, | ||
bytes calldata keyCheckPrefix_ | ||
) external initializer { | ||
__AbstractCDispatcher_init(signer_, keyByteLength_, keyCheckPrefix_); | ||
} | ||
|
||
function getCertificateKey( | ||
bytes memory certificatePublicKey_ | ||
) external pure override returns (uint256 keyHash_) { | ||
return certificatePublicKey_.hash512(); | ||
} | ||
} |
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
73 changes: 73 additions & 0 deletions
73
contracts/certificate/dispatchers/abstract/AbstractCDispatcher.sol
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,73 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.16; | ||
|
||
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
import {ICertificateDispatcher} from "../../../interfaces/dispatchers/ICertificateDispatcher.sol"; | ||
import {ICertificateSigner} from "../../../interfaces/signers/ICertificateSigner.sol"; | ||
|
||
import {X509} from "../../../utils/X509.sol"; | ||
|
||
abstract contract AbstractCDispatcher is ICertificateDispatcher, Initializable { | ||
using X509 for bytes; | ||
|
||
uint256 public keyByteLength; | ||
bytes public keyCheckPrefix; | ||
|
||
address public signer; | ||
|
||
function __AbstractCDispatcher_init( | ||
address signer_, | ||
uint256 keyByteLength_, | ||
bytes calldata keyCheckPrefix_ | ||
) internal onlyInitializing { | ||
signer = signer_; | ||
keyByteLength = keyByteLength_; | ||
keyCheckPrefix = keyCheckPrefix_; | ||
} | ||
|
||
/** | ||
* @notice Verifies the ICAO master signature over certificate's signed attributes | ||
*/ | ||
function verifyICAOSignature( | ||
bytes memory x509SignedAttributes_, | ||
bytes memory icaoMemberSignature_, | ||
bytes memory icaoMemberKey_ | ||
) external view override returns (bool) { | ||
return | ||
ICertificateSigner(signer).verifyICAOSignature( | ||
x509SignedAttributes_, | ||
icaoMemberSignature_, | ||
icaoMemberKey_ | ||
); | ||
} | ||
|
||
/** | ||
* @notice Extracts the certificate's expiration timestamp from its signed attributes | ||
*/ | ||
function getCertificateExpirationTimestamp( | ||
bytes memory x509SignedAttributes_, | ||
uint256 byteOffset_ | ||
) external pure override returns (uint256) { | ||
return x509SignedAttributes_.extractExpirationTimestamp(byteOffset_); | ||
} | ||
|
||
/** | ||
* @notice Extracts the certificate's public key from its signed attributes | ||
*/ | ||
function getCertificatePublicKey( | ||
bytes memory x509SignedAttributes_, | ||
uint256 byteOffset_ | ||
) external view override returns (bytes memory) { | ||
return x509SignedAttributes_.extractPublicKey(keyCheckPrefix, byteOffset_, keyByteLength); | ||
} | ||
|
||
/** | ||
* @notice Poseidon5 hash of the `x509KeyByteLength` long RSA X509 key. | ||
* | ||
* See X509 library for more information | ||
*/ | ||
function getCertificateKey( | ||
bytes memory certificatePublicKey_ | ||
) external pure virtual override returns (uint256 keyHash_); | ||
} |
Oops, something went wrong.