Skip to content
This repository was archived by the owner on Apr 25, 2026. It is now read-only.
Merged
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion forge/lib/tnt-core
97 changes: 3 additions & 94 deletions forge/src/cggmp21/CGGMP21Blueprint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pragma solidity >=0.8.3;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "core/BlueprintServiceManager.sol";
import "core/BlueprintServiceManagerBase.sol";

contract CGGMP21Blueprint is BlueprintServiceManager {
contract CGGMP21Blueprint is BlueprintServiceManagerBase {
/// A Simple List of all Operator Ecdsa Public Keys
struct Operator {
address addr;
Expand Down Expand Up @@ -76,7 +76,7 @@ contract CGGMP21Blueprint is BlueprintServiceManager {
// Job 0 is the Keygen Job
if (job == KEYGEN_JOB) {
// The inputs are the DKG threshold
(uint8 t) = abi.decode(inputs, (uint8));
uint8 t = abi.decode(inputs, (uint8));
uint256 n = services[serviceId].operators.length;
// verify the DKG threshold is valid
if (t == 0 || t > n) {
Expand All @@ -100,94 +100,3 @@ contract CGGMP21Blueprint is BlueprintServiceManager {
return address(uint160(uint256(keccak256(publicKey))));
}
}

// contract CGGMP21JobResultVerifier is JobResultVerifier {
// uint8 constant KEYGEN_JOB = 0;
// uint8 constant SIGNING_JOB = 1;

// struct Keygen {
// uint64 jobCallId;
// uint8 t;
// bytes publicKey;
// }

// // A mapping of serviceId & JobCallId to Keygen
// mapping(uint64 => mapping(uint64 => Keygen)) public keygens;

// /// @dev Errors
// /// @dev InvalidJob The job is invalid
// error InvalidJob();
// /// @dev InvalidPublicKey The public key is invalid
// error InvalidPublicKey();
// /// @dev InvalidDKGThreshold The DKG threshold is invalid
// error InvalidDKGThreshold();
// /// @dev InvalidKeygenResult The keygen result is invalid
// error InvalidKeygenResult();
// /// @dev InvalidSignature The signature is invalid
// error InvalidSignature();
// /// @dev InvalidSigner The signer is invalid
// error InvalidSigner();

// function verify(
// uint64 serviceId,
// uint8 jobIndex,
// uint64 jobCallId,
// bytes calldata participant,
// bytes calldata inputs,
// bytes calldata outputs
// ) public override onlyRuntime {
// if (jobIndex == KEYGEN_JOB) {
// verifyKeygen(serviceId, jobCallId, inputs, outputs);
// } else if (jobIndex == SIGNING_JOB) {
// verifySigning(serviceId, jobCallId, inputs, outputs);
// } else {
// revert InvalidJob();
// }
// }

// function verifyKeygen(uint64 serviceId, uint64 jobCallId, bytes calldata inputs, bytes calldata outputs) internal {
// // The inputs are the DKG threshold
// (uint8 t) = abi.decode(inputs, (uint8));
// // The outputs are the public key
// bytes memory publicKey = outputs[0:33];
// // verify the public key is valid Ecdsa public key in the compressed format.
// if (publicKey.length != 33) {
// revert InvalidPublicKey();
// }
// // verify the DKG threshold is valid
// if (t == 0) {
// revert InvalidDKGThreshold();
// }
// // store the keygen
// keygens[serviceId][jobCallId] = Keygen(jobCallId, t, outputs);
// }

// function verifySigning(uint64 serviceId, uint64 jobCallId, bytes calldata inputs, bytes calldata outputs)
// internal
// view
// {
// // The inputs are the keygen result id (which is jobCallId) and the message hash.
// (uint64 keygenJobCallId, bytes32 message) = abi.decode(inputs, (uint64, bytes32));
// // The outputs are the signature
// bytes memory signature = outputs[0:65];
// // verify the signature is valid
// if (signature.length != 65) {
// revert InvalidSignature();
// }

// // get the keygen result
// Keygen memory keygen = keygens[serviceId][keygenJobCallId];
// // verify the keygen result exists
// if (keygen.jobCallId != keygenJobCallId) {
// revert InvalidKeygenResult();
// }
// // recover the public key from the signature
// address signer = ECDSA.recover(message, signature);
// // convert the public key to address format
// address keygenAddr = address(uint160(uint256(keccak256(keygen.publicKey))));
// // verify the public key is valid
// if (signer != keygenAddr) {
// revert InvalidSigner();
// }
// }
// }
Loading