From 850d6b85ac9d8d58187aba04260095369290426f Mon Sep 17 00:00:00 2001 From: Tony C Date: Wed, 16 Apr 2025 18:43:06 +0400 Subject: [PATCH 1/3] Rename BridgedBiomapperLib --- README.md | 4 ++-- .../{BridgedBiomapperReadLib.sol => BridgedBiomapperLib.sol} | 2 +- tests/hardhat/contracts/CanImport.sol | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename libraries/{BridgedBiomapperReadLib.sol => BridgedBiomapperLib.sol} (98%) 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/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"; From bd4663071fc5ea54f819c8ea7592e04cb5d9ad17 Mon Sep 17 00:00:00 2001 From: Tony C Date: Wed, 16 Apr 2025 18:49:03 +0400 Subject: [PATCH 2/3] Update BiomapperLogLib --- libraries/BiomapperLogLib.sol | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) { From 9bde23250487f7b871a898c896a8a8e11cfacbde Mon Sep 17 00:00:00 2001 From: Tony C Date: Wed, 16 Apr 2025 18:49:20 +0400 Subject: [PATCH 3/3] Update examples --- .../contracts/SybilResistantAirdrop.sol | 8 ++++++-- .../contracts/SybilResistantStaking.sol | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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" + ); _; }