Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV-3553 #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
[submodule "lib/automata-on-chain-pccs"]
path = lib/automata-on-chain-pccs
url = https://github.com/automata-network/automata-on-chain-pccs
branch = DEV-3553
26 changes: 23 additions & 3 deletions contracts/PCCSRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,13 @@ contract PCCSRouter is IPCCSRouter, Ownable {
valid = data.length > 0;
if (valid) {
bytes memory encodedLevels;
(tcbInfo, tdxModule, tdxModuleIdentities, encodedLevels,,) =
abi.decode(data, (TcbInfoBasic, TDXModule, TDXModuleIdentity[], bytes, string, bytes));
bytes memory encodedTdxModuleIdentities;
(tcbInfo, tdxModule, encodedTdxModuleIdentities, encodedLevels,,) =
abi.decode(data, (TcbInfoBasic, TDXModule, bytes, bytes, string, bytes));
tcbLevelsV3 = _decodeTcbLevels(encodedLevels);
if (encodedTdxModuleIdentities.length > 0) {
tdxModuleIdentities = _decodeTdxModuleIdentities(encodedTdxModuleIdentities);
}
} else {
revert FmspcTcbNotFound(id, 3);
}
Expand Down Expand Up @@ -210,8 +214,24 @@ contract PCCSRouter is IPCCSRouter, Ownable {
bytes[] memory encodedTcbLevelsArr = abi.decode(encodedTcbLevels, (bytes[]));
uint256 n = encodedTcbLevelsArr.length;
tcbLevels = new TCBLevelsObj[](n);
for (uint256 i = 0; i < n; i++) {
for (uint256 i = 0; i < n; ) {
tcbLevels[i] = fmspcTcbHelper.tcbLevelsObjFromBytes(encodedTcbLevelsArr[i]);
unchecked {
i++;
}
}
}

function _decodeTdxModuleIdentities(bytes memory encodedTdxModuleIdentities) private view returns (TDXModuleIdentity[] memory tdxModuleIdentities) {
FmspcTcbHelper fmspcTcbHelper = FmspcTcbHelper(fmspcTcbHelperAddr);
bytes[] memory encodedTdxModuleIdentitiesArr = abi.decode(encodedTdxModuleIdentities, (bytes[]));
uint256 n = encodedTdxModuleIdentitiesArr.length;
tdxModuleIdentities = new TDXModuleIdentity[](n);
for (uint256 i = 0; i < n; ) {
tdxModuleIdentities[i] = fmspcTcbHelper.tdxModuleIdentityFromBytes(encodedTdxModuleIdentitiesArr[i]);
unchecked {
i++;
}
}
}

Expand Down
Loading