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

feat: verify msg.sender to be the owner when calling registerPoh #106

Merged
merged 1 commit into from
Apr 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ error InsufficientValue();
error Unauthorised(bytes32 node);
error MaxCommitmentAgeTooLow();
error MaxCommitmentAgeTooHigh();
error PohVerificationFailed(address owner);
error OwnerAlreadyRegistered(address owner);
error SenderNotOwner(address owner, address sender);

/**
* @dev A registrar controller for registering and renewing names at fixed cost.
Expand Down Expand Up @@ -177,15 +180,20 @@ contract ETHRegistrarController is
uint16 ownerControlledFuses,
bytes memory signature
) public {
// Check if the address has already registered using registerPoh
require(
!hasRegisteredPoh[owner],
"Address has already registered using PoH"
);
require(
pohVerifier.verify(signature, owner),
"POH verification failed"
);
// The sender of the transaction needs to be the owner
if (msg.sender != owner) {
revert SenderNotOwner(owner, msg.sender);
}

// An andress can own only one domain using its PoH
if (hasRegisteredPoh[owner]) {
revert OwnerAlreadyRegistered(owner);
}

// Check that the signature sent is valid, this is the reference for an address to have a valid PoH
if (!pohVerifier.verify(signature, owner)) {
revert PohVerificationFailed(owner);
}

// Mark this address as having successfully registered
hasRegisteredPoh[owner] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ contract('ETHRegistrarController', function () {
const name = 'pohname'
const duration = 28 * 24 * 60 * 60 // 28 days in seconds
const secret = ethers.utils.formatBytes32String('secret')
const human = signers[1].address
const human = signers[0].address
const signature = ethers.utils.hexlify(ethers.utils.randomBytes(65)) // Mock signature

// Generate a commitment for the registration
Expand Down
Loading