Skip to content

Commit

Permalink
feat: add identity resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
dawksh committed Aug 4, 2024
1 parent 7c92d97 commit b97b69d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
19 changes: 19 additions & 0 deletions src/INebulaResolver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.24;

interface INebulaResolver {
function issue(
address recipient,
bytes calldata data
) external returns (bool);

function verify(
address recipient,
bytes calldata data
) external view returns (bool);

function revoke(
address recipient,
bytes calldata data
) external returns (bool);
}
25 changes: 15 additions & 10 deletions src/Nebula.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
pragma solidity ^0.8.24;

import {WorldIDVerifier} from "./WorldIDVerifier.sol";
import {NebulaRegistry} from "./NebulaRegistry.sol";
import {WorldIDProof} from "./Types.sol";
import {INebulaResolver} from "./INebulaResolver.sol";

contract Nebula {
/// @dev Universal Nebula world id verifier
WorldIDVerifier verifier;
NebulaRegistry registry;

struct WorldIDProof {
address signal;
uint256 root;
uint256 nullifierHash;
uint256[8] proof;
}
error ResolverIssueFail();

/// @param _verifier Universal verifier for worldid
constructor(address _verifier) {
constructor(address _verifier, address _registry) {
verifier = WorldIDVerifier(_verifier);
registry = NebulaRegistry(_registry);
}

/// @notice Verifies a given proof
/// @param proof WorldID Proof
/// @param identity WorldID Proof
function verifyIdentity(
function claimIdentity(
WorldIDProof calldata proof,
bytes8 identity
bytes8 identity,
bytes calldata data
) external {
verifier.verifyAndExecute(
proof.signal,
Expand All @@ -33,6 +34,10 @@ contract Nebula {
proof.proof
);

// Resolve Identity, Verify and Issue
INebulaResolver resolver = INebulaResolver(registry.resolve(identity));

bool s = resolver.issue(msg.sender, data);

if (!s) revert ResolverIssueFail();
}
}
10 changes: 10 additions & 0 deletions src/Types.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicencsed

pragma solidity ^0.8.24;

struct WorldIDProof {
address signal;
uint256 root;
uint256 nullifierHash;
uint256[8] proof;
}
8 changes: 7 additions & 1 deletion test/Nebula.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {Nebula} from "../src/Nebula.sol";
import {NebulaRegistry} from "../src/NebulaRegistry.sol";

contract NebulaTest is Test {
Nebula public nebula;
NebulaRegistry public registry;

function setUp() public {
registry = new NebulaRegistry();
// update with correct verifier contract address
nebula = new Nebula(0x5B38Da6a701c568545dCfcB03FcB875f56beddC4);
nebula = new Nebula(
0x5B38Da6a701c568545dCfcB03FcB875f56beddC4,
address(registry)
);
}

function testNebula() public {}
Expand Down

0 comments on commit b97b69d

Please sign in to comment.