diff --git a/README.md b/README.md index 2fd6a89..2bf3f8b 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Import the dependencies from the `@biomapper-sdk` like this: import {IBiomapperLogRead} from "@biomapper-sdk/core/IBiomapperLogRead.sol"; import {IBridgedBiomapperRead} from "@biomapper-sdk/core/IBridgedBiomapperRead.sol"; import {BiomapperLogLib} from "@biomapper-sdk/libraries/BiomapperLogLib.sol"; -import {BridgedBiomapperReadLib} from "@biomapper-sdk/libraries/BridgedBiomapperReadLib.sol"; +import {BridgedBiomapperLib} from "@biomapper-sdk/libraries/BridgedBiomapperLib.sol"; ``` ### With Foundry @@ -66,7 +66,7 @@ Import the dependencies from `biomapper-sdk` like this: import {IBiomapperLogRead} from "biomapper-sdk/core/IBiomapperLogRead.sol"; import {IBridgedBiomapperRead} from "biomapper-sdk/core/IBridgedBiomapperRead.sol"; import {BiomapperLogLib} from "biomapper-sdk/libraries/BiomapperLogLib.sol"; -import {BridgedBiomapperReadLib} from "biomapper-sdk/libraries/BridgedBiomapperReadLib.sol"; +import {BridgedBiomapperLib} from "biomapper-sdk/libraries/BridgedBiomapperLib.sol"; ``` ## Usage diff --git a/examples/sybil-resistant-airdrop/contracts/SybilResistantAirdrop.sol b/examples/sybil-resistant-airdrop/contracts/SybilResistantAirdrop.sol index b0b9e86..7918603 100644 --- a/examples/sybil-resistant-airdrop/contracts/SybilResistantAirdrop.sol +++ b/examples/sybil-resistant-airdrop/contracts/SybilResistantAirdrop.sol @@ -48,11 +48,15 @@ contract SybilResistantAirdrop { event Claimed(address who); /** - * @dev Allows a user to claim their tokens if they haven't already claimed and are unique. + * @dev Allows a user to claim their tokens if they haven't already claimed + * and are unique in the last generation. */ function claim() public { require(!isAlreadyClaimed[msg.sender], "User has already claimed"); - require(BIOMAPPER_LOG.isUnique(msg.sender), "User is not unique"); + require( + BIOMAPPER_LOG.isUniqueInLastGeneration(msg.sender), + "User is not unique" + ); ERC20_TOKEN.safeTransferFrom(TOKEN_VAULT, msg.sender, AMOUNT_PER_USER); diff --git a/examples/sybil-resistant-staking/contracts/SybilResistantStaking.sol b/examples/sybil-resistant-staking/contracts/SybilResistantStaking.sol index a1d6e07..e29500a 100644 --- a/examples/sybil-resistant-staking/contracts/SybilResistantStaking.sol +++ b/examples/sybil-resistant-staking/contracts/SybilResistantStaking.sol @@ -35,7 +35,10 @@ contract SybilResistantStaking { } modifier mustBeUnique() { - require(BIOMAPPER_LOG.isUnique(msg.sender), "User is not unique"); + require( + BIOMAPPER_LOG.isUniqueInLastGeneration(msg.sender), + "User is not unique" + ); _; } diff --git a/libraries/BiomapperLogLib.sol b/libraries/BiomapperLogLib.sol index fda485b..09ec4bd 100644 --- a/libraries/BiomapperLogLib.sol +++ b/libraries/BiomapperLogLib.sol @@ -6,11 +6,17 @@ import {IBiomapperLogRead} from "@biomapper-sdk/core/IBiomapperLogRead.sol"; /// @notice A utility library for the `BiomapperLog` contract. library BiomapperLogLib { /// @notice Determines the uniqueness status of a given address in the current biomapper generation. - /// The alternative way of using the `Biomapper` contract. + /// + /// @notice This call does not guarantee uniqueness across generations, + /// meaning the same person can pass this check more than once (perform a Sybil-attack): + /// with same biometrics but different account after each generation change. + /// Ensure you are fully understand the implications of generations and the security guarantees they provide, + /// and consider explicitly scoping your uniqueness check by a particular generation. + /// /// @param biomapperLog The `BiomapperLog` contract. /// @param who The address to check for uniqueness. /// @return A boolean value indicating whether the address is biomapped (true) or not (false). - function isUnique( + function isUniqueInLastGeneration( IBiomapperLogRead biomapperLog, address who ) external view returns (bool) { diff --git a/libraries/BridgedBiomapperReadLib.sol b/libraries/BridgedBiomapperLib.sol similarity index 98% rename from libraries/BridgedBiomapperReadLib.sol rename to libraries/BridgedBiomapperLib.sol index 4c20425..6563b9b 100644 --- a/libraries/BridgedBiomapperReadLib.sol +++ b/libraries/BridgedBiomapperLib.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import {IBridgedBiomapperRead} from "@biomapper-sdk/core/IBridgedBiomapperRead.sol"; /// @notice A utility library for the `BridgedBiomapper` contract. -library BridgedBiomapperReadLib { +library BridgedBiomapperLib { /// @notice Determines the uniqueness status of a given address in the last known biomapper generation. /// /// @notice This call does not guarantee uniqueness across generations, diff --git a/tests/hardhat/contracts/CanImport.sol b/tests/hardhat/contracts/CanImport.sol index d1ff823..4a8240e 100644 --- a/tests/hardhat/contracts/CanImport.sol +++ b/tests/hardhat/contracts/CanImport.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.24; import {IBiomapperLogRead} from "@biomapper-sdk/core/IBiomapperLogRead.sol"; import {BiomapperLogLib} from "@biomapper-sdk/libraries/BiomapperLogLib.sol"; -import {BridgedBiomapperReadLib} from "@biomapper-sdk/libraries/BridgedBiomapperReadLib.sol"; +import {BridgedBiomapperLib} from "@biomapper-sdk/libraries/BridgedBiomapperLib.sol"; import {IGenerationChangeEvents} from "@biomapper-sdk/events/IGenerationChangeEvents.sol"; import {IProveUniquenessEvents} from "@biomapper-sdk/events/IProveUniquenessEvents.sol"; import {IBridgeBiomappingEvents} from "@biomapper-sdk/events/IBridgeBiomappingEvents.sol";